Android: merge SDLJoystickHandler_API12 and SDLJoystickHandler_API16
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 56 57 58 59 60 61 62 63 64
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 b5276b9..cdc9fbb 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
@@ -118,7 +118,6 @@ public class SDLControllerManager
}
-/* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */
class SDLJoystickHandler {
/**
@@ -138,7 +137,7 @@ class SDLJoystickHandler {
}
/* Actual joystick functionality available for API >= 12 devices */
-class SDLJoystickHandler_API12 extends SDLJoystickHandler {
+class SDLJoystickHandler_API16 extends SDLJoystickHandler {
static class SDLJoystick {
public int device_id;
@@ -170,7 +169,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
private ArrayList<SDLJoystick> mJoysticks;
- public SDLJoystickHandler_API12() {
+ public SDLJoystickHandler_API16() {
mJoysticks = new ArrayList<SDLJoystick>();
}
@@ -274,6 +273,12 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
}
public String getJoystickDescriptor(InputDevice joystickDevice) {
+ String desc = joystickDevice.getDescriptor();
+
+ if (desc != null && !desc.isEmpty()) {
+ return desc;
+ }
+
return joystickDevice.getName();
}
public int getProductId(InputDevice joystickDevice) {
@@ -287,20 +292,6 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
}
}
-class SDLJoystickHandler_API16 extends SDLJoystickHandler_API12 {
-
- @Override
- public String getJoystickDescriptor(InputDevice joystickDevice) {
- String desc = joystickDevice.getDescriptor();
-
- if (desc != null && !desc.isEmpty()) {
- return desc;
- }
-
- return super.getJoystickDescriptor(joystickDevice);
- }
-}
-
class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
@Override