Example usage for com.badlogic.gdx.controllers PovDirection northEast

List of usage examples for com.badlogic.gdx.controllers PovDirection northEast

Introduction

In this page you can find the example usage for com.badlogic.gdx.controllers PovDirection northEast.

Prototype

PovDirection northEast

To view the source code for com.badlogic.gdx.controllers PovDirection northEast.

Click Source Link

Usage

From source file:com.intrepid.nicge.controller.keyboard.KeyboardPOV.java

@Override
public void update() {
    direction = PovDirection.center;//from   www.j a  va  2 s . c  om

    boolean x = MathUtilz.logic.NXOR(left, right);
    boolean y = MathUtilz.logic.NXOR(up, down);

    if (x && y) {
        return;
    }

    if (x) {
        if (left) {
            direction = PovDirection.west;
        } else {
            direction = PovDirection.east;
        }
    }

    if (y) {
        if (direction == PovDirection.center) {
            if (up) {
                direction = PovDirection.north;
            } else {
                direction = PovDirection.south;
            }
        } else {
            if (up) {
                if (direction == PovDirection.east) {
                    direction = PovDirection.northEast;
                } else {
                    direction = PovDirection.northWest;
                }
            } else {
                if (direction == PovDirection.east) {
                    direction = PovDirection.southEast;
                } else {
                    direction = PovDirection.southWest;
                }
            }
        }
    }
}

From source file:org.ah.gcc.rover.desktop.DesktopRealController.java

License:Open Source License

@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
    // System.out.println("new pov: " + value.toString());
    if (value == PovDirection.center) {
        state.getHat1().set(JoystickState.zero());
    } else if (value == PovDirection.north) {
        state.getHat1().set(0, 1);/* ww  w  .j a  v  a2s  .  c o m*/
    } else if (value == PovDirection.south) {
        state.getHat1().set(0, -1);
    } else if (value == PovDirection.east) {
        state.getHat1().set(1, 0);
    } else if (value == PovDirection.west) {
        state.getHat1().set(-1, 0);
    } else if (value == PovDirection.northEast) {
        state.getHat1().set(1, 1);
    } else if (value == PovDirection.northWest) {
        state.getHat1().set(-1, 1);
    } else if (value == PovDirection.southEast) {
        state.getHat1().set(1, -1);
    } else if (value == PovDirection.southWest) {
        state.getHat1().set(-1, -1);
    }
    return false;
}

From source file:seventh.client.inputs.ControllerInput.java

License:Open Source License

/**
 * Determines if a particular button is down
 * // ww  w.  jav a2s . c o m
 * @param button
 * @return true if the button is down, false otherwise
 */
public boolean isButtonDown(ControllerButtons button) {
    switch (button) {
    case NORTH_DPAD_BTN:
        return isPovDirectionDown(PovDirection.north);
    case NE_DPAD_BTN:
        return isPovDirectionDown(PovDirection.northEast);
    case EAST_DPAD_BTN:
        return isPovDirectionDown(PovDirection.east);
    case SE_DPAD_BTN:
        return isPovDirectionDown(PovDirection.southEast);
    case SOUTH_DPAD_BTN:
        return isPovDirectionDown(PovDirection.south);
    case SW_DPAD_BTN:
        return isPovDirectionDown(PovDirection.southWest);
    case WEST_DPAD_BTN:
        return isPovDirectionDown(PovDirection.west);
    case NW_DPAD_BTN:
        return isPovDirectionDown(PovDirection.northWest);

    case LEFT_TRIGGER_BTN:
        return isLeftTriggerDown();
    case RIGHT_TRIGGER_BTN:
        return isRightTriggerDown();

    case LEFT_BUMPER_BTN:
        return this.buttons[4];
    case RIGHT_BUMPER_BTN:
        return this.buttons[5];

    case LEFT_JOYSTICK_BTN:
        return this.buttons[8];
    case RIGHT_JOYSTICK_BTN:
        return this.buttons[9];

    case START_BTN:
        return this.buttons[7];
    case SELECT_BTN:
        return this.buttons[6];

    case A_BTN:
        return this.buttons[0];
    case B_BTN:
        return this.buttons[1];
    case X_BTN:
        return this.buttons[2];
    case Y_BTN:
        return this.buttons[3];
    default:
        return false;
    }
}

From source file:seventh.client.inputs.JoystickGameController.java

License:Open Source License

public boolean isButtonReleased(ControllerButtons button) {
    switch (button) {
    case NORTH_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.north);
    case NE_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.northEast);
    case EAST_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.east);
    case SE_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.southEast);
    case SOUTH_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.south);
    case SW_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.southWest);
    case WEST_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.west);
    case NW_DPAD_BTN:
        return !isPovDirectionDown(PovDirection.northWest);

    case LEFT_TRIGGER_BTN:
        return !isLeftTriggerDown();
    case RIGHT_TRIGGER_BTN:
        return !isRightTriggerDown();

    case LEFT_BUMPER_BTN:
        return this.isButtonReleased[4];
    case RIGHT_BUMPER_BTN:
        return this.isButtonReleased[5];

    case LEFT_JOYSTICK_BTN:
        return this.isButtonReleased[8];
    case RIGHT_JOYSTICK_BTN:
        return this.isButtonReleased[9];

    case START_BTN:
        return this.isButtonReleased[7];
    case SELECT_BTN:
        return this.isButtonReleased[6];

    case A_BTN://  ww w.j  a  v  a2  s  .c  om
        return this.isButtonReleased[0];
    case B_BTN:
        return this.isButtonReleased[1];
    case X_BTN:
        return this.isButtonReleased[2];
    case Y_BTN:
        return this.isButtonReleased[3];
    default:
        return false;
    }
}

From source file:seventh.client.inputs.JoystickGameController.java

License:Open Source License

private int handleDPad(int inputKeys) {
    if (isPovDirectionDown(PovDirection.north)) {
        inputKeys |= Actions.UP.getMask();
    } else if (isPovDirectionDown(PovDirection.northEast)) {
        inputKeys |= Actions.UP.getMask();
        inputKeys |= Actions.RIGHT.getMask();
    }//from www  .java 2s .  co  m

    else if (isPovDirectionDown(PovDirection.northWest)) {
        inputKeys |= Actions.UP.getMask();
        inputKeys |= Actions.LEFT.getMask();
    }

    else if (isPovDirectionDown(PovDirection.south)) {
        inputKeys |= Actions.DOWN.getMask();
    } else if (isPovDirectionDown(PovDirection.southEast)) {
        inputKeys |= Actions.DOWN.getMask();
        inputKeys |= Actions.RIGHT.getMask();
    } else if (isPovDirectionDown(PovDirection.southWest)) {
        inputKeys |= Actions.DOWN.getMask();
        inputKeys |= Actions.LEFT.getMask();
    } else if (isPovDirectionDown(PovDirection.east)) {
        inputKeys |= Actions.RIGHT.getMask();
    } else if (isPovDirectionDown(PovDirection.west)) {
        inputKeys |= Actions.LEFT.getMask();
    }

    return inputKeys;
}