Android: merge SDLJoystickHandler_API12 and SDLJoystickHandler_API16
authorSylvain Becker <sylvain.becker@gmail.com>
Wed, 16 Jan 2019 09:22:20 +0100
changeset 1255190d2f58dcf0a
parent 12550 08ef17bb974a
child 12552 6bc8c73ab0fe
Android: merge SDLJoystickHandler_API12 and SDLJoystickHandler_API16
android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Wed Jan 16 09:12:31 2019 +0100
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Wed Jan 16 09:22:20 2019 +0100
     1.3 @@ -118,7 +118,6 @@
     1.4  
     1.5  }
     1.6  
     1.7 -/* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */
     1.8  class SDLJoystickHandler {
     1.9  
    1.10      /**
    1.11 @@ -138,7 +137,7 @@
    1.12  }
    1.13  
    1.14  /* Actual joystick functionality available for API >= 12 devices */
    1.15 -class SDLJoystickHandler_API12 extends SDLJoystickHandler {
    1.16 +class SDLJoystickHandler_API16 extends SDLJoystickHandler {
    1.17  
    1.18      static class SDLJoystick {
    1.19          public int device_id;
    1.20 @@ -170,7 +169,7 @@
    1.21  
    1.22      private ArrayList<SDLJoystick> mJoysticks;
    1.23  
    1.24 -    public SDLJoystickHandler_API12() {
    1.25 +    public SDLJoystickHandler_API16() {
    1.26  
    1.27          mJoysticks = new ArrayList<SDLJoystick>();
    1.28      }
    1.29 @@ -274,6 +273,12 @@
    1.30      }
    1.31  
    1.32      public String getJoystickDescriptor(InputDevice joystickDevice) {
    1.33 +        String desc = joystickDevice.getDescriptor();
    1.34 +
    1.35 +        if (desc != null && !desc.isEmpty()) {
    1.36 +            return desc;
    1.37 +        }
    1.38 +
    1.39          return joystickDevice.getName();
    1.40      }
    1.41      public int getProductId(InputDevice joystickDevice) {
    1.42 @@ -287,20 +292,6 @@
    1.43      }
    1.44  }
    1.45  
    1.46 -class SDLJoystickHandler_API16 extends SDLJoystickHandler_API12 {
    1.47 -
    1.48 -    @Override
    1.49 -    public String getJoystickDescriptor(InputDevice joystickDevice) {
    1.50 -        String desc = joystickDevice.getDescriptor();
    1.51 -
    1.52 -        if (desc != null && !desc.isEmpty()) {
    1.53 -            return desc;
    1.54 -        }
    1.55 -
    1.56 -        return super.getJoystickDescriptor(joystickDevice);
    1.57 -    }
    1.58 -}
    1.59 -
    1.60  class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
    1.61  
    1.62      @Override