Search in sources :

Example 1 with MouseAxisEvent

use of org.terasology.input.events.MouseAxisEvent in project Terasology by MovingBlocks.

the class InputSystem method processMouseInput.

private void processMouseInput(float delta) {
    if (!isCapturingMouse()) {
        return;
    }
    Vector2i deltaMouse = mouse.getDelta();
    // process mouse movement x axis
    if (deltaMouse.x != 0) {
        float xValue = deltaMouse.x * inputDeviceConfig.getMouseSensitivity();
        MouseAxisEvent event = MouseAxisEvent.create(MouseAxis.X, xValue, delta);
        send(event);
    }
    // process mouse movement y axis
    if (deltaMouse.y != 0) {
        int yMovement = inputDeviceConfig.isMouseYAxisInverted() ? deltaMouse.y * -1 : deltaMouse.y;
        float yValue = yMovement * inputDeviceConfig.getMouseSensitivity();
        MouseAxisEvent event = MouseAxisEvent.create(MouseAxis.Y, yValue, delta);
        send(event);
    }
    // process mouse clicks
    for (MouseAction action : mouse.getInputQueue()) {
        switch(action.getInput().getType()) {
            case MOUSE_BUTTON:
                processMouseButtonInput(delta, action);
                break;
            case MOUSE_WHEEL:
                processMouseWheelInput(delta, action);
                break;
            default:
                break;
        }
    }
}
Also used : MouseAction(org.terasology.input.device.MouseAction) Vector2i(org.terasology.math.geom.Vector2i) MouseAxisEvent(org.terasology.input.events.MouseAxisEvent)

Aggregations

MouseAction (org.terasology.input.device.MouseAction)1 MouseAxisEvent (org.terasology.input.events.MouseAxisEvent)1 Vector2i (org.terasology.math.geom.Vector2i)1