Fixed access of command line arguments on Android in two test programs.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 25 Dec 2013 00:11:28 +0100
changeset 8078ef59ad725ac5
parent 8077 05bbcc1056e6
child 8079 f8ef325265ed
Fixed access of command line arguments on Android in two test programs.
test/controllermap.c
test/testjoystick.c
     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              }
     2.1 --- a/test/testjoystick.c	Wed Dec 25 00:04:31 2013 +0100
     2.2 +++ b/test/testjoystick.c	Wed Dec 25 00:11:28 2013 +0100
     2.3 @@ -251,15 +251,18 @@
     2.4          SDL_bool reportederror = SDL_FALSE;
     2.5          SDL_bool keepGoing = SDL_TRUE;
     2.6          SDL_Event event;
     2.7 +        int device;
     2.8  #ifdef ANDROID
     2.9 -        joystick = SDL_JoystickOpen(0);
    2.10 +        device = 0;
    2.11  #else
    2.12 -        joystick = SDL_JoystickOpen(atoi(argv[1]));
    2.13 +        device = atoi(argv[1]);
    2.14  #endif
    2.15 +        joystick = SDL_JoystickOpen(device);
    2.16 +
    2.17          while ( keepGoing ) {
    2.18              if (joystick == NULL) {
    2.19                  if ( !reportederror ) {
    2.20 -                    SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
    2.21 +                    SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError());
    2.22                      keepGoing = SDL_FALSE;
    2.23                      reportederror = SDL_TRUE;
    2.24                  }
    2.25 @@ -279,7 +282,7 @@
    2.26                      || (event.type == SDL_MOUSEBUTTONDOWN)) {
    2.27                      keepGoing = SDL_FALSE;
    2.28                  } else if (event.type == SDL_JOYDEVICEADDED) {
    2.29 -                    joystick = SDL_JoystickOpen(atoi(argv[1]));
    2.30 +                    joystick = SDL_JoystickOpen(device);
    2.31                      break;
    2.32                  }
    2.33              }