diff --git a/input/common/wayland_common.c b/input/common/wayland_common.c index aca4b3b6f2..9fc2924017 100644 --- a/input/common/wayland_common.c +++ b/input/common/wayland_common.c @@ -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, diff --git a/input/common/wayland_common.h b/input/common/wayland_common.h index 1f20561094..2c709be573 100644 --- a/input/common/wayland_common.h +++ b/input/common/wayland_common.h @@ -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; diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c index 153eb623f8..9eb1968644 100644 --- a/input/drivers/wayland_input.c +++ b/input/drivers/wayland_input.c @@ -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: