src/video/cocoa/SDL_cocoamouse.m
changeset 5057 bdff53ed6c8b
parent 4498 3d91e31fcf71
child 5058 03db7d4b02b4
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Thu Jan 20 16:05:59 2011 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Fri Jan 21 00:15:18 2011 +0100
     1.3 @@ -93,6 +93,9 @@
     1.4      case NSRightMouseUp:
     1.5          SDL_SendMouseButton(window, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber]));
     1.6          break;
     1.7 +    case NSScrollWheel:
     1.8 +        Cocoa_HandleMouseWheel(window, event);
     1.9 +        break;
    1.10      case NSLeftMouseDragged:
    1.11      case NSRightMouseDragged:
    1.12      case NSOtherMouseDragged: /* usually middle mouse dragged */
    1.13 @@ -109,4 +112,23 @@
    1.14  {
    1.15  }
    1.16  
    1.17 +void
    1.18 +Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
    1.19 +{
    1.20 +    float x = [event deltaX];
    1.21 +    float y = [event deltaY];
    1.22 +
    1.23 +    if (x > 0) {
    1.24 +        x += 0.9f;
    1.25 +    } else if (x < 0) {
    1.26 +        x -= 0.9f;
    1.27 +    }
    1.28 +    if (y > 0) {
    1.29 +        y += 0.9f;
    1.30 +    } else if (y < 0) {
    1.31 +        y -= 0.9f;
    1.32 +    }
    1.33 +    SDL_SendMouseWheel(window, (int)x, (int)y);
    1.34 +}
    1.35 +
    1.36  /* vi: set ts=4 sw=4 expandtab: */