@Override public JoystickButton getButton(String logicalId) { for( JoystickButton b : buttons ) { if( b.getLogicalId().equals(logicalId) ) return b; } return null; }
public void setButtonValue( JoystickButton button, boolean isPressed ) { System.out.println( "Button:" + button.getName() + "=" + (isPressed ? "Down" : "Up") ); setButtonValue( button.getLogicalId(), isPressed ); lastButton = button; }
private void pickGamePad(Vector2f mouseLoc){ if (lastButton != null) { CollisionResults cresults = pick(cam, mouseLoc, gamepad); for (CollisionResult cr : cresults) { Node n = cr.getGeometry().getParent(); if (n != null && (n instanceof ButtonView)) { String b = ((ButtonView) n).getName().substring("Button:".length()); String name = lastButton.getJoystick().getName().replaceAll(" ", "\\\\ "); String id = lastButton.getLogicalId().replaceAll(" ", "\\\\ "); System.out.println(name + "." + id + "=" + b); return; } } } }
addInfo( " '" + b.getName() + "' id:'" + b.getLogicalId() + "'", 0 );
@Override public JoystickButton getButton(String logicalId) { for( JoystickButton b : buttons ) { if( b.getLogicalId().equals(logicalId) ) return b; } return null; }
protected void mapJoystick( Joystick j ) { // We attempt to determine what kind of stick it is so // that we can provide more intelligent button and axis mappings if( j.getAxis(JoystickAxis.Z_ROTATION) != null && j.getAxis(JoystickAxis.Z_AXIS) != null ) { mapGamepad(j); return; } // Else it's a generic one joystickAxisMap.put(j.getXAxis(), Axis.JOYSTICK_X); joystickAxisMap.put(j.getYAxis(), Axis.JOYSTICK_Y); joystickAxisMap.put(j.getPovXAxis(), Axis.JOYSTICK_HAT_X); joystickAxisMap.put(j.getPovYAxis(), Axis.JOYSTICK_HAT_Y); for( JoystickButton b : j.getButtons() ) { String id = b.getLogicalId(); if( !Character.isDigit(id.charAt(0)) ) continue; int idVal = Integer.parseInt(id) + 1; joystickButtonMap.put(b, new Button("joystick_" + idVal, "Button " + idVal)); } }