WinRT: added touch input event support for Windows 8/RT devices

This commit is contained in:
David Ludwig 2013-09-01 10:20:17 -04:00
parent dbdc4b84ec
commit a94e41854a

View File

@ -157,10 +157,8 @@ WINRT_InitMouse(_THIS)
SDL_SetDefaultCursor(WINRT_CreateDefaultCursor()); SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
#endif #endif
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
/* Init touch: */ /* Init touch: */
SDL_AddTouch(WINRT_TouchID, ""); SDL_AddTouch(WINRT_TouchID, "");
#endif
} }
void void
@ -378,6 +376,23 @@ WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
// return ""; // 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 void
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) 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); SDL_SendMouseMotion(window, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
} }
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP if (WINRT_IsTouchEvent(pointerPoint)) {
// TODO, WinRT: make touch input work with Windows 8/RT, seeing if touches can be distinguished from mouse input. SDL_SendTouchMotion(
SDL_SendTouchMotion( WINRT_TouchID,
WINRT_TouchID, (SDL_FingerID) pointerPoint->PointerId,
(SDL_FingerID) pointerPoint->PointerId, transformedPoint.X,
transformedPoint.X, transformedPoint.Y,
transformedPoint.Y, pointerPoint->Properties->Pressure);
pointerPoint->Properties->Pressure); }
#endif
} }
void void
@ -430,15 +444,15 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P
WINRT_LeftFingerDown = 0; WINRT_LeftFingerDown = 0;
} }
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP if (WINRT_IsTouchEvent(pointerPoint)) {
SDL_SendTouch( SDL_SendTouch(
WINRT_TouchID, WINRT_TouchID,
(SDL_FingerID) pointerPoint->PointerId, (SDL_FingerID) pointerPoint->PointerId,
SDL_FALSE, SDL_FALSE,
transformedPoint.X, transformedPoint.X,
transformedPoint.Y, transformedPoint.Y,
pointerPoint->Properties->Pressure); pointerPoint->Properties->Pressure);
#endif }
} }
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
@ -461,15 +475,15 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po
WINRT_LeftFingerDown = pointerPoint->PointerId; WINRT_LeftFingerDown = pointerPoint->PointerId;
} }
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP if (WINRT_IsTouchEvent(pointerPoint)) {
SDL_SendTouch( SDL_SendTouch(
WINRT_TouchID, WINRT_TouchID,
(SDL_FingerID) pointerPoint->PointerId, (SDL_FingerID) pointerPoint->PointerId,
SDL_TRUE, SDL_TRUE,
transformedPoint.X, transformedPoint.X,
transformedPoint.Y, transformedPoint.Y,
pointerPoint->Properties->Pressure); pointerPoint->Properties->Pressure);
#endif }
} }
#endif /* SDL_VIDEO_DRIVER_WINRT */ #endif /* SDL_VIDEO_DRIVER_WINRT */