Direct Input or GetKeyboardState()?

Started by
3 comments, last by Haiduk67 16 years, 10 months ago
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?
Advertisement
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.
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.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I am much obliged. Many thanks.

This topic is closed to new replies.

Advertisement