[SDL] mouse button/movement troubles

John Drinkwater john at nextraweb.com
Thu Oct 16 03:20:01 PDT 2003


 From going through the code,
   SDL_WarpMouse resets the mouse states

Makes sense for most applications to have this as the default (lets say, you 
move off of one button onto another); yet there isn't an option to get it to 
either retain button state, or give it new ones.

Could you use the ignore (which i'm presuming you're using to stop the warpmouse 
event changing your mouse position again) to prevent the SDL_MOUSEBUTTONs 
getting triggered ?

Regards,
John

Andrew wrote:
> To handle mouse input in my game I have this code inside my event
> handler:
> 
> 	case SDL_MOUSEMOTION:
> 		if(!ignore) {
> 			mov_mouse_x += event.motion.xrel;
> 			mov_mouse_y += event.motion.yrel;
> 			mov_mouse_z = 0;
> 			SDL_WarpMouse(thegame->options.GetWidth()/2,
> thegame->options.GetWidth()/2);
> 			ignore = true;
> 		}
> 		else ignore = false;
> 		break;
> 	case SDL_MOUSEBUTTONDOWN:
> 		if(event.button.button == SDL_BUTTON_LEFT) 
> 			buttons[0] = true;
> 		else buttons[1] = true;
> 		break;
> 	case SDL_MOUSEBUTTONUP:
> 		if(event.button.button == SDL_BUTTON_LEFT) 
> 			buttons[0] = false;
> 		else buttons[1] = false;
> 		break;
> 
> The problem is that when the mouse is moving, and I press a button, it
> starts flickering, like the button is being pressed on and off.  The
> code works as expected if the mouse wasn't moving while button was
> pressed.  Any ideas?
> 
> Thanks,
> Andrew
> 
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
> 





More information about the SDL mailing list