PDA

View Full Version : Simultaneous key presses



Caleb
06-14-2000, 12:03 AM
Hi,

I'm currently coding a 3D engine in C and using GLUT to maintain maximum portability.

How do you allow for simultaneous key presses? For example, when I'm moving forward and then I want to strafe, I need to press the 'forward' button, let go, then press 'strafe' button. is there a way to handle button presses better without having to let go?

also, is there a platform-independent way to detect if you have RELEASED a key button? this would be very helpful to trigger deceleration in a 3D engine so your player doesn't just stop instantaneously.

thanks.

MikeC
06-14-2000, 05:04 AM
Q2: use glutKeyboardUpFunc()

Q1: I've never had any problems with simultaneous keypresses in GLUT. Just associate a flag with each control key, set it to true in glutKeyboardFunc and to false in glutKeyboardUpFunc(). Then base your movement on the combination of the various key flags.

Caleb
06-14-2000, 10:59 AM
thanks a lot for your help. much appreciated.

btw, how did you know about glutKeyboardUp()?

i did not find that in the GLUT API.

thx.

MikeC
06-15-2000, 03:30 AM
Heh... get into the habit of reading the headers. The GLUT API docs aren't particularly up-to-date.