Commit be01a86b authored by Sam Lantinga's avatar Sam Lantinga

Implemented Cocoa mouse wheel events

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402003
parent c8d7322d
...@@ -60,11 +60,11 @@ typedef enum ...@@ -60,11 +60,11 @@ typedef enum
SDL_WINDOWEVENT, /**< Window state change */ SDL_WINDOWEVENT, /**< Window state change */
SDL_KEYDOWN, /**< Keys pressed */ SDL_KEYDOWN, /**< Keys pressed */
SDL_KEYUP, /**< Keys released */ SDL_KEYUP, /**< Keys released */
SDL_TEXTINPUT, /**< Keyboard text input */ SDL_TEXTINPUT, /**< Keyboard text input */
SDL_MOUSEMOTION, /**< Mouse moved */ SDL_MOUSEMOTION, /**< Mouse moved */
SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
SDL_MOUSEBUTTONUP, /**< Mouse button released */ SDL_MOUSEBUTTONUP, /**< Mouse button released */
SDL_MOUSEWHEEL, /**< Mouse wheel motion */ SDL_MOUSEWHEEL, /**< Mouse wheel motion */
SDL_JOYAXISMOTION, /**< Joystick axis motion */ SDL_JOYAXISMOTION, /**< Joystick axis motion */
SDL_JOYBALLMOTION, /**< Joystick trackball motion */ SDL_JOYBALLMOTION, /**< Joystick trackball motion */
SDL_JOYHATMOTION, /**< Joystick hat position change */ SDL_JOYHATMOTION, /**< Joystick hat position change */
......
...@@ -54,6 +54,7 @@ typedef struct SDL_WindowData SDL_WindowData; ...@@ -54,6 +54,7 @@ typedef struct SDL_WindowData SDL_WindowData;
-(void) rightMouseUp:(NSEvent *) theEvent; -(void) rightMouseUp:(NSEvent *) theEvent;
-(void) otherMouseUp:(NSEvent *) theEvent; -(void) otherMouseUp:(NSEvent *) theEvent;
-(void) mouseMoved:(NSEvent *) theEvent; -(void) mouseMoved:(NSEvent *) theEvent;
-(void) mouseDragged:(NSEvent *) theEvent;
-(void) scrollWheel:(NSEvent *) theEvent; -(void) scrollWheel:(NSEvent *) theEvent;
-(void) keyDown:(NSEvent *) theEvent; -(void) keyDown:(NSEvent *) theEvent;
-(void) keyUp:(NSEvent *) theEvent; -(void) keyUp:(NSEvent *) theEvent;
......
...@@ -208,26 +208,22 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -208,26 +208,22 @@ static __inline__ void ConvertNSRect(NSRect *r)
} }
point = [NSEvent mouseLocation]; point = [NSEvent mouseLocation];
if (point.x < rect.origin.x ||
point.x > (rect.origin.x + rect.size.width) ||
point.y < rect.origin.y ||
point.y > (rect.origin.y + rect.size.height)) {
if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_LEAVE, 0, 0);
}
} else {
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_ENTER, 0, 0);
}
}
point.x = point.x - rect.origin.x; point.x = point.x - rect.origin.x;
point.y = rect.size.height - (point.y - rect.origin.y); point.y = rect.size.height - (point.y - rect.origin.y);
SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y); SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y);
} }
- (void)mouseDragged:(NSEvent *)theEvent
{
[self mouseMoved:theEvent];
}
- (void)scrollWheel:(NSEvent *)theEvent - (void)scrollWheel:(NSEvent *)theEvent
{ {
fprintf(stderr, "scrollWheel\n"); int index;
index = _data->videodata->mouse;
SDL_SendMouseWheel(index, (int)([theEvent deltaY]+0.9f));
} }
- (void)keyDown:(NSEvent *)theEvent - (void)keyDown:(NSEvent *)theEvent
......
...@@ -827,7 +827,7 @@ PrintEvent(SDL_Event * event) ...@@ -827,7 +827,7 @@ PrintEvent(SDL_Event * event)
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
fprintf(stderr, "Mouse %d: wheel scrolled %d in window %d", fprintf(stderr, "Mouse %d: wheel scrolled %d in window %d",
event->wheel.which, event->wheel.motion, event->wheel.which, event->wheel.motion,
event->button.windowID); event->wheel.windowID);
break; break;
case SDL_JOYBALLMOTION: case SDL_JOYBALLMOTION:
fprintf(stderr, "Joystick %d: ball %d moved by %d,%d", fprintf(stderr, "Joystick %d: ball %d moved by %d,%d",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment