mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Fixed bug 2346 - Mac: mousewheel events have flipped horizontal scroll values
Alex Szpakowski On my Mac OS X system (10.9.1), the SDL_MOUSEWHEEL event reports negative X values when my trackpad scrolls to the right, and positive X values when my trackpad scrolls to the left. This is backwards from what I'd expect, and I don't think it matches the Windows wheel events. The vertical scroll values are what I'd expect though, and are consistent what gets reported on Windows (positive Y for scrolling up, negative Y for scrolling down.) This is with "scroll direction: natural" disabled in the OS X trackpad settings (i.e. my scroll direction in non-SDL OS X programs matches what happens in Windows and Linux.) I also tested with the horizontal scroll on a real mouse (Logitech G500 without custom drivers), and the horizontal scroll values in SDL are still flipped. I "solved" the issue for myself by changing this line in the Cocoa_HandleMouseWheel function: float x = [event deltaX]; to this: float x = -[event deltaX]; I believe it should work fine with that change - I found something similar in another codebase while looking online for my issue - but I haven't tested on anything below Mac OS 10.8.
This commit is contained in:
parent
7c33f23361
commit
af0ab49003
@ -257,8 +257,8 @@ typedef struct SDL_MouseWheelEvent
|
|||||||
Uint32 timestamp;
|
Uint32 timestamp;
|
||||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||||
Sint32 x; /**< The amount scrolled horizontally */
|
Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
|
||||||
Sint32 y; /**< The amount scrolled vertically */
|
Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
|
||||||
} SDL_MouseWheelEvent;
|
} SDL_MouseWheelEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,7 +291,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
|||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
|
||||||
float x = [event deltaX];
|
float x = -[event deltaX];
|
||||||
float y = [event deltaY];
|
float y = [event deltaY];
|
||||||
|
|
||||||
if (x > 0) {
|
if (x > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user