shithub: choc

Download patch

ref: a046ab8196c6483b62e9193eeb4ae2af1f4b550a
parent: f794c7692bac019f9f91cc821382a3f2d3b1011d
author: Simon Howard <[email protected]>
date: Fri Jan 1 17:28:25 EST 2016

video: Remove invisible cursor hack.

This hack was added a while back to work around the fact that SDL
would add latency when using SDL_ShowCursor(0) on Windows. I doubt
it's still necessary and if it is still a problem, we should report
it to the upstream SDL devs.

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -319,23 +319,7 @@
 
 static void SetShowCursor(boolean show)
 {
-    // On Windows, using SDL_ShowCursor() adds lag to the mouse input,
-    // so work around this by setting an invisible cursor instead. On
-    // other systems, it isn't possible to change the cursor, so this
-    // hack has to be Windows-only. (Thanks to entryway for this)
-
-#ifdef _WIN32
-    if (show)
-    {
-        SDL_SetCursor(cursors[1]);
-    }
-    else
-    {
-        SDL_SetCursor(cursors[0]);
-    }
-#else
     SDL_ShowCursor(show);
-#endif
 
     // When the cursor is hidden, grab the input.
 
@@ -690,23 +674,6 @@
     }
 }
 
-// Warp the mouse back to the middle of the screen
-
-static void CenterMouse(void)
-{
-    int screen_w, screen_h;
-
-    // Warp the the screen center
-
-    SDL_GetWindowSize(screen, &screen_w, &screen_h);
-    SDL_WarpMouseInWindow(screen, screen_w / 2, screen_h / 2);
-
-    // Clear any relative movement caused by warping
-
-    SDL_PumpEvents();
-    SDL_GetRelativeMouseState(NULL, NULL);
-}
-
 //
 // Read the change in mouse state to generate mouse motion events
 //
@@ -737,11 +704,6 @@
         
         D_PostEvent(&ev);
     }
-
-    if (MouseShouldBeGrabbed())
-    {
-        CenterMouse();
-    }
 }
 
 //
@@ -789,7 +751,6 @@
     else if (grab && !currently_grabbed)
     {
         SetShowCursor(false);
-        CenterMouse();
     }
     else if (!grab && currently_grabbed)
     {