mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
cocoa: fix mouse movement
The input driver was using absolute coordinate arithmetic while making use of delta changes for each coordinate, as a result the absolute change netted to zero. This fixes that and tries to mitigate cursor event sync issues (sync issues will require more work).
This commit is contained in:
parent
9c749f03eb
commit
edfafd9fad
@ -192,35 +192,41 @@ static void cocoa_input_poll(void *data)
|
|||||||
apple->joypad->poll();
|
apple->joypad->poll();
|
||||||
if (apple->sec_joypad)
|
if (apple->sec_joypad)
|
||||||
apple->sec_joypad->poll();
|
apple->sec_joypad->poll();
|
||||||
|
|
||||||
apple->mouse_x_last = apple->mouse_rel_x;
|
|
||||||
apple->mouse_y_last = apple->mouse_rel_y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
|
static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
|
||||||
unsigned id)
|
unsigned id)
|
||||||
{
|
{
|
||||||
switch (id)
|
int16_t val;
|
||||||
{
|
switch (id)
|
||||||
case RETRO_DEVICE_ID_MOUSE_X:
|
{
|
||||||
return apple->mouse_rel_x - apple->mouse_x_last;
|
case RETRO_DEVICE_ID_MOUSE_X:
|
||||||
case RETRO_DEVICE_ID_MOUSE_Y:
|
val = apple->mouse_rel_x;
|
||||||
return apple->mouse_rel_y - apple->mouse_y_last;
|
// NOTE: Because cocoa events are effectively handled async we reset
|
||||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
// the delta which we cumulate on each event
|
||||||
return apple->mouse_buttons & 1;
|
apple->mouse_rel_x = 0;
|
||||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
return val;
|
||||||
return apple->mouse_buttons & 2;
|
case RETRO_DEVICE_ID_MOUSE_Y:
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
val = apple->mouse_rel_y;
|
||||||
return apple->mouse_wu;
|
// NOTE: Because cocoa events are effectively handled async we reset
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
// the delta which we cumulate on each event
|
||||||
return apple->mouse_wd;
|
apple->mouse_rel_y = 0;
|
||||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
return val;
|
||||||
return apple->mouse_wl;
|
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
return apple->mouse_buttons & 1;
|
||||||
return apple->mouse_wr;
|
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||||
}
|
return apple->mouse_buttons & 2;
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||||
|
return apple->mouse_wu;
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||||
|
return apple->mouse_wd;
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
||||||
|
return apple->mouse_wl;
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
||||||
|
return apple->mouse_wr;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t cocoa_mouse_state_screen(cocoa_input_data_t *apple,
|
static int16_t cocoa_mouse_state_screen(cocoa_input_data_t *apple,
|
||||||
|
@ -132,8 +132,8 @@ static void app_terminate(void)
|
|||||||
pos.y = 0;
|
pos.y = 0;
|
||||||
|
|
||||||
/* Relative */
|
/* Relative */
|
||||||
apple->mouse_rel_x = (int16_t)event.deltaX;
|
apple->mouse_rel_x += (int16_t)event.deltaX;
|
||||||
apple->mouse_rel_y = (int16_t)event.deltaY;
|
apple->mouse_rel_y += (int16_t)event.deltaY;
|
||||||
|
|
||||||
/* Absolute */
|
/* Absolute */
|
||||||
#if defined(HAVE_COCOA_METAL)
|
#if defined(HAVE_COCOA_METAL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user