Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index c33dabf..7a3ceb3 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -466,10 +466,20 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
{
- /* FIXME: This may need to accumulate deltas up to WHEEL_DELTA */
- short motion = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
+ static short s_AccumulatedMotion;
- SDL_SendMouseWheel(data->window, 0, 0, motion);
+ s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
+ if (s_AccumulatedMotion > 0) {
+ while (s_AccumulatedMotion >= WHEEL_DELTA) {
+ SDL_SendMouseWheel(data->window, 0, 0, 1);
+ s_AccumulatedMotion -= WHEEL_DELTA;
+ }
+ } else {
+ while (s_AccumulatedMotion <= -WHEEL_DELTA) {
+ SDL_SendMouseWheel(data->window, 0, 0, -1);
+ s_AccumulatedMotion += WHEEL_DELTA;
+ }
+ }
break;
}