Jump to content
  • Advertisement
Sign in to follow this  
WizardOfOZ

Get key state without using Direct Input

This topic is 5414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!