|
@@ -116,8 +116,8 @@ WINRT_TransformCursorPosition(SDL_Window * window,
|
|
|
return outputPosition;
|
|
|
}
|
|
|
|
|
|
-Uint8
|
|
|
-WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
|
|
|
+SDL_bool
|
|
|
+WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt, Uint8 *button, Uint8 *pressed)
|
|
|
{
|
|
|
using namespace Windows::UI::Input;
|
|
|
|
|
@@ -128,30 +128,42 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
|
|
|
{
|
|
|
case PointerUpdateKind::LeftButtonPressed:
|
|
|
case PointerUpdateKind::LeftButtonReleased:
|
|
|
- return SDL_BUTTON_LEFT;
|
|
|
+ *button = SDL_BUTTON_LEFT;
|
|
|
+ *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::LeftButtonPressed);
|
|
|
+ return SDL_TRUE;
|
|
|
|
|
|
case PointerUpdateKind::RightButtonPressed:
|
|
|
case PointerUpdateKind::RightButtonReleased:
|
|
|
- return SDL_BUTTON_RIGHT;
|
|
|
+ *button = SDL_BUTTON_RIGHT;
|
|
|
+ *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::RightButtonPressed);
|
|
|
+ return SDL_TRUE;
|
|
|
|
|
|
case PointerUpdateKind::MiddleButtonPressed:
|
|
|
case PointerUpdateKind::MiddleButtonReleased:
|
|
|
- return SDL_BUTTON_MIDDLE;
|
|
|
+ *button = SDL_BUTTON_MIDDLE;
|
|
|
+ *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::MiddleButtonPressed);
|
|
|
+ return SDL_TRUE;
|
|
|
|
|
|
case PointerUpdateKind::XButton1Pressed:
|
|
|
case PointerUpdateKind::XButton1Released:
|
|
|
- return SDL_BUTTON_X1;
|
|
|
+ *button = SDL_BUTTON_X1;
|
|
|
+ *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton1Pressed);
|
|
|
+ return SDL_TRUE;
|
|
|
|
|
|
case PointerUpdateKind::XButton2Pressed:
|
|
|
case PointerUpdateKind::XButton2Released:
|
|
|
- return SDL_BUTTON_X2;
|
|
|
+ *button = SDL_BUTTON_X2;
|
|
|
+ *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton2Pressed);
|
|
|
+ return SDL_TRUE;
|
|
|
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
- return 0;
|
|
|
+ *button = 0;
|
|
|
+ *pressed = 0;
|
|
|
+ return SDL_FALSE;
|
|
|
}
|
|
|
|
|
|
//const char *
|
|
@@ -211,9 +223,10 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
|
|
|
-
|
|
|
if ( ! WINRT_IsTouchEvent(pointerPoint)) {
|
|
|
+ Uint8 button, pressed;
|
|
|
+ WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed);
|
|
|
+ SDL_assert(pressed == 1);
|
|
|
SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
|
|
|
} else {
|
|
|
Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
|
|
@@ -241,6 +254,12 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo
|
|
|
Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
|
|
|
|
|
|
if ( ! WINRT_IsTouchEvent(pointerPoint)) {
|
|
|
+ /* For some odd reason Moved events are used for multiple mouse buttons */
|
|
|
+ Uint8 button, pressed;
|
|
|
+ if (WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed)) {
|
|
|
+ SDL_SendMouseButton(window, 0, pressed, button);
|
|
|
+ }
|
|
|
+
|
|
|
SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
|
|
|
} else {
|
|
|
SDL_SendTouchMotion(
|
|
@@ -259,9 +278,10 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
|
|
|
-
|
|
|
if (!WINRT_IsTouchEvent(pointerPoint)) {
|
|
|
+ Uint8 button, pressed;
|
|
|
+ WINRT_GetSDLButtonForPointerPoint(pointerPoint, &button, &pressed);
|
|
|
+ SDL_assert(pressed == 0);
|
|
|
SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
|
|
|
} else {
|
|
|
Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
|