Search in sources :

Example 6 with InputSystem

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);
    }
}
Also used : ControllerConfig(org.terasology.config.ControllerConfig) LwjglMouseDevice(org.terasology.input.lwjgl.LwjglMouseDevice) LwjglKeyboardDevice(org.terasology.input.lwjgl.LwjglKeyboardDevice) InputSystem(org.terasology.input.InputSystem) JInputControllerDevice(org.terasology.input.lwjgl.JInputControllerDevice) LWJGLException(org.lwjgl.LWJGLException)

Example 7 with InputSystem

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();
}
Also used : InputSystem(org.terasology.input.InputSystem)

Example 8 with InputSystem

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));
}
Also used : TranslationSystemImpl(org.terasology.i18n.TranslationSystemImpl) InputSystem(org.terasology.input.InputSystem) IOException(java.io.IOException) File(java.io.File) HeadlessCanvasRenderer(org.terasology.engine.subsystem.headless.renderer.HeadlessCanvasRenderer) NUIManagerInternal(org.terasology.rendering.nui.internal.NUIManagerInternal) JsonParser(com.google.gson.JsonParser) BeforeClass(org.junit.BeforeClass)

Aggregations

InputSystem (org.terasology.input.InputSystem)8 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)2 CameraTargetSystem (org.terasology.input.cameraTarget.CameraTargetSystem)2 LwjglKeyboardDevice (org.terasology.input.lwjgl.LwjglKeyboardDevice)2 LwjglMouseDevice (org.terasology.input.lwjgl.LwjglMouseDevice)2 NUIManagerInternal (org.terasology.rendering.nui.internal.NUIManagerInternal)2 JsonParser (com.google.gson.JsonParser)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 BeforeClass (org.junit.BeforeClass)1 LWJGLException (org.lwjgl.LWJGLException)1 Config (org.terasology.config.Config)1 ControllerConfig (org.terasology.config.ControllerConfig)1 RegisterInputSystem (org.terasology.engine.modes.loadProcesses.RegisterInputSystem)1 HeadlessCanvasRenderer (org.terasology.engine.subsystem.headless.renderer.HeadlessCanvasRenderer)1 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)1 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)1 TranslationSystemImpl (org.terasology.i18n.TranslationSystemImpl)1