mirror of https://github.com/encounter/SDL.git
WinRT: added touch input event support for Windows 8/RT devices
This commit is contained in:
parent
dbdc4b84ec
commit
a94e41854a
|
@ -157,10 +157,8 @@ WINRT_InitMouse(_THIS)
|
|||
SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
|
||||
#endif
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
/* Init touch: */
|
||||
SDL_AddTouch(WINRT_TouchID, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -378,6 +376,23 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
|
|||
// return "";
|
||||
//}
|
||||
|
||||
static bool
|
||||
WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint)
|
||||
{
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
return true;
|
||||
#else
|
||||
using namespace Windows::Devices::Input;
|
||||
switch (pointerPoint->PointerDevice->PointerDeviceType) {
|
||||
case PointerDeviceType::Touch:
|
||||
case PointerDeviceType::Pen:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
|
||||
{
|
||||
|
@ -391,15 +406,14 @@ WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPo
|
|||
SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
|
||||
}
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
// TODO, WinRT: make touch input work with Windows 8/RT, seeing if touches can be distinguished from mouse input.
|
||||
if (WINRT_IsTouchEvent(pointerPoint)) {
|
||||
SDL_SendTouchMotion(
|
||||
WINRT_TouchID,
|
||||
(SDL_FingerID) pointerPoint->PointerId,
|
||||
transformedPoint.X,
|
||||
transformedPoint.Y,
|
||||
pointerPoint->Properties->Pressure);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -430,7 +444,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
|
|||
WINRT_LeftFingerDown = 0;
|
||||
}
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
if (WINRT_IsTouchEvent(pointerPoint)) {
|
||||
SDL_SendTouch(
|
||||
WINRT_TouchID,
|
||||
(SDL_FingerID) pointerPoint->PointerId,
|
||||
|
@ -438,7 +452,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
|
|||
transformedPoint.X,
|
||||
transformedPoint.Y,
|
||||
pointerPoint->Properties->Pressure);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
|
||||
|
@ -461,7 +475,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po
|
|||
WINRT_LeftFingerDown = pointerPoint->PointerId;
|
||||
}
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
if (WINRT_IsTouchEvent(pointerPoint)) {
|
||||
SDL_SendTouch(
|
||||
WINRT_TouchID,
|
||||
(SDL_FingerID) pointerPoint->PointerId,
|
||||
|
@ -469,7 +483,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po
|
|||
transformedPoint.X,
|
||||
transformedPoint.Y,
|
||||
pointerPoint->Properties->Pressure);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINRT */
|
||||
|
|
Loading…
Reference in New Issue