MAJ BROSSARD

Dependencies:   mbed

joystick.c

Committer:
singularity
Date:
2014-10-22
Revision:
3:8f2c0c324296
Parent:
1:3440622d30fc

File content as of revision 3:8f2c0c324296:

#include <stdlib.h>
#include <SDL/SDL.h>

int main(int argc, char **argv)
{
    if(SDL_Init(SDL_INIT_JOYSTICK) < 0) // initialise juste le joystick (pas besoin d'une fenêtre pour nos tests)
        return EXIT_FAILURE;


    SDL_Joystick *joystick; // on crée le joystick
    joystick = SDL_JoystickOpen(0); // on l'assigne au numéro 0
    SDL_Event evenements;
    Sint16 dir;
    Sint16 propulsion;
    
    while(SDL_PollEvent(&evenements)) // tant qu'il y a des évènements à traiter
    {
        /*if(joystick != NULL)                    //si le joystick existe
        {*/
            switch(evenements.type)
            {
                case SDL_JOYAXISMOTION:
                    if(evenements.jaxis.axis == && evenements.jaxis.which ==) {
                        dir = evenements.jaxis.value;
                    }
                    if(evenements.jaxis.axis == && evenements.jaxis.which ==) {
                        propulsion = evenements.jaxis.value;
                    }
                    
                    input->axes[evenements.jaxis.axis] = evenements.jaxis.value;
                    break;
                    
                default:
                    break;
            }
        /*}*/
    }
    
    SDL_JoystickClose(joystick);
    SDL_Quit();
    return EXIT_SUCCESS;
}