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 8078 ef59ad725ac5
parent 8077 05bbcc1056e6
child 8079 f8ef325265ed
Fixed access of command line arguments on Android in two test programs.
test/controllermap.c
test/testjoystick.c
--- a/test/controllermap.c	Wed Dec 25 00:04:31 2013 +0100
+++ b/test/controllermap.c	Wed Dec 25 00:11:28 2013 +0100
@@ -386,15 +386,18 @@
         SDL_bool reportederror = SDL_FALSE;
         SDL_bool keepGoing = SDL_TRUE;
         SDL_Event event;
+        int device;
 #ifdef ANDROID
-        joystick = SDL_JoystickOpen(0);
+        device = 0;
 #else
-        joystick = SDL_JoystickOpen(atoi(argv[1]));
+        device = atoi(argv[1]);
 #endif
+        joystick = SDL_JoystickOpen(device);
+
         while ( keepGoing ) {
             if (joystick == NULL) {
                 if ( !reportederror ) {
-                    SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
+                    SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError());
                     keepGoing = SDL_FALSE;
                     reportederror = SDL_TRUE;
                 }
@@ -414,7 +417,7 @@
                     || (event.type == SDL_MOUSEBUTTONDOWN)) {
                     keepGoing = SDL_FALSE;
                 } else if (event.type == SDL_JOYDEVICEADDED) {
-                    joystick = SDL_JoystickOpen(atoi(argv[1]));
+                    joystick = SDL_JoystickOpen(device);
                     break;
                 }
             }
--- a/test/testjoystick.c	Wed Dec 25 00:04:31 2013 +0100
+++ b/test/testjoystick.c	Wed Dec 25 00:11:28 2013 +0100
@@ -251,15 +251,18 @@
         SDL_bool reportederror = SDL_FALSE;
         SDL_bool keepGoing = SDL_TRUE;
         SDL_Event event;
+        int device;
 #ifdef ANDROID
-        joystick = SDL_JoystickOpen(0);
+        device = 0;
 #else
-        joystick = SDL_JoystickOpen(atoi(argv[1]));
+        device = atoi(argv[1]);
 #endif
+        joystick = SDL_JoystickOpen(device);
+
         while ( keepGoing ) {
             if (joystick == NULL) {
                 if ( !reportederror ) {
-                    SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
+                    SDL_Log("Couldn't open joystick %d: %s\n", device, SDL_GetError());
                     keepGoing = SDL_FALSE;
                     reportederror = SDL_TRUE;
                 }
@@ -279,7 +282,7 @@
                     || (event.type == SDL_MOUSEBUTTONDOWN)) {
                     keepGoing = SDL_FALSE;
                 } else if (event.type == SDL_JOYDEVICEADDED) {
-                    joystick = SDL_JoystickOpen(atoi(argv[1]));
+                    joystick = SDL_JoystickOpen(device);
                     break;
                 }
             }