src/video/cocoa/SDL_cocoamouse.m
changeset 5057 bdff53ed6c8b
parent 4498 3d91e31fcf71
child 5058 03db7d4b02b4
--- a/src/video/cocoa/SDL_cocoamouse.m	Thu Jan 20 16:05:59 2011 -0800
+++ b/src/video/cocoa/SDL_cocoamouse.m	Fri Jan 21 00:15:18 2011 +0100
@@ -93,6 +93,9 @@
     case NSRightMouseUp:
         SDL_SendMouseButton(window, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber]));
         break;
+    case NSScrollWheel:
+        Cocoa_HandleMouseWheel(window, event);
+        break;
     case NSLeftMouseDragged:
     case NSRightMouseDragged:
     case NSOtherMouseDragged: /* usually middle mouse dragged */
@@ -109,4 +112,23 @@
 {
 }
 
+void
+Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
+{
+    float x = [event deltaX];
+    float y = [event deltaY];
+
+    if (x > 0) {
+        x += 0.9f;
+    } else if (x < 0) {
+        x -= 0.9f;
+    }
+    if (y > 0) {
+        y += 0.9f;
+    } else if (y < 0) {
+        y -= 0.9f;
+    }
+    SDL_SendMouseWheel(window, (int)x, (int)y);
+}
+
 /* vi: set ts=4 sw=4 expandtab: */