Skip to content

Commit

Permalink
Horizontal wheel support in windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Nov 7, 2013
1 parent 22770a8 commit 3b050fc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/video/windows/SDL_windowsevents.c
Expand Up @@ -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 )
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3b050fc

Please sign in to comment.