mirror of
https://github.com/libretro/RetroArch
synced 2025-02-10 03:39:56 +00:00
Pointer sanitization, rwebinput driver (#17327)
This commit is contained in:
parent
2e3fc4f52d
commit
401e169865
@ -507,26 +507,17 @@ static int16_t rwebinput_input_state(
|
|||||||
case RARCH_DEVICE_POINTER_SCREEN:
|
case RARCH_DEVICE_POINTER_SCREEN:
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
{
|
{
|
||||||
struct video_viewport vp;
|
struct video_viewport vp = {0};
|
||||||
rwebinput_mouse_state_t
|
rwebinput_mouse_state_t
|
||||||
*mouse = &rwebinput->mouse;
|
*mouse = &rwebinput->mouse;
|
||||||
const int edge_detect = 32700;
|
|
||||||
bool screen = device ==
|
bool screen = device ==
|
||||||
RARCH_DEVICE_POINTER_SCREEN;
|
RARCH_DEVICE_POINTER_SCREEN;
|
||||||
bool inside = false;
|
|
||||||
int16_t res_x = 0;
|
int16_t res_x = 0;
|
||||||
int16_t res_y = 0;
|
int16_t res_y = 0;
|
||||||
int16_t res_screen_x = 0;
|
int16_t res_screen_x = 0;
|
||||||
int16_t res_screen_y = 0;
|
int16_t res_screen_y = 0;
|
||||||
|
|
||||||
vp.x = 0;
|
if (!(video_driver_translate_coord_viewport_confined_wrap(
|
||||||
vp.y = 0;
|
|
||||||
vp.width = 0;
|
|
||||||
vp.height = 0;
|
|
||||||
vp.full_width = 0;
|
|
||||||
vp.full_height = 0;
|
|
||||||
|
|
||||||
if (!(video_driver_translate_coord_viewport_wrap(
|
|
||||||
&vp, mouse->x, mouse->y,
|
&vp, mouse->x, mouse->y,
|
||||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||||
return 0;
|
return 0;
|
||||||
@ -537,25 +528,16 @@ static int16_t rwebinput_input_state(
|
|||||||
res_y = res_screen_y;
|
res_y = res_screen_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inside = (res_x >= -edge_detect)
|
|
||||||
&& (res_y >= -edge_detect)
|
|
||||||
&& (res_x <= edge_detect)
|
|
||||||
&& (res_y <= edge_detect);
|
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_ID_POINTER_X:
|
case RETRO_DEVICE_ID_POINTER_X:
|
||||||
if (inside)
|
return res_x;
|
||||||
return res_x;
|
|
||||||
break;
|
|
||||||
case RETRO_DEVICE_ID_POINTER_Y:
|
case RETRO_DEVICE_ID_POINTER_Y:
|
||||||
if (inside)
|
return res_y;
|
||||||
return res_y;
|
|
||||||
break;
|
|
||||||
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
||||||
return !!(mouse->buttons & (1 << RWEBINPUT_MOUSE_BTNL));
|
return !!(mouse->buttons & (1 << RWEBINPUT_MOUSE_BTNL));
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
case RETRO_DEVICE_ID_POINTER_IS_OFFSCREEN:
|
||||||
return !inside;
|
return input_driver_pointer_is_offscreen(res_x, res_y);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user