[SDL] SDL mouse events.

Tim Angus tim at ngus.net
Mon Mar 17 05:05:58 PDT 2008


Sam Lantinga wrote:
>> Btw. I've seen a razor mouse which has a 1200Hz sample rate which would fill 
>> the queue at ~10fps, which isn't unheard of.
> 
> Have you actually seen this fill the SDL queue on any platform?
> Even with ~15 FPS, I've never seen more than 20 or 30 mouse events in the
> queue with any mouse on any platform.

Hmmm. Does this mean that in 1.3 the mouse input is still gathered using 
a thread? This is one of my biggest gripes with 1.2. The problem is that 
if your input gathering rate differs from your game's framerate (which 
it almost always will), you get beats in the mouse input.

Time         SDL input thread            Game loop
  |
\|/          Read mouse 1px              Process mouse 1px


              Read mouse 1px
                                          Process mouse 1px

              Read mouse 1px

                                          Process mouse 1px
              Read mouse 1px


              Read mouse 1px              Process mouse 2px


              Read mouse 1px
                                          Process mouse 1px

              Read mouse 1px

                                          Process mouse 1px

...etc.

As you can see the mouse movement as far as the game is concerned is 
uneven, despite the input being perfectly smooth. This problem only gets 
worse when your render rate is variable.

Given that I don't have the reaction times of a hummingbird, personally 
I don't really care that much; I only really notice it if I'm looking 
for it. Unfortunately we've been getting widespread antipathy towards 
SDL for the Windows version of ioquake3.org for reasons of the mouse 
input alone. I have to admit that it's quite apparent when compared 
against an older build which uses dinput directly.

Note that the SDL_Get*MouseState API functions don't help since these 
still query the SDL event queue. It would be nice if these calls simply 
passed through to the platform specific mouse query functions directly. 
Obviously this approach is mutually exclusive with handling mouse events 
on the SDL queue, so it would need to be disabled. I think this is what 
is required to placate the twitch-shooter brigade :(

However, I was under the impression (without actually looking at the 
evidence) that 1.3 had fixed this issue with ManyMouse stuff? Is this 
not the case?


More information about the SDL mailing list