Jump to content
  • Advertisement

Archived

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

Real World

Mouse clicking problem...

This topic is 5761 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 using Direct Input 8 to check the mouse for left clicks in my game for the purpose of navigating through a selection of menu screens. The problem I''m having is that when one button is clicked and the screen loads the next option menu, the button below that gets clicked too as the input is checked again and the mouse is still registered as being pressed. Is there a good way to reset the state of the mouse after each check so this doesnt happen? Cheers Dave
		// Make sure the mouse has been initialized
		if( !m_bInitialized )
			return FALSE;

		// Get the state of the mouse into the key buffer
		r = m_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &m_dims2 );
		if( FAILED( r ) )
		{
			// If the device is not acquired...
			if( r == DIERR_INPUTLOST  || r == DIERR_NOTACQUIRED)
			{
				// ...then reacquire the device
				while( r == DIERR_INPUTLOST  || r == DIERR_NOTACQUIRED)
					r = m_pMouse->Acquire();

				if( SUCCEEDED( r ) )
					m_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &m_dims2 );
				else
					return FALSE;
			}
			else
				// ...Otherwise it was some other error
				return FALSE;
		}

		// Check if the mouse was clicked
		if( key & 0x80 )
			return TRUE;
		else
			return FALSE;
  
sorry for the double post :\

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!