WinRT: minor code cleanup regarding events
authorDavid Ludwig <dludwig@pobox.com>
Fri, 06 Sep 2013 21:00:52 -0400
changeset 8521 cefdaf414ead
parent 8520 66c31b377506
child 8522 3ae9dc9c439f
WinRT: minor code cleanup regarding events Some event handling functions got sorted in a somewhat consistent manner, and in some cases, were also segregated a bit from app-lifecycle code.
src/core/winrt/SDL_winrtapp.cpp
src/core/winrt/SDL_winrtxaml.cpp
src/video/winrt/SDL_winrtevents_c.h
src/video/winrt/SDL_winrtpointerinput.cpp
--- a/src/core/winrt/SDL_winrtapp.cpp	Fri Sep 06 19:23:42 2013 -0400
+++ b/src/core/winrt/SDL_winrtapp.cpp	Fri Sep 06 21:00:52 2013 -0400
@@ -299,15 +299,15 @@
     window->PointerPressed +=
         ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
 
+    window->PointerMoved +=
+        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
+
     window->PointerReleased +=
         ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
 
     window->PointerWheelChanged +=
         ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
 
-    window->PointerMoved +=
-        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
-
 #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
     // Retrieves relative-only mouse movements:
     Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
@@ -409,71 +409,6 @@
     m_windowClosed = true;
 }
 
-static void
-WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
-{
-    Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
-    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
-        header,
-        pt->Position.X, pt->Position.Y,
-        transformedPoint.X, transformedPoint.Y,
-        pt->Properties->MouseWheelDelta,
-        pt->FrameId,
-        pt->PointerId,
-        WINRT_GetSDLButtonForPointerPoint(pt));
-}
-
-void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
-    WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
-    WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
-    WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
-    WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
-    WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
-    WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
-    WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
-    WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
-{
-    WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
-}
-
-void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
-{
-    WINRT_ProcessKeyDownEvent(args);
-}
-
-void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
-{
-    WINRT_ProcessKeyUpEvent(args);
-}
-
 void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
 {
     CoreWindow::GetForCurrentThread()->Activate();
@@ -547,3 +482,68 @@
         SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
     }
 }
+
+static void
+WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
+{
+    Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
+    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
+        header,
+        pt->Position.X, pt->Position.Y,
+        transformedPoint.X, transformedPoint.Y,
+        pt->Properties->MouseWheelDelta,
+        pt->FrameId,
+        pt->PointerId,
+        WINRT_GetSDLButtonForPointerPoint(pt));
+}
+
+void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+    WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+    WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+    WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+    WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+    WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+    WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+    WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+    WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
+{
+    WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
+}
+
+void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+    WINRT_ProcessKeyDownEvent(args);
+}
+
+void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+    WINRT_ProcessKeyUpEvent(args);
+}
--- a/src/core/winrt/SDL_winrtxaml.cpp	Fri Sep 06 19:23:42 2013 -0400
+++ b/src/core/winrt/SDL_winrtxaml.cpp	Fri Sep 06 21:00:52 2013 -0400
@@ -58,6 +58,12 @@
 }
 
 static void
+WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+    WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+static void
 WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
 {
     WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
@@ -69,12 +75,6 @@
     WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
 }
 
-static void
-WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
-    WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
 #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
 
 
--- a/src/video/winrt/SDL_winrtevents_c.h	Fri Sep 06 19:23:42 2013 -0400
+++ b/src/video/winrt/SDL_winrtevents_c.h	Fri Sep 06 21:00:52 2013 -0400
@@ -45,19 +45,19 @@
  */
 #ifdef __cplusplus_winrt
 
+/* Pointers (Mice, Touch, etc.) */
+extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window * window, Windows::Foundation::Point rawPosition);
+extern Uint8 WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt);
+extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
+extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
+extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
+extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
+extern void WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args);
+
 /* Keyboard */
 extern void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args);
 extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args);
 
-/* Pointers (Mice, Touch, etc.) */
-extern void WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args);
-extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
-extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
-extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
-extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
-extern Uint8 WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt);
-extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window * window, Windows::Foundation::Point rawPosition);
-
 /* XAML Thread Management */
 extern void WINRT_CycleXAMLThread();
 
--- a/src/video/winrt/SDL_winrtpointerinput.cpp	Fri Sep 06 19:23:42 2013 -0400
+++ b/src/video/winrt/SDL_winrtpointerinput.cpp	Fri Sep 06 21:00:52 2013 -0400
@@ -47,7 +47,6 @@
     SDL_AddTouch(WINRT_TouchID, "");
 }
 
-
 // Applies necessary geometric transformations to raw cursor positions:
 Windows::Foundation::Point
 WINRT_TransformCursorPosition(SDL_Window * window, Windows::Foundation::Point rawPosition)
@@ -114,79 +113,6 @@
     }
 }
 
-void
-WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
-{
-    if (!window || !WINRT_UsingRelativeMouseMode) {
-        return;
-    }
-
-    // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
-    // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
-    // MouseDelta field often reports very large values.  More information
-    // on this can be found at the following pages on MSDN:
-    //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
-    //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
-    //
-    // The values do not appear to be as large when running on some systems,
-    // most notably a Surface RT.  Furthermore, the values returned by
-    // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
-    // method, do not ever appear to be large, even when MouseEventArgs'
-    // MouseDelta is reporting to the contrary.
-    //
-    // On systems with the large-values behavior, it appears that the values
-    // get reported as if the screen's size is 65536 units in both the X and Y
-    // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
-    // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
-    //
-    // MSDN's documentation on MouseEventArgs' MouseDelta field (at
-    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
-    // does not seem to indicate (to me) that its values should be so large.  It
-    // says that its values should be a "change in screen location".  I could
-    // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
-    // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
-    // indicates that these values are in DIPs, which is the same unit used
-    // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
-    // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
-    // for details.)
-    //
-    // To note, PointerMoved events are sent a 'RawPosition' value (via the
-    // CurrentPoint property in MouseEventArgs), however these do not seem
-    // to exhibit the same large-value behavior.
-    //
-    // The values passed via PointerMoved events can't always be used for relative
-    // mouse motion, unfortunately.  Its values are bound to the cursor's position,
-    // which stops when it hits one of the screen's edges.  This can be a problem in
-    // first person shooters, whereby it is normal for mouse motion to travel far
-    // along any one axis for a period of time.  MouseMoved events do not have the
-    // screen-bounding limitation, and can be used regardless of where the system's
-    // cursor is.
-    //
-    // One possible workaround would be to programmatically set the cursor's
-    // position to the screen's center (when SDL's relative mouse mode is enabled),
-    // however WinRT does not yet seem to have the ability to set the cursor's
-    // position via a public API.  Win32 did this via an API call, SetCursorPos,
-    // however WinRT makes this function be private.  Apps that use it won't get
-    // approved for distribution in the Windows Store.  I've yet to be able to find
-    // a suitable, store-friendly counterpart for WinRT.
-    //
-    // There may be some room for a workaround whereby OnPointerMoved's values
-    // are compared to the values from OnMouseMoved in order to detect
-    // when this bug is active.  A suitable transformation could then be made to
-    // OnMouseMoved's values.  For now, however, the system-reported values are sent
-    // to SDL with minimal transformation: from native screen coordinates (in DIPs)
-    // to SDL window coordinates.
-    //
-    const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
-    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs);
-    SDL_SendMouseMotion(
-        window,
-        0,
-        1,
-        _lround(mouseDeltaInSDLWindowCoords.X),
-        _lround(mouseDeltaInSDLWindowCoords.Y));
-}
-
 Uint8
 WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
 {
@@ -276,68 +202,6 @@
 #endif
 }
 
-void
-WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
-{
-    if (!window || WINRT_UsingRelativeMouseMode) {
-        return;
-    }
-
-    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
-
-    if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
-        SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
-    }
-
-    if (WINRT_IsTouchEvent(pointerPoint)) {
-        SDL_SendTouchMotion(
-            WINRT_TouchID,
-            (SDL_FingerID) pointerPoint->PointerId,
-            transformedPoint.X,
-            transformedPoint.Y,
-            pointerPoint->Properties->Pressure);
-    }
-}
-
-void
-WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
-{
-    if (!window) {
-        return;
-    }
-
-    // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
-    short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
-    SDL_SendMouseWheel(window, 0, 0, motion);
-}
-
-void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
-{
-    if (!window) {
-        return;
-    }
-
-    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
-
-    if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
-        Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
-        if (button) {
-            SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
-        }
-        WINRT_LeftFingerDown = 0;
-    }
-
-    if (WINRT_IsTouchEvent(pointerPoint)) {
-        SDL_SendTouch(
-            WINRT_TouchID,
-            (SDL_FingerID) pointerPoint->PointerId,
-            SDL_FALSE,
-            transformedPoint.X,
-            transformedPoint.Y,
-            pointerPoint->Properties->Pressure);
-    }
-}
-
 void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
 {
     if (!window) {
@@ -368,5 +232,140 @@
             pointerPoint->Properties->Pressure);
     }
 }
+
+void
+WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
+{
+    if (!window || WINRT_UsingRelativeMouseMode) {
+        return;
+    }
+
+    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
+
+    if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
+        SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
+    }
+
+    if (WINRT_IsTouchEvent(pointerPoint)) {
+        SDL_SendTouchMotion(
+            WINRT_TouchID,
+            (SDL_FingerID) pointerPoint->PointerId,
+            transformedPoint.X,
+            transformedPoint.Y,
+            pointerPoint->Properties->Pressure);
+    }
+}
+
+void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
+{
+    if (!window) {
+        return;
+    }
+
+    Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
+
+    if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
+        Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
+        if (button) {
+            SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
+        }
+        WINRT_LeftFingerDown = 0;
+    }
+
+    if (WINRT_IsTouchEvent(pointerPoint)) {
+        SDL_SendTouch(
+            WINRT_TouchID,
+            (SDL_FingerID) pointerPoint->PointerId,
+            SDL_FALSE,
+            transformedPoint.X,
+            transformedPoint.Y,
+            pointerPoint->Properties->Pressure);
+    }
+}
+
+void
+WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
+{
+    if (!window) {
+        return;
+    }
+
+    // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
+    short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
+    SDL_SendMouseWheel(window, 0, 0, motion);
+}
+
+void
+WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
+{
+    if (!window || !WINRT_UsingRelativeMouseMode) {
+        return;
+    }
+
+    // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
+    // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
+    // MouseDelta field often reports very large values.  More information
+    // on this can be found at the following pages on MSDN:
+    //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
+    //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
+    //
+    // The values do not appear to be as large when running on some systems,
+    // most notably a Surface RT.  Furthermore, the values returned by
+    // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
+    // method, do not ever appear to be large, even when MouseEventArgs'
+    // MouseDelta is reporting to the contrary.
+    //
+    // On systems with the large-values behavior, it appears that the values
+    // get reported as if the screen's size is 65536 units in both the X and Y
+    // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
+    // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
+    //
+    // MSDN's documentation on MouseEventArgs' MouseDelta field (at
+    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
+    // does not seem to indicate (to me) that its values should be so large.  It
+    // says that its values should be a "change in screen location".  I could
+    // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
+    // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
+    // indicates that these values are in DIPs, which is the same unit used
+    // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
+    // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
+    // for details.)
+    //
+    // To note, PointerMoved events are sent a 'RawPosition' value (via the
+    // CurrentPoint property in MouseEventArgs), however these do not seem
+    // to exhibit the same large-value behavior.
+    //
+    // The values passed via PointerMoved events can't always be used for relative
+    // mouse motion, unfortunately.  Its values are bound to the cursor's position,
+    // which stops when it hits one of the screen's edges.  This can be a problem in
+    // first person shooters, whereby it is normal for mouse motion to travel far
+    // along any one axis for a period of time.  MouseMoved events do not have the
+    // screen-bounding limitation, and can be used regardless of where the system's
+    // cursor is.
+    //
+    // One possible workaround would be to programmatically set the cursor's
+    // position to the screen's center (when SDL's relative mouse mode is enabled),
+    // however WinRT does not yet seem to have the ability to set the cursor's
+    // position via a public API.  Win32 did this via an API call, SetCursorPos,
+    // however WinRT makes this function be private.  Apps that use it won't get
+    // approved for distribution in the Windows Store.  I've yet to be able to find
+    // a suitable, store-friendly counterpart for WinRT.
+    //
+    // There may be some room for a workaround whereby OnPointerMoved's values
+    // are compared to the values from OnMouseMoved in order to detect
+    // when this bug is active.  A suitable transformation could then be made to
+    // OnMouseMoved's values.  For now, however, the system-reported values are sent
+    // to SDL with minimal transformation: from native screen coordinates (in DIPs)
+    // to SDL window coordinates.
+    //
+    const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
+    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs);
+    SDL_SendMouseMotion(
+        window,
+        0,
+        1,
+        _lround(mouseDeltaInSDLWindowCoords.X),
+        _lround(mouseDeltaInSDLWindowCoords.Y));
+}
 
 #endif // SDL_VIDEO_DRIVER_WINRT