Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()

This commit is contained in:
Sam Lantinga
2014-06-04 10:55:26 -07:00
parent 3e3b34adc9
commit 45ed5ee494
11 changed files with 99 additions and 6 deletions

View File

@@ -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)
{

View File

@@ -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);