Jump to content
  • Advertisement

Archived

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

LordKaT

SDL Mouse problems

This topic is 5252 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

Heyahn Given this bit of code:
	/* We''ve pressed the mouse down */
	if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(iMouse) && bClick[iMouse] == false && bTest[iMouse] == false)
	{
		bTest[iMouse] = true;
		printf("%i was pressed down.\n", iMouse);
	}

	/* The mouse has been released */
	else if (!SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(iMouse) && bTest[iMouse] == true)
	{
		bClick[iMouse] = true;
		printf("%i was clicked.\n", iMouse);
	}
If bClick is false and bTest is true, the mouse button is depressed (being pressed) - when bTest and bClick are both true, the mouse button has been pressed then released (clicked). When I left-mouse click, it works perfectly - the depression is detected, and the release is detected; however, any other button (middle or right), the depression is detected, but the release is not. bTest and bClick are simply boolean variables. And, before you ask, yes, they have enough array members. I''ve tried using this bit of code as both being called once per frame, and during an SDL event, but no go. What the heck am I missing? --LordKaT

Share this post


Link to post
Share on other sites
Advertisement
You should probably add some parantheses into your if sentences to make the logic less ambiguous (the "!func() & int && bool" is not going to do what you want it to)

I would also only query the mouse state once, for the sake of cleanliness...

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.

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

Sign me up!