Get key state without using Direct Input

Started by
8 comments, last by doynax 19 years, 6 months ago
Is there an effective and quick way to get if the keys are pressed or not without using Direct Input? Thanks.
________________________________________________________www.wizardofoz.hwgn.net
Advertisement
When you press a key, your window will get sent a WM_KEYDOWN message, when the key is released you get sent a WM_KEYUP message. It 'does the job', but it's a lot slower then DirectInput.
In fact there are WM_KEYDOWN and WM_KEYUP or also the GetKeyState() function and they are slower than Direct Input.
But is there a way to access directly to the key state?
________________________________________________________www.wizardofoz.hwgn.net
int GetAsyncKeyState(int)

i think this is realy fast...
read about it on msdn.microsoft.com
if you acces the keystate directly, i dont know...
-Anders-Oredsson-Norway-
Thanks.
And is GetKeyboardState() slower than Direct Input to get all the keys state?
________________________________________________________www.wizardofoz.hwgn.net
I believe Direct Input is faster than any of the built in Windows functions, but depending on what you need it for, the aforementioned will do :)
"Imagination is more important than knowledge" - A. Einstein
Quote:Original post by WizardOfOZ
Thanks.
And is GetKeyboardState() slower than Direct Input to get all the keys state?

Direct Input doesn't need to account for keyboard layouts and accessability features. Although querying the complete state once per frame should be fast enough on 386..

I'd be more worried about what windows does to the input's 'quality'. For example GetAsyncKeyState() refuses to report more than four simultanous key presses on my system.
most keyboard cannot react to more than four keys presseing simultaneously, which has noting to do with windows. I think it may be the keyboard's limitation.
Quote:Original post by myjpa
most keyboard cannot react to more than four keys presseing simultaneously, which has noting to do with windows. I think it may be the keyboard's limitation.


Yup its even worse than that, the only 3 key combination guaranteed to work is CTRL-ALT_DELETE IIRC. The other cobmos that do work are dependant upon the manufactures implementation. For example i can't use Up, Left and Keypad 0 at the same time.
Quote:Original post by myjpa
most keyboard cannot react to more than four keys presseing simultaneously, which has noting to do with windows. I think it may be the keyboard's limitation.

No, it actually has. The problem still exists on the hardware level but it's not necessarily as bad.

We recently had a problem with out game and a microsoft natural keyboard using ps2. When too many keys were pressed simultaneously and then released the direct input never reported a key up event.

Windows solves these problems by assuming that your keyboard can't handle more than a fixed number of presses and filters out the oldest ones.

This topic is closed to new replies.

Advertisement