| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | |
| | | /* File-specific globals: */ |
| | | static SDL_TouchID WINRT_TouchID = 1; |
| | | static unsigned int WINRT_LeftFingerDown = 0; |
| | | |
| | | |
| | | void |
| | | WINRT_InitTouch(_THIS) |
| | | { |
| | | SDL_AddTouch(WINRT_TouchID, ""); |
| | | SDL_AddTouch(WINRT_TouchID, SDL_TOUCH_DEVICE_DIRECT, ""); |
| | | } |
| | | |
| | | |
| | |
| | | Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); |
| | | Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize); |
| | | |
| | | if (!WINRT_LeftFingerDown) { |
| | | if (button) { |
| | | SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, (int)windowPoint.X, (int)windowPoint.Y); |
| | | SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, button); |
| | | } |
| | | |
| | | WINRT_LeftFingerDown = pointerPoint->PointerId; |
| | | } |
| | | |
| | | SDL_SendTouch( |
| | | WINRT_TouchID, |
| | | (SDL_FingerID) pointerPoint->PointerId, |
| | | window, |
| | | SDL_TRUE, |
| | | normalizedPoint.X, |
| | | normalizedPoint.Y, |
| | |
| | | if ( ! WINRT_IsTouchEvent(pointerPoint)) { |
| | | SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y); |
| | | } else { |
| | | if (pointerPoint->PointerId == WINRT_LeftFingerDown) { |
| | | SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, (int)windowPoint.X, (int)windowPoint.Y); |
| | | } |
| | | |
| | | SDL_SendTouchMotion( |
| | | WINRT_TouchID, |
| | | (SDL_FingerID) pointerPoint->PointerId, |
| | | window, |
| | | normalizedPoint.X, |
| | | normalizedPoint.Y, |
| | | pointerPoint->Properties->Pressure); |
| | |
| | | } else { |
| | | Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); |
| | | |
| | | if (WINRT_LeftFingerDown == pointerPoint->PointerId) { |
| | | if (button) { |
| | | SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, button); |
| | | } |
| | | WINRT_LeftFingerDown = 0; |
| | | } |
| | | |
| | | SDL_SendTouch( |
| | | WINRT_TouchID, |
| | | (SDL_FingerID) pointerPoint->PointerId, |
| | | window, |
| | | SDL_FALSE, |
| | | normalizedPoint.X, |
| | | normalizedPoint.Y, |