Skip to content

Commit

Permalink
Fixed reinitializing the SDL joystick subsystem on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Oct 23, 2018
1 parent f0549cc commit b699ddc
Showing 1 changed file with 17 additions and 20 deletions.
Expand Up @@ -36,27 +36,24 @@ public static native void onNativeHat(int device_id, int hat_id,
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();
}
}
}

Expand Down Expand Up @@ -846,4 +843,4 @@ public float getEventY(MotionEvent event) {
// Relative mouse in capture mode will only have relative for X/Y
return event.getY(0);
}
}
}

0 comments on commit b699ddc

Please sign in to comment.