[visionegg] Re: Low latency keyboard input.

Hi Simeon,

I agree that if your frames take a long time to draw (relative to your
desired timing accuracy), the present solution is a non-ideal. I think
the best thing to do would be a multi-threaded application, where one
thread listens for keyboard input while the other draws the screen.  You
may have to modify the Presentation class to support this (we wouldn't
want to touch the event queue in 2 threads, I don't think). I'm happy to
integrate any changes necessary for you to do this.

I assume pygame/SDL won't have any trouble accessing events from one
thread and drawing in another (really, the only call to pygame/SDL in
the draw thread is the swap_buffers() call -- the rest go straight to
OpenGL). I could be wrong, on this, though.  Still, if this is a
problem, it should be fairly easy to work around.

Before you go down this path, it might be useful to somehow measure the
timestamp latency jitter attainable by pygame/SDL without drawing.  I'm
not sure what you might find, but I suspect various operating systems
and/or drivers may buffer keystrokes for at least a millisecond or two.

Cheers!
Andrew

Simeon Fitch wrote:

> Over a year ago Timothy Vickery asked a question about bypassing
> pygame/SDL for keyboard input, that I'm also curious to know the
> answer to:
>
> http://www.freelists.org/archives/visionegg/08-2004/msg00018.html
>
> Is there a way to trap the keyboard input event outside the event loop?
>
> My larger issue is basically knowning what the right approach is to
> capturing and timing keyboard responses. The way I'm currently doing
> it is via a keydown callback added to the Presentation class'
> "handle_event_callbacks" property. I call "time.time()" right before
> calling "Presentation.go()" for the start time, and record the start
> time when the "keydown" callback is triggered.... an approach I don't
> feel very confident in. Any tips/advice out there? Am I (and my
> clients) worrying about a non-issue?
>
> Thanks,
>
> Simeon
>
>
> -- 
> Simeon H.K. Fitch, Owner
> Mustard Seed Software
>

======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: