WinRT: made simulated-mouse (via touch) input work on Windows Phone in Portrait mode Proper SDL_MOUSE* event support for non-Portrait orientations in Windows Phone is pending.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
diff --git a/src/core/winrt/SDL_winrtapp.cpp b/src/core/winrt/SDL_winrtapp.cpp
index de62b41..aecab9a 100644
--- a/src/core/winrt/SDL_winrtapp.cpp
+++ b/src/core/winrt/SDL_winrtapp.cpp
@@ -412,29 +412,59 @@ void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
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::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
+void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
{
- WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, 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::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
+void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
{
- WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+ WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
}
void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
diff --git a/src/core/winrt/SDL_winrtapp.h b/src/core/winrt/SDL_winrtapp.h
index 5136643..93fd61a 100644
--- a/src/core/winrt/SDL_winrtapp.h
+++ b/src/core/winrt/SDL_winrtapp.h
@@ -15,7 +15,6 @@ public:
internal:
// SDL-specific methods
void PumpEvents();
- Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
protected:
// Event Handlers.
diff --git a/src/video/winrt/SDL_winrtevents_c.h b/src/video/winrt/SDL_winrtevents_c.h
index 6038a7c..b8f132f 100644
--- a/src/video/winrt/SDL_winrtevents_c.h
+++ b/src/video/winrt/SDL_winrtevents_c.h
@@ -54,6 +54,8 @@ extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Inpu
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();
diff --git a/src/video/winrt/SDL_winrtmouse.cpp b/src/video/winrt/SDL_winrtmouse.cpp
index 841a28c..40530bf 100644
--- a/src/video/winrt/SDL_winrtmouse.cpp
+++ b/src/video/winrt/SDL_winrtmouse.cpp
@@ -160,8 +160,8 @@ WINRT_QuitMouse(_THIS)
}
// Applies necessary geometric transformations to raw cursor positions:
-static Windows::Foundation::Point
-TransformCursor(SDL_Window * window, Windows::Foundation::Point rawPosition)
+Windows::Foundation::Point
+WINRT_TransformCursorPosition(SDL_Window * window, Windows::Foundation::Point rawPosition)
{
if (!window) {
return rawPosition;
@@ -247,7 +247,7 @@ WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::Mouse
// to SDL window coordinates.
//
const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
- const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = TransformCursor(window, mouseDeltaInDIPs);
+ const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs);
SDL_SendMouseMotion(
window,
0,
@@ -256,11 +256,14 @@ WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::Mouse
_lround(mouseDeltaInSDLWindowCoords.Y));
}
-static Uint8
+Uint8
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
{
using namespace Windows::UI::Input;
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ return SDL_BUTTON_LEFT;
+#else
switch (pt->Properties->PointerUpdateKind)
{
case PointerUpdateKind::LeftButtonPressed:
@@ -286,80 +289,59 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
default:
break;
}
+#endif
return 0;
}
-static const char *
-WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
-{
- using namespace Windows::UI::Input;
-
- switch (kind)
- {
- case PointerUpdateKind::Other:
- return "Other";
- case PointerUpdateKind::LeftButtonPressed:
- return "LeftButtonPressed";
- case PointerUpdateKind::LeftButtonReleased:
- return "LeftButtonReleased";
- case PointerUpdateKind::RightButtonPressed:
- return "RightButtonPressed";
- case PointerUpdateKind::RightButtonReleased:
- return "RightButtonReleased";
- case PointerUpdateKind::MiddleButtonPressed:
- return "MiddleButtonPressed";
- case PointerUpdateKind::MiddleButtonReleased:
- return "MiddleButtonReleased";
- case PointerUpdateKind::XButton1Pressed:
- return "XButton1Pressed";
- case PointerUpdateKind::XButton1Released:
- return "XButton1Released";
- case PointerUpdateKind::XButton2Pressed:
- return "XButton2Pressed";
- case PointerUpdateKind::XButton2Released:
- return "XButton2Released";
- }
-
- return "";
-}
-
-static void
-WINRT_LogPointerEvent(const char * header, 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, PointerUpdateKind=%s\n",
- header,
- pt->Position.X, pt->Position.Y,
- transformedPoint.X, transformedPoint.Y,
- pt->Properties->MouseWheelDelta,
- pt->FrameId,
- pt->PointerId,
- WINRT_ConvertPointerUpdateKindToString(args->CurrentPoint->Properties->PointerUpdateKind));
-}
+//const char *
+//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
+//{
+// using namespace Windows::UI::Input;
+//
+// switch (kind)
+// {
+// case PointerUpdateKind::Other:
+// return "Other";
+// case PointerUpdateKind::LeftButtonPressed:
+// return "LeftButtonPressed";
+// case PointerUpdateKind::LeftButtonReleased:
+// return "LeftButtonReleased";
+// case PointerUpdateKind::RightButtonPressed:
+// return "RightButtonPressed";
+// case PointerUpdateKind::RightButtonReleased:
+// return "RightButtonReleased";
+// case PointerUpdateKind::MiddleButtonPressed:
+// return "MiddleButtonPressed";
+// case PointerUpdateKind::MiddleButtonReleased:
+// return "MiddleButtonReleased";
+// case PointerUpdateKind::XButton1Pressed:
+// return "XButton1Pressed";
+// case PointerUpdateKind::XButton1Released:
+// return "XButton1Released";
+// case PointerUpdateKind::XButton2Pressed:
+// return "XButton2Pressed";
+// case PointerUpdateKind::XButton2Released:
+// return "XButton2Released";
+// }
+//
+// return "";
+//}
void
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer moved", args, TransformCursor(pointerPoint->Position));
-#endif
-
if (!window || WINRT_UseRelativeMouseMode) {
return;
}
- Windows::Foundation::Point transformedPoint = TransformCursor(window, pointerPoint->Position);
+ Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
}
void
WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("wheel changed", args, TransformCursor(pointerPoint->Position));
-#endif
-
if (!window) {
return;
}
@@ -371,10 +353,6 @@ WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::Po
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("mouse up", args, TransformCursor(args->CurrentPoint->Position));
-#endif
-
if (!window) {
return;
}
@@ -387,16 +365,16 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("mouse down", args, TransformCursor(args->CurrentPoint->Position));
-#endif
-
if (!window) {
return;
}
Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
if (button) {
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ Windows::Foundation::Point transformedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position);
+ SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
+#endif
SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
}
}