Skip to content

Commit d5a780d

Browse files
author
ubkp
authored
[split] rcore, web, desktop, android changes (batch 3) (#3338)
* First pass to remove unneeded platform macros for web * Second pass to remove unneeded platform macros for web * Move GetTouchX, GetTouchY, GetTouchPosition from rcore to web, desktop, android * Move SetMouseCursor from rcore to android, desktop, web
1 parent 0ef3e09 commit d5a780d

File tree

4 files changed

+154
-541
lines changed

4 files changed

+154
-541
lines changed

src/rcore.c

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,60 +2106,60 @@ Vector2 GetMouseWheelMoveV(void)
21062106
return result;
21072107
}
21082108

2109-
// Set mouse cursor
2110-
// NOTE: This is a no-op on platforms other than PLATFORM_DESKTOP
2111-
void SetMouseCursor(int cursor)
2112-
{
2113-
#if defined(PLATFORM_DESKTOP)
2114-
CORE.Input.Mouse.cursor = cursor;
2115-
if (cursor == MOUSE_CURSOR_DEFAULT) glfwSetCursor(CORE.Window.handle, NULL);
2116-
else
2117-
{
2118-
// NOTE: We are relating internal GLFW enum values to our MouseCursor enum values
2119-
glfwSetCursor(CORE.Window.handle, glfwCreateStandardCursor(0x00036000 + cursor));
2120-
}
2121-
#endif
2122-
}
2123-
2124-
// Get touch position X for touch point 0 (relative to screen size)
2125-
int GetTouchX(void)
2126-
{
2127-
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
2128-
return (int)CORE.Input.Touch.position[0].x;
2129-
#else // PLATFORM_DESKTOP, PLATFORM_DRM
2130-
return GetMouseX();
2131-
#endif
2132-
}
2133-
2134-
// Get touch position Y for touch point 0 (relative to screen size)
2135-
int GetTouchY(void)
2136-
{
2137-
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
2138-
return (int)CORE.Input.Touch.position[0].y;
2139-
#else // PLATFORM_DESKTOP, PLATFORM_DRM
2140-
return GetMouseY();
2141-
#endif
2142-
}
2143-
2144-
// Get touch position XY for a touch point index (relative to screen size)
2145-
// TODO: Touch position should be scaled depending on display size and render size
2146-
Vector2 GetTouchPosition(int index)
2147-
{
2148-
Vector2 position = { -1.0f, -1.0f };
2149-
2150-
#if defined(PLATFORM_DESKTOP)
2151-
// TODO: GLFW does not support multi-touch input just yet
2152-
// https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
2153-
// https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
2154-
if (index == 0) position = GetMousePosition();
2155-
#endif
2156-
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_DRM)
2157-
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
2158-
else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
2159-
#endif
2160-
2161-
return position;
2162-
}
2109+
//// Set mouse cursor
2110+
//// NOTE: This is a no-op on platforms other than PLATFORM_DESKTOP
2111+
//void SetMouseCursor(int cursor)
2112+
//{
2113+
//#if defined(PLATFORM_DESKTOP)
2114+
// CORE.Input.Mouse.cursor = cursor;
2115+
// if (cursor == MOUSE_CURSOR_DEFAULT) glfwSetCursor(CORE.Window.handle, NULL);
2116+
// else
2117+
// {
2118+
// // NOTE: We are relating internal GLFW enum values to our MouseCursor enum values
2119+
// glfwSetCursor(CORE.Window.handle, glfwCreateStandardCursor(0x00036000 + cursor));
2120+
// }
2121+
//#endif
2122+
//}
2123+
2124+
//// Get touch position X for touch point 0 (relative to screen size)
2125+
//int GetTouchX(void)
2126+
//{
2127+
//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
2128+
// return (int)CORE.Input.Touch.position[0].x;
2129+
//#else // PLATFORM_DESKTOP, PLATFORM_DRM
2130+
// return GetMouseX();
2131+
//#endif
2132+
//}
2133+
2134+
//// Get touch position Y for touch point 0 (relative to screen size)
2135+
//int GetTouchY(void)
2136+
//{
2137+
//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
2138+
// return (int)CORE.Input.Touch.position[0].y;
2139+
//#else // PLATFORM_DESKTOP, PLATFORM_DRM
2140+
// return GetMouseY();
2141+
//#endif
2142+
//}
2143+
2144+
//// Get touch position XY for a touch point index (relative to screen size)
2145+
//// TODO: Touch position should be scaled depending on display size and render size
2146+
//Vector2 GetTouchPosition(int index)
2147+
//{
2148+
// Vector2 position = { -1.0f, -1.0f };
2149+
//
2150+
//#if defined(PLATFORM_DESKTOP)
2151+
// // TODO: GLFW does not support multi-touch input just yet
2152+
// // https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
2153+
// // https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
2154+
// if (index == 0) position = GetMousePosition();
2155+
//#endif
2156+
//#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_DRM)
2157+
// if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
2158+
// else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
2159+
//#endif
2160+
//
2161+
// return position;
2162+
//}
21632163

21642164
// Get touch point identifier for given index
21652165
int GetTouchPointId(int index)

src/rcore_android.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,21 +1677,49 @@ void SetMousePosition(int x, int y)
16771677
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
16781678
}
16791679

1680-
16811680
// Get mouse wheel movement Y
16821681
float GetMouseWheelMove(void)
16831682
{
16841683
return 0.0f;
16851684
}
16861685

1686+
// Set mouse cursor
1687+
// NOTE: This is a no-op on platforms other than PLATFORM_DESKTOP
1688+
void SetMouseCursor(int cursor)
1689+
{
1690+
TRACELOG(LOG_INFO, "SetMouseCursor not implemented in rcore_android.c");
1691+
}
1692+
1693+
// Get touch position X for touch point 0 (relative to screen size)
1694+
int GetTouchX(void)
1695+
{
1696+
return (int)CORE.Input.Touch.position[0].x;
1697+
}
1698+
1699+
// Get touch position Y for touch point 0 (relative to screen size)
1700+
int GetTouchY(void)
1701+
{
1702+
return (int)CORE.Input.Touch.position[0].y;
1703+
}
1704+
1705+
// Get touch position XY for a touch point index (relative to screen size)
1706+
// TODO: Touch position should be scaled depending on display size and render size
1707+
Vector2 GetTouchPosition(int index)
1708+
{
1709+
Vector2 position = { -1.0f, -1.0f };
1710+
1711+
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
1712+
else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
1713+
1714+
return position;
1715+
}
16871716

16881717
// Swap back buffer with front buffer (screen drawing)
16891718
void SwapScreenBuffer(void)
16901719
{
16911720
eglSwapBuffers(CORE.Window.device, CORE.Window.surface);
16921721
}
16931722

1694-
16951723
// Register all input events
16961724
void PollInputEvents(void)
16971725
{
@@ -1745,4 +1773,4 @@ void PollInputEvents(void)
17451773
//ANativeActivity_finish(CORE.Android.app->activity);
17461774
}
17471775
}
1748-
}
1776+
}

src/rcore_desktop.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,6 @@ void SetMousePosition(int x, int y)
15681568
glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y);
15691569
}
15701570

1571-
15721571
// Get mouse wheel movement Y
15731572
float GetMouseWheelMove(void)
15741573
{
@@ -1580,14 +1579,51 @@ float GetMouseWheelMove(void)
15801579
return result;
15811580
}
15821581

1582+
// Set mouse cursor
1583+
// NOTE: This is a no-op on platforms other than PLATFORM_DESKTOP
1584+
void SetMouseCursor(int cursor)
1585+
{
1586+
CORE.Input.Mouse.cursor = cursor;
1587+
if (cursor == MOUSE_CURSOR_DEFAULT) glfwSetCursor(CORE.Window.handle, NULL);
1588+
else
1589+
{
1590+
// NOTE: We are relating internal GLFW enum values to our MouseCursor enum values
1591+
glfwSetCursor(CORE.Window.handle, glfwCreateStandardCursor(0x00036000 + cursor));
1592+
}
1593+
}
1594+
1595+
// Get touch position X for touch point 0 (relative to screen size)
1596+
int GetTouchX(void)
1597+
{
1598+
return GetMouseX();
1599+
}
1600+
1601+
// Get touch position Y for touch point 0 (relative to screen size)
1602+
int GetTouchY(void)
1603+
{
1604+
return GetMouseY();
1605+
}
1606+
1607+
// Get touch position XY for a touch point index (relative to screen size)
1608+
// TODO: Touch position should be scaled depending on display size and render size
1609+
Vector2 GetTouchPosition(int index)
1610+
{
1611+
Vector2 position = { -1.0f, -1.0f };
1612+
1613+
// TODO: GLFW does not support multi-touch input just yet
1614+
// https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
1615+
// https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
1616+
if (index == 0) position = GetMousePosition();
1617+
1618+
return position;
1619+
}
15831620

15841621
// Swap back buffer with front buffer (screen drawing)
15851622
void SwapScreenBuffer(void)
15861623
{
15871624
glfwSwapBuffers(CORE.Window.handle);
15881625
}
15891626

1590-
15911627
// Register all input events
15921628
void PollInputEvents(void)
15931629
{

0 commit comments

Comments
 (0)