From 0913bd44af597940bc1e8e66cd60b4c1b396eea8 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Thu, 13 Nov 2014 03:51:33 -0600 Subject: [PATCH] Fix mouse warping In some cases, the warp back to center was being detected as a mouse motion, causing all sorts of silliness with the mouse. The workaround is by only using the first motion event and ignoring every event after that, until the next call to I_GetEvent. --- src/sdl/i_video.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 6be2ede12..b592d3bc1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -987,6 +987,9 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type) void I_GetEvent(void) { SDL_Event evt; + // We only want the first motion event, + // otherwise we'll end up catching the warp back to center. + int mouseMotionOnce = 0; if (!graphics_started) { @@ -1005,7 +1008,8 @@ void I_GetEvent(void) Impl_HandleKeyboardEvent(evt.key, evt.type); break; case SDL_MOUSEMOTION: - Impl_HandleMouseMotionEvent(evt.motion); + if (!mouseMotionOnce) Impl_HandleMouseMotionEvent(evt.motion); + mouseMotionOnce = 1; break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: