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);
}
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);
}
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;
}
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;
}
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));
}
Aggregations