com.jme3.input.controls.MouseAxisTrigger Java Examples

The following examples show how to use com.jme3.input.controls.MouseAxisTrigger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestWriteToTexture.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    initOpenCL1();
    
    tex = new Texture2D(settings.getWidth(), settings.getHeight(), 1, com.jme3.texture.Image.Format.RGBA8);
    Picture pic = new Picture("julia");
    pic.setTexture(assetManager, tex, true);
    pic.setPosition(0, 0);
    pic.setWidth(settings.getWidth());
    pic.setHeight(settings.getHeight());
    guiNode.attachChild(pic);
    
    initCounter = 0;
    
    flyCam.setEnabled(false);
    inputManager.setCursorVisible(true);
    inputManager.addMapping("right", new MouseAxisTrigger(MouseInput.AXIS_X, false));
    inputManager.addMapping("left", new MouseAxisTrigger(MouseInput.AXIS_X, true));
    inputManager.addMapping("up", new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    inputManager.addMapping("down", new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    inputManager.addMapping("drag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(this, "right", "left", "up", "down", "drag");
    dragging = false;
}
 
Example #2
Source File: GroundCameraManager.java    From OpenRTS with MIT License 6 votes vote down vote up
@Override
public void registerInputs(InputManager inputManager){
	inputManager.addMapping(ROTATE_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
	inputManager.addMapping(ROTATE_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
	inputManager.addMapping(ROTATE_LEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
	inputManager.addMapping(ROTATE_RIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));

	inputManager.addMapping(STRAFE_LEFT, new KeyTrigger(KeyInput.KEY_Q),
			new KeyTrigger(KeyInput.KEY_LEFT));
	inputManager.addMapping(STRAFE_RIGHT, new KeyTrigger(KeyInput.KEY_D),
			new KeyTrigger(KeyInput.KEY_RIGHT));
	inputManager.addMapping(MOVE_FOREWARD, new KeyTrigger(KeyInput.KEY_Z),
			new KeyTrigger(KeyInput.KEY_UP));
	inputManager.addMapping(MOVE_BACKWARD, new KeyTrigger(KeyInput.KEY_S),
			new KeyTrigger(KeyInput.KEY_DOWN));
	inputManager.addListener(this, mappings);
}
 
Example #3
Source File: TestControls.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    // Test multiple inputs per mapping
    inputManager.addMapping("My Action",
            new KeyTrigger(KeyInput.KEY_SPACE),
            new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));

    // Test multiple listeners per mapping
    inputManager.addListener(actionListener, "My Action");
    inputManager.addListener(analogListener, "My Action");
}
 
Example #4
Source File: ChaseCameraAppState.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void initVerticalAxisInputs() {
    if (!invertYaxis) {
        inputManager.addMapping(CameraInput.CHASECAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
        inputManager.addMapping(CameraInput.CHASECAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    } else {
        inputManager.addMapping(CameraInput.CHASECAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
        inputManager.addMapping(CameraInput.CHASECAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    }
}
 
Example #5
Source File: ChaseCameraAppState.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void initHorizontalAxisInput() {
    if (!invertXaxis) {
        inputManager.addMapping(CameraInput.CHASECAM_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
        inputManager.addMapping(CameraInput.CHASECAM_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    } else {
        inputManager.addMapping(CameraInput.CHASECAM_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
        inputManager.addMapping(CameraInput.CHASECAM_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    }
}
 
Example #6
Source File: FlyByCamera.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Register this controller to receive input events from the specified input
 * manager.
 *
 * @param inputManager
 */
public void registerWithInput(InputManager inputManager){
    this.inputManager = inputManager;

    // both mouse and button - rotation of cam
    inputManager.addMapping(CameraInput.FLYCAM_LEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true),
            new KeyTrigger(KeyInput.KEY_LEFT));

    inputManager.addMapping(CameraInput.FLYCAM_RIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false),
            new KeyTrigger(KeyInput.KEY_RIGHT));

    inputManager.addMapping(CameraInput.FLYCAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false),
            new KeyTrigger(KeyInput.KEY_UP));

    inputManager.addMapping(CameraInput.FLYCAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true),
            new KeyTrigger(KeyInput.KEY_DOWN));

    // mouse only - zoom in/out with wheel, and rotate drag
    inputManager.addMapping(CameraInput.FLYCAM_ZOOMIN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
    inputManager.addMapping(CameraInput.FLYCAM_ZOOMOUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
    inputManager.addMapping(CameraInput.FLYCAM_ROTATEDRAG, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

    // keyboard only WASD for movement and WZ for rise/lower height
    inputManager.addMapping(CameraInput.FLYCAM_STRAFELEFT, new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping(CameraInput.FLYCAM_STRAFERIGHT, new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping(CameraInput.FLYCAM_FORWARD, new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping(CameraInput.FLYCAM_BACKWARD, new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping(CameraInput.FLYCAM_RISE, new KeyTrigger(KeyInput.KEY_Q));
    inputManager.addMapping(CameraInput.FLYCAM_LOWER, new KeyTrigger(KeyInput.KEY_Z));

    inputManager.addListener(this, mappings);
    inputManager.setCursorVisible(dragToRotate || !isEnabled());

    Joystick[] joysticks = inputManager.getJoysticks();
    if (joysticks != null && joysticks.length > 0){
        for (Joystick j : joysticks) {
            mapJoystick(j);
        }
    }
}
 
Example #7
Source File: IsometricCameraManager.java    From OpenRTS with MIT License 5 votes vote down vote up
@Override
public void registerInputs(InputManager inputManager){
	inputManager.addMapping(STRAFE_NORTH, new KeyTrigger(KeyInput.KEY_UP));
	inputManager.addMapping(STRAFE_SOUTH, new KeyTrigger(KeyInput.KEY_DOWN));
	inputManager.addMapping(STRAFE_EAST, new KeyTrigger(KeyInput.KEY_RIGHT));
	inputManager.addMapping(STRAFE_WEST, new KeyTrigger(KeyInput.KEY_LEFT));
	inputManager.addMapping(ZOOM_IN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
	inputManager.addMapping(ZOOM_OUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
	inputManager.addListener(this, mappings);
}
 
Example #8
Source File: EditorCamera.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Registers inputs with the input manager
 *
 * @param inputManager the input manager
 */
public final void registerInput(final InputManager inputManager) {
    this.inputManager = inputManager;

    if (!inputManager.hasMapping(CHASECAM_DOWN)) {
        inputManager.addMapping(CHASECAM_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    }

    if (!inputManager.hasMapping(CHASECAM_UP)) {
        inputManager.addMapping(CHASECAM_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    }

    if (!inputManager.hasMapping(CHASECAM_ZOOMIN)) {
        inputManager.addMapping(CHASECAM_ZOOMIN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
    }

    if (!inputManager.hasMapping(CHASECAM_ZOOMOUT)) {
        inputManager.addMapping(CHASECAM_ZOOMOUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
    }

    if (!inputManager.hasMapping(CHASECAM_MOVELEFT)) {
        inputManager.addMapping(CHASECAM_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    }

    if (!inputManager.hasMapping(CHASECAM_MOVERIGHT)) {
        inputManager.addMapping(CHASECAM_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    }

    if (!inputManager.hasMapping(CHASECAM_TOGGLEROTATE)) {
        inputManager.addMapping(CHASECAM_TOGGLEROTATE, new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));
    }

    inputManager.addListener(this, ALL_INPUTS);
}
 
Example #9
Source File: LockableChaseCamera.java    From OpenRTS with MIT License 5 votes vote down vote up
public void unLock() {
	String[] inputs = {ChaseCamToggleRotate,
            ChaseCamDown,
            ChaseCamUp,
            ChaseCamMoveLeft,
            ChaseCamMoveRight,
            ChaseCamZoomIn,
            ChaseCamZoomOut};

        if (!invertYaxis) {
            inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
            inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
        } else {
            inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
            inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
        }
        inputManager.addMapping(ChaseCamZoomIn, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
        inputManager.addMapping(ChaseCamZoomOut, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
        if(!invertXaxis){
            inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, true));
            inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, false));
        }else{
            inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, false));
            inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, true));
        }
        inputManager.addMapping(ChaseCamToggleRotate, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        inputManager.addMapping(ChaseCamToggleRotate, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));

        inputManager.addListener(this, inputs);
        
        if(!isDragToRotate())
        	inputManager.setCursorVisible(false);
        	
        
}
 
Example #10
Source File: ChaseCamera.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * invert the Horizontal axis movement of the mouse
 * @param invertYaxis
 */
public void setInvertHorizontalAxis(boolean invertXaxis) {
    this.invertXaxis = invertXaxis;
    inputManager.deleteMapping(ChaseCamMoveLeft);
    inputManager.deleteMapping(ChaseCamMoveRight);
    if(!invertXaxis){
        inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, true));
        inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    }else{
        inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, false));
        inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    }
    inputManager.addListener(this, ChaseCamMoveLeft, ChaseCamMoveRight);
}
 
Example #11
Source File: TestCameraNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void registerInput() {
  inputManager.addMapping("moveForward", new KeyTrigger(keyInput.KEY_UP), new KeyTrigger(keyInput.KEY_W));
  inputManager.addMapping("moveBackward", new KeyTrigger(keyInput.KEY_DOWN), new KeyTrigger(keyInput.KEY_S));
  inputManager.addMapping("moveRight", new KeyTrigger(keyInput.KEY_RIGHT), new KeyTrigger(keyInput.KEY_D));
  inputManager.addMapping("moveLeft", new KeyTrigger(keyInput.KEY_LEFT), new KeyTrigger(keyInput.KEY_A));
  inputManager.addMapping("toggleRotate", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
  inputManager.addMapping("rotateRight", new MouseAxisTrigger(MouseInput.AXIS_X, true));
  inputManager.addMapping("rotateLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false));
  inputManager.addListener(this, "moveForward", "moveBackward", "moveRight", "moveLeft");
  inputManager.addListener(this, "rotateRight", "rotateLeft", "toggleRotate");
}
 
Example #12
Source File: TestControls.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    // Test multiple inputs per mapping
    inputManager.addMapping("My Action",
            new KeyTrigger(KeyInput.KEY_SPACE),
            new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));

    // Test multiple listeners per mapping
    inputManager.addListener(actionListener, "My Action");
    inputManager.addListener(analogListener, "My Action");
}
 
Example #13
Source File: ChaseCamera.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Registers inputs with the input manager
 * @param inputManager
 */
public final void registerWithInput(InputManager inputManager) {

    String[] inputs = {ChaseCamToggleRotate,
        ChaseCamDown,
        ChaseCamUp,
        ChaseCamMoveLeft,
        ChaseCamMoveRight,
        ChaseCamZoomIn,
        ChaseCamZoomOut};

    this.inputManager = inputManager;
    if (!invertYaxis) {
        inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
        inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    } else {
        inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
        inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    }
    inputManager.addMapping(ChaseCamZoomIn, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
    inputManager.addMapping(ChaseCamZoomOut, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
    if(!invertXaxis){
        inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, true));
        inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    }else{
        inputManager.addMapping(ChaseCamMoveLeft, new MouseAxisTrigger(MouseInput.AXIS_X, false));
        inputManager.addMapping(ChaseCamMoveRight, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    }
    inputManager.addMapping(ChaseCamToggleRotate, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addMapping(ChaseCamToggleRotate, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));

    inputManager.addListener(this, inputs);
}
 
Example #14
Source File: ChaseCamera.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * invert the vertical axis movement of the mouse
 * @param invertYaxis
 */
public void setInvertVerticalAxis(boolean invertYaxis) {
    this.invertYaxis = invertYaxis;
    inputManager.deleteMapping(ChaseCamDown);
    inputManager.deleteMapping(ChaseCamUp);
    if (!invertYaxis) {
        inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
        inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    } else {
        inputManager.addMapping(ChaseCamDown, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
        inputManager.addMapping(ChaseCamUp, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    }
    inputManager.addListener(this, ChaseCamDown, ChaseCamUp);
}
 
Example #15
Source File: FlyByCamera.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Registers the FlyByCamera to receive input events from the provided
 * Dispatcher.
 * @param dispacher
 */
public void registerWithInput(InputManager inputManager){
    this.inputManager = inputManager;
    
    String[] mappings = new String[]{
        "FLYCAM_Left",
        "FLYCAM_Right",
        "FLYCAM_Up",
        "FLYCAM_Down",

        "FLYCAM_StrafeLeft",
        "FLYCAM_StrafeRight",
        "FLYCAM_Forward",
        "FLYCAM_Backward",

        "FLYCAM_ZoomIn",
        "FLYCAM_ZoomOut",
        "FLYCAM_RotateDrag",

        "FLYCAM_Rise",
        "FLYCAM_Lower"
    };

    // both mouse and button - rotation of cam
    inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true),
                                           new KeyTrigger(KeyInput.KEY_LEFT));

    inputManager.addMapping("FLYCAM_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false),
                                            new KeyTrigger(KeyInput.KEY_RIGHT));

    inputManager.addMapping("FLYCAM_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false),
                                         new KeyTrigger(KeyInput.KEY_UP));

    inputManager.addMapping("FLYCAM_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true),
                                           new KeyTrigger(KeyInput.KEY_DOWN));

    // mouse only - zoom in/out with wheel, and rotate drag
    inputManager.addMapping("FLYCAM_ZoomIn", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
    inputManager.addMapping("FLYCAM_ZoomOut", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
    inputManager.addMapping("FLYCAM_RotateDrag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

    // keyboard only WASD for movement and WZ for rise/lower height
    inputManager.addMapping("FLYCAM_StrafeLeft", new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("FLYCAM_StrafeRight", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("FLYCAM_Forward", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("FLYCAM_Backward", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("FLYCAM_Rise", new KeyTrigger(KeyInput.KEY_Q));
    inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_Z));

    inputManager.addListener(this, mappings);
    inputManager.setCursorVisible(dragToRotate);

    Joystick[] joysticks = inputManager.getJoysticks();
    if (joysticks != null && joysticks.length > 0){
        Joystick joystick = joysticks[0];
        joystick.assignAxis("FLYCAM_StrafeRight", "FLYCAM_StrafeLeft", JoyInput.AXIS_POV_X);
        joystick.assignAxis("FLYCAM_Forward", "FLYCAM_Backward", JoyInput.AXIS_POV_Y);
        joystick.assignAxis("FLYCAM_Right", "FLYCAM_Left", joystick.getXAxisIndex());
        joystick.assignAxis("FLYCAM_Down", "FLYCAM_Up", joystick.getYAxisIndex());
    }
}
 
Example #16
Source File: AzertyFlyByCamera.java    From OpenRTS with MIT License 4 votes vote down vote up
@Override
public void registerWithInput(InputManager inputManager){
       this.inputManager = inputManager;
       
       String[] mappings = new String[]{
           "FLYCAM_Left",
           "FLYCAM_Right",
           "FLYCAM_Up",
           "FLYCAM_Down",

           "FLYCAM_StrafeLeft",
           "FLYCAM_StrafeRight",
           "FLYCAM_Forward",
           "FLYCAM_Backward",

           "FLYCAM_ZoomIn",
           "FLYCAM_ZoomOut",
           "FLYCAM_RotateDrag",

           "FLYCAM_Rise",
           "FLYCAM_Lower"
       };

       // both mouse and button - rotation of cam
       inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true),
                                              new KeyTrigger(KeyInput.KEY_LEFT));

       inputManager.addMapping("FLYCAM_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false),
                                               new KeyTrigger(KeyInput.KEY_RIGHT));

       inputManager.addMapping("FLYCAM_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false),
                                            new KeyTrigger(KeyInput.KEY_UP));

       inputManager.addMapping("FLYCAM_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true),
                                              new KeyTrigger(KeyInput.KEY_DOWN));

       // mouse only - zoom in/out with wheel, and rotate drag
       inputManager.addMapping("FLYCAM_ZoomIn", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
       inputManager.addMapping("FLYCAM_ZoomOut", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
       inputManager.addMapping("FLYCAM_RotateDrag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

       // keyboard only WASD for movement and WZ for rise/lower height
       inputManager.addMapping("FLYCAM_StrafeLeft", new KeyTrigger(KeyInput.KEY_Q));
       inputManager.addMapping("FLYCAM_StrafeRight", new KeyTrigger(KeyInput.KEY_D));
       inputManager.addMapping("FLYCAM_Forward", new KeyTrigger(KeyInput.KEY_Z));
       inputManager.addMapping("FLYCAM_Backward", new KeyTrigger(KeyInput.KEY_S));
       inputManager.addMapping("FLYCAM_Rise", new KeyTrigger(KeyInput.KEY_R));
       inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_F));

       inputManager.addListener(this, mappings);
       inputManager.setCursorVisible(dragToRotate);

       Joystick[] joysticks = inputManager.getJoysticks();
       if (joysticks != null && joysticks.length > 0){
           Joystick joystick = joysticks[0];
           joystick.assignAxis("FLYCAM_StrafeRight", "FLYCAM_StrafeLeft", JoyInput.AXIS_POV_X);
           joystick.assignAxis("FLYCAM_Forward", "FLYCAM_Backward", JoyInput.AXIS_POV_Y);
           joystick.assignAxis("FLYCAM_Right", "FLYCAM_Left", joystick.getXAxisIndex());
           joystick.assignAxis("FLYCAM_Down", "FLYCAM_Up", joystick.getYAxisIndex());
       }
   }
 
Example #17
Source File: StaticCamera.java    From OpenRTS with MIT License 4 votes vote down vote up
/**
     * Registers the FlyByCamera to receive input events from the provided
     * Dispatcher.
     * @param dispacher
     */
    public void registerWithInput(InputManager inputManager){
        this.inputManager = inputManager;
        
        String[] mappings = new String[]{
            "FLYCAM_Left",
            "FLYCAM_Right",
            "FLYCAM_Up",
            "FLYCAM_Down",

//            "FLYCAM_ZoomIn",
//            "FLYCAM_ZoomOut",
            "FLYCAM_RotateDrag",

        };

        // both mouse and button - rotation of cam
        inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true),
                                               new KeyTrigger(KeyInput.KEY_LEFT));

        inputManager.addMapping("FLYCAM_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false),
                                                new KeyTrigger(KeyInput.KEY_RIGHT));

        inputManager.addMapping("FLYCAM_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false),
                                             new KeyTrigger(KeyInput.KEY_UP));

        inputManager.addMapping("FLYCAM_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true),
                                               new KeyTrigger(KeyInput.KEY_DOWN));

        // mouse only - zoom in/out with wheel, and rotate drag
//        inputManager.addMapping("FLYCAM_ZoomIn", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
//        inputManager.addMapping("FLYCAM_ZoomOut", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
        inputManager.addMapping("FLYCAM_RotateDrag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

        inputManager.addListener(this, mappings);
        inputManager.setCursorVisible(dragToRotate);

        Joystick[] joysticks = inputManager.getJoysticks();
        if (joysticks != null && joysticks.length > 0){
            Joystick joystick = joysticks[0];
            joystick.assignAxis("FLYCAM_Right", "FLYCAM_Left", joystick.getXAxisIndex());
            joystick.assignAxis("FLYCAM_Down", "FLYCAM_Up", joystick.getYAxisIndex());
        }
    }