From cd667eeac58dce0dc699bc12010482bdd96d8297 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 10 Feb 2022 15:15:01 +0200 Subject: macOS: Handle regular mouse wheel scrolling Since we're listening to scroll events directly, should handle the regular mouse, too. --- src/macos.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/macos.m b/src/macos.m index 191842f6..7b248c3b 100644 --- a/src/macos.m +++ b/src/macos.m @@ -475,10 +475,20 @@ static iBool processScrollWheelEvent_(NSEvent *event) { break; } } + else { + SDL_MouseWheelEvent e = { .type = SDL_MOUSEWHEEL }; + e.timestamp = SDL_GetTicks(); + e.which = 1; /* Distinction between trackpad and regular mouse. */ + /* Disregard any wheel acceleration. */ + e.x = event.scrollingDeltaX > 0 ? 1 : event.scrollingDeltaX < 0 ? -1 : 0; + e.y = event.scrollingDeltaY > 0 ? 1 : event.scrollingDeltaY < 0 ? -1 : 0; + SDL_PushEvent((SDL_Event *) &e); + return iTrue; + } /* Post corresponding MOUSEWHEEL events. */ SDL_MouseWheelEvent e = { .type = SDL_MOUSEWHEEL }; e.timestamp = SDL_GetTicks(); - e.which = isPerPixel ? 0 : 1; /* Distinction between trackpad and regular mouse. TODO: Still needed? */ + e.which = isPerPixel ? 0 : 1; /* Distinction between trackpad and regular mouse. */ setPerPixel_MouseWheelEvent(&e, isPerPixel); if (isPerPixel) { setInertia_MouseWheelEvent(&e, isInertia); -- cgit v1.2.3