Jump to content
  • Advertisement
Sign in to follow this  
Ganoosh_

Best way to get input?

This topic is 4866 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

What is the best way to get input on Windows? WM_KEYDOWN is slow and has delays, I've heard of GetAsyncKeyState(), is that any good? Or is there a better way? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
GetAsyncKeyState works well if you are looping through code that expects a keypress... IOW, you have to check GetAsyncKeyState in response to another message, likely. Or you can run an infinite loop, checking GetAsyncKeyState inside of it.

The WM_KEYDOWN message is "slow", in that by the time the system gets around to sending it to the WndProc, and the switch statement selects that case, the keypress event might be over.

If WM_KEYDOWN is too slow for you, then GetAsyncKeyState might not work for you anyway... unless you loop it as described. Put a call to it in your message pump, if you really need the speed.

Some people swear on DirectInput

Just use the right tool for the right job.

Share this post


Link to post
Share on other sites
If you're open to it, a good way is to create a separate input thread, with the described infinite loop of "GetAsyncKeyState"... of course, you'd have to provide a way to break the loop... like checking a global bool variable, or something
(g_stillPlaying == true, or something)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!