Просмотр исходного кода

cocoa: restore discrete mouse wheel ticks

(cherry picked from commit 1f3f71439308e9469480b2fe0061e9b99cbc2773)
Isabella Basso 1 день назад
Родитель
Сommit
27e6b7a119
1 измененных файлов с 6 добавлено и 5 удалено
  1. 6 5
      src/video/cocoa/SDL_cocoamouse.m

+ 6 - 5
src/video/cocoa/SDL_cocoamouse.m

@@ -618,17 +618,18 @@ void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
     SDL_MouseWheelDirection direction;
     CGFloat x, y;
 
-    x = -[event deltaX];
-    y = [event deltaY];
     direction = SDL_MOUSEWHEEL_NORMAL;
 
     if ([event isDirectionInvertedFromDevice] == YES) {
         direction = SDL_MOUSEWHEEL_FLIPPED;
     }
 
-    /* For discrete scroll events from conventional mice, always send a full tick.
-       For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */
-    if (![event hasPreciseScrollingDeltas]) {
+    if ([event hasPreciseScrollingDeltas]) {
+        x = -[event scrollingDeltaX] * 0.1f;
+        y = [event scrollingDeltaY] * 0.1f;
+    } else {
+        x = -[event deltaX];
+        y = [event deltaY];
         if (x > 0) {
             x = SDL_ceil(x);
         } else if (x < 0) {