If there isn't a GetGlobalMouseState() implementation, fall back to the normal one.

This commit is contained in:
Sam Lantinga 2020-05-26 16:34:50 -07:00
parent 437577f91e
commit bcbaa4ec1f
3 changed files with 16 additions and 35 deletions

View File

@ -722,6 +722,8 @@ Uint32
SDL_GetGlobalMouseState(int *x, int *y) SDL_GetGlobalMouseState(int *x, int *y)
{ {
SDL_Mouse *mouse = SDL_GetMouse(); SDL_Mouse *mouse = SDL_GetMouse();
if (mouse->GetGlobalMouseState) {
int tmpx, tmpy; int tmpx, tmpy;
/* make sure these are never NULL for the backend implementations... */ /* make sure these are never NULL for the backend implementations... */
@ -734,11 +736,10 @@ SDL_GetGlobalMouseState(int *x, int *y)
*x = *y = 0; *x = *y = 0;
if (!mouse->GetGlobalMouseState) {
return 0;
}
return mouse->GetGlobalMouseState(x, y); return mouse->GetGlobalMouseState(x, y);
} else {
return SDL_GetMouseState(x, y);
}
} }
void void

View File

@ -466,8 +466,6 @@ KMSDRM_InitMouse(_THIS)
mouse->FreeCursor = KMSDRM_FreeCursor; mouse->FreeCursor = KMSDRM_FreeCursor;
mouse->WarpMouse = KMSDRM_WarpMouse; mouse->WarpMouse = KMSDRM_WarpMouse;
mouse->WarpMouseGlobal = KMSDRM_WarpMouseGlobal; mouse->WarpMouseGlobal = KMSDRM_WarpMouseGlobal;
/* No desktop on KMSDRM, so just return the normal mouse state. */
mouse->GetGlobalMouseState = SDL_GetMouseState;
SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor()); SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor());
} }

View File

@ -109,19 +109,6 @@ VideoBootStrap OFFSCREEN_bootstrap = {
OFFSCREEN_Available, OFFSCREEN_CreateDevice OFFSCREEN_Available, OFFSCREEN_CreateDevice
}; };
static Uint32
OFFSCREEN_GetGlobalMouseState(int *x, int *y)
{
if (x) {
*x = 0;
}
if (y) {
*y = 0;
}
return 0;
}
int int
OFFSCREEN_VideoInit(_THIS) OFFSCREEN_VideoInit(_THIS)
{ {
@ -141,11 +128,6 @@ OFFSCREEN_VideoInit(_THIS)
SDL_zero(mode); SDL_zero(mode);
SDL_AddDisplayMode(&_this->displays[0], &mode); SDL_AddDisplayMode(&_this->displays[0], &mode);
/* Init mouse */
mouse = SDL_GetMouse();
/* This function needs to be implemented by every driver */
mouse->GetGlobalMouseState = OFFSCREEN_GetGlobalMouseState;
/* We're done! */ /* We're done! */
return 0; return 0;
} }