From 59af265398839ec82115597ded8f296e4e320735 Mon Sep 17 00:00:00 2001 From: Paul Speed Date: Sun, 31 Mar 2019 20:38:33 -0400 Subject: [PATCH] Updated the joystick test to indicate when the new LEFT_TRIGGER/RIGHT_TRIGGER axes are used. Also changed the console output to include the logical ID of triggered axes instead of just the name. --- .../java/jme3test/input/TestJoystick.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/jme3-examples/src/main/java/jme3test/input/TestJoystick.java b/jme3-examples/src/main/java/jme3test/input/TestJoystick.java index 8633b0aef..fbc8ea198 100644 --- a/jme3-examples/src/main/java/jme3test/input/TestJoystick.java +++ b/jme3-examples/src/main/java/jme3test/input/TestJoystick.java @@ -290,7 +290,7 @@ public class TestJoystick extends SimpleApplication { public void setAxisValue( JoystickAxis axis, float value ) { - System.out.println( "Axis:" + axis.getName() + "=" + value ); + System.out.println( "Axis:" + axis.getName() + "(id:" + axis.getLogicalId() + ")=" + value ); if( axis == axis.getJoystick().getXAxis() ) { setXAxis(value); } else if( axis == axis.getJoystick().getYAxis() ) { @@ -304,6 +304,22 @@ public class TestJoystick extends SimpleApplication { setZAxis(value); } else if( axis == axis.getJoystick().getAxis(JoystickAxis.Z_ROTATION) ) { setZRotation(-value); + } else if( axis == axis.getJoystick().getAxis(JoystickAxis.LEFT_TRIGGER) ) { + if( axis.getJoystick().getButton(JoystickButton.BUTTON_6) == null ) { + // left/right triggers sometimes only show up as axes + boolean pressed = value != 0; + if( pressed != buttons.get(JoystickButton.BUTTON_6).isDown() ) { + setButtonValue(JoystickButton.BUTTON_6, pressed); + } + } + } else if( axis == axis.getJoystick().getAxis(JoystickAxis.RIGHT_TRIGGER) ) { + if( axis.getJoystick().getButton(JoystickButton.BUTTON_7) == null ) { + // left/right triggers sometimes only show up as axes + boolean pressed = value != 0; + if( pressed != buttons.get(JoystickButton.BUTTON_7).isDown() ) { + setButtonValue(JoystickButton.BUTTON_7, pressed); + } + } } else if( axis == axis.getJoystick().getPovXAxis() ) { if( lastPovX < 0 ) { setButtonValue( "POV -X", false ); @@ -426,6 +442,10 @@ public class TestJoystick extends SimpleApplication { System.out.println( getName() + " state:" + state ); } + public boolean isDown() { + return state > 0; + } + public void down() { state++; resetState();