Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL Mouse problems

Started by LordKaT Jan 5, 2004 at 7:59 PM 0 replies 400+ views
Original Post
LordKaT
LordKaT
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
Fingers_
Fingers_
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...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.