Skip to content

Commit

Permalink
Fix MacOS mouse grabbing issue
Browse files Browse the repository at this point in the history
Fixes #48 by
centering the mouse on the window prior to grabbing it.
  • Loading branch information
Macil authored and sezero committed Mar 11, 2023
1 parent aa3cfce commit 88d9a8f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Quake/in_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 88d9a8f

Please sign in to comment.