Temporary fix for bug 3432 - macOS 10.12: small scrolls (1 wheel notch) don't generate events
authorSam Lantinga <slouken@libsdl.org>
Sat, 10 Mar 2018 21:13:50 -0800
changeset 1192632b708d2f684
parent 11925 ddb8dcdaa8d0
child 11927 6e61fc35c129
Temporary fix for bug 3432 - macOS 10.12: small scrolls (1 wheel notch) don't generate events

Eric Wasylishen

This bug was reintroduced by https://hg.libsdl.org/SDL/rev/68a80d7afec3

The steps to reproduce are the same: run the "testrelative" SDL demo with "--info all",
connect a USB mouse with a scroll wheel, and roll the scroll wheel one "notch". You'll get log output like:

testdraw2[1644:67222] INFO: SDL EVENT: Mouse: wheel scrolled 0 in x and 0 in y (reversed: 1) in window 1

As far as I can tell macOS doesn't have an API for getting the number of "wheel notches"; I get a deltaY of 0.100006 for one "notch", and it's heavily accelerated (if you roll the wheel quickly you'll get large deltas). So NSEvent's deltaY is only meant to be used for scrolling a scroll view, with the given distance in points, not something like selecting an item in a game.

Here's a temporary patch that at restores the foor/ceil in Cocoa_HandleMouseWheel.
Not ideal, but at least it restores the ability to scroll one notch of a mousewheel.
src/video/cocoa/SDL_cocoamouse.m
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Thu Mar 08 16:32:22 2018 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Sat Mar 10 21:13:50 2018 -0800
     1.3 @@ -432,6 +432,16 @@
     1.4          }
     1.5      }
     1.6  
     1.7 +    if (x > 0) {
     1.8 +        x = SDL_ceil(x);
     1.9 +    } else if (x < 0) {
    1.10 +        x = SDL_floor(x);
    1.11 +    }
    1.12 +    if (y > 0) {
    1.13 +        y = SDL_ceil(y);
    1.14 +    } else if (y < 0) {
    1.15 +        y = SDL_floor(y);
    1.16 +    }
    1.17      SDL_SendMouseWheel(window, mouse->mouseID, x, y, direction);
    1.18  }
    1.19