mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-20 03:55:16 +08:00
Mouse coordinates are floating point
You can get sub-pixel mouse coordinates and motion depending on the platform and display scaling. Fixes https://github.com/libsdl-org/SDL/issues/2999
This commit is contained in:
@@ -297,12 +297,12 @@ typedef struct SDL_MouseMotionEvent
|
||||
Uint32 type; /**< ::SDL_MOUSEMOTION */
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
Uint32 state; /**< The current button state */
|
||||
Sint32 x; /**< X coordinate, relative to window */
|
||||
Sint32 y; /**< Y coordinate, relative to window */
|
||||
Sint32 xrel; /**< The relative motion in the X direction */
|
||||
Sint32 yrel; /**< The relative motion in the Y direction */
|
||||
float x; /**< X coordinate, relative to window */
|
||||
float y; /**< Y coordinate, relative to window */
|
||||
float xrel; /**< The relative motion in the X direction */
|
||||
float yrel; /**< The relative motion in the Y direction */
|
||||
} SDL_MouseMotionEvent;
|
||||
|
||||
/**
|
||||
@@ -313,13 +313,13 @@ typedef struct SDL_MouseButtonEvent
|
||||
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
Uint8 button; /**< The mouse button index */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
|
||||
Uint8 padding1;
|
||||
Sint32 x; /**< X coordinate, relative to window */
|
||||
Sint32 y; /**< Y coordinate, relative to window */
|
||||
Uint8 padding;
|
||||
float x; /**< X coordinate, relative to window */
|
||||
float y; /**< Y coordinate, relative to window */
|
||||
} SDL_MouseButtonEvent;
|
||||
|
||||
/**
|
||||
@@ -330,14 +330,12 @@ typedef struct SDL_MouseWheelEvent
|
||||
Uint32 type; /**< ::SDL_MOUSEWHEEL */
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
|
||||
Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
|
||||
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
|
||||
float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
|
||||
Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
|
||||
float preciseX; /**< The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18) */
|
||||
float preciseY; /**< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18) */
|
||||
Sint32 mouseX; /**< X coordinate, relative to window (added in 2.26.0) */
|
||||
Sint32 mouseY; /**< Y coordinate, relative to window (added in 2.26.0) */
|
||||
float mouseX; /**< X coordinate, relative to window */
|
||||
float mouseY; /**< Y coordinate, relative to window */
|
||||
} SDL_MouseWheelEvent;
|
||||
|
||||
/**
|
||||
|
||||
@@ -103,7 +103,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
|
||||
* \sa SDL_GetRelativeMouseState
|
||||
* \sa SDL_PumpEvents
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(float *x, float *y);
|
||||
|
||||
/**
|
||||
* Get the current state of the mouse in relation to the desktop.
|
||||
@@ -132,7 +132,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
|
||||
*
|
||||
* \sa SDL_CaptureMouse
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(float *x, float *y);
|
||||
|
||||
/**
|
||||
* Retrieve the relative state of the mouse.
|
||||
@@ -151,7 +151,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y);
|
||||
*
|
||||
* \sa SDL_GetMouseState
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(float *x, float *y);
|
||||
|
||||
/**
|
||||
* Move the mouse cursor to the given position within the window.
|
||||
@@ -173,7 +173,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
|
||||
* \sa SDL_WarpMouseGlobal
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
|
||||
int x, int y);
|
||||
float x, float y);
|
||||
|
||||
/**
|
||||
* Move the mouse to the given position in global screen space.
|
||||
@@ -195,7 +195,7 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
|
||||
*
|
||||
* \sa SDL_WarpMouseInWindow
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
|
||||
extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(float x, float y);
|
||||
|
||||
/**
|
||||
* Set relative mouse mode.
|
||||
|
||||
@@ -1034,10 +1034,10 @@ extern DECLSPEC void SDLCALL SDL_GetRenderScale(SDL_Renderer * renderer,
|
||||
* \sa SDL_GetRenderLogicalSize
|
||||
* \sa SDL_SetRenderLogicalSize
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
|
||||
int windowX, int windowY,
|
||||
float *logicalX, float *logicalY);
|
||||
|
||||
extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer *renderer,
|
||||
float windowX, float windowY,
|
||||
float *logicalX, float *logicalY);
|
||||
|
||||
|
||||
/**
|
||||
* Get real coordinates of point in window when given logical coordinates of
|
||||
@@ -1060,9 +1060,9 @@ extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
|
||||
* \sa SDL_GetRenderLogicalSize
|
||||
* \sa SDL_SetRenderLogicalSize
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer,
|
||||
float logicalX, float logicalY,
|
||||
int *windowX, int *windowY);
|
||||
extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer *renderer,
|
||||
float logicalX, float logicalY,
|
||||
float *windowX, float *windowY);
|
||||
|
||||
/**
|
||||
* Set the color used for drawing operations (Rect, Line and Clear).
|
||||
|
||||
Reference in New Issue
Block a user