Search in sources :

Example 1 with KeyReleaseEvent

use of net.catacombsnatch.game.event.input.events.KeyReleaseEvent in project Catacomb-Snatch by Catacomb-Snatch.

the class InputManager method keyUp.

@Override
public boolean keyUp(int keycode) {
    Scene scene = SceneManager.getCurrent();
    if (scene != null)
        scene.keyUp(keycode);
    InputSource source = InputSource.KEYBOARD;
    Key key = getKeyForSource(source, keycode, null);
    pressed.put(key, false);
    KeyReleaseEvent event = new KeyReleaseEvent(source, key, null);
    EventManager.callEvent(event);
    return true;
}
Also used : Scene(net.catacombsnatch.game.scene.Scene) KeyReleaseEvent(net.catacombsnatch.game.event.input.events.KeyReleaseEvent)

Example 2 with KeyReleaseEvent

use of net.catacombsnatch.game.event.input.events.KeyReleaseEvent in project Catacomb-Snatch by Catacomb-Snatch.

the class InputManager method buttonUp.

@Override
public boolean buttonUp(Controller controller, int button) {
    InputSource source = InputSource.CONTROLLER;
    Key key = getKeyForSource(source, button, controller);
    pressed.put(key, false);
    KeyReleaseEvent event = new KeyReleaseEvent(source, key, controller);
    EventManager.callEvent(event);
    return true;
}
Also used : KeyReleaseEvent(net.catacombsnatch.game.event.input.events.KeyReleaseEvent)

Example 3 with KeyReleaseEvent

use of net.catacombsnatch.game.event.input.events.KeyReleaseEvent in project Catacomb-Snatch by Catacomb-Snatch.

the class InputManager method povMoved.

@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    Gdx.app.log(TAG, "Controller: " + controller.getName() + " povCode: " + povCode + " Value: " + value);
    InputSource source = InputSource.CONTROLLER;
    this.axisMoved(controller, 5, controller.getAxis(5));
    this.axisMoved(controller, 6, controller.getAxis(6));
    Gdx.app.log(TAG, "Controller: " + controller.getName() + " Axis5 Value: " + controller.getAxis(5));
    Gdx.app.log(TAG, "Controller: " + controller.getName() + " Axis6 Value: " + controller.getAxis(6));
    if (value == PovDirection.south) {
        Key key = Key.MOVE_DOWN;
        pressed.put(key, true);
        KeyPressedEvent event = new KeyPressedEvent(source, key, controller);
        EventManager.callEvent(event);
        lastKey = key;
    } else if (value == PovDirection.north) {
        Key key = Key.MOVE_UP;
        pressed.put(key, true);
        KeyPressedEvent event = new KeyPressedEvent(source, key, controller);
        EventManager.callEvent(event);
        lastKey = key;
    } else if (value == PovDirection.west) {
        Key key = Key.MOVE_LEFT;
        pressed.put(key, true);
        KeyPressedEvent event = new KeyPressedEvent(source, key, controller);
        EventManager.callEvent(event);
        lastKey = key;
    } else if (value == PovDirection.east) {
        Key key = Key.MOVE_RIGHT;
        pressed.put(key, true);
        KeyPressedEvent event = new KeyPressedEvent(source, key, controller);
        EventManager.callEvent(event);
        lastKey = key;
    } else {
        if (lastKey != Key.UNKNOWN) {
            pressed.put(lastKey, false);
            KeyReleaseEvent event = new KeyReleaseEvent(source, lastKey, controller);
            EventManager.callEvent(event);
        }
    }
    // TODO
    return true;
}
Also used : KeyPressedEvent(net.catacombsnatch.game.event.input.events.KeyPressedEvent) KeyReleaseEvent(net.catacombsnatch.game.event.input.events.KeyReleaseEvent)

Aggregations

KeyReleaseEvent (net.catacombsnatch.game.event.input.events.KeyReleaseEvent)3 KeyPressedEvent (net.catacombsnatch.game.event.input.events.KeyPressedEvent)1 Scene (net.catacombsnatch.game.scene.Scene)1