Fixed reinitializing the SDL joystick subsystem on Android
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
index 782a92e..6c5623d 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
@@ -36,27 +36,24 @@ public class SDLControllerManager
private static final String TAG = "SDLControllerManager";
public static void initialize() {
- mJoystickHandler = null;
- mHapticHandler = null;
-
- SDLControllerManager.setup();
- }
-
- public static void setup() {
- if (Build.VERSION.SDK_INT >= 19) {
- mJoystickHandler = new SDLJoystickHandler_API19();
- } else if (Build.VERSION.SDK_INT >= 16) {
- mJoystickHandler = new SDLJoystickHandler_API16();
- } else if (Build.VERSION.SDK_INT >= 12) {
- mJoystickHandler = new SDLJoystickHandler_API12();
- } else {
- mJoystickHandler = new SDLJoystickHandler();
+ if (mJoystickHandler == null) {
+ if (Build.VERSION.SDK_INT >= 19) {
+ mJoystickHandler = new SDLJoystickHandler_API19();
+ } else if (Build.VERSION.SDK_INT >= 16) {
+ mJoystickHandler = new SDLJoystickHandler_API16();
+ } else if (Build.VERSION.SDK_INT >= 12) {
+ mJoystickHandler = new SDLJoystickHandler_API12();
+ } else {
+ mJoystickHandler = new SDLJoystickHandler();
+ }
}
- if (Build.VERSION.SDK_INT >= 26) {
- mHapticHandler = new SDLHapticHandler_API26();
- } else {
- mHapticHandler = new SDLHapticHandler();
+ if (mHapticHandler == null) {
+ if (Build.VERSION.SDK_INT >= 26) {
+ mHapticHandler = new SDLHapticHandler_API26();
+ } else {
+ mHapticHandler = new SDLHapticHandler();
+ }
}
}
@@ -846,4 +843,4 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
// Relative mouse in capture mode will only have relative for X/Y
return event.getY(0);
}
-}
+}
\ No newline at end of file