Ejemplo n.º 1
0
static bool apple_hid_joypad_button(void *data, unsigned port, uint16_t joykey)
{
   uint64_t buttons          = apple_hid_joypad_get_buttons(data, port);

   if (joykey == NO_BTN)
      return false;

   /* Check hat. */
   if (GET_HAT_DIR(joykey))
      return false;

   /* Check the button. */
   if ((port < MAX_USERS) && (joykey < 32))
      return ((buttons & (1 << joykey)) != 0);
   return false;
}
Ejemplo n.º 2
0
static bool apple_joypad_button(unsigned port, uint16_t joykey)
{
   apple_input_data_t *apple = (apple_input_data_t*)driver.input_data;
   uint32_t buttons = pad_connection_get_buttons(&slots[port], port);
   if (!apple || joykey == NO_BTN)
      return false;

   // Check hat.
   if (GET_HAT_DIR(joykey))
      return false;
   // Check the button
   if ((port < MAX_PLAYERS) && (joykey < 32))
       return ((apple->buttons[port] & (1 << joykey)) != 0) ||
              ((buttons & (1 << joykey)) != 0);
    return false;
}
Ejemplo n.º 3
0
static bool btstack_hid_joypad_button(void *data,
      unsigned port, uint16_t joykey)
{
  input_bits_t buttons;
  btstack_hid_joypad_get_buttons(data, port, &buttons);

  /* Check hat. */
  if (GET_HAT_DIR(joykey))
    return false;

  /* Check the button. */
  if ((port < MAX_USERS) && (joykey < 32))
    return (BIT256_GET(buttons, joykey) != 0);

  return false;
}
Ejemplo n.º 4
0
static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey)
{
   uint64_t buttons          = iohidmanager_hid_joypad_get_buttons(data, port);
   iohidmanager_hid_t *hid   = (iohidmanager_hid_t*)data;

   if (joykey == NO_BTN)
      return false;

   /* Check hat. */
   if (GET_HAT_DIR(joykey))
      return false;

   /* Check the button. */
   if ((port < MAX_USERS) && (joykey < 32))
      return ((buttons & (1 << joykey)) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0)
         ;
   return false;
}
Ejemplo n.º 5
0
static bool sdl_joypad_button(unsigned port, uint16_t joykey)
{
   unsigned hat_dir  = 0;
   sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[port];
   if (!pad || !pad->joypad)
      return false;

   hat_dir = GET_HAT_DIR(joykey);
   /* Check hat. */
   if (hat_dir)
   {
      uint8_t  dir;
      uint16_t hat = GET_HAT(joykey);

      if (hat >= pad->num_hats)
         return false;

      dir = sdl_pad_get_hat(pad, hat);

      switch (hat_dir)
      {
         case HAT_UP_MASK:
            return dir & SDL_HAT_UP;
         case HAT_DOWN_MASK:
            return dir & SDL_HAT_DOWN;
         case HAT_LEFT_MASK:
            return dir & SDL_HAT_LEFT;
         case HAT_RIGHT_MASK:
            return dir & SDL_HAT_RIGHT;
         default:
            break;
      }
      return false;
   }

   /* Check the button */
   if (joykey < pad->num_buttons && sdl_pad_get_button(pad, joykey))
      return true;

   return false;
}
Ejemplo n.º 6
0
static bool iohidmanager_hid_joypad_button(void *data,
      unsigned port, uint16_t joykey)
{
  retro_bits_t buttons;
  iohidmanager_hid_t *hid   = (iohidmanager_hid_t*)data;
  unsigned hat_dir = GET_HAT_DIR(joykey);

  iohidmanager_hid_joypad_get_buttons(data, port, &buttons);

   /* Check hat. */
   if (hat_dir)
   {
      unsigned h = GET_HAT(joykey);
      if(h >= 1)
         return false;

      switch(hat_dir)
      {
         case HAT_LEFT_MASK:
            return hid->hats[port][0] < 0;
         case HAT_RIGHT_MASK:
            return hid->hats[port][0] > 0;
         case HAT_UP_MASK:
            return hid->hats[port][1] < 0;
         case HAT_DOWN_MASK:
            return hid->hats[port][1] > 0;
      }

      return 0;
   }

   /* Check the button. */
   if ((port < MAX_USERS) && (joykey < 32))
      return (BIT256_GET(buttons, joykey) != 0)
         || ((hid->buttons[port] & (1 << joykey)) != 0);

   return false;
}