src/video/cocoa/SDL_cocoamouse.m
changeset 10365 7f3be5258f80
parent 10159 d41acf6379f6
child 10737 3406a0f8b041
equal deleted inserted replaced
10364:4bbf64fdd9d9 10365:7f3be5258f80
   419 void
   419 void
   420 Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
   420 Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
   421 {
   421 {
   422     SDL_Mouse *mouse = SDL_GetMouse();
   422     SDL_Mouse *mouse = SDL_GetMouse();
   423 
   423 
   424     float x = -[event deltaX];
   424     CGFloat x = -[event deltaX];
   425     float y = [event deltaY];
   425     CGFloat y = [event deltaY];
   426     SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
   426     SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
   427 
   427 
   428     if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
   428     if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
   429         if ([event isDirectionInvertedFromDevice] == YES) {
   429         if ([event isDirectionInvertedFromDevice] == YES) {
   430             direction = SDL_MOUSEWHEEL_FLIPPED;
   430             direction = SDL_MOUSEWHEEL_FLIPPED;
   431         }
   431         }
   432     }
   432     }
   433 
   433 
   434     if (x > 0) {
   434     if (x > 0) {
   435         x += 0.9f;
   435         x = SDL_ceil(x);
   436     } else if (x < 0) {
   436     } else if (x < 0) {
   437         x -= 0.9f;
   437         x = SDL_floor(x);
   438     }
   438     }
   439     if (y > 0) {
   439     if (y > 0) {
   440         y += 0.9f;
   440         y = SDL_ceil(y);
   441     } else if (y < 0) {
   441     } else if (y < 0) {
   442         y -= 0.9f;
   442         y = SDL_floor(y);
   443     }
   443     }
   444     SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, direction);
   444     SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, direction);
   445 }
   445 }
   446 
   446 
   447 void
   447 void