WinRT: fixed two bugs regarding mouse events
authorDavid Ludwig <dludwig@pobox.com>
Sun, 27 Oct 2013 14:31:57 -0400
changeset 853450177f518fdb
parent 8533 89cf2a2635d1
child 8535 e8ee0708ef5c
WinRT: fixed two bugs regarding mouse events

The first bug had mouse motion events not getting sent out on non-touch devices, if and when a mouse button wasn't pressed.

The second bug caused virtual mouse motion events to get sent out-of-order on touch devices: the motion event would get sent after the touch occurred, rather than before.
src/video/winrt/SDL_winrtpointerinput.cpp
     1.1 --- a/src/video/winrt/SDL_winrtpointerinput.cpp	Fri Oct 25 20:31:43 2013 -0400
     1.2 +++ b/src/video/winrt/SDL_winrtpointerinput.cpp	Sun Oct 27 14:31:57 2013 -0400
     1.3 @@ -209,20 +209,20 @@
     1.4      }
     1.5  
     1.6      Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
     1.7 +    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
     1.8  
     1.9 -    if (!WINRT_LeftFingerDown) {
    1.10 -        Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
    1.11 -        if (button) {
    1.12 -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    1.13 -            SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
    1.14 -#endif
    1.15 -            SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
    1.16 +    if (!WINRT_IsTouchEvent(pointerPoint)) {
    1.17 +        SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
    1.18 +    } else {
    1.19 +        if (!WINRT_LeftFingerDown) {
    1.20 +            if (button) {
    1.21 +                SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
    1.22 +                SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
    1.23 +            }
    1.24 +
    1.25 +            WINRT_LeftFingerDown = pointerPoint->PointerId;
    1.26          }
    1.27  
    1.28 -        WINRT_LeftFingerDown = pointerPoint->PointerId;
    1.29 -    }
    1.30 -
    1.31 -    if (WINRT_IsTouchEvent(pointerPoint)) {
    1.32          SDL_SendTouch(
    1.33              WINRT_TouchID,
    1.34              (SDL_FingerID) pointerPoint->PointerId,
    1.35 @@ -242,11 +242,13 @@
    1.36  
    1.37      Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
    1.38  
    1.39 -    if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
    1.40 +    if (!WINRT_IsTouchEvent(pointerPoint)) {
    1.41          SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
    1.42 -    }
    1.43 +    } else if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
    1.44 +        if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
    1.45 +            SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
    1.46 +        }
    1.47  
    1.48 -    if (WINRT_IsTouchEvent(pointerPoint)) {
    1.49          SDL_SendTouchMotion(
    1.50              WINRT_TouchID,
    1.51              (SDL_FingerID) pointerPoint->PointerId,
    1.52 @@ -263,16 +265,18 @@
    1.53      }
    1.54  
    1.55      Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
    1.56 +    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
    1.57  
    1.58 -    if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
    1.59 -        Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
    1.60 -        if (button) {
    1.61 -            SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
    1.62 +    if (!WINRT_IsTouchEvent(pointerPoint)) {
    1.63 +        SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
    1.64 +    } else {
    1.65 +        if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
    1.66 +            if (button) {
    1.67 +                SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
    1.68 +            }
    1.69 +            WINRT_LeftFingerDown = 0;
    1.70          }
    1.71 -        WINRT_LeftFingerDown = 0;
    1.72 -    }
    1.73 -
    1.74 -    if (WINRT_IsTouchEvent(pointerPoint)) {
    1.75 +    
    1.76          SDL_SendTouch(
    1.77              WINRT_TouchID,
    1.78              (SDL_FingerID) pointerPoint->PointerId,