src/video/winrt/SDL_winrtmouse.cpp
changeset 8511 326b43e1276b
parent 8505 a76a3842c9eb
child 8512 5b345a756965
     1.1 --- a/src/video/winrt/SDL_winrtmouse.cpp	Wed Aug 28 15:27:01 2013 -0400
     1.2 +++ b/src/video/winrt/SDL_winrtmouse.cpp	Wed Aug 28 16:14:27 2013 -0400
     1.3 @@ -160,8 +160,8 @@
     1.4  }
     1.5  
     1.6  // Applies necessary geometric transformations to raw cursor positions:
     1.7 -static Windows::Foundation::Point
     1.8 -TransformCursor(SDL_Window * window, Windows::Foundation::Point rawPosition)
     1.9 +Windows::Foundation::Point
    1.10 +WINRT_TransformCursorPosition(SDL_Window * window, Windows::Foundation::Point rawPosition)
    1.11  {
    1.12      if (!window) {
    1.13          return rawPosition;
    1.14 @@ -247,7 +247,7 @@
    1.15      // to SDL window coordinates.
    1.16      //
    1.17      const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
    1.18 -    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = TransformCursor(window, mouseDeltaInDIPs);
    1.19 +    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs);
    1.20      SDL_SendMouseMotion(
    1.21          window,
    1.22          0,
    1.23 @@ -256,11 +256,14 @@
    1.24          _lround(mouseDeltaInSDLWindowCoords.Y));
    1.25  }
    1.26  
    1.27 -static Uint8
    1.28 +Uint8
    1.29  WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
    1.30  {
    1.31      using namespace Windows::UI::Input;
    1.32  
    1.33 +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    1.34 +    return SDL_BUTTON_LEFT;
    1.35 +#else
    1.36      switch (pt->Properties->PointerUpdateKind)
    1.37      {
    1.38          case PointerUpdateKind::LeftButtonPressed:
    1.39 @@ -286,80 +289,59 @@
    1.40          default:
    1.41              break;
    1.42      }
    1.43 +#endif
    1.44  
    1.45      return 0;
    1.46  }
    1.47  
    1.48 -static const char *
    1.49 -WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
    1.50 -{
    1.51 -    using namespace Windows::UI::Input;
    1.52 -
    1.53 -    switch (kind)
    1.54 -    {
    1.55 -        case PointerUpdateKind::Other:
    1.56 -            return "Other";
    1.57 -        case PointerUpdateKind::LeftButtonPressed:
    1.58 -            return "LeftButtonPressed";
    1.59 -        case PointerUpdateKind::LeftButtonReleased:
    1.60 -            return "LeftButtonReleased";
    1.61 -        case PointerUpdateKind::RightButtonPressed:
    1.62 -            return "RightButtonPressed";
    1.63 -        case PointerUpdateKind::RightButtonReleased:
    1.64 -            return "RightButtonReleased";
    1.65 -        case PointerUpdateKind::MiddleButtonPressed:
    1.66 -            return "MiddleButtonPressed";
    1.67 -        case PointerUpdateKind::MiddleButtonReleased:
    1.68 -            return "MiddleButtonReleased";
    1.69 -        case PointerUpdateKind::XButton1Pressed:
    1.70 -            return "XButton1Pressed";
    1.71 -        case PointerUpdateKind::XButton1Released:
    1.72 -            return "XButton1Released";
    1.73 -        case PointerUpdateKind::XButton2Pressed:
    1.74 -            return "XButton2Pressed";
    1.75 -        case PointerUpdateKind::XButton2Released:
    1.76 -            return "XButton2Released";
    1.77 -    }
    1.78 -
    1.79 -    return "";
    1.80 -}
    1.81 -
    1.82 -static void
    1.83 -WINRT_LogPointerEvent(const char * header, PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
    1.84 -{
    1.85 -    Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
    1.86 -    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, PointerUpdateKind=%s\n",
    1.87 -        header,
    1.88 -        pt->Position.X, pt->Position.Y,
    1.89 -        transformedPoint.X, transformedPoint.Y,
    1.90 -        pt->Properties->MouseWheelDelta,
    1.91 -        pt->FrameId,
    1.92 -        pt->PointerId,
    1.93 -        WINRT_ConvertPointerUpdateKindToString(args->CurrentPoint->Properties->PointerUpdateKind));
    1.94 -}
    1.95 +//const char *
    1.96 +//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
    1.97 +//{
    1.98 +//    using namespace Windows::UI::Input;
    1.99 +//
   1.100 +//    switch (kind)
   1.101 +//    {
   1.102 +//        case PointerUpdateKind::Other:
   1.103 +//            return "Other";
   1.104 +//        case PointerUpdateKind::LeftButtonPressed:
   1.105 +//            return "LeftButtonPressed";
   1.106 +//        case PointerUpdateKind::LeftButtonReleased:
   1.107 +//            return "LeftButtonReleased";
   1.108 +//        case PointerUpdateKind::RightButtonPressed:
   1.109 +//            return "RightButtonPressed";
   1.110 +//        case PointerUpdateKind::RightButtonReleased:
   1.111 +//            return "RightButtonReleased";
   1.112 +//        case PointerUpdateKind::MiddleButtonPressed:
   1.113 +//            return "MiddleButtonPressed";
   1.114 +//        case PointerUpdateKind::MiddleButtonReleased:
   1.115 +//            return "MiddleButtonReleased";
   1.116 +//        case PointerUpdateKind::XButton1Pressed:
   1.117 +//            return "XButton1Pressed";
   1.118 +//        case PointerUpdateKind::XButton1Released:
   1.119 +//            return "XButton1Released";
   1.120 +//        case PointerUpdateKind::XButton2Pressed:
   1.121 +//            return "XButton2Pressed";
   1.122 +//        case PointerUpdateKind::XButton2Released:
   1.123 +//            return "XButton2Released";
   1.124 +//    }
   1.125 +//
   1.126 +//    return "";
   1.127 +//}
   1.128  
   1.129  void
   1.130  WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
   1.131  {
   1.132 -#if LOG_POINTER_EVENTS
   1.133 -    WINRT_LogPointerEvent("pointer moved", args, TransformCursor(pointerPoint->Position));
   1.134 -#endif
   1.135 -
   1.136      if (!window || WINRT_UseRelativeMouseMode) {
   1.137          return;
   1.138      }
   1.139  
   1.140 -    Windows::Foundation::Point transformedPoint = TransformCursor(window, pointerPoint->Position);
   1.141 +    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
   1.142      SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
   1.143  }
   1.144  
   1.145  void
   1.146  WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
   1.147  {
   1.148 -#if LOG_POINTER_EVENTS
   1.149 -    WINRT_LogPointerEvent("wheel changed", args, TransformCursor(pointerPoint->Position));
   1.150 -#endif
   1.151 -
   1.152      if (!window) {
   1.153          return;
   1.154      }
   1.155 @@ -371,10 +353,6 @@
   1.156  
   1.157  void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
   1.158  {
   1.159 -#if LOG_POINTER_EVENTS
   1.160 -    WINRT_LogPointerEvent("mouse up", args, TransformCursor(args->CurrentPoint->Position));
   1.161 -#endif
   1.162 -
   1.163      if (!window) {
   1.164          return;
   1.165      }
   1.166 @@ -387,16 +365,16 @@
   1.167  
   1.168  void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
   1.169  {
   1.170 -#if LOG_POINTER_EVENTS
   1.171 -    WINRT_LogPointerEvent("mouse down", args, TransformCursor(args->CurrentPoint->Position));
   1.172 -#endif
   1.173 -
   1.174      if (!window) {
   1.175          return;
   1.176      }
   1.177  
   1.178      Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
   1.179      if (button) {
   1.180 +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
   1.181 +        Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
   1.182 +        SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
   1.183 +#endif
   1.184          SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
   1.185      }
   1.186  }