test/testgamecontroller.c
changeset 9916 9429bc102632
parent 9876 1496e502e51d
child 9922 b066d5fd5fa7
equal deleted inserted replaced
9915:77cf2d1b7215 9916:9429bc102632
   289         } else {
   289         } else {
   290             SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device),
   290             SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device),
   291                                       guid, sizeof (guid));
   291                                       guid, sizeof (guid));
   292             SDL_Log("Attempting to open device %i, guid %s\n", device, guid);
   292             SDL_Log("Attempting to open device %i, guid %s\n", device, guid);
   293             gamecontroller = SDL_GameControllerOpen(device);
   293             gamecontroller = SDL_GameControllerOpen(device);
       
   294 
       
   295             if (gamecontroller != NULL) {
       
   296                 SDL_assert(SDL_GameControllerFromInstanceID(SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller))) == gamecontroller);
       
   297             }
       
   298 
   294             while (keepGoing) {
   299             while (keepGoing) {
   295                 if (gamecontroller == NULL) {
   300                 if (gamecontroller == NULL) {
   296                     if (!reportederror) {
   301                     if (!reportederror) {
   297                         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open gamecontroller %d: %s\n", device, SDL_GetError());
   302                         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open gamecontroller %d: %s\n", device, SDL_GetError());
   298                         retcode = 1;
   303                         retcode = 1;
   314                     if ((event.type == SDL_QUIT) || (event.type == SDL_FINGERDOWN)
   319                     if ((event.type == SDL_QUIT) || (event.type == SDL_FINGERDOWN)
   315                         || (event.type == SDL_MOUSEBUTTONDOWN)) {
   320                         || (event.type == SDL_MOUSEBUTTONDOWN)) {
   316                         keepGoing = SDL_FALSE;
   321                         keepGoing = SDL_FALSE;
   317                     } else if (event.type == SDL_CONTROLLERDEVICEADDED) {
   322                     } else if (event.type == SDL_CONTROLLERDEVICEADDED) {
   318                         gamecontroller = SDL_GameControllerOpen(event.cdevice.which);
   323                         gamecontroller = SDL_GameControllerOpen(event.cdevice.which);
       
   324                         if (gamecontroller != NULL) {
       
   325                             SDL_assert(SDL_GameControllerFromInstanceID(SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller))) == gamecontroller);
       
   326                         }
   319                         break;
   327                         break;
   320                     }
   328                     }
   321                 }
   329                 }
   322             }
   330             }
   323         }
   331         }