Move GetMouseX, GetMouseY, GetMousePosition out of rcore
This commit is contained in:
parent
4c59791903
commit
a18fe28e6f
38
src/rcore.c
38
src/rcore.c
|
|
@ -2074,44 +2074,6 @@ bool IsMouseButtonUp(int button)
|
||||||
return up;
|
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
|
// Get mouse delta between frames
|
||||||
Vector2 GetMouseDelta(void)
|
Vector2 GetMouseDelta(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1651,3 +1651,21 @@ int SetGamepadMappings(const char *mappings)
|
||||||
{
|
{
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
|
|
@ -1535,3 +1535,26 @@ int SetGamepadMappings(const char *mappings)
|
||||||
{
|
{
|
||||||
return glfwUpdateGamepadMappings(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;
|
||||||
|
}
|
||||||
|
|
@ -976,3 +976,26 @@ int SetGamepadMappings(const char *mappings)
|
||||||
{
|
{
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|
@ -1573,3 +1573,29 @@ int SetGamepadMappings(const char *mappings)
|
||||||
{
|
{
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user