Direct Input

Started by
2 comments, last by DmitryNik 11 years, 4 months ago
Hello.

May it's a very stupid question, but why we should not use Direct Input for fetching keyboard's and mouse signals? The answer: because MS said so is not applicable in current situation. Yeah, good for MS, but they didn't explain why, as far as I know. Here is the link to official msdn tutorial about Direct Input http://msdn.microsoft.com/en-us/library/windows/desktop/ee416842(v=vs.85).aspx

And here is the citation: The use of DirectInput for keyboard and mouse input is not recommended. You should use Windows messages instead.

Thank you for your answers in advance rolleyes.gif
Advertisement
Already found the answer: DirectInput does not recognize keyboard character repeat settings. When using buffered data, DirectInput interprets each press and release as a single event with no repetition. When using immediate data, DirectInput is concerned only with the present physical state of the keys, not with keyboard events as interpreted by Windows.
DirectInput does not perform any character conversion or translation. For example, the SHIFT key is treated like any other key, not as a modifier of another keypress. Keys return the same identifiers regardless of the user's system language settings.
etc.

So, if it's all, why it shouldn't be used, then it's not that bad and Direct Input still could be used, if even somebody think it's a bad idea.
Those are rather significant disadvantages. As soon as you need to input even a bit of text (and be it only the player's name or naming a save) and might have to deal with non-(keyboard you are used to), it becomes a rather huge problem.

If a practice has several disadvantages AND is discouraged as not recommended by the API designer, then the question you should be asking is "Is there any really compelling reason to still do it?" instead of "Why should that stop me from using it?".

Honestly, I do not see any point of DirectInput for these cases. You need to handle Windows messages anyway, and you even have functions like GetKeyboardState to query the current state.


Honestly, I do not see any point of DirectInput for these cases. You need to handle Windows messages anyway, and you even have functions like GetKeyboardState to query the current state.


Thank you for your answer.
To be honest, I rather will handle windows messages. So for me it's more natural than using Direct Input. I was only curios about talks around Direct Input. Also the windows messaging is already in use during the main window drawing.

This topic is closed to new replies.

Advertisement