2
\$\begingroup\$

I have read that the Windows messages are recommended way over DirectInput to control mouse and keyboard.

From http://msdn.microsoft.com/en-us/library/windows/desktop/ee416842(v=vs.85).aspx

The use of DirectInput for keyboard and mouse input is not recommended. You should use Windows messages instead.

Why is it so? Because the DirectInput is still in version 8? Isn't it extending anymore?

\$\endgroup\$
  • 2
    \$\begingroup\$ AFAIK, DirectInput doesn't queue actions. So if for instance your game lags for a few frames, whatever was pressed in those frames weren't detected. Imagine your weapon not firing because of that. With messages, your firing would be delayed, but it'd still happen as soon as possible. \$\endgroup\$ – William Mariager May 22 '13 at 5:55
7
\$\begingroup\$

Well, it's deprecated, so that's the biggest reason you'd want to avoid it.

All it does is sit on top of other Windowing APIs (Raw Input in particular) and never really provided a significantly useful abstraction that justified bothering with it, especially since for everything except (non-360) joysticks and whatnot, everything you could do with it you could probably do more efficiently and more readily with Windows messages or Raw Input itself.

A Windows game has to have a Windows message pump anyway, so you may as well use that. DirectInput additionally had poor internationalization and multi-window support (which in practice could become an issue if you ever embedded your game engine into a tool, for example).

\$\endgroup\$
  • \$\begingroup\$ You're absolutely right because inside my editor, I've been noticing issues using DirectInput. If I'm in notepad and my editor is running, I type in A in the keyboard - then it will move the camera inside the editor. Plus, it will save some memory by not including the DirectInput. Because like you said if it's multi-windowed then it's going to be messy re-creating the direct input for each window which allocates memory. Now it makes sense why to prefer Windows Messaging API than DirectInput. \$\endgroup\$ – SICGames2013 Dec 4 '13 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.