PDA

View Full Version : Strange behavior in GLUT Key Up/down



butcher
01-18-2004, 11:05 PM
Hi gang,

I wish to detect key-press / release for as many simultaneous keys as possible at a given instant of time only using GLUT api.

I have used c++ code that looks like :

/*usual code replaced by ... for simplicity*/

/*...*/

void keyPressed(unsigned char key, int x, int y) {cout << "pressed " << key << endl;}

void keyReleased(unsigned char key, int x, int y) {cout << "released " << key << endl;}

/*...*/

int main(int argc, char **argv){
/*...*/

glutIgnoreKeyRepeat(1);
glutKeyboardFunc(&keyPressed);
glutKeyboardUpFunc(&keyReleased);

/*...*/

glutMainLoop();
}

Tried this on win2K PC with VC++6.0 GLUT API ver 3. This works as expected as long as I press keys on a single row of the keyboard.

Example: (simultaneoulsy )a,s,d,f,g,h,j,k,l,;,' pressed and released in any order are detected properly.
But, pressing (simultaneoulsy ) a,s,z,d 'z' goes undetected.

And lots of such similar combinations where things can go wrong exist.

Any ideas?

Thanks for reading till this point http://www.opengl.org/discussion_boards/ubb/smile.gif

Tom Nuydens
01-18-2004, 11:38 PM
The toolkits forum is more appropriate for this post...

-- Tom

Bob
01-19-2004, 01:45 AM
Clicky (http://www.sjbaker.org/steve/omniv/keyboards_are_evil.html) .

butcher
01-19-2004, 05:04 AM
Thanks a lot. That really helped me.

I was getting doubtful that GLUT api was flawed. I tested out with the more specific case of Win API GetAsyncKeyState. Same problem exists.

so, Keyboards ARE evil http://www.opengl.org/discussion_boards/ubb/frown.gif