فهرست منبع

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.

Paul Speed 6 سال پیش
والد
کامیت
59af265398
1فایلهای تغییر یافته به همراه21 افزوده شده و 1 حذف شده
  1. 21 1
      jme3-examples/src/main/java/jme3test/input/TestJoystick.java

+ 21 - 1
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();