mirror of
https://github.com/encounter/SDL.git
synced 2025-12-09 21:47:44 +00:00
Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
This commit is contained in:
@@ -482,10 +482,10 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
if ( window == NULL )
|
||||
if (window == NULL)
|
||||
window = mouse->focus;
|
||||
|
||||
if ( window == NULL )
|
||||
if (window == NULL)
|
||||
return;
|
||||
|
||||
if (mouse->WarpMouse) {
|
||||
@@ -495,6 +495,16 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
if (mouse->WarpMouseGlobal) {
|
||||
mouse->WarpMouseGlobal(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
|
||||
{
|
||||
|
||||
@@ -57,9 +57,12 @@ typedef struct
|
||||
/* Free a window manager cursor */
|
||||
void (*FreeCursor) (SDL_Cursor * cursor);
|
||||
|
||||
/* Warp the mouse to (x,y) */
|
||||
/* Warp the mouse to (x,y) within a window */
|
||||
void (*WarpMouse) (SDL_Window * window, int x, int y);
|
||||
|
||||
/* Warp the mouse to (x,y) in screen space */
|
||||
void (*WarpMouseGlobal) (int x, int y);
|
||||
|
||||
/* Set relative mode */
|
||||
int (*SetRelativeMouseMode) (SDL_bool enabled);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user