   DInput and mouse button issues
  I am trying to have DInput set a variable to allow me to rotate when I click a button. As of now DInput with this functionif(directInput.mouseButtonDown(1))gRotate = !gRotate;is causing me a headache, due to it returns everytime the button is down... Now the issue is unless you can tap it  quick enough it jumps in and out of true/false so quick sometime it will rotate and sometimes not... So you have to keep clicking until it lands on true or false correctly. Do I need to do Mousebutton UP state? Or how do I go about fixing this... Thanks   
  Hi,are you using MDX or unmanaged?   ;  C++ Or I guess unmanaged?   ;  *BUMP Thanks   ;  Personally, I have code that returns true only the first time the check is made, which is handy for UI stuff, etc.Something like: input.DidButtonJustBecomePressed(MOUSE_Left);It's easy enough to implement, but this would obviously be better done in the dinput class:bool gRotate = false;bool gRotating = true;if(directInput.mouseButtonDown(1) && !gRotating){   gRotate = !gRotate;   gRotating = true;}else   gRotating = false;;  Hmm it still isn't working... Basically I hit the mouse button and its like its going to fast and it misses and doesn't register and then if I keep hitting it it will register... I still think its due to it ping pongs the true/false state...   ;  Are you saying that every time you call the function it returns true if the mouse button is down? And hence it is flipping the variable every time you poll?If that's the case why not just:g_IsRotating = blah.mouseButtonDown( 1 );I must be missunderstanding the problem.   ;  Oh I am missunderstanding the problem. I reread your post and saw that you want a click to toggle wether or not you are rotating. So you can do this:bool WasButtonDown( false );bool IsButtonDown( false );do // your loop{IsButtonDown = directInput.mouseButtonDown( 1 );if( IsButtonDown != WasButtonDown ){// mouse button state has changed since we last polledgRotate = !gRotate;}WasButtonDown = IsButtonDown;}   ;Quote:Original post by ProgramMaxAre you saying that every time you call the function it returns true if the mouse button is down? And hence it is flipping the variable every time you poll?If that's the case why not just:g_IsRotating = blah.mouseButtonDown( 1 );I must be missunderstanding the problem.Yeah that works fine if you want to hold the button down while you rotate, but I want to click a button and then rotate and click again to shutdown the rotation. Hope that clears things up a bit...On a side note I for some reason now when I alt-tab lose my screen size? What are cause of this? I had it working and now its messed up and I don't recall changing anything that would affect it. Thanks   ;  Or better yet, don't have gRotate = !gRotate;. Instead have gRotate = IsButtonDown;. It might be a little more clear and self-documenting.   