Commit d0696784 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Merged r3295:3296 from trunk/SDL: testjoystick reusing "joystick" variable.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402540
parent 2fe61699
......@@ -158,18 +158,17 @@ int main(int argc, char *argv[])
/* Print information about the joysticks */
printf("There are %d joysticks attached\n", SDL_NumJoysticks());
for ( i=0; i<SDL_NumJoysticks(); ++i ) {
SDL_Joystick *stick = NULL;
name = SDL_JoystickName(i);
printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick");
stick = SDL_JoystickOpen(i);
if (stick == NULL) {
joystick = SDL_JoystickOpen(i);
if (joystick == 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);
printf(" axes: %d\n", SDL_JoystickNumAxes(joystick));
printf(" balls: %d\n", SDL_JoystickNumBalls(joystick));
printf(" hats: %d\n", SDL_JoystickNumHats(joystick));
printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
SDL_JoystickClose(joystick);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment