Added SetMouseOffset
- Changed mouseScale to Vector2. - Added SetMouseOffset to change XY of mouseScale.
This commit is contained in:
parent
d5735720b0
commit
8933298864
2 changed files with 17 additions and 7 deletions
23
src/core.c
23
src/core.c
|
@ -333,7 +333,7 @@ static int defaultKeyboardMode; // Used to store default keyboar
|
||||||
|
|
||||||
// Mouse states
|
// Mouse states
|
||||||
static Vector2 mousePosition; // Mouse position on screen
|
static Vector2 mousePosition; // Mouse position on screen
|
||||||
static float mouseScale = 1.0f; // Mouse default scale
|
static Vector2 mouseScale = { 1.0f }; // Mouse default scale
|
||||||
static bool cursorHidden = false; // Track if cursor is hidden
|
static bool cursorHidden = false; // Track if cursor is hidden
|
||||||
static bool cursorOnScreen = false; // Tracks if cursor is inside client area
|
static bool cursorOnScreen = false; // Tracks if cursor is inside client area
|
||||||
static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen
|
static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen
|
||||||
|
@ -2075,7 +2075,7 @@ int GetMouseX(void)
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
return (int)touchPosition[0].x;
|
return (int)touchPosition[0].x;
|
||||||
#else
|
#else
|
||||||
return (int)(mousePosition.x*mouseScale);
|
return (int)(mousePosition.x*mouseScale.x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2085,7 +2085,7 @@ int GetMouseY(void)
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
return (int)touchPosition[0].x;
|
return (int)touchPosition[0].x;
|
||||||
#else
|
#else
|
||||||
return (int)(mousePosition.y*mouseScale);
|
return (int)(mousePosition.y*mouseScale.y);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2095,7 +2095,7 @@ Vector2 GetMousePosition(void)
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
return GetTouchPosition(0);
|
return GetTouchPosition(0);
|
||||||
#else
|
#else
|
||||||
return (Vector2){ mousePosition.x*mouseScale, mousePosition.y*mouseScale };
|
return (Vector2){ mousePosition.x*mouseScale.x, mousePosition.y*mouseScale.y };
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2114,7 +2114,16 @@ void SetMousePosition(Vector2 position)
|
||||||
void SetMouseScale(float scale)
|
void SetMouseScale(float scale)
|
||||||
{
|
{
|
||||||
#if !defined(PLATFORM_ANDROID)
|
#if !defined(PLATFORM_ANDROID)
|
||||||
mouseScale = scale;
|
mouseScale = (Vector2){ scale };
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set mouse scaling
|
||||||
|
// NOTE: Useful when rendering to different size targets
|
||||||
|
void SetMouseOffset(Vector2 offset)
|
||||||
|
{
|
||||||
|
#if !defined(PLATFORM_ANDROID)
|
||||||
|
mouseScale = offset;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4225,10 +4234,10 @@ static void *EventThread(void *arg)
|
||||||
|
|
||||||
// Screen confinement
|
// Screen confinement
|
||||||
if (mousePosition.x < 0) mousePosition.x = 0;
|
if (mousePosition.x < 0) mousePosition.x = 0;
|
||||||
if (mousePosition.x > screenWidth/mouseScale) mousePosition.x = screenWidth/mouseScale;
|
if (mousePosition.x > screenWidth/mouseScale.x) mousePosition.x = screenWidth/mouseScale.x;
|
||||||
|
|
||||||
if (mousePosition.y < 0) mousePosition.y = 0;
|
if (mousePosition.y < 0) mousePosition.y = 0;
|
||||||
if (mousePosition.y > screenHeight/mouseScale) mousePosition.y = screenHeight/mouseScale;
|
if (mousePosition.y > screenHeight/mouseScale) mousePosition.y = screenHeight/mouseScale.y;
|
||||||
|
|
||||||
// Gesture update
|
// Gesture update
|
||||||
if (GestureNeedsUpdate)
|
if (GestureNeedsUpdate)
|
||||||
|
|
|
@ -942,6 +942,7 @@ RLAPI int GetMouseY(void); // Returns mouse p
|
||||||
RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY
|
RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY
|
||||||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||||
RLAPI void SetMouseScale(float scale); // Set mouse scaling
|
RLAPI void SetMouseScale(float scale); // Set mouse scaling
|
||||||
|
RLAPI void SetMouseOffset(Vector2 scale); // Set mouse scaling XY
|
||||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||||
|
|
||||||
// Input-related functions: touch
|
// Input-related functions: touch
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue