Jump to content
  • Advertisement
Sign in to follow this  
JohnHurt

Keyboard input

This topic is 4860 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 do you guys use for getting keyboard input? For ages I've been using GetAsyncKeyState(), is there any advantage of using say Direct Input?

Share this post


Link to post
Share on other sites
Advertisement
Oh yes![smile] Direct Input, while a bit more complicated than Win32 API input, is far more powerful and useful. There is possibilities to get buffered input, so you can be sure you do not miss any keystrokes. Hey, nothing worse than your ship not firing in your game, right? [grin]

While Direct Input has some nice features for handling input, it is by no means the best. You will have to do some research before you can get a good working library out of it, as it seems you would have to do with ALL of DX components... Luckily I had a book that went over it, so it was ok for me.

If you are doing game programming, I would suggest Direct Input, unless what you are using has built in input - such as SDL, GLFW, Allegro, etc... I know that I can use my DI library in GLFW, for it is just an OpenGL wrapper, but It does not work in SDL and I'm sure it won't work in Allegro.

It all depends on what you are doing. If you could use some more control over input, DI is the way to go. It is well worth the extra time to learn how it works in order to have a better input system in your games. Be aware though, it's a litle tricky! I know I could not figre out how to use the mouse coordinates since they are in relative terms (change in movments) and not the actual position, so I just used the Win32 API method of getting it [lol]. I know Oluseyi has pointed out how to change this, but I can't remember where that post was.

Share this post


Link to post
Share on other sites
Yes, buffered input seems to be a good reason. I've noticed that during occasional pauses in gameplay (for whatever reason - random hard-drive activity, email prog firing up!) i would lose some keystrokes. I already use DX to get mouse input, and it certainly seems to be the easiest of the DX modules to use (i abandoned D3D last year in favour of OGL). I'll give it a go. BTW is the buffering of input under the hood, or do you need to handle it in some way?

Share this post


Link to post
Share on other sites
The buffering is handled automatically (assuming you enable buffering when you set up the device). But, with buffered input, you will (obviously) have to use a loop to extract the buffered events.

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!