From c750ec3cc7b921cf7d11d4d04a9e0240ebef47f3 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 18 May 2022 00:24:58 -0500 Subject: [PATCH] Add workaround for macOS scrolling acceleration See #778 --- app/streaming/input/mouse.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/streaming/input/mouse.cpp b/app/streaming/input/mouse.cpp index 07dc6abd..61ff9ba9 100644 --- a/app/streaming/input/mouse.cpp +++ b/app/streaming/input/mouse.cpp @@ -219,6 +219,12 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event) event->preciseY = -event->preciseY; } +#ifdef Q_OS_DARWIN + // HACK: Clamp the scroll values on macOS to prevent OS scroll acceleration + // from generating wild scroll deltas when scrolling quickly. + event->preciseY = SDL_clamp(event->preciseY, -1.0f, 1.0f); +#endif + LiSendHighResScrollEvent((short)(event->preciseY * 120)); // WHEEL_DELTA } #else @@ -228,6 +234,11 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event) event->y = -event->y; } +#ifdef Q_OS_DARWIN + // See comment above + event->y = SDL_clamp(event->y, -1, 1); +#endif + LiSendScrollEvent((signed char)event->y); } #endif