test/testgamecontroller.c
changeset 7705 e70dc8b38f26
parent 7639 9406b7dd2f2d
child 8043 74fcbf6987ba
equal deleted inserted replaced
7704:3182291fc65f 7705:e70dc8b38f26
   227     }
   227     }
   228 
   228 
   229     /* Print information about the controller */
   229     /* Print information about the controller */
   230     for (i = 0; i < SDL_NumJoysticks(); ++i) {
   230     for (i = 0; i < SDL_NumJoysticks(); ++i) {
   231         const char *name;
   231         const char *name;
   232         const char *description = "Joystick (not recognized as game controller)";
   232         const char *description;
   233 
   233 
   234         SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i),
   234         SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i),
   235                                   guid, sizeof (guid));
   235                                   guid, sizeof (guid));
   236 
   236 
   237         if ( SDL_IsGameController(i) )
   237         if ( SDL_IsGameController(i) )
   238         {
   238         {
   239             nController++;
   239             nController++;
   240             name = SDL_GameControllerNameForIndex(i);
   240             name = SDL_GameControllerNameForIndex(i);
       
   241             description = "Controller";
   241         } else {
   242         } else {
   242             name = SDL_JoystickNameForIndex(i);
   243             name = SDL_JoystickNameForIndex(i);
       
   244             description = "Joystick";
   243         }
   245         }
   244         SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
   246         SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
   245     }
   247     }
   246     SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
   248     SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
   247 
   249