21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_WINRT 33 #include "../SDL_sysvideo.h" 34 #include "../../events/SDL_events_c.h" 35 #include "../../events/SDL_mouse_c.h" 36 #include "../../events/SDL_touch_c.h" 41 static unsigned int WINRT_LeftFingerDown = 0;
54 Windows::Foundation::Point
56 Windows::Foundation::Point rawPosition,
57 WINRT_CursorNormalizationType normalization)
67 if (windowData->coreWindow ==
nullptr) {
78 SDL_assert(CoreWindow::GetForCurrentThread() !=
nullptr);
80 CoreWindow ^ nativeWindow = windowData->coreWindow.Get();
81 Windows::Foundation::Point outputPosition;
86 #if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8) 87 outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
88 outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
90 switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation))
92 case DisplayOrientations::Portrait:
93 outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
94 outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
96 case DisplayOrientations::PortraitFlipped:
97 outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
98 outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
100 case DisplayOrientations::Landscape:
101 outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height;
102 outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
104 case DisplayOrientations::LandscapeFlipped:
105 outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
106 outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width;
113 if (normalization == TransformToSDLWindowSize) {
114 outputPosition.X *= ((float32) window->
w);
115 outputPosition.Y *= ((float32) window->
h);
118 return outputPosition;
125 return (
int)
floor(arg + 0.5
f);
127 return (
int)ceil(arg - 0.5
f);
132 WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
136 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP 139 switch (pt->Properties->PointerUpdateKind)
141 case PointerUpdateKind::LeftButtonPressed:
142 case PointerUpdateKind::LeftButtonReleased:
145 case PointerUpdateKind::RightButtonPressed:
146 case PointerUpdateKind::RightButtonReleased:
149 case PointerUpdateKind::MiddleButtonPressed:
150 case PointerUpdateKind::MiddleButtonReleased:
153 case PointerUpdateKind::XButton1Pressed:
154 case PointerUpdateKind::XButton1Released:
157 case PointerUpdateKind::XButton2Pressed:
158 case PointerUpdateKind::XButton2Released:
204 WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint)
206 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP 210 switch (pointerPoint->PointerDevice->PointerDeviceType) {
211 case PointerDeviceType::Touch:
212 case PointerDeviceType::Pen:
220 void WINRT_ProcessPointerPressedEvent(
SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
226 Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
228 if ( ! WINRT_IsTouchEvent(pointerPoint)) {
231 Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
232 Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
234 if (!WINRT_LeftFingerDown) {
240 WINRT_LeftFingerDown = pointerPoint->PointerId;
249 pointerPoint->Properties->Pressure);
254 WINRT_ProcessPointerMovedEvent(
SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
260 Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
261 Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
263 if ( ! WINRT_IsTouchEvent(pointerPoint)) {
266 if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
275 pointerPoint->Properties->Pressure);
279 void WINRT_ProcessPointerReleasedEvent(
SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
285 Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
287 if (!WINRT_IsTouchEvent(pointerPoint)) {
290 Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
292 if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
296 WINRT_LeftFingerDown = 0;
305 pointerPoint->Properties->Pressure);
309 void WINRT_ProcessPointerEnteredEvent(
SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
315 if (!WINRT_IsTouchEvent(pointerPoint)) {
320 void WINRT_ProcessPointerExitedEvent(
SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
326 if (!WINRT_IsTouchEvent(pointerPoint)) {
332 WINRT_ProcessPointerWheelChangedEvent(
SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
338 float motion = (float) pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
343 WINRT_ProcessMouseMovedEvent(
SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
405 const Windows::Foundation::Point mouseDeltaInDIPs((
float)args->MouseDelta.X, (
float)args->MouseDelta.Y);
406 const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize);
411 _lround(mouseDeltaInSDLWindowCoords.X),
412 _lround(mouseDeltaInSDLWindowCoords.Y));
415 #endif // SDL_VIDEO_DRIVER_WINRT
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure)
void SDL_SetMouseFocus(SDL_Window *window)
#define SDL_TOUCH_MOUSEID
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
void WINRT_InitTouch(_THIS)
#define SDL_BUTTON_MIDDLE
int SDL_AddTouch(SDL_TouchID touchID, const char *name)
#define SDL_assert(condition)
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction)
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
SDL_bool WINRT_UsingRelativeMouseMode
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)