Fixed reinitializing the SDL joystick subsystem on Android
authorSam Lantinga <slouken@libsdl.org>
Tue, 23 Oct 2018 12:40:25 -0700
changeset 123547846ac86d46e
parent 12353 2cacb7bd6441
child 12355 a46837d71c0a
Fixed reinitializing the SDL joystick subsystem on Android
android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Tue Oct 23 09:10:02 2018 +0300
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Tue Oct 23 12:40:25 2018 -0700
     1.3 @@ -36,27 +36,24 @@
     1.4      private static final String TAG = "SDLControllerManager";
     1.5  
     1.6      public static void initialize() {
     1.7 -        mJoystickHandler = null;
     1.8 -        mHapticHandler = null;
     1.9 -
    1.10 -        SDLControllerManager.setup();
    1.11 -    }
    1.12 -
    1.13 -    public static void setup() {
    1.14 -        if (Build.VERSION.SDK_INT >= 19) {
    1.15 -            mJoystickHandler = new SDLJoystickHandler_API19();
    1.16 -        } else if (Build.VERSION.SDK_INT >= 16) {
    1.17 -            mJoystickHandler = new SDLJoystickHandler_API16();
    1.18 -        } else if (Build.VERSION.SDK_INT >= 12) {
    1.19 -            mJoystickHandler = new SDLJoystickHandler_API12();
    1.20 -        } else {
    1.21 -            mJoystickHandler = new SDLJoystickHandler();
    1.22 +        if (mJoystickHandler == null) {
    1.23 +            if (Build.VERSION.SDK_INT >= 19) {
    1.24 +                mJoystickHandler = new SDLJoystickHandler_API19();
    1.25 +            } else if (Build.VERSION.SDK_INT >= 16) {
    1.26 +                mJoystickHandler = new SDLJoystickHandler_API16();
    1.27 +            } else if (Build.VERSION.SDK_INT >= 12) {
    1.28 +                mJoystickHandler = new SDLJoystickHandler_API12();
    1.29 +            } else {
    1.30 +                mJoystickHandler = new SDLJoystickHandler();
    1.31 +            }
    1.32          }
    1.33  
    1.34 -        if (Build.VERSION.SDK_INT >= 26) {
    1.35 -            mHapticHandler = new SDLHapticHandler_API26();
    1.36 -        } else {
    1.37 -            mHapticHandler = new SDLHapticHandler();
    1.38 +        if (mHapticHandler == null) {
    1.39 +            if (Build.VERSION.SDK_INT >= 26) {
    1.40 +                mHapticHandler = new SDLHapticHandler_API26();
    1.41 +            } else {
    1.42 +                mHapticHandler = new SDLHapticHandler();
    1.43 +            }
    1.44          }
    1.45      }
    1.46  
    1.47 @@ -846,4 +843,4 @@
    1.48          // Relative mouse in capture mode will only have relative for X/Y
    1.49          return event.getY(0);
    1.50      }
    1.51 -}
    1.52 +}
    1.53 \ No newline at end of file