Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix mouse wheel events in fullscreen mode for OS X

With proposed patch by vernier.
  • Loading branch information
jjgod committed Jan 20, 2011
1 parent 79ee2ff commit d63b12f7b121c1bedebade803a8289f79c3d84fa
@@ -201,6 +201,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged: /* usually middle mouse dragged */
case NSScrollWheel:
case NSMouseMoved:
Cocoa_HandleMouseEvent(_this, event);
/* Pass through to NSApp to make sure everything stays in sync */
@@ -27,6 +27,7 @@
extern void Cocoa_InitMouse(_THIS);
extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event);
extern void Cocoa_QuitMouse(_THIS);
extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event);

#endif /* _SDL_cocoamouse_h */

@@ -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: */
@@ -29,6 +29,7 @@
#include "../../events/SDL_windowevents_c.h"
#include "SDL_cocoavideo.h"
#include "SDL_cocoashape.h"
#include "SDL_cocoamouse.h"

static __inline__ void ConvertNSRect(NSRect *r)
{
@@ -260,20 +261,7 @@ - (void)otherMouseDragged:(NSEvent *)theEvent

- (void)scrollWheel:(NSEvent *)theEvent
{
float x = [theEvent deltaX];
float y = [theEvent 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(_data->window, (int)x, (int)y);
Cocoa_HandleMouseWheel(_data->window, theEvent);
}

- (void)touchesBeganWithEvent:(NSEvent *) theEvent

0 comments on commit d63b12f

Please sign in to comment.