walbourn/directx-sdk-samples

Why DirectInput is not recommended for keyboard and mouse?

sunzhuoshi opened this issue · 2 comments

I'm trying to handle keyboard with DirectInput. but I read this from you blog:
"Keyboard and Mouse samples are not included as use of DirectInput for these scenarios is not recommended."
https://blogs.msdn.microsoft.com/chuckw/2013/09/20/directx-sdk-samples-catalog/
Why it is not recommended for keyboard and mouse? Then what is the recommended way?
Thank you.

DirectInput back in the era of Windows 9x/ME was in fact 'direct'. It implemented it's own device access that bypassed the Windows mechanisms for input. That, however, has not been true since Windows 2000/XP. It's just a wrapper over the existing Win32 messages for mouse and keyboard input. A such, it's less 'direct' than just using the Win32 messages. It also can have strange interactions with other event hooks and systems.

The only good modern use of DirectInput is for dealing with gaming devices that use HID.

Thank you so much for your quick and detail explanation!