test/testjoystick.c
changeset 6736 03dd4a1d06e9
parent 6733 cfef740efada
child 6747 b617821795bf
--- a/test/testjoystick.c	Tue Dec 11 10:49:54 2012 -0800
+++ b/test/testjoystick.c	Tue Dec 11 10:50:26 2012 -0800
@@ -250,11 +250,17 @@
                 SDL_JoystickClose(joystick);
             }
 
+            joystick = NULL;
             if (keepGoing) {
-                joystick = NULL;
-                SDL_WaitEvent( &event );
-                if ( event.type == SDL_JOYDEVICEADDED ) {
+                printf("Waiting for attach\n");
+            }
+            while (keepGoing) {
+                SDL_WaitEvent(&event);
+                if (event.type == SDL_QUIT) {
+                    keepGoing = SDL_FALSE;
+                } else if (event.type == SDL_JOYDEVICEADDED) {
                     joystick = SDL_JoystickOpen(atoi(argv[1]));
+                    break;
                 }
             }
         }