Adapt the sanitized pointer handling, discussed at libretro#17196 : (#17312)

Cocoa driver specific changes:

- make sure pointer position is always within [-0x7fff,0x7fff] by using the confined wrapper
- enable pointer offscreen query
This commit is contained in:
zoltanvb 2024-12-30 23:50:02 +01:00 committed by GitHub
parent 33ec89306e
commit b66263a034
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -34,6 +34,7 @@ typedef struct
int16_t screen_x, screen_y;
int16_t fixed_x, fixed_y;
int16_t full_x, full_y;
int16_t confined_x, confined_y;
} cocoa_touch_data_t;
typedef struct

View File

@ -402,6 +402,15 @@ static void cocoa_input_poll(void *data)
memset(&vp, 0, sizeof(vp));
video_driver_translate_coord_viewport_confined_wrap(
&vp,
apple->touches[i].screen_x * backing_scale_factor,
apple->touches[i].screen_y * backing_scale_factor,
&apple->touches[i].confined_x,
&apple->touches[i].confined_y,
&apple->touches[i].full_x,
&apple->touches[i].full_y);
video_driver_translate_coord_viewport_wrap(
&vp,
apple->touches[i].screen_x * backing_scale_factor,
@ -588,11 +597,13 @@ static int16_t cocoa_input_state(
return (touch->full_x != -0x8000) && (touch->full_y != -0x8000); /* Inside? */
return (touch->fixed_x != -0x8000) && (touch->fixed_y != -0x8000); /* Inside? */
case RETRO_DEVICE_ID_POINTER_X:
return (device == RARCH_DEVICE_POINTER_SCREEN) ? touch->full_x : touch->fixed_x;
return (device == RARCH_DEVICE_POINTER_SCREEN) ? touch->full_x : touch->confined_x;
case RETRO_DEVICE_ID_POINTER_Y:
return (device == RARCH_DEVICE_POINTER_SCREEN) ? touch->full_y : touch->fixed_y;
return (device == RARCH_DEVICE_POINTER_SCREEN) ? touch->full_y : touch->confined_y;
case RETRO_DEVICE_ID_POINTER_COUNT:
return apple->touch_count;
case RETRO_DEVICE_ID_POINTER_IS_OFFSCREEN:
return input_driver_pointer_is_offscreen(touch->fixed_x, touch->fixed_y);
}
}
}