mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Pointer sanitization - sdl (#17286)
This commit is contained in:
parent
92f134fb87
commit
ac6b30471b
@ -256,7 +256,7 @@ static int16_t sdl_input_state(
|
|||||||
case RARCH_DEVICE_POINTER_SCREEN:
|
case RARCH_DEVICE_POINTER_SCREEN:
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
{
|
{
|
||||||
struct video_viewport vp = {0};
|
video_viewport_t vp = {0};
|
||||||
bool screen = device ==
|
bool screen = device ==
|
||||||
RARCH_DEVICE_POINTER_SCREEN;
|
RARCH_DEVICE_POINTER_SCREEN;
|
||||||
int16_t res_x = 0;
|
int16_t res_x = 0;
|
||||||
@ -290,26 +290,42 @@ static int16_t sdl_input_state(
|
|||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_KEYBOARD:
|
case RETRO_DEVICE_KEYBOARD:
|
||||||
return (id && id < RETROK_LAST) && sdl_key_pressed(id);
|
return (id && id < RETROK_LAST) && sdl_key_pressed(id);
|
||||||
/* TODO: update to match other input drivers (aiming state, button binds) */
|
/* TODO: update button binds to match other input drivers */
|
||||||
case RETRO_DEVICE_LIGHTGUN:
|
case RETRO_DEVICE_LIGHTGUN:
|
||||||
|
{
|
||||||
|
video_viewport_t vp = {0};
|
||||||
|
int16_t res_x = 0;
|
||||||
|
int16_t res_y = 0;
|
||||||
|
int16_t res_screen_x = 0;
|
||||||
|
int16_t res_screen_y = 0;
|
||||||
|
|
||||||
|
if (video_driver_translate_coord_viewport_wrap(
|
||||||
|
&vp, sdl->mouse_abs_x, sdl->mouse_abs_y,
|
||||||
|
&res_x, &res_y, &res_screen_x, &res_screen_y))
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||||
|
return res_x;
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||||
|
return res_y;
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||||
|
return input_driver_pointer_is_offscreen(res_x, res_y);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||||
return sdl->mouse_x;
|
return sdl->mouse_x;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_Y:
|
case RETRO_DEVICE_ID_LIGHTGUN_Y:
|
||||||
return sdl->mouse_y;
|
return sdl->mouse_y;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||||
return sdl->mouse_l;
|
return sdl->mouse_l;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_CURSOR:
|
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
||||||
return sdl->mouse_m;
|
return sdl->mouse_m;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_TURBO:
|
|
||||||
return sdl->mouse_r;
|
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
||||||
return sdl->mouse_m && sdl->mouse_r;
|
return sdl->mouse_r;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
||||||
return sdl->mouse_m && sdl->mouse_l;
|
return sdl->mouse_l && sdl->mouse_r;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user