[visionegg] Re: Low latency keyboard input.

  • From: Timothy Vickery <tim.vickery@xxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Fri, 2 Dec 2005 21:15:10 -0500

Hi Simeon,
where this becomes a problem is when you have to measure responses while
motion is occurring. If you want RT, you are bound to some degree by the
frame rate of your monitor in that case, unless you do as Andrew suggests
and use mutlithreading. If you are putting up a static image and waiting for
a response, then your RT should be pretty reliable, I think. The event queue
may introduce some small amount of variability over direct polling of the
keyboard, but variability inherent in human RT should be so great that it
won't really matter. So, any difference worth detecting will probably still
show up.
Just my 2 cents...
Best,
Tim



On 12/2/05, Andrew Straw <astraw@xxxxxxxxxxx> wrote:
>
> 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:
> >
> > //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: //www.freelists.org/archives/visionegg
> Website: http://www.visionegg.org/mailinglist.html
>



--
------------------------------------------------------------
Visual Cognition Lab @ Harvard University
------------------------------------------------------------

Other related posts: