use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.
the class LwjglInput method initControls.
private void initControls() {
try {
Keyboard.create();
Keyboard.enableRepeatEvents(true);
Mouse.create();
InputSystem inputSystem = new InputSystem();
context.put(InputSystem.class, inputSystem);
inputSystem.setMouseDevice(new LwjglMouseDevice());
inputSystem.setKeyboardDevice(new LwjglKeyboardDevice());
ControllerConfig controllerConfig = context.get(Config.class).getInput().getControllers();
JInputControllerDevice controllerDevice = new JInputControllerDevice(controllerConfig);
inputSystem.setControllerDevice(controllerDevice);
} catch (LWJGLException e) {
throw new RuntimeException("Could not initialize controls.", e);
}
}
use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.
the class TerasologyEngine method switchState.
private void switchState(GameState newState) {
if (currentState != null) {
currentState.dispose();
}
currentState = newState;
LoggingContext.setGameState(newState);
newState.init(this);
stateChangeSubscribers.forEach(StateChangeSubscriber::onStateChange);
InputSystem inputSystem = rootContext.get(InputSystem.class);
inputSystem.drainQueues();
}
use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.
the class ContextMenuUtilsTest method setupInput.
@BeforeClass
public static void setupInput() {
context.put(InputSystem.class, new InputSystem());
context.put(TranslationSystem.class, new TranslationSystemImpl(context));
context.put(CanvasRenderer.class, new HeadlessCanvasRenderer());
context.put(NUIManager.class, new NUIManagerInternal(context.get(CanvasRenderer.class), context));
File file = new File(ContextMenuUtilsTest.class.getClassLoader().getResource("contextMenuBuilderInput.ui").getFile());
String content = null;
try {
content = Files.toString(file, Charsets.UTF_8);
} catch (IOException e) {
fail("Could not load input file");
}
inputTree = JsonTreeConverter.serialize(new JsonParser().parse(content));
}
Aggregations