Pointer sanitization - sdl (#17286)

This commit is contained in:
zoltanvb 2024-12-26 00:55:13 +01:00 committed by GitHub
parent 92f134fb87
commit ac6b30471b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -256,7 +256,7 @@ static int16_t sdl_input_state(
case RARCH_DEVICE_POINTER_SCREEN:
if (idx == 0)
{
struct video_viewport vp = {0};
video_viewport_t vp = {0};
bool screen = device ==
RARCH_DEVICE_POINTER_SCREEN;
int16_t res_x = 0;
@ -290,26 +290,42 @@ static int16_t sdl_input_state(
break;
case RETRO_DEVICE_KEYBOARD:
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:
{
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)
{
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:
return sdl->mouse_x;
case RETRO_DEVICE_ID_LIGHTGUN_Y:
return sdl->mouse_y;
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
return sdl->mouse_l;
case RETRO_DEVICE_ID_LIGHTGUN_CURSOR:
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
return sdl->mouse_m;
case RETRO_DEVICE_ID_LIGHTGUN_TURBO:
return sdl->mouse_r;
case RETRO_DEVICE_ID_LIGHTGUN_START:
return sdl->mouse_m && sdl->mouse_r;
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
return sdl->mouse_m && sdl->mouse_l;
return sdl->mouse_r;
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
return sdl->mouse_l && sdl->mouse_r;
}
break;
}
}
return 0;