Add workaround for macOS scrolling acceleration

See #778
This commit is contained in:
Cameron Gutman 2022-05-18 00:24:58 -05:00
parent c75b781d3f
commit c750ec3cc7

View File

@ -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