From 32ebb0029226d98eeeddfef59fa7370a340fb4df Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 21 Feb 2023 23:31:00 -0600 Subject: [PATCH] Add horizontal scrolling support with Sunshine --- src/input/evdev.c | 17 ++++++++++++----- src/input/sdl.c | 2 ++ src/input/x11.c | 6 ++++++ third_party/moonlight-common-c | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/input/evdev.c b/src/input/evdev.c index f1df4ab..04e8ce2 100644 --- a/src/input/evdev.c +++ b/src/input/evdev.c @@ -66,7 +66,7 @@ struct input_device { int hats_state[3][2]; int fd; char modifiers; - __s32 mouseDeltaX, mouseDeltaY, mouseScroll; + __s32 mouseDeltaX, mouseDeltaY, mouseVScroll, mouseHScroll; __s32 touchDownX, touchDownY, touchX, touchY; struct timeval touchDownTime; struct timeval btnDownTime; @@ -273,9 +273,13 @@ static bool evdev_handle_event(struct input_event *ev, struct input_device *dev) dev->mouseDeltaX = 0; dev->mouseDeltaY = 0; } - if (dev->mouseScroll != 0) { - LiSendScrollEvent(dev->mouseScroll); - dev->mouseScroll = 0; + if (dev->mouseVScroll != 0) { + LiSendScrollEvent(dev->mouseVScroll); + dev->mouseVScroll = 0; + } + if (dev->mouseHScroll != 0) { + LiSendHScrollEvent(dev->mouseHScroll); + dev->mouseHScroll = 0; } if (dev->gamepadModified) { if (dev->controllerId < 0) { @@ -483,8 +487,11 @@ static bool evdev_handle_event(struct input_event *ev, struct input_device *dev) case REL_Y: dev->mouseDeltaY = ev->value; break; + case REL_HWHEEL: + dev->mouseHScroll = ev->value; + break; case REL_WHEEL: - dev->mouseScroll = ev->value; + dev->mouseVScroll = ev->value; break; } break; diff --git a/src/input/sdl.c b/src/input/sdl.c index f377054..3f48b98 100644 --- a/src/input/sdl.c +++ b/src/input/sdl.c @@ -164,8 +164,10 @@ int sdlinput_handle_event(SDL_Window* window, SDL_Event* event) { break; case SDL_MOUSEWHEEL: #if SDL_VERSION_ATLEAST(2, 0, 18) + LiSendHighResHScrollEvent((short)(event->wheel.preciseX * 120)); // WHEEL_DELTA LiSendHighResScrollEvent((short)(event->wheel.preciseY * 120)); // WHEEL_DELTA #else + LiSendHScrollEvent(event->wheel.x); LiSendScrollEvent(event->wheel.y); #endif break; diff --git a/src/input/x11.c b/src/input/x11.c index 88d6470..fa7e45d 100644 --- a/src/input/x11.c +++ b/src/input/x11.c @@ -111,6 +111,12 @@ static int x11_handler(int fd) { case Button5: LiSendScrollEvent(-1); break; + case 6: + LiSendHScrollEvent(-1); + break; + case 7: + LiSendHScrollEvent(1); + break; case 8: button = BUTTON_X1; break; diff --git a/third_party/moonlight-common-c b/third_party/moonlight-common-c index 50c0a51..d3cb813 160000 --- a/third_party/moonlight-common-c +++ b/third_party/moonlight-common-c @@ -1 +1 @@ -Subproject commit 50c0a51b10ecc5b3415ea78c21d96d679e2288f9 +Subproject commit d3cb8131d12832898af31c4f2484ec1bd6bed0f4