Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events
authorDavid Ludwig <dludwig@pobox.com>
Sat, 22 Nov 2014 21:13:46 -0500
changeset 9226bea2e725e29a
parent 9225 5b97e1f05e53
child 9227 4d9126f64347
Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events

This patch makes sure that any SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, and
SDL_MOUSEMOTION events, as triggered by a touch event in a WinRT app, set the
event's 'which' field to SDL_TOUCH_MOUSEID. Previously, this was getting set
to the same value as events from a real mouse, '0'.

Thanks to Diego for providing information on this bug, and to Tamas Hamor for
sending over a patch!
src/video/winrt/SDL_winrtpointerinput.cpp
     1.1 --- a/src/video/winrt/SDL_winrtpointerinput.cpp	Sat Nov 22 22:20:40 2014 +0100
     1.2 +++ b/src/video/winrt/SDL_winrtpointerinput.cpp	Sat Nov 22 21:13:46 2014 -0500
     1.3 @@ -233,8 +233,8 @@
     1.4  
     1.5          if (!WINRT_LeftFingerDown) {
     1.6              if (button) {
     1.7 -                SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
     1.8 -                SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
     1.9 +                SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, (int)windowPoint.X, (int)windowPoint.Y);
    1.10 +                SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, button);
    1.11              }
    1.12  
    1.13              WINRT_LeftFingerDown = pointerPoint->PointerId;
    1.14 @@ -264,7 +264,7 @@
    1.15          SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
    1.16      } else {
    1.17          if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
    1.18 -            SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
    1.19 +            SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, (int)windowPoint.X, (int)windowPoint.Y);
    1.20          }
    1.21  
    1.22          SDL_SendTouchMotion(
    1.23 @@ -291,7 +291,7 @@
    1.24  
    1.25          if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
    1.26              if (button) {
    1.27 -                SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
    1.28 +                SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, button);
    1.29              }
    1.30              WINRT_LeftFingerDown = 0;
    1.31          }