Implemented touch how I "think" it should work. I cant test this.

This commit is contained in:
Reece Mackie 2020-04-30 16:01:12 +01:00
commit 01cd6b9a7c
2 changed files with 86 additions and 12 deletions

View file

@ -2687,9 +2687,9 @@ int GetMouseWheelMove(void)
// Returns touch position X for touch point 0 (relative to screen size)
int GetTouchX(void)
{
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
return (int)CORE.Input.Touch.position[0].x;
#else // PLATFORM_DESKTOP, PLATFORM_RPI
#else // PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_UWP
return GetMouseX();
#endif
}
@ -2697,9 +2697,9 @@ int GetTouchX(void)
// Returns touch position Y for touch point 0 (relative to screen size)
int GetTouchY(void)
{
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
return (int)CORE.Input.Touch.position[0].y;
#else // PLATFORM_DESKTOP, PLATFORM_RPI
#else // PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_UWP
return GetMouseY();
#endif
}
@ -2710,7 +2710,7 @@ Vector2 GetTouchPosition(int index)
{
Vector2 position = { -1.0f, -1.0f };
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_RPI)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_UWP)
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
@ -5442,7 +5442,7 @@ void UWPMousePosEvent(double x, double y)
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0] = CORE.Input.Touch.position[0];
gestureEvent.position[0] = CORE.Input.Mouse.position;
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
@ -5496,4 +5496,54 @@ void UWPRegisterGamepadAxis(int gamepad, int axis, float value)
}
}
void UWPGestureMove(int pointer, float x, float y)
{
#if defined(SUPPORT_GESTURES_SYSTEM)
GestureEvent gestureEvent = { 0 };
// Assign the pointer ID and touch action
gestureEvent.pointerId[0] = pointer;
gestureEvent.touchAction = TOUCH_MOVE;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0].x = x;
gestureEvent.position[0].y = y;
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures system for processing
ProcessGestureEvent(gestureEvent);
#endif
}
void UWPGestureTouch(int pointer, float x, float y, bool touch)
{
#if defined(SUPPORT_GESTURES_SYSTEM)
GestureEvent gestureEvent = { 0 };
// Assign the pointer ID and touch action
gestureEvent.pointerId[0] = pointer;
gestureEvent.touchAction = touch ? TOUCH_DOWN : TOUCH_UP;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0].x = x;
gestureEvent.position[0].y = y;
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures system for processing
ProcessGestureEvent(gestureEvent);
#endif
}
#endif // PLATFORM_UWP

View file

@ -100,6 +100,12 @@ void UWPRegisterGamepadButton(int gamepad, int button, bool down);
// Call when a gamepad axis state changes
void UWPRegisterGamepadAxis(int gamepad, int axis, float value);
// Call when the touch point moves
void UWPGestureMove(int pointer, float x, float y);
// Call when there is a touch down or up
void UWPGestureTouch(int pointer, float x, float y, bool touch);
// Set the core window pointer so that we can pass it to EGL.
void* UWPGetCoreWindowPtr();
void UWPSetCoreWindowPtr(void* ptr);