Search in sources :

Example 1 with LwjglMouseDevice

use of org.terasology.input.lwjgl.LwjglMouseDevice in project Terasology by MovingBlocks.

the class OpenVRInput method postInitialise.

/**
 * Set up listeners and input devices.
 * @param rootContext
 */
@Override
public void postInitialise(Context rootContext) {
    config = context.get(Config.class);
    if (!config.getRendering().isVrSupport()) {
        return;
    }
    this.context = rootContext;
    InputSystem inputSystem = context.get(InputSystem.class);
    if (inputSystem == null) {
        inputSystem = new InputSystem();
        inputSystem.setMouseDevice(new LwjglMouseDevice());
        inputSystem.setKeyboardDevice(new LwjglKeyboardDevice());
        context.put(InputSystem.class, inputSystem);
    }
    controllerDevice = new OpenVRControllers();
    vrProvider.getState().addControllerListener(controllerDevice);
    inputSystem.setControllerDevice(controllerDevice);
}
Also used : Config(org.terasology.config.Config) LwjglMouseDevice(org.terasology.input.lwjgl.LwjglMouseDevice) LwjglKeyboardDevice(org.terasology.input.lwjgl.LwjglKeyboardDevice) InputSystem(org.terasology.input.InputSystem)

Example 2 with LwjglMouseDevice

use of org.terasology.input.lwjgl.LwjglMouseDevice 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)

Aggregations

InputSystem (org.terasology.input.InputSystem)2 LwjglKeyboardDevice (org.terasology.input.lwjgl.LwjglKeyboardDevice)2 LwjglMouseDevice (org.terasology.input.lwjgl.LwjglMouseDevice)2 LWJGLException (org.lwjgl.LWJGLException)1 Config (org.terasology.config.Config)1 ControllerConfig (org.terasology.config.ControllerConfig)1 JInputControllerDevice (org.terasology.input.lwjgl.JInputControllerDevice)1