protected void mapJoystick( Joystick joystick ) { // Map it differently if there are Z axis if( joystick.getAxis( JoystickAxis.Z_ROTATION ) != null && joystick.getAxis( JoystickAxis.Z_AXIS ) != null ) { // Make the left stick move joystick.getXAxis().assignAxis( CameraInput.FLYCAM_STRAFERIGHT, CameraInput.FLYCAM_STRAFELEFT ); joystick.getYAxis().assignAxis( CameraInput.FLYCAM_BACKWARD, CameraInput.FLYCAM_FORWARD ); // And the right stick control the camera joystick.getAxis( JoystickAxis.Z_ROTATION ).assignAxis( CameraInput.FLYCAM_DOWN, CameraInput.FLYCAM_UP ); joystick.getAxis( JoystickAxis.Z_AXIS ).assignAxis( CameraInput.FLYCAM_RIGHT, CameraInput.FLYCAM_LEFT ); // And let the dpad be up and down joystick.getPovYAxis().assignAxis(CameraInput.FLYCAM_RISE, CameraInput.FLYCAM_LOWER); if( joystick.getButton( "Button 8" ) != null ) { // Let the stanard select button be the y invert toggle joystick.getButton( "Button 8" ).assignButton( CameraInput.FLYCAM_INVERTY ); } } else { joystick.getPovXAxis().assignAxis(CameraInput.FLYCAM_STRAFERIGHT, CameraInput.FLYCAM_STRAFELEFT); joystick.getPovYAxis().assignAxis(CameraInput.FLYCAM_FORWARD, CameraInput.FLYCAM_BACKWARD); joystick.getXAxis().assignAxis(CameraInput.FLYCAM_RIGHT, CameraInput.FLYCAM_LEFT); joystick.getYAxis().assignAxis(CameraInput.FLYCAM_DOWN, CameraInput.FLYCAM_UP); } }
} else if( axis == axis.getJoystick().getPovYAxis() ) { if( lastPovY < 0 ) { setButtonValue( "POV -Y", false );
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)); } }
protected void mapGamepad( Joystick j ) { joystickAxisMap.put(j.getXAxis(), Axis.JOYSTICK_LEFT_X); joystickAxisMap.put(j.getYAxis(), Axis.JOYSTICK_LEFT_Y); joystickAxisMap.put(j.getAxis(JoystickAxis.Z_AXIS), Axis.JOYSTICK_RIGHT_X); joystickAxisMap.put(j.getAxis(JoystickAxis.Z_ROTATION), Axis.JOYSTICK_RIGHT_Y); joystickAxisMap.put(j.getPovXAxis(), Axis.JOYSTICK_HAT_X); joystickAxisMap.put(j.getPovYAxis(), Axis.JOYSTICK_HAT_Y); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_0), Button.JOYSTICK_BUTTON1); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_1), Button.JOYSTICK_BUTTON2); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_2), Button.JOYSTICK_BUTTON3); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_3), Button.JOYSTICK_BUTTON4); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_4), Button.JOYSTICK_LEFT1); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_5), Button.JOYSTICK_RIGHT1); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_6), Button.JOYSTICK_LEFT2); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_7), Button.JOYSTICK_RIGHT2); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_8), Button.JOYSTICK_SELECT); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_9), Button.JOYSTICK_START); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_10), Button.JOYSTICK_LEFT3); joystickButtonMap.put(j.getButton(JoystickButton.BUTTON_11), Button.JOYSTICK_RIGHT3); }
protected void mapJoystick( Joystick joystick ) { // Map it differently if there are Z axis if( joystick.getAxis( JoystickAxis.Z_ROTATION ) != null && joystick.getAxis( JoystickAxis.Z_AXIS ) != null ) { // Make the left stick move joystick.getXAxis().assignAxis( CameraInput.FLYCAM_STRAFERIGHT, CameraInput.FLYCAM_STRAFELEFT ); joystick.getYAxis().assignAxis( CameraInput.FLYCAM_BACKWARD, CameraInput.FLYCAM_FORWARD ); // And the right stick control the camera joystick.getAxis( JoystickAxis.Z_ROTATION ).assignAxis( CameraInput.FLYCAM_DOWN, CameraInput.FLYCAM_UP ); joystick.getAxis( JoystickAxis.Z_AXIS ).assignAxis( CameraInput.FLYCAM_RIGHT, CameraInput.FLYCAM_LEFT ); // And let the dpad be up and down joystick.getPovYAxis().assignAxis(CameraInput.FLYCAM_RISE, CameraInput.FLYCAM_LOWER); if( joystick.getButton( "Button 8" ) != null ) { // Let the stanard select button be the y invert toggle joystick.getButton( "Button 8" ).assignButton( CameraInput.FLYCAM_INVERTY ); } } else { joystick.getPovXAxis().assignAxis(CameraInput.FLYCAM_STRAFERIGHT, CameraInput.FLYCAM_STRAFELEFT); joystick.getPovYAxis().assignAxis(CameraInput.FLYCAM_FORWARD, CameraInput.FLYCAM_BACKWARD); joystick.getXAxis().assignAxis(CameraInput.FLYCAM_RIGHT, CameraInput.FLYCAM_LEFT); joystick.getYAxis().assignAxis(CameraInput.FLYCAM_DOWN, CameraInput.FLYCAM_UP); } }