test/testjoystick.c
changeset 6731 572559876818
parent 6730 36158e4061f4
child 6732 b4201930fb9f
     1.1 --- a/test/testjoystick.c	Tue Dec 11 11:26:08 2012 -0500
     1.2 +++ b/test/testjoystick.c	Tue Dec 11 11:28:29 2012 -0500
     1.3 @@ -66,7 +66,7 @@
     1.4      SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE);
     1.5      SDL_RenderClear(screen);
     1.6      SDL_RenderPresent(screen);
     1.7 -	SDL_RaiseWindow(window);
     1.8 +    SDL_RaiseWindow(window);
     1.9  
    1.10      /* Print info about the joystick we are watching */
    1.11      name = SDL_JoystickName(joystick);
    1.12 @@ -229,30 +229,31 @@
    1.13      }
    1.14  
    1.15      if (argv[1]) {
    1.16 -		int nreportederror = 0;
    1.17 +        SDL_bool reportederror = SDL_FALSE;
    1.18          SDL_bool keepGoing = SDL_TRUE;
    1.19 -		SDL_Event event;
    1.20 -		joystick = SDL_JoystickOpen(atoi(argv[1]));
    1.21 -		while ( keepGoing ) {
    1.22 -			if (joystick == NULL) {
    1.23 -				if ( nreportederror == 0 ) {
    1.24 -					printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
    1.25 -					nreportederror = 1;
    1.26 -				}
    1.27 -			} else {
    1.28 -				nreportederror = 0;
    1.29 -				keepGoing = WatchJoystick(joystick);
    1.30 -				SDL_JoystickClose(joystick);
    1.31 -			}
    1.32 -			
    1.33 +        SDL_Event event;
    1.34 +        joystick = SDL_JoystickOpen(atoi(argv[1]));
    1.35 +        while ( keepGoing ) {
    1.36 +            if (joystick == NULL) {
    1.37 +                if ( !reportederror ) {
    1.38 +                    printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
    1.39 +                    reportederror = SDL_TRUE;
    1.40 +                }
    1.41 +            } else {
    1.42 +                reportederror = SDL_FALSE;
    1.43 +                keepGoing = WatchJoystick(joystick);
    1.44 +                SDL_JoystickClose(joystick);
    1.45 +            }
    1.46 +
    1.47              if (keepGoing) {
    1.48 -    			joystick = NULL;
    1.49 -    			SDL_WaitEvent( &event );
    1.50 -    			if ( event.type == SDL_JOYDEVICEADDED )
    1.51 -    				joystick = SDL_JoystickOpen(atoi(argv[1]));
    1.52 +                joystick = NULL;
    1.53 +                SDL_WaitEvent( &event );
    1.54 +                if ( event.type == SDL_JOYDEVICEADDED ) {
    1.55 +                    joystick = SDL_JoystickOpen(atoi(argv[1]));
    1.56 +                }
    1.57              }
    1.58 -		}
    1.59 -	}
    1.60 +        }
    1.61 +    }
    1.62      SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
    1.63  
    1.64      return 0;