mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
(Wayland) Add scroll wheel support (#13398)
This commit is contained in:
parent
1afbe4a326
commit
c48d533950
@ -240,7 +240,26 @@ static void pointer_handle_axis(void *data,
|
||||
struct wl_pointer *wl_pointer,
|
||||
uint32_t time,
|
||||
uint32_t axis,
|
||||
wl_fixed_t value) { }
|
||||
wl_fixed_t value) {
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
double dvalue = wl_fixed_to_double(value);
|
||||
switch (axis) {
|
||||
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||
if (dvalue < 0) {
|
||||
wl->input.mouse.wu = true;
|
||||
} else if (dvalue > 0) {
|
||||
wl->input.mouse.wd = true;
|
||||
}
|
||||
break;
|
||||
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||
if (dvalue < 0) {
|
||||
wl->input.mouse.wl = true;
|
||||
} else if (dvalue > 0) {
|
||||
wl->input.mouse.wr = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void touch_handle_down(void *data,
|
||||
struct wl_touch *wl_touch,
|
||||
|
@ -102,6 +102,7 @@ typedef struct input_ctx_wayland_data
|
||||
bool last_valid;
|
||||
bool focus;
|
||||
bool left, right, middle;
|
||||
bool wu, wd, wl, wr;
|
||||
} mouse;
|
||||
|
||||
bool keyboard_focus;
|
||||
|
@ -263,6 +263,14 @@ static int16_t input_wl_state(
|
||||
if (port > 0) return 0; /* TODO: support mouse on additional ports */
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||
bool wheel_up = wl->mouse.wu;
|
||||
wl->mouse.wu = false;
|
||||
return wheel_up;
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||
bool wheel_down = wl->mouse.wd;
|
||||
wl->mouse.wd = false;
|
||||
return wheel_down;
|
||||
case RETRO_DEVICE_ID_MOUSE_X:
|
||||
return screen ? wl->mouse.x : wl->mouse.delta_x;
|
||||
case RETRO_DEVICE_ID_MOUSE_Y:
|
||||
|
Loading…
x
Reference in New Issue
Block a user