Fix MacOS mouse grabbing issue

Fixes https://github.com/sezero/quakespasm/issues/48 by
centering the mouse on the window prior to grabbing it.
This commit is contained in:
Chris Cowan 2023-03-04 22:56:40 -08:00 committed by Ozkan Sezer
parent aa3cfce04d
commit 88d9a8f45d
1 changed files with 9 additions and 0 deletions

View File

@ -212,6 +212,15 @@ void IN_Activate (void)
#endif
#if defined(USE_SDL2)
#ifdef __APPLE__
{
// Work around https://github.com/sezero/quakespasm/issues/48
int width, height;
SDL_GetWindowSize((SDL_Window*) VID_GetWindow(), &width, &height);
SDL_WarpMouseInWindow((SDL_Window*) VID_GetWindow(), width / 2, height / 2);
}
#endif
if (SDL_SetRelativeMouseMode(SDL_TRUE) != 0)
{
Con_Printf("WARNING: SDL_SetRelativeMouseMode(SDL_TRUE) failed.\n");