Archived

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

LordKaT

SDL Mouse problems

Recommended Posts

LordKaT    122
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
Fingers_    410
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