Simplify the mouse grabbing/relative mode setting code.

This commit is contained in:
svdijk 2014-03-26 21:13:07 +01:00
parent 5338566852
commit 503eefc301
2 changed files with 4 additions and 33 deletions

View file

@ -595,22 +595,8 @@ IN_KeyboardInit(Key_Event_fp_t fp)
this must be done after video is initialized. */
have_grab = GLimp_InputIsGrabbed();
#if SDL_VERSION_ATLEAST(2, 0, 0)
if (have_grab)
{
if (SDL_SetRelativeMouseMode(SDL_TRUE) < 0)
{
in_relativemode = false;
}
else
{
in_relativemode = true;
}
}
else
{
SDL_SetRelativeMouseMode(SDL_FALSE);
in_relativemode = false;
}
SDL_SetRelativeMouseMode(have_grab ? SDL_TRUE : SDL_FALSE);
in_relativemode = (SDL_GetRelativeMouseMode() == SDL_TRUE);
#else
SDL_EnableUNICODE(0);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

View file

@ -714,23 +714,8 @@ void GLimp_GrabInput(qboolean grab)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_SetWindowGrab(window, grab ? SDL_TRUE : SDL_FALSE);
if (grab)
{
if (SDL_SetRelativeMouseMode(SDL_TRUE) < 0)
{
in_relativemode = false;
}
else
{
in_relativemode = true;
}
}
else
{
SDL_SetRelativeMouseMode(SDL_FALSE);
in_relativemode = false;
}
SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE);
in_relativemode = (SDL_GetRelativeMouseMode() == SDL_TRUE);
#else
SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
#endif