Fix mouse wheel events on macOS 10.12 (thanks Eric Wasylishen!)
authorAlex Szpakowski <slime73@gmail.com>
Sat, 24 Sep 2016 13:28:40 -0300
changeset 103657f3be5258f80
parent 10364 4bbf64fdd9d9
child 10366 e1b52e69578b
Fix mouse wheel events on macOS 10.12 (thanks Eric Wasylishen!)

Fixes bug #3432
src/video/cocoa/SDL_cocoamouse.m
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Wed Sep 21 18:23:59 2016 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Sat Sep 24 13:28:40 2016 -0300
     1.3 @@ -421,8 +421,8 @@
     1.4  {
     1.5      SDL_Mouse *mouse = SDL_GetMouse();
     1.6  
     1.7 -    float x = -[event deltaX];
     1.8 -    float y = [event deltaY];
     1.9 +    CGFloat x = -[event deltaX];
    1.10 +    CGFloat y = [event deltaY];
    1.11      SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
    1.12  
    1.13      if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
    1.14 @@ -432,14 +432,14 @@
    1.15      }
    1.16  
    1.17      if (x > 0) {
    1.18 -        x += 0.9f;
    1.19 +        x = SDL_ceil(x);
    1.20      } else if (x < 0) {
    1.21 -        x -= 0.9f;
    1.22 +        x = SDL_floor(x);
    1.23      }
    1.24      if (y > 0) {
    1.25 -        y += 0.9f;
    1.26 +        y = SDL_ceil(y);
    1.27      } else if (y < 0) {
    1.28 -        y -= 0.9f;
    1.29 +        y = SDL_floor(y);
    1.30      }
    1.31      SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, direction);
    1.32  }