Fix mouse wheel events in fullscreen mode for OS X
With proposed patch by vernier.
This commit is contained in:
parent
5c9e54ea34
commit
e666b3b289
4 changed files with 26 additions and 14 deletions
|
@ -201,6 +201,7 @@ Cocoa_PumpEvents(_THIS)
|
|||
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 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
|
|||
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 @@ Cocoa_QuitMouse(_THIS)
|
|||
{
|
||||
}
|
||||
|
||||
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 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
|||
|
||||
- (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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue