Question

This is a similar problem: Link
Which was solved by calling GetAsyncKeyState(). While all fine and dandy, I need a Linux alternative. I need to know if a button is being held down, not just being pressed (because of the keyboard buffer delay).

Does anything like this exist in the OpenGL/Glut libraries, or will I have to look elsewhere?

Was it helpful?

Solution

I have never used Glut, but I know that many people will say SDL is better. I have used SDL and I like it a lot. It does everything Glut does and a lot more. In SDL, you can use SDL_PollEvent() to get key state without the keyboard buffer delay.

Edit: I know almost nothing about Glut, but it looks like you can use glutKeyboardFunc to detect normal keys, and glutSpecialFunc for keys that do not generate ASCII characters (such as shift). I'm not sure if there is a better way, as this doesn't seem very nice.

OTHER TIPS

You can detect when a keypress event occurs, record that state, and then listen for a key release event.

As said, you will have to make your own state machine, which is easy. But you also need to use this callback method I think.

http://pyopengl.sourceforge.net/documentation/manual/glutKeyboardUpFunc.3GLUT.xml

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top