mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-29 20:50:38 +00:00
Merge branch 'autofocus' into 'master'
Grab mouse focus whenever the window is focused See merge request KartKrew/Kart-Public!120
This commit is contained in:
commit
62140e1481
1 changed files with 13 additions and 4 deletions
|
@ -359,6 +359,14 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void SDLdoGrabMouse(void)
|
||||
{
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_SetWindowGrab(window, SDL_TRUE);
|
||||
if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful
|
||||
wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore?
|
||||
}
|
||||
|
||||
static void SDLdoUngrabMouse(void)
|
||||
{
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
@ -629,6 +637,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
//else firsttimeonmouse = SDL_FALSE;
|
||||
|
||||
capslock = !!( SDL_GetModState() & KMOD_CAPS );// in case CL changes
|
||||
|
||||
if (USE_MOUSEINPUT)
|
||||
SDLdoGrabMouse();
|
||||
}
|
||||
else if (!mousefocus && !kbfocus)
|
||||
{
|
||||
|
@ -708,9 +719,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
|||
// -- Monster Iestyn
|
||||
if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
|
||||
{
|
||||
SDL_SetWindowGrab(window, SDL_TRUE);
|
||||
if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful
|
||||
wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore?
|
||||
SDLdoGrabMouse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1277,7 +1286,7 @@ void I_StartupMouse(void)
|
|||
else
|
||||
firsttimeonmouse = SDL_FALSE;
|
||||
if (cv_usemouse.value)
|
||||
return;
|
||||
SDLdoGrabMouse();
|
||||
else
|
||||
SDLdoUngrabMouse();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue