mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Disable keyboard input and restrict mouse input in some cases
This commit is contained in:
parent
d2cdc97e8f
commit
aa99f4f5ba
@ -549,6 +549,20 @@ static void udev_input_poll(void *data)
|
||||
udev->joypad->poll();
|
||||
}
|
||||
|
||||
static bool udev_pointer_is_off_window(udev_input_mouse_t *mouse)
|
||||
{
|
||||
struct video_viewport view;
|
||||
bool r = video_driver_get_viewport_info(&view);
|
||||
|
||||
if (r)
|
||||
r = mouse->x < view.x ||
|
||||
mouse->x >= view.x + view.width ||
|
||||
mouse->y < view.y ||
|
||||
mouse->y >= view.y + view.height;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int16_t udev_mouse_state(udev_input_t *udev,
|
||||
unsigned port, unsigned id, bool screen)
|
||||
{
|
||||
@ -557,6 +571,10 @@ static int16_t udev_mouse_state(udev_input_t *udev,
|
||||
if (!mouse)
|
||||
return 0;
|
||||
|
||||
if (id != RETRO_DEVICE_ID_MOUSE_X && id != RETRO_DEVICE_ID_MOUSE_Y &&
|
||||
udev_pointer_is_off_window(mouse))
|
||||
return 0;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_MOUSE_X:
|
||||
@ -706,8 +724,10 @@ static int16_t udev_input_state(void *data,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
return ret;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return id < RETROK_LAST && BIT_GET(udev_key_state,
|
||||
rarch_keysym_lut[(enum retro_key)id]);
|
||||
if (video_driver_cb_has_focus())
|
||||
return id < RETROK_LAST && BIT_GET(udev_key_state,
|
||||
rarch_keysym_lut[(enum retro_key)id]);
|
||||
break;
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
return udev_mouse_state(udev, port, id, false);
|
||||
case RARCH_DEVICE_MOUSE_SCREEN:
|
||||
|
Loading…
x
Reference in New Issue
Block a user