Move GetTouchX, GetTouchY, GetTouchPosition from rcore to web, desktop, android
This commit is contained in:
parent
ab1afa36e1
commit
430f6dd1e7
74
src/rcore.c
74
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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user