Jump to content
  • Advertisement
Sign in to follow this  
svcoyle

c# Direct Input keyboard problems

This topic is 5110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!