Horizontal wheel support in windows
authorSam Lantinga <slouken@libsdl.org>
Wed, 06 Nov 2013 23:35:08 -0800
changeset 7911a9135f92ddba
parent 7910 261addaa47d0
child 7912 10eff60470b3
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
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Wed Nov 06 11:23:24 2013 -0300
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Wed Nov 06 23:35:08 2013 -0800
     1.3 @@ -67,6 +67,9 @@
     1.4  #ifndef WM_TOUCH
     1.5  #define WM_TOUCH 0x0240
     1.6  #endif
     1.7 +#ifndef WM_MOUSEHWHEEL
     1.8 +#define WM_MOUSEHWHEEL 0x020E
     1.9 +#endif
    1.10  
    1.11  static SDL_Scancode
    1.12  WindowsScanCodeToSDLScanCode( LPARAM lParam, WPARAM wParam )
    1.13 @@ -481,6 +484,25 @@
    1.14              break;
    1.15          }
    1.16  
    1.17 +    case WM_MOUSEHWHEEL:
    1.18 +        {
    1.19 +            static short s_AccumulatedMotion;
    1.20 +
    1.21 +            s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
    1.22 +            if (s_AccumulatedMotion > 0) {
    1.23 +                while (s_AccumulatedMotion >= WHEEL_DELTA) {
    1.24 +                    SDL_SendMouseWheel(data->window, 0, 1, 0, timestamp);
    1.25 +                    s_AccumulatedMotion -= WHEEL_DELTA;
    1.26 +                }
    1.27 +            } else {
    1.28 +                while (s_AccumulatedMotion <= -WHEEL_DELTA) {
    1.29 +                    SDL_SendMouseWheel(data->window, 0, -1, 0, timestamp);
    1.30 +                    s_AccumulatedMotion += WHEEL_DELTA;
    1.31 +                }
    1.32 +            }
    1.33 +            break;
    1.34 +        }
    1.35 +
    1.36  #ifdef WM_MOUSELEAVE
    1.37      case WM_MOUSELEAVE:
    1.38          if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode) {