From 041db6b34833f9f4314bc00145fcaa0774ddea3d Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 15 Jun 2021 01:53:35 -0400 Subject: [PATCH] Capture mouse properly on macOS when outside of window, fixes issue #584 --- neo/sys/sdl/sdl_glimp.cpp | 5 +++++ neo/sys/sdl/sdl_vkimp.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/neo/sys/sdl/sdl_glimp.cpp b/neo/sys/sdl/sdl_glimp.cpp index d004ff50..384a3baa 100644 --- a/neo/sys/sdl/sdl_glimp.cpp +++ b/neo/sys/sdl/sdl_glimp.cpp @@ -366,6 +366,11 @@ bool GLimp_Init( glimpParms_t parms ) { common->Printf( "Using GLEW %s\n", glewGetString( GLEW_VERSION ) ); } + +#if defined(__APPLE__) && SDL_VERSION_ATLEAST(2, 0, 2) + // SRS - On OSX enable SDL2 relative mouse mode warping to capture mouse properly if outside of window + SDL_SetHintWithPriority( SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1", SDL_HINT_OVERRIDE ); +#endif // DG: disable cursor, we have two cursors in menu (because mouse isn't grabbed in menu) SDL_ShowCursor( SDL_DISABLE ); diff --git a/neo/sys/sdl/sdl_vkimp.cpp b/neo/sys/sdl/sdl_vkimp.cpp index 9a59eb19..e6935ff9 100644 --- a/neo/sys/sdl/sdl_vkimp.cpp +++ b/neo/sys/sdl/sdl_vkimp.cpp @@ -317,6 +317,11 @@ bool VKimp_Init( glimpParms_t parms ) common->Printf( "No usable VK mode found: %s", SDL_GetError() ); return false; } + +#if defined(__APPLE__) && SDL_VERSION_ATLEAST(2, 0, 2) + // SRS - On OSX enable SDL2 relative mouse mode warping to capture mouse properly if outside of window + SDL_SetHintWithPriority( SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1", SDL_HINT_OVERRIDE ); +#endif // DG: disable cursor, we have two cursors in menu (because mouse isn't grabbed in menu) SDL_ShowCursor( SDL_DISABLE );