add in support for passing down the "natural" (or flipped) scrolling direction in the MouseWheelEvent event
--- a/include/SDL_events.h Wed Dec 03 10:55:23 2014 -0500
+++ b/include/SDL_events.h Sun Nov 23 21:09:54 2014 -0500
@@ -260,6 +260,7 @@
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
+ Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
} SDL_MouseWheelEvent;
/**
--- a/include/SDL_mouse.h Wed Dec 03 10:55:23 2014 -0500
+++ b/include/SDL_mouse.h Sun Nov 23 21:09:54 2014 -0500
@@ -60,6 +60,15 @@
SDL_NUM_SYSTEM_CURSORS
} SDL_SystemCursor;
+/**
+ * \brief Scroll direction types for the Scroll event
+ */
+typedef enum
+{
+ SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */
+ SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */
+} SDL_MouseWheelDirection;
+
/* Function prototypes */
/**
--- a/src/core/linux/SDL_evdev.c Wed Dec 03 10:55:23 2014 -0500
+++ b/src/core/linux/SDL_evdev.c Sun Nov 23 21:09:54 2014 -0500
@@ -681,10 +681,10 @@
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value);
break;
case REL_WHEEL:
- SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value);
+ SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value, SDL_MOUSEWHEEL_NORMAL);
break;
case REL_HWHEEL:
- SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0);
+ SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL);
break;
default:
break;
--- a/src/events/SDL_mouse.c Wed Dec 03 10:55:23 2014 -0500
+++ b/src/events/SDL_mouse.c Sun Nov 23 21:09:54 2014 -0500
@@ -397,7 +397,7 @@
}
int
-SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y)
+SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction)
{
SDL_Mouse *mouse = SDL_GetMouse();
int posted;
@@ -419,6 +419,7 @@
event.wheel.which = mouseID;
event.wheel.x = x;
event.wheel.y = y;
+ event.wheel.direction = (Uint32)direction;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
--- a/src/events/SDL_mouse_c.h Wed Dec 03 10:55:23 2014 -0500
+++ b/src/events/SDL_mouse_c.h Sun Nov 23 21:09:54 2014 -0500
@@ -120,7 +120,7 @@
extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button);
/* Send a mouse wheel event */
-extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y);
+extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction);
/* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void);
--- a/src/main/haiku/SDL_BApp.h Wed Dec 03 10:55:23 2014 -0500
+++ b/src/main/haiku/SDL_BApp.h Sun Nov 23 21:09:54 2014 -0500
@@ -254,7 +254,7 @@
return;
}
win = GetSDLWindow(winID);
- SDL_SendMouseWheel(win, 0, xTicks, yTicks);
+ SDL_SendMouseWheel(win, 0, xTicks, yTicks, SDL_MOUSEWHEEL_NORMAL);
}
void _HandleKey(BMessage *msg) {
--- a/src/video/cocoa/SDL_cocoamouse.m Wed Dec 03 10:55:23 2014 -0500
+++ b/src/video/cocoa/SDL_cocoamouse.m Sun Nov 23 21:09:54 2014 -0500
@@ -399,6 +399,13 @@
float x = -[event deltaX];
float y = [event deltaY];
+ SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
+
+ if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
+ if ([event isDirectionInvertedFromDevice] == YES) {
+ direction = SDL_MOUSEWHEEL_FLIPPED;
+ }
+ }
if (x > 0) {
x += 0.9f;
@@ -410,7 +417,7 @@
} else if (y < 0) {
y -= 0.9f;
}
- SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y);
+ SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, direction);
}
void
--- a/src/video/mir/SDL_mirevents.c Wed Dec 03 10:55:23 2014 -0500
+++ b/src/video/mir/SDL_mirevents.c Sun Nov 23 21:09:54 2014 -0500
@@ -137,7 +137,7 @@
static void
HandleMouseScroll(SDL_Window* sdl_window, int hscroll, int vscroll)
{
- SDL_SendMouseWheel(sdl_window, 0, hscroll, vscroll);
+ SDL_SendMouseWheel(sdl_window, 0, hscroll, vscroll, SDL_MOUSEWHEEL_NORMAL);
}
static void
--- a/src/video/nacl/SDL_naclevents.c Wed Dec 03 10:55:23 2014 -0500
+++ b/src/video/nacl/SDL_naclevents.c Sun Nov 23 21:09:54 2014 -0500
@@ -357,7 +357,7 @@
case PP_INPUTEVENT_TYPE_WHEEL:
/* FIXME: GetTicks provides high resolution scroll events */
fp = driverdata->ppb_wheel_input_event->GetDelta(event);
- SDL_SendMouseWheel(mouse->focus, mouse->mouseID, (int) fp.x, (int) fp.y);
+ SDL_SendMouseWheel(mouse->focus, mouse->mouseID, (int) fp.x, (int) fp.y, SDL_MOUSEWHEEL_NORMAL);
break;
case PP_INPUTEVENT_TYPE_MOUSEENTER:
--- a/src/video/wayland/SDL_waylandevents.c Wed Dec 03 10:55:23 2014 -0500
+++ b/src/video/wayland/SDL_waylandevents.c Sun Nov 23 21:09:54 2014 -0500
@@ -184,7 +184,7 @@
return;
}
- SDL_SendMouseWheel(window->sdlwindow, 0, x, y);
+ SDL_SendMouseWheel(window->sdlwindow, 0, x, y, SDL_MOUSEWHEEL_NORMAL);
}
}
--- a/src/video/windows/SDL_windowsevents.c Wed Dec 03 10:55:23 2014 -0500
+++ b/src/video/windows/SDL_windowsevents.c Sun Nov 23 21:09:54 2014 -0500
@@ -498,12 +498,12 @@
s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
if (s_AccumulatedMotion > 0) {
while (s_AccumulatedMotion >= WHEEL_DELTA) {
- SDL_SendMouseWheel(data->window, 0, 0, 1);
+ SDL_SendMouseWheel(data->window, 0, 0, 1, SDL_MOUSEWHEEL_NORMAL);
s_AccumulatedMotion -= WHEEL_DELTA;
}
} else {
while (s_AccumulatedMotion <= -WHEEL_DELTA) {
- SDL_SendMouseWheel(data->window, 0, 0, -1);
+ SDL_SendMouseWheel(data->window, 0, 0, -1, SDL_MOUSEWHEEL_NORMAL);
s_AccumulatedMotion += WHEEL_DELTA;
}
}
@@ -517,12 +517,12 @@
s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
if (s_AccumulatedMotion > 0) {
while (s_AccumulatedMotion >= WHEEL_DELTA) {
- SDL_SendMouseWheel(data->window, 0, 1, 0);
+ SDL_SendMouseWheel(data->window, 0, 1, 0, SDL_MOUSEWHEEL_NORMAL);
s_AccumulatedMotion -= WHEEL_DELTA;
}
} else {
while (s_AccumulatedMotion <= -WHEEL_DELTA) {
- SDL_SendMouseWheel(data->window, 0, -1, 0);
+ SDL_SendMouseWheel(data->window, 0, -1, 0, SDL_MOUSEWHEEL_NORMAL);
s_AccumulatedMotion += WHEEL_DELTA;
}
}
--- a/src/video/winrt/SDL_winrtpointerinput.cpp Wed Dec 03 10:55:23 2014 -0500
+++ b/src/video/winrt/SDL_winrtpointerinput.cpp Sun Nov 23 21:09:54 2014 -0500
@@ -315,7 +315,7 @@
// FIXME: This may need to accumulate deltas up to WHEEL_DELTA
short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
- SDL_SendMouseWheel(window, 0, 0, motion);
+ SDL_SendMouseWheel(window, 0, 0, motion, SDL_MOUSEWHEEL_NORMAL);
}
void
--- a/src/video/x11/SDL_x11events.c Wed Dec 03 10:55:23 2014 -0500
+++ b/src/video/x11/SDL_x11events.c Sun Nov 23 21:09:54 2014 -0500
@@ -990,7 +990,7 @@
case ButtonPress:{
int ticks = 0;
if (X11_IsWheelEvent(display,&xevent,&ticks)) {
- SDL_SendMouseWheel(data->window, 0, 0, ticks);
+ SDL_SendMouseWheel(data->window, 0, 0, ticks, SDL_MOUSEWHEEL_NORMAL);
} else {
if(xevent.xbutton.button == Button1) {
if (ProcessHitTest(_this, data, &xevent)) {