From 291f6006a19a583bff845c7d7a265047e2776d57 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Wed, 16 Jan 2019 09:22:20 +0100 Subject: [PATCH] Android: merge SDLJoystickHandler_API12 and SDLJoystickHandler_API16 --- .../org/libsdl/app/SDLControllerManager.java | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) 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 b5276b9b24629..cdc9fbb64f5d7 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 static boolean isDeviceSDLJoystick(int deviceId) { } -/* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */ class SDLJoystickHandler { /** @@ -138,7 +137,7 @@ public void pollInputDevices() { } /* 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 @@ public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) { private ArrayList mJoysticks; - public SDLJoystickHandler_API12() { + public SDLJoystickHandler_API16() { mJoysticks = new ArrayList(); } @@ -274,6 +273,12 @@ public boolean handleMotionEvent(MotionEvent event) { } 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 @@ public int getButtonMask(InputDevice joystickDevice) { } } -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