Sign in to follow this  
Haiduk67

Direct Input or GetKeyboardState()?

Recommended Posts

I have done a fair amount of work using both Direct Input as well as simply using the GetKeyboardState() and GetAsyncKeyState() functions. As far as I can tell, both methods seem to operate at about the same speed. It even seems easier to simply use an STL deque to "push_back()" the WM_KEYUP and WM_KEYDOWN windows messages to "buffer" keys. Given the ease of using the two functions compared to setting up and using Direct Input, I ask the question, "why would someone hassle with Direct Input to read the keyboard?" What are the advantages? I'm asking mainly because the GUI project that I'm working on currently uses the "deque" method of detecting key states to determine whether or not a control object needs to fire a key event. Should I be worried about the case where the programmer using the GUI intends to use Direct Input for reading the keyboard in their application? Possible conflicts?

Share this post


Link to post
Share on other sites
The various posts here about this seem to come to the same conclusion. There is no benefit to using Direct Input for keyboard or mouse input. You may as well use the standard Windows messaging system. Where Direct Input comes into play is with joysticks and analogue devices.

I don't think there would be conflicts at all. You can add support for both if you wanted to. But I don't think it would be necessary. If your writing a GUI system then your input processing would be external to the one they use anyway. And from my experience there is no conflicts.

Share this post


Link to post
Share on other sites
Aye, thank you for confirming what I originally thought. It was one of those "oh no, did I overlook something that I'm gonna have to spend even more time on" moments.

Share this post


Link to post
Share on other sites
Quote:
Original post by Headkaze
There is no benefit to using Direct Input for keyboard or mouse input. You may as well use the standard Windows messaging system. Where Direct Input comes into play is with joysticks and analogue devices.
I concur - this comment sums things up nicely [smile]

ISTR on the DirectXDev list a long time ago the exact same conclusion was given by one of the Microsoft SDE's and they alluded to the fact that on more recent DX builds DInput actually just maps to the underlying windows messaging system and it no longer goes direct to the metal.

hth
Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this