Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer sanitization: cocoa #17312

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions input/drivers/cocoa_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions input/drivers/cocoa_input.m
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Loading