Move GetMouseX, GetMouseY, GetMousePosition out of rcore

This commit is contained in:
MichaelFiber 2023-09-18 16:22:47 -04:00
parent 4c59791903
commit a18fe28e6f
5 changed files with 90 additions and 38 deletions

View File

@ -2074,44 +2074,6 @@ bool IsMouseButtonUp(int button)
return up;
}
// Get mouse position X
int GetMouseX(void)
{
#if defined(PLATFORM_ANDROID)
return (int)CORE.Input.Touch.position[0].x;
#else
return (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x);
#endif
}
// Get mouse position Y
int GetMouseY(void)
{
#if defined(PLATFORM_ANDROID)
return (int)CORE.Input.Touch.position[0].y;
#else
return (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y);
#endif
}
// Get mouse position XY
Vector2 GetMousePosition(void)
{
Vector2 position = { 0 };
// TODO: Review touch position on PLATFORM_WEB
#if defined(PLATFORM_ANDROID) //|| defined(PLATFORM_WEB)
position = GetTouchPosition(0);
#else
// NOTE: On PLATFORM_WEB, even on canvas scaling, mouse position is proportionally returned
position.x = (CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x;
position.y = (CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y;
#endif
return position;
}
// Get mouse delta between frames
Vector2 GetMouseDelta(void)
{

View File

@ -1651,3 +1651,21 @@ int SetGamepadMappings(const char *mappings)
{
return 0;
}
// Get mouse position X
int GetMouseX(void)
{
return (int)CORE.Input.Touch.position[0].x;
}
// Get mouse position Y
int GetMouseY(void)
{
return (int)CORE.Input.Touch.position[0].y;
}
// Get mouse position XY
Vector2 GetMousePosition(void)
{
return GetTouchPosition(0);
}

View File

@ -1535,3 +1535,26 @@ int SetGamepadMappings(const char *mappings)
{
return glfwUpdateGamepadMappings(mappings);
}
// Get mouse position X
int GetMouseX(void)
{
return (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x);
}
// Get mouse position Y
int GetMouseY(void)
{
return (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y);
}
// Get mouse position XY
Vector2 GetMousePosition(void)
{
Vector2 position = { 0 };
position.x = (CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x;
position.y = (CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y;
return position;
}

View File

@ -976,3 +976,26 @@ int SetGamepadMappings(const char *mappings)
{
return 0;
}
// Get mouse position X
int GetMouseX(void)
{
return (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x);
}
// Get mouse position Y
int GetMouseY(void)
{
return (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y);
}
// Get mouse position XY
Vector2 GetMousePosition(void)
{
Vector2 position = { 0 };
position.x = (CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x;
position.y = (CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y;
return position;
}

View File

@ -1573,3 +1573,29 @@ int SetGamepadMappings(const char *mappings)
{
return 0;
}
// Get mouse position X
int GetMouseX(void)
{
return (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x);
}
// Get mouse position Y
int GetMouseY(void)
{
return (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y);
}
// Get mouse position XY
Vector2 GetMousePosition(void)
{
Vector2 position = { 0 };
// TODO: Review touch position on PLATFORM_WEB
// NOTE: On PLATFORM_WEB, even on canvas scaling, mouse position is proportionally returned
position.x = (CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x;
position.y = (CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y;
return position;
}