Skip to content

Commit

Permalink
Temporary fix for bug 3432 - macOS 10.12: small scrolls (1 wheel notc…
Browse files Browse the repository at this point in the history
…h) don't generate events

Eric Wasylishen

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

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.
  • Loading branch information
slouken committed Mar 11, 2018
1 parent 129431b commit cc7b2fc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/video/cocoa/SDL_cocoamouse.m
Expand Up @@ -432,6 +432,16 @@ + (NSCursor *)invisibleCursor
}
}

if (x > 0) {
x = SDL_ceil(x);
} else if (x < 0) {
x = SDL_floor(x);
}
if (y > 0) {
y = SDL_ceil(y);
} else if (y < 0) {
y = SDL_floor(y);
}
SDL_SendMouseWheel(window, mouse->mouseID, x, y, direction);
}

Expand Down

0 comments on commit cc7b2fc

Please sign in to comment.