Re : Re : Using the mouse

actually, read “catching the mouse events” instead of “catching the mouse motion:slight_smile:

----- Message d’origine ----De : julien CLEMENT <@Julien_Clement1>
? : A list for developers using the SDL library. (includes SDL-announce)
Envoy? le : Mardi, 22 Juillet 2008, 11h33mn 27s
Objet : [SDL] Re : Using the mouse

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 ----
? : sdl at libsdl.org
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


Envoy? avec Yahoo! Mail.
Une boite mail plus intelligente.

  _____________________________________________________________________________ 

Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr