mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
REVIEWED some functions parameters
Decided to allow user to provide values directly instead of requiring a Vector2 struct, probably more confortable to use. - SetMousePosition() - SetMouseOffset() - SetMouseScale()
This commit is contained in:
40
src/core.c
40
src/core.c
@ -332,9 +332,9 @@ static int defaultKeyboardMode; // Used to store default keyboar
|
||||
#endif
|
||||
|
||||
// Mouse states
|
||||
static Vector2 mousePosition; // Mouse position on screen
|
||||
static Vector2 mouseScale = { 1.0f, 1.0f }; // Mouse default scale
|
||||
static Vector2 mouseOffset = { 0.0f, 0.0f }; // Mouse default scale
|
||||
static Vector2 mousePosition = { 0.0f, 0.0f }; // Mouse position on screen
|
||||
static Vector2 mouseScale = { 1.0f, 1.0f }; // Mouse scaling
|
||||
static Vector2 mouseOffset = { 0.0f, 0.0f }; // Mouse offset
|
||||
static bool cursorHidden = false; // Track if cursor is hidden
|
||||
static bool cursorOnScreen = false; // Tracks if cursor is inside client area
|
||||
static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen
|
||||
@ -2076,7 +2076,7 @@ int GetMouseX(void)
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
return (int)touchPosition[0].x;
|
||||
#else
|
||||
return (int)((mousePosition.x+mouseOffset.x)*mouseScale.x);
|
||||
return (int)((mousePosition.x + mouseOffset.x)*mouseScale.x);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2086,7 +2086,7 @@ int GetMouseY(void)
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
return (int)touchPosition[0].x;
|
||||
#else
|
||||
return (int)((mousePosition.y+mouseOffset.y)*mouseScale.y);
|
||||
return (int)((mousePosition.y + mouseOffset.y)*mouseScale.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2096,36 +2096,32 @@ Vector2 GetMousePosition(void)
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
return GetTouchPosition(0);
|
||||
#else
|
||||
return (Vector2){ (mousePosition.x+mouseOffset.x)*mouseScale.x, (mousePosition.y+mouseOffset.y)*mouseScale.y };
|
||||
return (Vector2){ (mousePosition.x + mouseOffset.x)*mouseScale.x, (mousePosition.y + mouseOffset.y)*mouseScale.y };
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set mouse position XY
|
||||
void SetMousePosition(Vector2 position)
|
||||
void SetMousePosition(int x, int y)
|
||||
{
|
||||
mousePosition = position;
|
||||
mousePosition = (Vector2){ (float)x, (float)y };
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
// NOTE: emscripten not implemented
|
||||
glfwSetCursorPos(window, position.x, position.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set mouse scaling
|
||||
// NOTE: Useful when rendering to different size targets
|
||||
void SetMouseScale(Vector2 scale)
|
||||
{
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
mouseScale = scale;
|
||||
glfwSetCursorPos(window, mousePosition.x, mousePosition.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set mouse offset
|
||||
// NOTE: Useful when rendering to different size targets
|
||||
void SetMouseOffset(Vector2 offset)
|
||||
void SetMouseOffset(int offsetX, int offsetY)
|
||||
{
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
mouseScale = offset;
|
||||
#endif
|
||||
mouseOffset = (Vector2){ (float)offsetX, (float)offsetY };
|
||||
}
|
||||
|
||||
// Set mouse scaling
|
||||
// NOTE: Useful when rendering to different size targets
|
||||
void SetMouseScale(float scaleX, float scaleY)
|
||||
{
|
||||
mouseScale = (Vector2){ scaleX, scaleY };
|
||||
}
|
||||
|
||||
// Returns mouse wheel movement Y
|
||||
|
||||
@ -940,9 +940,9 @@ RLAPI bool IsMouseButtonUp(int button); // Detect if a mou
|
||||
RLAPI int GetMouseX(void); // Returns mouse position X
|
||||
RLAPI int GetMouseY(void); // Returns mouse position Y
|
||||
RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY
|
||||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
RLAPI void SetMouseScale(Vector2 scale); // Set mouse scaling
|
||||
RLAPI void SetMouseOffset(Vector2 scale); // Set mouse offset
|
||||
RLAPI void SetMousePosition(int x, int y); // Set mouse position XY
|
||||
RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset
|
||||
RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling
|
||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
// Input-related functions: touch
|
||||
|
||||
Reference in New Issue
Block a user