mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
REVIEWED: Mouse and Touch functions generic to all platforms #3313
This commit is contained in:
@ -642,24 +642,6 @@ 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);
|
||||
}
|
||||
|
||||
// Set mouse position XY
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
@ -667,43 +649,12 @@ void SetMousePosition(int x, int y)
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
|
||||
// Get mouse wheel movement Y
|
||||
float GetMouseWheelMove(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetMouseWheelMove() not implemented on target platform");
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
// Set mouse cursor
|
||||
void SetMouseCursor(int cursor)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform");
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
@ -1247,6 +1198,10 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
|
||||
if (CORE.Input.Touch.pointCount > 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1;
|
||||
else CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0;
|
||||
|
||||
// Map touch[0] as mouse input for convenience
|
||||
CORE.Input.Mouse.currentPosition = CORE.Input.Touch.position[0];
|
||||
CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f };
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user