From 3b050fc953ec6e1c025b77f34bd9991114846bd9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 6 Nov 2013 23:35:08 -0800 Subject: [PATCH] Horizontal wheel support in windows Lorenzo Pistone this patch adds support for the horizontal wheel in Windows. It is shamelessly copied off the vertical wheel code, but I guess that that is a value added in consistency. --- src/video/windows/SDL_windowsevents.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 1826258c820cc..0c9fcb94fd8b9 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -67,6 +67,9 @@ #ifndef WM_TOUCH #define WM_TOUCH 0x0240 #endif +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif static SDL_Scancode WindowsScanCodeToSDLScanCode( LPARAM lParam, WPARAM wParam ) @@ -481,6 +484,25 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; } + case WM_MOUSEHWHEEL: + { + static short s_AccumulatedMotion; + + s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam); + if (s_AccumulatedMotion > 0) { + while (s_AccumulatedMotion >= WHEEL_DELTA) { + SDL_SendMouseWheel(data->window, 0, 1, 0, timestamp); + s_AccumulatedMotion -= WHEEL_DELTA; + } + } else { + while (s_AccumulatedMotion <= -WHEEL_DELTA) { + SDL_SendMouseWheel(data->window, 0, -1, 0, timestamp); + s_AccumulatedMotion += WHEEL_DELTA; + } + } + break; + } + #ifdef WM_MOUSELEAVE case WM_MOUSELEAVE: if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode) {