test/testjoystick.c
changeset 6736 03dd4a1d06e9
parent 6733 cfef740efada
child 6747 b617821795bf
equal deleted inserted replaced
6735:486800c3f44c 6736:03dd4a1d06e9
   248                 reportederror = SDL_FALSE;
   248                 reportederror = SDL_FALSE;
   249                 keepGoing = WatchJoystick(joystick);
   249                 keepGoing = WatchJoystick(joystick);
   250                 SDL_JoystickClose(joystick);
   250                 SDL_JoystickClose(joystick);
   251             }
   251             }
   252 
   252 
       
   253             joystick = NULL;
   253             if (keepGoing) {
   254             if (keepGoing) {
   254                 joystick = NULL;
   255                 printf("Waiting for attach\n");
   255                 SDL_WaitEvent( &event );
   256             }
   256                 if ( event.type == SDL_JOYDEVICEADDED ) {
   257             while (keepGoing) {
       
   258                 SDL_WaitEvent(&event);
       
   259                 if (event.type == SDL_QUIT) {
       
   260                     keepGoing = SDL_FALSE;
       
   261                 } else if (event.type == SDL_JOYDEVICEADDED) {
   257                     joystick = SDL_JoystickOpen(atoi(argv[1]));
   262                     joystick = SDL_JoystickOpen(atoi(argv[1]));
       
   263                     break;
   258                 }
   264                 }
   259             }
   265             }
   260         }
   266         }
   261     }
   267     }
   262     SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
   268     SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);