1

DirectInput requires a lot of initialization functions and cetera to detect keyboard input, so what benefits are there to using it rather than the GetAsyncKeyState() function?

2 Answers2

1

Courtesy of Wikipedia...

DirectInput and XInput have benefits over normal Win32 input events:

  • They enable an application to retrieve data from input devices even when the application is in the background.
  • They provide full support for any type of input device, as well as for force feedback.
  • Through action mapping, applications can retrieve input data without needing to know what kind of device is being used to generate it.

Basically DirectInput gives you more flexibility to move away from the keyboard. If the keyboard is all you ever plan on using then there is probably no harm in using GetAsyncKeyState()

Pace
  • 33,215
  • 10
  • 99
  • 130
  • This question went up years ago, but I've been working on this myself lately and want to clarify that XInput is only for the XBox 360 controller. DirectInput can handle other devices, but XInput can't. Comparison at https://msdn.microsoft.com/en-us/library/windows/desktop/ee417014%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 – Stevens Miller Aug 23 '16 at 22:05
0

Also see Should I use DirectInput or Windows message loop?

Microsoft seem to recommend just using windows messages to handle input data where possible now.

Community
  • 1
  • 1
jcoder
  • 28,098
  • 16
  • 76
  • 120