[visionegg] Keyboard input in python

  • From: Timothy Vickery <tim.vickery@xxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Sun, 22 Aug 2004 03:07:48 -0400

Hi everyone,
I have a few questions related to keyboard input, and I would greatly
appreciate any comments on the matter. I apologize if this discussion
is redundant but I have looked through the archives available here and
not all this ground has been covered before.

Does anyone know of a way to directly poll the keyboard, independent
of the event manager, in python? I've looked into Pygame and SDL and I
don't think there's anything there that does this. The best candidates
are pygame.key.get_pressed() and SDL_GetKeyState(), and after
examining the source code for these commands I don't believe they do
what I'm looking to do. The former actually wraps the latter, which
returns the state of the keyboard at the last call to
SDL_PumpEvents(). So, it would seem that this function is reliant on
the event manager, after all.
The command for doing this in Psychophysics Toolbox is KbCheck, which
actually employs a different strategy for each platform. On Win32
machines, for example, it calls GetAsyncKeyState(), a Win32 api
function. On MacOS classic, it uses a procedure called GetKeys. The
Mac OSX version of the software appears to rely solely on the USB HID
libraries.
I can and will write my own module for python to do this, if needed,
but it would be nice if something like this already existed. The USB 1
ms frame problem is not a bother to me, so I won't mind too much if
I'm limited to only USB keyboards. In other words, if there's
something out there for python that will allow me to poll the state of
a USB keyboard whenever I want (independent of the EM), that would
make me happy. I have not been able to locate anything like this, so
far.
On the other hand, perhaps I'm worried about nothing and the event
manager isn't a problem. On the major platforms, does the event
manager add any substantial wait time when a.) the hardware is modern
and fast, and b.) an absolute minimum number of competing processes
are running?
Thanks for your input!
Regards,
Tim Vickery
======================================
The Vision Egg mailing list
Archives: //www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts:

  • » [visionegg] Keyboard input in python