use of org.terasology.input.device.MouseAction in project Terasology by MovingBlocks.
the class LwjglMouseDevice method getInputQueue.
@Override
public Queue<MouseAction> getInputQueue() {
Queue<MouseAction> result = Queues.newArrayDeque();
while (Mouse.next()) {
if (Mouse.getEventButton() != -1) {
ButtonState state = (Mouse.getEventButtonState()) ? ButtonState.DOWN : ButtonState.UP;
result.add(new MouseAction(InputType.MOUSE_BUTTON.getInput(Mouse.getEventButton()), state, getPosition()));
}
if (Mouse.getEventDWheel() != 0) {
int id = (Mouse.getEventDWheel() > 0) ? 1 : -1;
result.add(new MouseAction(InputType.MOUSE_WHEEL.getInput(id), id * Mouse.getEventDWheel() / 120, getPosition()));
}
}
return result;
}
use of org.terasology.input.device.MouseAction 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;
}
}
}
Aggregations