Search in sources :

Example 1 with CharKeyboardAction

use of org.terasology.input.device.CharKeyboardAction in project Terasology by MovingBlocks.

the class AwtKeyboardDevice method getCharInputQueue.

@Override
public Queue<CharKeyboardAction> getCharInputQueue() {
    Queue<CharKeyboardAction> charActions = Lists.newLinkedList();
    CharKeyboardAction action;
    while ((action = charQueue.poll()) != null) {
        charActions.add(action);
    }
    return charActions;
}
Also used : CharKeyboardAction(org.terasology.input.device.CharKeyboardAction)

Example 2 with CharKeyboardAction

use of org.terasology.input.device.CharKeyboardAction in project Terasology by MovingBlocks.

the class LwjglKeyboardDevice method getCharInputQueue.

@Override
public Queue<CharKeyboardAction> getCharInputQueue() {
    Queue<CharKeyboardAction> charActions = Lists.newLinkedList();
    CharKeyboardAction action;
    while ((action = charQueue.poll()) != null) {
        charActions.add(action);
    }
    return charActions;
}
Also used : CharKeyboardAction(org.terasology.input.device.CharKeyboardAction)

Example 3 with CharKeyboardAction

use of org.terasology.input.device.CharKeyboardAction in project Terasology by MovingBlocks.

the class InputSystem method processKeyboardInput.

/**
 * Processes input actions by keyboard buttons, sends key events and updates bind buttons accordingly.
 *
 * @param delta The length of the current frame.
 */
private void processKeyboardInput(float delta) {
    Queue<RawKeyboardAction> keyQueue = keyboard.getInputQueue();
    keyQueue.addAll(simulatedKeys);
    simulatedKeys.clear();
    for (RawKeyboardAction action : keyQueue) {
        boolean consumed = sendKeyEvent(action.getInput(), action.getState(), delta);
        // Update bind
        BindableButton bind = bindsManager.getKeyBinds().get(action.getInput().getId());
        if (bind != null && action.getState() != ButtonState.REPEAT) {
            boolean pressed = action.getState() == ButtonState.DOWN;
            updateBindState(bind, action.getInput(), pressed, delta, consumed);
        }
    }
    Queue<CharKeyboardAction> charQueue = keyboard.getCharInputQueue();
    charQueue.addAll(simulatedTextInput);
    simulatedTextInput.clear();
    charQueue.forEach((action) -> sendCharEvent(action.getCharacter(), delta));
}
Also used : CharKeyboardAction(org.terasology.input.device.CharKeyboardAction) RawKeyboardAction(org.terasology.input.device.RawKeyboardAction)

Aggregations

CharKeyboardAction (org.terasology.input.device.CharKeyboardAction)3 RawKeyboardAction (org.terasology.input.device.RawKeyboardAction)1