mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Grab mouse on window focus
Window focus does not necessarily imply mouse movement.
This commit is contained in:
parent
3ffa84a77b
commit
602c66d173
1 changed files with 13 additions and 4 deletions
|
@ -357,6 +357,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);
|
||||
|
@ -579,6 +587,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||
if (cv_usemouse.value) I_StartupMouse();
|
||||
}
|
||||
//else firsttimeonmouse = SDL_FALSE;
|
||||
|
||||
if (USE_MOUSEINPUT)
|
||||
SDLdoGrabMouse();
|
||||
}
|
||||
else if (!mousefocus && !kbfocus)
|
||||
{
|
||||
|
@ -655,9 +666,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1056,7 +1065,7 @@ void I_StartupMouse(void)
|
|||
else
|
||||
firsttimeonmouse = SDL_FALSE;
|
||||
if (cv_usemouse.value)
|
||||
return;
|
||||
SDLdoGrabMouse();
|
||||
else
|
||||
SDLdoUngrabMouse();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue