From f46ec14ce6b78b284546dd5608b43a739bcf25f6 Mon Sep 17 00:00:00 2001 From: "wrenczes@gmail.com" Date: Sun, 11 Sep 2011 02:41:14 +0000 Subject: [PATCH] Fix for the mouse lag on windows. The issue with the mouse events lagging badly is that the while loop on SDL_WaitEventTimeout means that we'll wait consecutively 10 ms per mouse event, so we get flooded & never call onUpdate until the mouse stops moving. Replaced the gate with a simple for loop that guarantees that we call onUpdate at least once every 50 ms. We can try to tweak the value for better framerates, but this value seemed to be in the right ballpark. --- JGE/src/SDLmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JGE/src/SDLmain.cpp b/JGE/src/SDLmain.cpp index fadb0fc31..e7b0ac972 100644 --- a/JGE/src/SDLmain.cpp +++ b/JGE/src/SDLmain.cpp @@ -118,7 +118,7 @@ public: { if (g_engine) { - while(SDL_WaitEventTimeout(&Event, 10)) + for (int x = 0; x < 5 && SDL_WaitEventTimeout(&Event, 10); ++x) { if(!g_engine->IsPaused()) OnEvent(&Event);