c# Direct Input keyboard problems

Started by
3 comments, last by Flimflam 18 years, 4 months ago
I am new to direct input and am currently making a 3d game using managed direct x 9. Until now i was using the key down and key up events but would like to convert it to direct input. My problem is I need a way to detect the key up event via direct input. I have done extensive searching on these forums but never found an answer to this problem. I've read that there is a way to do this using GetBufferedData but I have no idea how to implement this. Any help would be appreciated.
Advertisement
Just use the SetEventNotification method to get notified if anything changes (e.g. for a mouse or keyboard device).

Anyway, DirectInput is best if you are polling. For event driven mouse input, just use the standard keyboard and mouse events of your form. There is no reason to reimplement that with DirectInput if you don't need any extra functionality. You can also use both DirectInput and your form events at the same time (just use Background and NonExclusive for CooperativeLevelFlags).
Microsoft DirectX MVP. My Blog: abi.exdream.com
Basically to better understand my problem is I have a basic fps engine. Direct Input works great for walking around etc but when you open a door (by hitting return) it keeps executing the open/close door function causing the door to "shake" What i need is to determine when the return key is released so that function only executes once.
Check whether the key was pressed before and check if it is pressed in the next frame. This way you know when a key has been released.
Quote:Original post by FoxHunter2
Check whether the key was pressed before and check if it is pressed in the next frame. This way you know when a key has been released.


I agree with this person. That's the best way to handle it. I had an input class that used that method to return whether or not a button was held since the last frame was pressed. Works very well.

This topic is closed to new replies.

Advertisement