Exemplo n.º 1
0
static int16_t udev_input_state(void *data, const struct retro_keybind **binds,
      unsigned port, unsigned device, unsigned idx, unsigned id)
{
   int16_t ret;
   udev_input_t *udev = (udev_input_t*)data;

   switch (device)
   {
      case RETRO_DEVICE_JOYPAD:
         return udev_input_is_pressed(binds[port], id) ||
            input_joypad_pressed(udev->joypad, port, binds[port], id);

      case RETRO_DEVICE_ANALOG:
         ret = udev_analog_pressed(binds[port], idx, id);
         if (!ret)
            ret = input_joypad_analog(udev->joypad, port, idx, id, binds[port]);
         return ret;

      case RETRO_DEVICE_KEYBOARD:
         return udev_input_state_kb(data, binds, port, device, idx, id);
      case RETRO_DEVICE_MOUSE:
         return udev_mouse_state(udev, id);

      case RETRO_DEVICE_POINTER:
      case RARCH_DEVICE_POINTER_SCREEN:
         return udev_pointer_state(udev, idx, id,
               device == RARCH_DEVICE_POINTER_SCREEN);

      case RETRO_DEVICE_LIGHTGUN:
         return udev_lightgun_state(udev, id);
   }

   return 0;
}
Exemplo n.º 2
0
static int16_t udev_input_state(void *data,
      rarch_joypad_info_t joypad_info,
      const struct retro_keybind **binds,
      unsigned port, unsigned device, unsigned idx, unsigned id)
{
   int16_t ret;
   unsigned bit;
   udev_input_t *udev         = (udev_input_t*)data;

   if (!udev)
      return 0;

   switch (device)
   {
      case RETRO_DEVICE_JOYPAD:
         bit = input_keymaps_translate_rk_to_keysym(binds[port][id].key);
         if (BIT_GET(udev_key_state, bit))
            return true;
         return input_joypad_pressed(udev->joypad, joypad_info, port, binds[port], id);
      case RETRO_DEVICE_ANALOG:
         ret = udev_analog_pressed(binds[port], idx, id);
         if (!ret && binds[port])
            ret = input_joypad_analog(udev->joypad, joypad_info, port, idx, id, binds[port]);
         return ret;

      case RETRO_DEVICE_KEYBOARD:
         bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id);
         return id < RETROK_LAST && BIT_GET(udev_key_state, bit);
      case RETRO_DEVICE_MOUSE:
         return udev_mouse_state(udev, id);

      case RETRO_DEVICE_POINTER:
      case RARCH_DEVICE_POINTER_SCREEN:
         if (idx == 0)
            return udev_pointer_state(udev, idx, id,
                  device == RARCH_DEVICE_POINTER_SCREEN);
         break;
      case RETRO_DEVICE_LIGHTGUN:
         return udev_lightgun_state(udev, id);
   }

   return 0;
}