To put it simply, catching mouse motion events can be made as follow:
/* Your application loop */
for ( ; ; )
{
while ( SDL_PollEvent(&evt) > 0 )
{
switch (evt.type)
{
case SDL_MOUSEMOTION:
printf ("Mouse position: %d,%d\n", evt.motion.x, evt.motion.y);
break;
case SDL_MOUSEBUTTONDOWN:
switch (evt.button.button)
{
case SDL_MOUSE_LEFT:
printf ("Left click\n");
break;
case SDL_MOUSE_RIGHT:
printf ("Right click\n");
break;
case SDL_MOUSE_MIDDLE:
printf ("Middle click\n");
break;
case SDL_MOUSE_WHEELUP:
printf ("Wheel up\n");
break;
case SDL_MOUSE_WHEELDOWN:
printf ("Wheel down\n");
break;
default:
;
} /* end switch (evt.button.button)
break;
default:
;
} /* end switch (evt.type) */
} /* end while ( poll event ) */
} /* End for (application loop)
Look also at the functions “SDL_GetMouseState()” and “SDL_GetRelativeMouseState()”
Anyway, go directly at:
http://www.libsdl.org/cgi/docwiki.cgi
Hope this help a little.
Cheers
Julien
----- Message d’origine ----
Envoy? le : Mardi, 22 Juillet 2008, 3h24mn 48s
Objet : [SDL] Using the mouse
Can anyone point me anywhere where mouse is used in SDL? I’m creating a menu in
my game and I want the user to be able to click on certain buttons. I know how
to capture input and use the keyboard but a bit confused on the mouse. Any help
would be appreciated. Thanks.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr