PDA

View Full Version : GLUT 3.7 and multiple keys held down



Little_Piggy
01-09-2001, 06:10 PM
Hi all,
I am writing a simple game, in which I use the GLUT 3.7 Keyboard and KeyboardUp callbacks with glutIgnoreKeyRepeat(1). The keys are used to move the little airplane around, so they are generally held down. Everything works fine if I only hold down one or two keys at once. If, however, I press and hold S, D and space bar (for example), the last keystroke is lost. By lost I mean it does not hit a breakpoint in the keydown callback, so this is something that GLUT is doing, not me. Some combinations of three and even four keys will work (e.g. S, D, O, K, but not O, K, '), however, which is puzzling.
I am wondering if anyone else has used the keydown and up callbacks and if they have the same difficulty. Documentation seems to be pretty slim, the man pages do not say anything about a keystroke limitation. I am running Win98.

Thanks.

zed
01-09-2001, 07:16 PM
nothing to do with the os or glut mate. the problem lies with your keyboards. the solution 'get a new one'.

its a problem with el cheapo (oldish keyboards)

grady
01-09-2001, 09:54 PM
DirectInput is very easy to learn.

mango
01-10-2001, 02:31 PM
I know that the keyboards has problems but I belived that also newer ones could not report all combinations?
DirectInput is better in many ways but suffers from the same problem.

You could try another combination of keys but even if that works for you is it not sure that it is OK with other keyboards.

mkennedy
01-22-2001, 08:09 PM
Hi Guys.

Your discussion seems to imply you have Direct Input working together with GLUT.

As far as I can tell this is not possible without hacking up GLUT a bit. You need the HINSTANCE and HWND from the OpenGL window to feed into DirectInputCreate() and so on. Do you know a way to get the HINSTANCE and HWND via GLUT???

Thanks,
Michael

--
Michael Kennedy - mkennedy@math.ucsd.edu http://mkennedy.101main.com/software

Elixer
01-22-2001, 09:17 PM
I remember glut having problems with multiple keypresses, but I haven't tried the latest glut to see if the problem was fixed.

Use:
#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

then...
if (KEY_DOWN('Z')) ...

BTW, some keyboards don't have n-key rollover, so that can be a problem on the el-cheapo ones. Also, others have a chep "matrix" mode, where if you press certain keys, you in effect short out the keypress. This is also a fault of the cheap keyboards.



[This message has been edited by Elixer (edited 01-22-2001).]