Question

I am making a wrapper for keyboard input using Direct Input. To grab the key states, the function GetDeviceState() is called with a char buffer.

This is all well and good, but now to send key events I must iterate through the buffer and check against all the keys that were pressed. I was hoping there would be a callback instead that only passed the key codes that were pressed.

If anybody has experience with Direct Input, is iterating through the key code buffer the only way to check for key presses?

Was it helpful?

Solution

That answer is to use GetDeviceData() instead. You will be able to get whether the key was pressed or released and the offset of the key that was pressed, which is pretty close to what I was looking for as now I can initiate my own callbacks and the overhead if no key is pressed is minimal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top