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

Re: [pygame] newbie: events and timing



I have some python code, where I wait in a loop for a trigger signal on
the lpt port.
during this waiting-loop: can I receive any mouse button events? are
they logged with some time-stamps, so that I can get, after I left my
waiting loop, the info, which mouse button has been pressed, and also at
what time.
i just had an idea. you could set a timer event to trigger every 1 millisecond. then you could use those events to set a rough timestamp for events in-between the timer events.

unfortunately timer events are usually pretty low resolution on most systems. i have a feeling the lowest you can go is probably 10ms. still, that's enough for a rough ballpark on timestamps. to set up the timer events is a simple call

pygame.time.set_timer(pygame.USEREVENT, 10)

then events with the type 'USEREVENT' will magically start appearing every 10ms. you may actually want to raise the time interval if you don't need such accuracy, since this will still be creating 100 events per second. something like 500 or 1000 might be better?

--
"Neither will I tell you by what authority I do these things"
pete*shinners.org