comparison src/video/cocoa/SDL_cocoamouse.m @ 5057:bdff53ed6c8b

Fix mouse wheel events in fullscreen mode for OS X With proposed patch by vernier.
author Jjgod Jiang <gzjjgod@gmail.com>
date Fri, 21 Jan 2011 00:15:18 +0100
parents 3d91e31fcf71
children 03db7d4b02b4
comparison
equal deleted inserted replaced
5056:8b7988f42fcb 5057:bdff53ed6c8b
91 case NSLeftMouseUp: 91 case NSLeftMouseUp:
92 case NSOtherMouseUp: 92 case NSOtherMouseUp:
93 case NSRightMouseUp: 93 case NSRightMouseUp:
94 SDL_SendMouseButton(window, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber])); 94 SDL_SendMouseButton(window, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber]));
95 break; 95 break;
96 case NSScrollWheel:
97 Cocoa_HandleMouseWheel(window, event);
98 break;
96 case NSLeftMouseDragged: 99 case NSLeftMouseDragged:
97 case NSRightMouseDragged: 100 case NSRightMouseDragged:
98 case NSOtherMouseDragged: /* usually middle mouse dragged */ 101 case NSOtherMouseDragged: /* usually middle mouse dragged */
99 case NSMouseMoved: 102 case NSMouseMoved:
100 SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y); 103 SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y);
107 void 110 void
108 Cocoa_QuitMouse(_THIS) 111 Cocoa_QuitMouse(_THIS)
109 { 112 {
110 } 113 }
111 114
115 void
116 Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
117 {
118 float x = [event deltaX];
119 float y = [event deltaY];
120
121 if (x > 0) {
122 x += 0.9f;
123 } else if (x < 0) {
124 x -= 0.9f;
125 }
126 if (y > 0) {
127 y += 0.9f;
128 } else if (y < 0) {
129 y -= 0.9f;
130 }
131 SDL_SendMouseWheel(window, (int)x, (int)y);
132 }
133
112 /* vi: set ts=4 sw=4 expandtab: */ 134 /* vi: set ts=4 sw=4 expandtab: */