Jump to content
  • Advertisement
Sign in to follow this  
Daaark

What to use in place of DirectInput?

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

I was doing some reading earlier and read that Microsoft recommends not using DirectInput anymore. What am I supposed to use in it's place? The Win32 API function GetAsyncKeyState()? What happened that suddenly DirectInput isn't the preferred way to get input anymore?

Share this post


Link to post
Share on other sites
Advertisement
I recently moved from direct input to raw input for both mouse and keyboard. Works very well, cant tell the difference really. You receive the WM_INPUT message after registering raw input devices. I check what went up/down or moved with that message, update my states for keys buttons and movement.

Share this post


Link to post
Share on other sites
One more thing, there is an example on msdn about getting the raw mouse input where they use a #define HID_USAGE_GENERIC_MOUSE 0x02. Not sure where this comes from, maybe I missed something but it works. I extended it to use keyboard initially but i wasnt receiving keys. Then I happened across 0x06 being used for keyboard. Which I use when registering a keyboard (RegisterRawInputDevices(...)) and the key input kicked in for WM_INPUT. Killed 15-20 minutes trying to figure that out thought might be helpful.

Share this post


Link to post
Share on other sites
Quote:
Original post by NumberXaero
I recently moved from direct input to raw input for both mouse and keyboard. Works very well, cant tell the difference really. You receive the WM_INPUT message after registering raw input devices. I check what went up/down or moved with that message, update my states for keys buttons and movement.


That's because all DInput does is create a separate thread for processing WM_INPUT messages (On WinXP and Vista, at least). If you process WM_INPUT yourself, you get all the advantages of high-resolution mouse input without the overhead of an additional thread or the complexity of DInput. You also don't stop receiving the legacy mouse messages (WM_MOUSEMOVE and friends) which means that you can use those for GUI input if needed.

As for the keyboard I find it's best to just stick with the standard Win32 messages, or just call GetAsyncKeystate(). Or at least don't kill those messages when you register your raw input devices, so that you can use them for GUI input (raw input ignores things like caps lock and key repeats, which is annoying for entering text into edit boxes).

Share this post


Link to post
Share on other sites
I think GetKeyboardState() will get the job done. I won't be needing the mouse on this one project. How do I check the 'high order bit' of my key values? The code below isn't working very well, because it's always true!

GetKeyboardState(Key);
if (Key[VK_ESCAPE]) do_something;

Share this post


Link to post
Share on other sites
BTW: if the input you want from the keyboard is text, use WM_CHAR instead of raw input or the Get*() functions so that you get things like key map and IME support. For "button number 102 was pressed" game control input where you want low latency, GetAsyncKeyState() or one of the other methods suggested is the way to go.

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!