Skip to content

Commit

Permalink
Android: merge SDLJoystickHandler_API12 and SDLJoystickHandler_API16
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl committed Jan 16, 2019
1 parent a867541 commit 291f600
Showing 1 changed file with 8 additions and 17 deletions.
Expand Up @@ -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 {

/**
Expand All @@ -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;
Expand Down Expand Up @@ -170,7 +169,7 @@ public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) {

private ArrayList<SDLJoystick> mJoysticks;

public SDLJoystickHandler_API12() {
public SDLJoystickHandler_API16() {

mJoysticks = new ArrayList<SDLJoystick>();
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 291f600

Please sign in to comment.