comparison test/testjoystick.c @ 2200:893c862eed86

Merged r3292:3293 from branches/SDL-1.2: testjoystick verbose info.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 15 Jul 2007 17:25:59 +0000
parents c121d94672cb
children 6280c111ee80
comparison
equal deleted inserted replaced
2199:7e1caa8452f3 2200:893c862eed86
155 155
156 /* Print information about the joysticks */ 156 /* Print information about the joysticks */
157 printf("There are %d joysticks attached\n", SDL_NumJoysticks()); 157 printf("There are %d joysticks attached\n", SDL_NumJoysticks());
158 for (i = 0; i < SDL_NumJoysticks(); ++i) { 158 for (i = 0; i < SDL_NumJoysticks(); ++i) {
159 name = SDL_JoystickName(i); 159 name = SDL_JoystickName(i);
160 printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); 160 printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick");
161 joystick = SDL_JoystickOpen(i);
162 if (joystick == NULL) {
163 fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError());
164 } else {
165 printf(" axes: %d\n", SDL_JoystickNumAxes(joystick));
166 printf(" balls: %d\n", SDL_JoystickNumBalls(joystick));
167 printf(" hats: %d\n", SDL_JoystickNumHats(joystick));
168 printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
169 SDL_JoystickClose(joystick);
170 }
161 } 171 }
162 172
163 if (argv[1]) { 173 if (argv[1]) {
164 joystick = SDL_JoystickOpen(atoi(argv[1])); 174 joystick = SDL_JoystickOpen(atoi(argv[1]));
165 if (joystick == NULL) { 175 if (joystick == NULL) {