Tested if a joystick axis is not the nullAxis before assigning action to it.

This commit is contained in:
Nehon 2015-07-10 21:28:42 +02:00
parent 34220640aa
commit 57dd2748e2

View File

@ -72,9 +72,11 @@ public class DefaultJoystickAxis implements JoystickAxis {
* @param negativeMapping The mapping to receive events when the axis is positive * @param negativeMapping The mapping to receive events when the axis is positive
*/ */
public void assignAxis(String positiveMapping, String negativeMapping){ public void assignAxis(String positiveMapping, String negativeMapping){
if (axisIndex != -1) {
inputManager.addMapping(positiveMapping, new JoyAxisTrigger(parent.getJoyId(), axisIndex, false)); inputManager.addMapping(positiveMapping, new JoyAxisTrigger(parent.getJoyId(), axisIndex, false));
inputManager.addMapping(negativeMapping, new JoyAxisTrigger(parent.getJoyId(), axisIndex, true)); inputManager.addMapping(negativeMapping, new JoyAxisTrigger(parent.getJoyId(), axisIndex, true));
} }
}
/** /**
* Returns the joystick to which this axis object belongs. * Returns the joystick to which this axis object belongs.