[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to handle keyboard input



Mads Bondo Dydensborg wrote:
> 
> Hey all.
> 
> Doing a game with OpenGL, using glutKeyboardFunc to get some
> keypresses. However, this is not good:
> 
> a) Having to handle both KeyboardFunc and SpecialFunc, and *Up* funcs is
>    tiresome, and I have no garantee that a keydown will eventually
>    generate a key up.
> b) I can't handle multiple pressed keys.


I must confess I am using Windows95, but I do use 
Glut and OpenGL (So that I can convert to Linux)

a) I have not seen randomly missing Keyups
(There are some problems with certain keys in the keyboard,
but this is certainly Windows specific ;-)

b) It is possible to handle multiple keys with Glut
functions. (Assuming you mean like "press forward key,
while pressing it press turn left for a while,
stop pressing forward, while still pressing turn left")

I handle multiple keys by keeping a state variable for each
interesting key. I update this state in the "down" and "up"
functions. The game logic then reads the "current value" 
of the key from this value when it needs it.



		Eero

---------------------------------------------------------------------
To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: linuxgames-help@sunsite.auc.dk