test/controllermap.c
changeset 8078 ef59ad725ac5
parent 8077 05bbcc1056e6
child 8149 681eb46b8ac4
     1.1 --- a/test/controllermap.c	Wed Dec 25 00:04:31 2013 +0100
     1.2 +++ b/test/controllermap.c	Wed Dec 25 00:11:28 2013 +0100
     1.3 @@ -386,15 +386,18 @@
     1.4          SDL_bool reportederror = SDL_FALSE;
     1.5          SDL_bool keepGoing = SDL_TRUE;
     1.6          SDL_Event event;
     1.7 +        int device;
     1.8  #ifdef ANDROID
     1.9 -        joystick = SDL_JoystickOpen(0);
    1.10 +        device = 0;
    1.11  #else
    1.12 -        joystick = SDL_JoystickOpen(atoi(argv[1]));
    1.13 +        device = atoi(argv[1]);
    1.14  #endif
    1.15 +        joystick = SDL_JoystickOpen(device);
    1.16 +
    1.17          while ( keepGoing ) {
    1.18              if (joystick == NULL) {
    1.19                  if ( !reportederror ) {
    1.20 -                    SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
    1.21 +                    SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError());
    1.22                      keepGoing = SDL_FALSE;
    1.23                      reportederror = SDL_TRUE;
    1.24                  }
    1.25 @@ -414,7 +417,7 @@
    1.26                      || (event.type == SDL_MOUSEBUTTONDOWN)) {
    1.27                      keepGoing = SDL_FALSE;
    1.28                  } else if (event.type == SDL_JOYDEVICEADDED) {
    1.29 -                    joystick = SDL_JoystickOpen(atoi(argv[1]));
    1.30 +                    joystick = SDL_JoystickOpen(device);
    1.31                      break;
    1.32                  }
    1.33              }