Dump more information about each joystick in testjoytick.c

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402536
This commit is contained in:
Ryan C. Gordon 2007-07-15 16:33:45 +00:00
parent 33dff0e240
commit 53dae52ecb

View file

@ -158,8 +158,19 @@ int main(int argc, char *argv[])
/* Print information about the joysticks */ /* Print information about the joysticks */
printf("There are %d joysticks attached\n", SDL_NumJoysticks()); printf("There are %d joysticks attached\n", SDL_NumJoysticks());
for ( i=0; i<SDL_NumJoysticks(); ++i ) { for ( i=0; i<SDL_NumJoysticks(); ++i ) {
SDL_Joystick *stick = NULL;
name = SDL_JoystickName(i); name = SDL_JoystickName(i);
printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick"); printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick");
stick = SDL_JoystickOpen(i);
if (stick == NULL) {
fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError());
} else {
printf(" axes: %d\n", SDL_JoystickNumAxes(stick));
printf(" balls: %d\n", SDL_JoystickNumBalls(stick));
printf(" hats: %d\n", SDL_JoystickNumHats(stick));
printf(" buttons: %d\n", SDL_JoystickNumButtons(stick));
SDL_JoystickClose(stick);
}
} }
if ( argv[1] ) { if ( argv[1] ) {