SDL Mouse problems

Started by
0 comments, last by LordKaT 20 years, 3 months ago
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
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...

This topic is closed to new replies.

Advertisement