Search code examples
windowsdirectxdirectinput

What is the difference between reading keyboard input asynchronously and using DirectInput?


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?


Solution

  • 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()