Skip to content
Snippets Groups Projects
Commit 62397a36 authored by LJ Sonic's avatar LJ Sonic
Browse files

Grab mouse on game startup

parent caadf6aa
No related branches found
No related tags found
No related merge requests found
...@@ -639,11 +639,14 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) ...@@ -639,11 +639,14 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
{ {
static boolean firstmove = true;
if (USE_MOUSEINPUT) if (USE_MOUSEINPUT)
{ {
if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window) || IGNORE_MOUSE) if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window) || (IGNORE_MOUSE && !firstmove))
{ {
SDLdoUngrabMouse(); SDLdoUngrabMouse();
firstmove = false;
return; return;
} }
...@@ -657,6 +660,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) ...@@ -657,6 +660,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
mousemovey += -evt.yrel; mousemovey += -evt.yrel;
SDL_SetWindowGrab(window, SDL_TRUE); SDL_SetWindowGrab(window, SDL_TRUE);
} }
firstmove = false;
return; return;
} }
...@@ -664,6 +668,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) ...@@ -664,6 +668,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
// of the screen then ignore it. // of the screen then ignore it.
if ((evt.x == realwidth/2) && (evt.y == realheight/2)) if ((evt.x == realwidth/2) && (evt.y == realheight/2))
{ {
firstmove = false;
return; return;
} }
...@@ -676,6 +681,8 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) ...@@ -676,6 +681,8 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
SDLdoGrabMouse(); SDLdoGrabMouse();
} }
} }
firstmove = false;
} }
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment