diff options
| author | raysan5 <[email protected]> | 2019-01-03 13:53:20 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2019-01-03 13:53:20 +0100 |
| commit | d427f17210170b4ae0f185208db504264056d3c1 (patch) | |
| tree | 186fd61f8a94ba55f23fb0640c2b4d866155e7f3 /src | |
| parent | 0333e5b6c2a0703185bc0e3aecd79f8b297df2c4 (diff) | |
| download | raylib-d427f17210170b4ae0f185208db504264056d3c1.tar.gz raylib-d427f17210170b4ae0f185208db504264056d3c1.zip | |
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()
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 34 | ||||
| -rw-r--r-- | src/raylib.h | 6 |
2 files changed, 18 insertions, 22 deletions
@@ -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); + glfwSetCursorPos(window, mousePosition.x, mousePosition.y); #endif } -// Set mouse scaling +// Set mouse offset // NOTE: Useful when rendering to different size targets -void SetMouseScale(Vector2 scale) +void SetMouseOffset(int offsetX, int offsetY) { -#if !defined(PLATFORM_ANDROID) - mouseScale = scale; -#endif + mouseOffset = (Vector2){ (float)offsetX, (float)offsetY }; } -// Set mouse offset +// Set mouse scaling // NOTE: Useful when rendering to different size targets -void SetMouseOffset(Vector2 offset) +void SetMouseScale(float scaleX, float scaleY) { -#if !defined(PLATFORM_ANDROID) - mouseScale = offset; -#endif + mouseScale = (Vector2){ scaleX, scaleY }; } // Returns mouse wheel movement Y diff --git a/src/raylib.h b/src/raylib.h index 2fef4fc8..c6156c10 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -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 |
