[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Speed of mouse position capture



On 5/14/06, Brian Bull <Brian.Bull@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Dear list,

Hey Brian

I am encountering one difficulty, which is that the speed of mouse position
capture seems quite slow. I had expected that the app would receive a
MOUSEMOTION event every time the mouse shifted to a new pixel, and that
connecting up the locations of these MOUSEMOTION events would give an almost
exact representation of the path of the mouth across the screen. However,
what happens in practice is that, if the mouse is moving fast, consecutive
MOUSEMOTION events can be separated by more than 20 pixels.

I've run into the exact same problem and done some testing & research.
Read this blog entry by a microsoft guy:
http://blogs.msdn.com/oldnewthing/archive/2003/10/01/55108.aspx

So basically it's not a pygame or SDL problem, it's a windows thing.
Windows throws out data before sending mouse motion messages (which
seems like bad design to me, but oh well)

Also, my cousin has tested on Linux (debian I think) and I tested on
Mac (OS X, not sure with version) for the same problem, and I haven't
seen it on either of those (meaning pygame was getting mousemotion
messages to describe the movement well)


Is there a way to make Pygame sample the position of the mouse more often?

The only thing I found that could help was to call one of the event
handling functions (pygame.event.pump works) because they would call a
windows message handling func which would make windows keep another
mouse position, but you'd have to have a good way to call it a bunch
of times during a frame.

...If SDL used DirectInput for mouse handling it is true it could
avoid this problem, but directx is the default video driver, and using
directx for video doesn't mean it uses directX for the mouse. I think
there may be some specific full screen conditions where SDL will use
DirectInput and then you can get those ditched mouse messages, but I
don't know when those cases are. (If somebody else knows how to get
pygame on windows to use DirectInput, I'd love to hear it)