Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ziplux

DirectInput

This topic is 6936 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''m having trouble with DirectInput and mouseclicks. Every frame, I call a function which checks the current status of the mouse by first updating it''s state and then checking mouse_state.rgbButtons[0] & 80 for true. This works fine, except that it''s too fast. Meaning that when one frame passes, ok the user has the button down. Ok, then the next frame comes up, but the user still has the button down, but not on purpose, it''s just that my frames go by too fast for the user to click once and then let go in one frame. So, my program think the user has clicked twice. Is there an easy way to solve this? I hope I''m making some sense here . Visit our web site: Asylum Entertainment

Share this post


Link to post
Share on other sites
Advertisement
Yes, in its most simple form:

 if(dimousestate.rgbButtons[0] & 80) {
   if(!button_pressed) {
     button_pressed = 1;
     // do something
   }
 } else {
   button_pressed = 0;
 }

I''ve used a similar way in my TrueFX-library, a DirectInput manager allowing to do Quake-like key-binding. There''s a function GetState() to obtain the current state of a bound key/axis and GetSwitch() which will return true only for the first time it is called after a key has been pressed, and only again if the key was released inbetween.

If you want to take a look,
http://www.lunaticsystems.de/truefx
(english page; html documentation; examples)

-Markus-

Share this post


Link to post
Share on other sites

  • 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!