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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get touch position X for touch point 0 (relative to screen size)
|
//// Get touch position X for touch point 0 (relative to screen size)
|
||||||
int GetTouchX(void)
|
//int GetTouchX(void)
|
||||||
{
|
//{
|
||||||
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
|
//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
|
||||||
return (int)CORE.Input.Touch.position[0].x;
|
// return (int)CORE.Input.Touch.position[0].x;
|
||||||
#else // PLATFORM_DESKTOP, PLATFORM_DRM
|
//#else // PLATFORM_DESKTOP, PLATFORM_DRM
|
||||||
return GetMouseX();
|
// return GetMouseX();
|
||||||
#endif
|
//#endif
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Get touch position Y for touch point 0 (relative to screen size)
|
//// Get touch position Y for touch point 0 (relative to screen size)
|
||||||
int GetTouchY(void)
|
//int GetTouchY(void)
|
||||||
{
|
//{
|
||||||
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
|
//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
|
||||||
return (int)CORE.Input.Touch.position[0].y;
|
// return (int)CORE.Input.Touch.position[0].y;
|
||||||
#else // PLATFORM_DESKTOP, PLATFORM_DRM
|
//#else // PLATFORM_DESKTOP, PLATFORM_DRM
|
||||||
return GetMouseY();
|
// return GetMouseY();
|
||||||
#endif
|
//#endif
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Get touch position XY for a touch point index (relative to screen size)
|
//// 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
|
//// TODO: Touch position should be scaled depending on display size and render size
|
||||||
Vector2 GetTouchPosition(int index)
|
//Vector2 GetTouchPosition(int index)
|
||||||
{
|
//{
|
||||||
Vector2 position = { -1.0f, -1.0f };
|
// Vector2 position = { -1.0f, -1.0f };
|
||||||
|
//
|
||||||
#if defined(PLATFORM_DESKTOP)
|
//#if defined(PLATFORM_DESKTOP)
|
||||||
// TODO: GLFW does not support multi-touch input just yet
|
// // TODO: GLFW does not support multi-touch input just yet
|
||||||
// https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
|
// // 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
|
// // https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
|
||||||
if (index == 0) position = GetMousePosition();
|
// if (index == 0) position = GetMousePosition();
|
||||||
#endif
|
//#endif
|
||||||
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_DRM)
|
//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_DRM)
|
||||||
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
|
// 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);
|
// else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
|
||||||
#endif
|
//#endif
|
||||||
|
//
|
||||||
return position;
|
// return position;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Get touch point identifier for given index
|
// Get touch point identifier for given index
|
||||||
int GetTouchPointId(int index)
|
int GetTouchPointId(int index)
|
||||||
|
|
|
||||||
|
|
@ -1677,13 +1677,35 @@ void SetMousePosition(int x, int y)
|
||||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get mouse wheel movement Y
|
// Get mouse wheel movement Y
|
||||||
float GetMouseWheelMove(void)
|
float GetMouseWheelMove(void)
|
||||||
{
|
{
|
||||||
return 0.0f;
|
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)
|
// Swap back buffer with front buffer (screen drawing)
|
||||||
void SwapScreenBuffer(void)
|
void SwapScreenBuffer(void)
|
||||||
|
|
@ -1691,7 +1713,6 @@ void SwapScreenBuffer(void)
|
||||||
eglSwapBuffers(CORE.Window.device, CORE.Window.surface);
|
eglSwapBuffers(CORE.Window.device, CORE.Window.surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Register all input events
|
// Register all input events
|
||||||
void PollInputEvents(void)
|
void PollInputEvents(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1745,4 +1766,4 @@ void PollInputEvents(void)
|
||||||
//ANativeActivity_finish(CORE.Android.app->activity);
|
//ANativeActivity_finish(CORE.Android.app->activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1568,7 +1568,6 @@ void SetMousePosition(int x, int y)
|
||||||
glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y);
|
glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get mouse wheel movement Y
|
// Get mouse wheel movement Y
|
||||||
float GetMouseWheelMove(void)
|
float GetMouseWheelMove(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1580,6 +1579,31 @@ float GetMouseWheelMove(void)
|
||||||
return result;
|
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)
|
// Swap back buffer with front buffer (screen drawing)
|
||||||
void SwapScreenBuffer(void)
|
void SwapScreenBuffer(void)
|
||||||
|
|
@ -1587,7 +1611,6 @@ void SwapScreenBuffer(void)
|
||||||
glfwSwapBuffers(CORE.Window.handle);
|
glfwSwapBuffers(CORE.Window.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Register all input events
|
// Register all input events
|
||||||
void PollInputEvents(void)
|
void PollInputEvents(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1111,6 +1111,29 @@ float GetMouseWheelMove(void)
|
||||||
return result;
|
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)
|
// Swap back buffer with front buffer (screen drawing)
|
||||||
void SwapScreenBuffer(void)
|
void SwapScreenBuffer(void)
|
||||||
|
|
@ -1118,7 +1141,6 @@ void SwapScreenBuffer(void)
|
||||||
glfwSwapBuffers(CORE.Window.handle);
|
glfwSwapBuffers(CORE.Window.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Register all input events
|
// Register all input events
|
||||||
void PollInputEvents(void)
|
void PollInputEvents(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user