Forum

Mouse lag?

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Mouse lag?

Postby r00k » Mon Sep 13, 2010 7:57 pm

I've added a workaround for mouse lag with vsync on, but wondered what's the true problem with vsync and mouse input lag.

qboolean Host_FilterTime (double time)
{
double fps;
extern cvar_t vid_refreshrate;

realtime += time;

if (sv.active)
fps = max(10, host_maxfps.value);//QuakeC requires at least 10fps and no more than 72fps(originally) for physics.
else
fps = max(10, cl_maxfps.value);

if (vid_vsync.value)//Workaround for mouse lag issues...
fps = min((fps - 0.1), (vid_refreshrate.value - 0.1));

if (!cls.capturedemo && !cls.timedemo && ((realtime - oldrealtime) < (1 / fps)))
{
return false;
}
...


Is it because vsync ON sustains all input (on the hardware level), and the condition above passes true, thus drawing the frame++, reading/clearing the mouse buffer?
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby mh » Mon Sep 13, 2010 9:40 pm

So far as I understand it, by default Windows samples the mouse 40 times per second, which means that it will go out of sync with each pass through the main loop (unless refresh rate is a multiple of 40, of course).

I believe there is an API call to change the sampling rate, but I've never really gone looking for it.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest