android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
changeset 11999 f3fc4b3d54f6
parent 11921 88a2982221ec
child 12004 757d81897470
equal deleted inserted replaced
11998:76124cc14cbb 11999:f3fc4b3d54f6
   142         public ArrayList<InputDevice.MotionRange> hats;
   142         public ArrayList<InputDevice.MotionRange> hats;
   143     }
   143     }
   144     static class RangeComparator implements Comparator<InputDevice.MotionRange> {
   144     static class RangeComparator implements Comparator<InputDevice.MotionRange> {
   145         @Override
   145         @Override
   146         public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) {
   146         public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) {
   147             return arg0.getAxis() - arg1.getAxis();
   147             // Some controllers, like the Moga Pro 2, return AXIS_GAS (22) for right trigger and AXIS_BRAKE (23) for left trigger - swap them so they're sorted in the right order for SDL
       
   148             int arg0Axis = arg0.getAxis();
       
   149             int arg1Axis = arg1.getAxis();
       
   150             if (arg0Axis == MotionEvent.AXIS_GAS) {
       
   151                 arg0Axis = MotionEvent.AXIS_BRAKE;
       
   152             } else if (arg0Axis == MotionEvent.AXIS_BRAKE) {
       
   153                 arg0Axis = MotionEvent.AXIS_GAS;
       
   154             }
       
   155             if (arg1Axis == MotionEvent.AXIS_GAS) {
       
   156                 arg1Axis = MotionEvent.AXIS_BRAKE;
       
   157             } else if (arg1Axis == MotionEvent.AXIS_BRAKE) {
       
   158                 arg1Axis = MotionEvent.AXIS_GAS;
       
   159             }
       
   160 
       
   161             return arg0Axis - arg1Axis;
   148         }
   162         }
   149     }
   163     }
   150 
   164 
   151     private ArrayList<SDLJoystick> mJoysticks;
   165     private ArrayList<SDLJoystick> mJoysticks;
   152 
   166