Access to keyboard key presses

This forum deals with BCI2000 configuration issues.
Locked
tmile77
Posts: 8
Joined: 18 Jan 2010, 09:21

Access to keyboard key presses

Post by tmile77 » 29 Jul 2010, 09:53

I'm having trouble to get access to reliable key presses of the keyboard (up and down keys in my case). Method that I'm using right now is to run application modul with "--LogKeyboard=1" and to read out the values of the "KeyDown" state at the beggining of my implementation of the ApplicationBase::Process function. Problem is that not all of the key-presses are received, so I need to press the key a bunch of times until it's received by the framework.

Is there a better way to do this?

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 29 Jul 2010, 10:31

When you just read the value of the "KeyDown" state this way:

Code: Select all

int keyDown = State( "KeyDown" );
you will not catch all keypresses. Rather, you need to consider the state's value for each sample in the block:

Code: Select all

int sampleBlockSize = Parameter( "SampleBlockSize" );
for( int i = 0; i < sampleBlockSize; ++i )
{
  int keyDown = State( "KeyDown" )( i );
  ...
}
HTH,
Juergen

tmile77
Posts: 8
Joined: 18 Jan 2010, 09:21

Post by tmile77 » 30 Jul 2010, 09:19

Fixed. Works great now. Thanks.

Locked

Who is online

Users browsing this forum: No registered users and 0 guests