MAJ BROSSARD

Dependencies:   mbed

Committer:
singularity
Date:
Wed Oct 22 23:26:41 2014 +0000
Revision:
3:8f2c0c324296
Parent:
1:3440622d30fc
tentative convert sint16 -> char

Who changed what in which revision?

UserRevisionLine numberNew contents of line
singularity 1:3440622d30fc 1 #include <stdlib.h>
singularity 1:3440622d30fc 2 #include <SDL/SDL.h>
singularity 1:3440622d30fc 3
singularity 1:3440622d30fc 4 int main(int argc, char **argv)
singularity 1:3440622d30fc 5 {
singularity 1:3440622d30fc 6 if(SDL_Init(SDL_INIT_JOYSTICK) < 0) // initialise juste le joystick (pas besoin d'une fenêtre pour nos tests)
singularity 1:3440622d30fc 7 return EXIT_FAILURE;
singularity 1:3440622d30fc 8
singularity 1:3440622d30fc 9
singularity 1:3440622d30fc 10 SDL_Joystick *joystick; // on crée le joystick
singularity 1:3440622d30fc 11 joystick = SDL_JoystickOpen(0); // on l'assigne au numéro 0
singularity 1:3440622d30fc 12 SDL_Event evenements;
singularity 1:3440622d30fc 13 Sint16 dir;
singularity 1:3440622d30fc 14 Sint16 propulsion;
singularity 1:3440622d30fc 15
singularity 1:3440622d30fc 16 while(SDL_PollEvent(&evenements)) // tant qu'il y a des évènements à traiter
singularity 1:3440622d30fc 17 {
singularity 1:3440622d30fc 18 /*if(joystick != NULL) //si le joystick existe
singularity 1:3440622d30fc 19 {*/
singularity 1:3440622d30fc 20 switch(evenements.type)
singularity 1:3440622d30fc 21 {
singularity 1:3440622d30fc 22 case SDL_JOYAXISMOTION:
singularity 1:3440622d30fc 23 if(evenements.jaxis.axis == && evenements.jaxis.which ==) {
singularity 1:3440622d30fc 24 dir = evenements.jaxis.value;
singularity 1:3440622d30fc 25 }
singularity 1:3440622d30fc 26 if(evenements.jaxis.axis == && evenements.jaxis.which ==) {
singularity 1:3440622d30fc 27 propulsion = evenements.jaxis.value;
singularity 1:3440622d30fc 28 }
singularity 1:3440622d30fc 29
singularity 1:3440622d30fc 30 input->axes[evenements.jaxis.axis] = evenements.jaxis.value;
singularity 1:3440622d30fc 31 break;
singularity 1:3440622d30fc 32
singularity 1:3440622d30fc 33 default:
singularity 1:3440622d30fc 34 break;
singularity 1:3440622d30fc 35 }
singularity 1:3440622d30fc 36 /*}*/
singularity 1:3440622d30fc 37 }
singularity 1:3440622d30fc 38
singularity 1:3440622d30fc 39 SDL_JoystickClose(joystick);
singularity 1:3440622d30fc 40 SDL_Quit();
singularity 1:3440622d30fc 41 return EXIT_SUCCESS;
singularity 1:3440622d30fc 42 }