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?
views:
298answers:
2
A:
You can detect when a keypress event occurs, record that state, and then listen for a key release event.
Scottie T
2009-04-30 20:20:47
Which is what I am (sort of) currently doing. The problem is, glutKeyboardFunc() doesn't pass the current state. It only passes the ASCII character of the key.
Wally
2009-04-30 20:26:18
So keep track of the button you're interested in. You'll have to roll your own button state machine.
Scottie T
2009-04-30 20:31:52
+2
A:
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.
Zifre
2009-04-30 20:29:49
Looks like this is what I'm going to have to do. SDL will fix other numerous problems as well. Thanks!
Wally
2009-04-30 20:37:50