Minor input grabbing cleanup.

This commit is contained in:
svdijk 2014-01-11 19:01:04 +01:00
parent b33c895d56
commit 98a83e2322
2 changed files with 5 additions and 6 deletions

View file

@ -569,13 +569,13 @@ IN_KeyboardInit(Key_Event_fp_t fp)
/* SDL stuff. Moved here from IN_BackendInit because /* SDL stuff. Moved here from IN_BackendInit because
this must be done after video is initialized. */ this must be done after video is initialized. */
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_SetRelativeMouseMode(SDL_TRUE);
have_grab = GLimp_InputIsGrabbed(); have_grab = GLimp_InputIsGrabbed();
#if SDL_VERSION_ATLEAST(2, 0, 0)
if (have_grab)
SDL_SetRelativeMouseMode(SDL_TRUE);
#else #else
SDL_EnableUNICODE(0); SDL_EnableUNICODE(0);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
have_grab = (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
#endif #endif
} }

View file

@ -692,7 +692,7 @@ void GLimp_GrabInput(qboolean grab)
{ {
#if SDL_VERSION_ATLEAST(2, 0, 0) #if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_SetWindowGrab(window, grab ? SDL_TRUE : SDL_FALSE); SDL_SetWindowGrab(window, grab ? SDL_TRUE : SDL_FALSE);
if(grab) if (grab)
SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetRelativeMouseMode(SDL_TRUE);
#else #else
@ -708,8 +708,7 @@ qboolean GLimp_InputIsGrabbed()
#if SDL_VERSION_ATLEAST(2, 0, 0) #if SDL_VERSION_ATLEAST(2, 0, 0)
return SDL_GetWindowGrab(window) ? true : false; return SDL_GetWindowGrab(window) ? true : false;
#else #else
SDL_GrabMode m = SDL_WM_GrabInput(SDL_GRAB_QUERY); return (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
return m == SDL_GRAB_ON;
#endif #endif
} }