Search in sources :

Example 1 with RawKeyboardAction

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

the class InputSystemTests method pressKey.

private void pressKey(Key key) {
    RawKeyboardAction rawKeyboardAction = new RawKeyboardAction(key, ButtonState.DOWN);
    testKeyboard.add(rawKeyboardAction);
}
Also used : RawKeyboardAction(org.terasology.input.device.RawKeyboardAction)

Example 2 with RawKeyboardAction

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

the class InputSystem method cancelSimulatedKeyStroke.

/**
 * Cancels the simulation of key strokes.
 *
 * @param key The key to cancel the simulation of.
 */
public void cancelSimulatedKeyStroke(Input key) {
    RawKeyboardAction action = new RawKeyboardAction(key, ButtonState.UP);
    simulatedKeys.add(action);
}
Also used : RawKeyboardAction(org.terasology.input.device.RawKeyboardAction)

Example 3 with RawKeyboardAction

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

the class LwjglKeyboardDevice method getInputQueue.

@Override
public Queue<RawKeyboardAction> getInputQueue() {
    Queue<RawKeyboardAction> rawKeyboardActions = Lists.newLinkedList();
    RawKeyboardAction action;
    while ((action = rawKeyQueue.poll()) != null) {
        rawKeyboardActions.add(action);
    }
    return rawKeyboardActions;
}
Also used : RawKeyboardAction(org.terasology.input.device.RawKeyboardAction)

Example 4 with RawKeyboardAction

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

the class AwtKeyboardDevice method getInputQueue.

@Override
public Queue<RawKeyboardAction> getInputQueue() {
    Queue<RawKeyboardAction> rawKeyboardActions = Lists.newLinkedList();
    RawKeyboardAction action;
    while ((action = rawKeyQueue.poll()) != null) {
        rawKeyboardActions.add(action);
    }
    return rawKeyboardActions;
}
Also used : RawKeyboardAction(org.terasology.input.device.RawKeyboardAction)

Example 5 with RawKeyboardAction

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

the class AwtKeyboardDevice method awtKeyCallback.

/**
 * Callback receive key input events.
 */
public void awtKeyCallback(int key, ButtonState state, int location) {
    int teraKey;
    TIntIntHashMap extraMap = AWT_TO_TERA_EXTRA.get(key);
    if (extraMap != null) {
        teraKey = extraMap.get(key);
    } else {
        teraKey = AWT_TO_TERA_MAPPING.get(key);
    }
    Input input = InputType.KEY.getInput(teraKey);
    if (state == ButtonState.DOWN) {
        buttonStates.add(teraKey);
    } else if (state == ButtonState.UP) {
        buttonStates.remove(teraKey);
    }
    rawKeyQueue.offer(new RawKeyboardAction(input, state));
}
Also used : Input(org.terasology.input.Input) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) RawKeyboardAction(org.terasology.input.device.RawKeyboardAction)

Aggregations

RawKeyboardAction (org.terasology.input.device.RawKeyboardAction)10 Input (org.terasology.input.Input)2 TIntIntHashMap (gnu.trove.map.hash.TIntIntHashMap)1 ButtonState (org.terasology.input.ButtonState)1 CharKeyboardAction (org.terasology.input.device.CharKeyboardAction)1