[Android] Fixes Bug 2370, don't send accelerometer changes when
authorGabriel Jacobo <gabomdq@gmail.com>
Mon, 27 Jan 2014 17:59:19 -0300
changeset 8129 47f67902b179
parent 8128 af040fdf47e4
child 8130 506eb1e0ae85
[Android] Fixes Bug 2370, don't send accelerometer changes when Android_JNI_GetAccelerometerValues return SDL_FALSE (thanks to Jairo Luiz)
src/joystick/android/SDL_sysjoystick.c
--- a/src/joystick/android/SDL_sysjoystick.c	Sun Jan 26 23:50:35 2014 +0100
+++ b/src/joystick/android/SDL_sysjoystick.c	Mon Jan 27 17:59:19 2014 -0300
@@ -497,10 +497,11 @@
     while (item) {
         if (item->is_accelerometer) {
             if (item->joystick) {
-                Android_JNI_GetAccelerometerValues(values);
-                for ( i = 0; i < 3; i++ ) {
-                    value = (Sint16)(values[i] * 32767.0f);
-                    SDL_PrivateJoystickAxis(item->joystick, i, value);
+                if (Android_JNI_GetAccelerometerValues(values)) {
+                    for ( i = 0; i < 3; i++ ) {
+                        value = (Sint16)(values[i] * 32767.0f);
+                        SDL_PrivateJoystickAxis(item->joystick, i, value);
+                    }
                 }
             }
             break;