Search in sources :

Example 1 with InputSystem

use of org.terasology.engine.input.InputSystem in project Terasology by MovingBlocks.

the class RegisterInputSystem method step.

@Override
public boolean step() {
    ComponentSystemManager componentSystemManager = context.get(ComponentSystemManager.class);
    LocalPlayerSystem localPlayerSystem = new LocalPlayerSystem();
    componentSystemManager.register(localPlayerSystem, "engine:localPlayerSystem");
    context.put(LocalPlayerSystem.class, localPlayerSystem);
    CameraTargetSystem cameraTargetSystem = new CameraTargetSystem();
    context.put(CameraTargetSystem.class, cameraTargetSystem);
    componentSystemManager.register(cameraTargetSystem, "engine:CameraTargetSystem");
    InputSystem inputSystem = context.get(InputSystem.class);
    componentSystemManager.register(inputSystem, "engine:InputSystem");
    return true;
}
Also used : LocalPlayerSystem(org.terasology.engine.logic.players.LocalPlayerSystem) InputSystem(org.terasology.engine.input.InputSystem) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager) CameraTargetSystem(org.terasology.engine.input.cameraTarget.CameraTargetSystem)

Example 2 with InputSystem

use of org.terasology.engine.input.InputSystem in project Terasology by MovingBlocks.

the class TerasologyEngine method switchState.

private void switchState(GameState newState) {
    if (currentState != null) {
        currentState.dispose();
    }
    CoreRegistry.setContext(newState.getContext());
    currentState = newState;
    LoggingContext.setGameState(newState);
    newState.init(this);
    stateChangeSubscribers.forEach(StateChangeSubscriber::onStateChange);
    InputSystem inputSystem = rootContext.get(InputSystem.class);
    if (inputSystem != null) {
        inputSystem.drainQueues();
    }
}
Also used : InputSystem(org.terasology.engine.input.InputSystem)

Example 3 with InputSystem

use of org.terasology.engine.input.InputSystem in project Terasology by MovingBlocks.

the class LwjglInput method initControls.

private void initControls() {
    Config config = context.get(Config.class);
    InputSystem inputSystem = new InputSystem();
    context.put(InputSystem.class, inputSystem);
    inputSystem.setMouseDevice(new LwjglMouseDevice(config.getRendering()));
    inputSystem.setKeyboardDevice(new LwjglKeyboardDevice());
    ControllerConfig controllerConfig = config.getInput().getControllers();
    LwjglControllerDevice controllerDevice = new LwjglControllerDevice(controllerConfig);
    inputSystem.setControllerDevice(controllerDevice);
    long window = GLFW.glfwGetCurrentContext();
    ((LwjglKeyboardDevice) inputSystem.getKeyboard()).registerToLwjglWindow(window);
    ((LwjglMouseDevice) inputSystem.getMouseDevice()).registerToLwjglWindow(window);
}
Also used : ControllerConfig(org.terasology.engine.config.ControllerConfig) LwjglControllerDevice(org.terasology.engine.input.lwjgl.LwjglControllerDevice) Config(org.terasology.engine.config.Config) ControllerConfig(org.terasology.engine.config.ControllerConfig) LwjglMouseDevice(org.terasology.engine.input.lwjgl.LwjglMouseDevice) LwjglKeyboardDevice(org.terasology.engine.input.lwjgl.LwjglKeyboardDevice) InputSystem(org.terasology.engine.input.InputSystem)

Example 4 with InputSystem

use of org.terasology.engine.input.InputSystem in project Terasology by MovingBlocks.

the class LwjglPortlet method initInputs.

public void initInputs() {
    final InputSystem inputSystem = context.get(InputSystem.class);
    Preconditions.checkNotNull(inputSystem);
    mouseDevice = ((AwtMouseDevice) inputSystem.getMouseDevice());
    mouseDevice.registerToAwtGlCanvas(canvas);
    ((AwtKeyboardDevice) inputSystem.getKeyboard()).registerToAwtGlCanvas(canvas);
}
Also used : AwtMouseDevice(org.terasology.editor.input.AwtMouseDevice) InputSystem(org.terasology.engine.input.InputSystem) AwtKeyboardDevice(org.terasology.editor.input.AwtKeyboardDevice)

Example 5 with InputSystem

use of org.terasology.engine.input.InputSystem in project Terasology by MovingBlocks.

the class AwtInput method initControls.

private void initControls() {
    Config config = context.get(Config.class);
    InputSystem inputSystem = new InputSystem();
    context.put(InputSystem.class, inputSystem);
    inputSystem.setMouseDevice(new AwtMouseDevice(config.getRendering()));
    inputSystem.setKeyboardDevice(new AwtKeyboardDevice());
    ControllerConfig controllerConfig = config.getInput().getControllers();
    LwjglControllerDevice controllerDevice = new LwjglControllerDevice(controllerConfig);
    inputSystem.setControllerDevice(controllerDevice);
}
Also used : AwtMouseDevice(org.terasology.editor.input.AwtMouseDevice) ControllerConfig(org.terasology.engine.config.ControllerConfig) LwjglControllerDevice(org.terasology.engine.input.lwjgl.LwjglControllerDevice) Config(org.terasology.engine.config.Config) ControllerConfig(org.terasology.engine.config.ControllerConfig) InputSystem(org.terasology.engine.input.InputSystem) AwtKeyboardDevice(org.terasology.editor.input.AwtKeyboardDevice)

Aggregations

InputSystem (org.terasology.engine.input.InputSystem)10 Config (org.terasology.engine.config.Config)3 AwtKeyboardDevice (org.terasology.editor.input.AwtKeyboardDevice)2 AwtMouseDevice (org.terasology.editor.input.AwtMouseDevice)2 ControllerConfig (org.terasology.engine.config.ControllerConfig)2 LwjglControllerDevice (org.terasology.engine.input.lwjgl.LwjglControllerDevice)2 LwjglKeyboardDevice (org.terasology.engine.input.lwjgl.LwjglKeyboardDevice)2 LwjglMouseDevice (org.terasology.engine.input.lwjgl.LwjglMouseDevice)2 JsonParser (com.google.gson.JsonParser)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Context (org.terasology.engine.context.Context)1 ContextImpl (org.terasology.engine.context.internal.ContextImpl)1 ComponentSystemManager (org.terasology.engine.core.ComponentSystemManager)1 RegisterInputSystem (org.terasology.engine.core.modes.loadProcesses.RegisterInputSystem)1 TimeSystem (org.terasology.engine.core.subsystem.headless.device.TimeSystem)1 HeadlessCanvasRenderer (org.terasology.engine.core.subsystem.headless.renderer.HeadlessCanvasRenderer)1