diff --git a/src/rcore.c b/src/rcore.c index de4a00335..0031a885c 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2121,45 +2121,45 @@ void SetMouseCursor(int cursor) #endif } -// Get touch position X for touch point 0 (relative to screen size) -int GetTouchX(void) -{ -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) - return (int)CORE.Input.Touch.position[0].x; -#else // PLATFORM_DESKTOP, PLATFORM_DRM - return GetMouseX(); -#endif -} +//// Get touch position X for touch point 0 (relative to screen size) +//int GetTouchX(void) +//{ +//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) +// return (int)CORE.Input.Touch.position[0].x; +//#else // PLATFORM_DESKTOP, PLATFORM_DRM +// return GetMouseX(); +//#endif +//} -// Get touch position Y for touch point 0 (relative to screen size) -int GetTouchY(void) -{ -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) - return (int)CORE.Input.Touch.position[0].y; -#else // PLATFORM_DESKTOP, PLATFORM_DRM - return GetMouseY(); -#endif -} +//// Get touch position Y for touch point 0 (relative to screen size) +//int GetTouchY(void) +//{ +//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) +// return (int)CORE.Input.Touch.position[0].y; +//#else // PLATFORM_DESKTOP, PLATFORM_DRM +// return GetMouseY(); +//#endif +//} -// Get touch position XY for a touch point index (relative to screen size) -// TODO: Touch position should be scaled depending on display size and render size -Vector2 GetTouchPosition(int index) -{ - Vector2 position = { -1.0f, -1.0f }; - -#if defined(PLATFORM_DESKTOP) - // TODO: GLFW does not support multi-touch input just yet - // https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch - // https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages - if (index == 0) position = GetMousePosition(); -#endif -#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_DRM) - 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); -#endif - - return position; -} +//// Get touch position XY for a touch point index (relative to screen size) +//// TODO: Touch position should be scaled depending on display size and render size +//Vector2 GetTouchPosition(int index) +//{ +// Vector2 position = { -1.0f, -1.0f }; +// +//#if defined(PLATFORM_DESKTOP) +// // TODO: GLFW does not support multi-touch input just yet +// // https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch +// // https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages +// if (index == 0) position = GetMousePosition(); +//#endif +//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_DRM) +// 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); +//#endif +// +// return position; +//} // Get touch point identifier for given index int GetTouchPointId(int index) diff --git a/src/rcore_android.c b/src/rcore_android.c index 2fa7d1eac..5a5f657ba 100644 --- a/src/rcore_android.c +++ b/src/rcore_android.c @@ -1677,13 +1677,35 @@ void SetMousePosition(int x, int y) CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; } - // Get mouse wheel movement Y float GetMouseWheelMove(void) { return 0.0f; } +// Get touch position X for touch point 0 (relative to screen size) +int GetTouchX(void) +{ + return (int)CORE.Input.Touch.position[0].x; +} + +// Get touch position Y for touch point 0 (relative to screen size) +int GetTouchY(void) +{ + return (int)CORE.Input.Touch.position[0].y; +} + +// Get touch position XY for a touch point index (relative to screen size) +// TODO: Touch position should be scaled depending on display size and render size +Vector2 GetTouchPosition(int index) +{ + Vector2 position = { -1.0f, -1.0f }; + + 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); + + return position; +} // Swap back buffer with front buffer (screen drawing) void SwapScreenBuffer(void) @@ -1691,7 +1713,6 @@ void SwapScreenBuffer(void) eglSwapBuffers(CORE.Window.device, CORE.Window.surface); } - // Register all input events void PollInputEvents(void) { @@ -1745,4 +1766,4 @@ void PollInputEvents(void) //ANativeActivity_finish(CORE.Android.app->activity); } } -} \ No newline at end of file +} diff --git a/src/rcore_desktop.c b/src/rcore_desktop.c index 9b8090e0c..6d0ee18c6 100644 --- a/src/rcore_desktop.c +++ b/src/rcore_desktop.c @@ -1568,7 +1568,6 @@ void SetMousePosition(int x, int y) glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y); } - // Get mouse wheel movement Y float GetMouseWheelMove(void) { @@ -1580,6 +1579,31 @@ float GetMouseWheelMove(void) return result; } +// Get touch position X for touch point 0 (relative to screen size) +int GetTouchX(void) +{ + return GetMouseX(); +} + +// Get touch position Y for touch point 0 (relative to screen size) +int GetTouchY(void) +{ + return GetMouseY(); +} + +// Get touch position XY for a touch point index (relative to screen size) +// TODO: Touch position should be scaled depending on display size and render size +Vector2 GetTouchPosition(int index) +{ + Vector2 position = { -1.0f, -1.0f }; + + // TODO: GLFW does not support multi-touch input just yet + // https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch + // https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages + if (index == 0) position = GetMousePosition(); + + return position; +} // Swap back buffer with front buffer (screen drawing) void SwapScreenBuffer(void) @@ -1587,7 +1611,6 @@ void SwapScreenBuffer(void) glfwSwapBuffers(CORE.Window.handle); } - // Register all input events void PollInputEvents(void) { diff --git a/src/rcore_web.c b/src/rcore_web.c index 684696d24..fab16ef4d 100644 --- a/src/rcore_web.c +++ b/src/rcore_web.c @@ -1111,6 +1111,29 @@ float GetMouseWheelMove(void) return result; } +// Get touch position X for touch point 0 (relative to screen size) +int GetTouchX(void) +{ + return (int)CORE.Input.Touch.position[0].x; +} + +// Get touch position Y for touch point 0 (relative to screen size) +int GetTouchY(void) +{ + return (int)CORE.Input.Touch.position[0].y; +} + +// Get touch position XY for a touch point index (relative to screen size) +// TODO: Touch position should be scaled depending on display size and render size +Vector2 GetTouchPosition(int index) +{ + Vector2 position = { -1.0f, -1.0f }; + + 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); + + return position; +} // Swap back buffer with front buffer (screen drawing) void SwapScreenBuffer(void) @@ -1118,7 +1141,6 @@ void SwapScreenBuffer(void) glfwSwapBuffers(CORE.Window.handle); } - // Register all input events void PollInputEvents(void) {