test/testjoystick.c
changeset 2200 893c862eed86
parent 1895 c121d94672cb
child 2201 6280c111ee80
     1.1 --- a/test/testjoystick.c	Sun Jul 15 16:59:16 2007 +0000
     1.2 +++ b/test/testjoystick.c	Sun Jul 15 17:25:59 2007 +0000
     1.3 @@ -157,7 +157,17 @@
     1.4      printf("There are %d joysticks attached\n", SDL_NumJoysticks());
     1.5      for (i = 0; i < SDL_NumJoysticks(); ++i) {
     1.6          name = SDL_JoystickName(i);
     1.7 -        printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
     1.8 +        printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick");
     1.9 +        joystick = SDL_JoystickOpen(i);
    1.10 +        if (joystick == NULL) {
    1.11 +            fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError());
    1.12 +        } else {
    1.13 +            printf("       axes: %d\n", SDL_JoystickNumAxes(joystick));
    1.14 +            printf("      balls: %d\n", SDL_JoystickNumBalls(joystick));
    1.15 +            printf("       hats: %d\n", SDL_JoystickNumHats(joystick));
    1.16 +            printf("    buttons: %d\n", SDL_JoystickNumButtons(joystick));
    1.17 +            SDL_JoystickClose(joystick);
    1.18 +        }
    1.19      }
    1.20  
    1.21      if (argv[1]) {