Fixed reinitializing the SDL joystick subsystem on Android

This commit is contained in:
Sam Lantinga 2018-10-23 12:40:25 -07:00
parent f0549cc9c9
commit b699ddc0a9

View File

@ -36,27 +36,24 @@ public class SDLControllerManager
private static final String TAG = "SDLControllerManager"; private static final String TAG = "SDLControllerManager";
public static void initialize() { public static void initialize() {
mJoystickHandler = null; if (mJoystickHandler == null) {
mHapticHandler = null; if (Build.VERSION.SDK_INT >= 19) {
mJoystickHandler = new SDLJoystickHandler_API19();
SDLControllerManager.setup(); } else if (Build.VERSION.SDK_INT >= 16) {
} mJoystickHandler = new SDLJoystickHandler_API16();
} else if (Build.VERSION.SDK_INT >= 12) {
public static void setup() { mJoystickHandler = new SDLJoystickHandler_API12();
if (Build.VERSION.SDK_INT >= 19) { } else {
mJoystickHandler = new SDLJoystickHandler_API19(); mJoystickHandler = new SDLJoystickHandler();
} 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) { if (mHapticHandler == null) {
mHapticHandler = new SDLHapticHandler_API26(); if (Build.VERSION.SDK_INT >= 26) {
} else { mHapticHandler = new SDLHapticHandler_API26();
mHapticHandler = new SDLHapticHandler(); } 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 // Relative mouse in capture mode will only have relative for X/Y
return event.getY(0); return event.getY(0);
} }
} }