mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
Simplify the mouse grabbing/relative mode setting code.
This commit is contained in:
parent
5338566852
commit
503eefc301
2 changed files with 4 additions and 33 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue