Example usage for com.badlogic.gdx.controllers.mappings Ouya BUTTON_A

List of usage examples for com.badlogic.gdx.controllers.mappings Ouya BUTTON_A

Introduction

In this page you can find the example usage for com.badlogic.gdx.controllers.mappings Ouya BUTTON_A.

Prototype

int BUTTON_A

To view the source code for com.badlogic.gdx.controllers.mappings Ouya BUTTON_A.

Click Source Link

Usage

From source file:ve.ucv.ciens.ccg.nxtar.states.AutomaticActionState.java

License:Apache License

@Override
public boolean buttonDown(Controller controller, int buttonCode) {
    if (stateActive) {
        if (buttonCode == Ouya.BUTTON_O && !startButton.isDisabled()) {
            oButtonPressed = true;//from  w  ww  .  j  av  a  2s . c  o  m
            startButton.setChecked(true);
        } else if (buttonCode == Ouya.BUTTON_A && !ignoreBackKey) {
            aButtonPressed = true;
        }

        return true;
    } else {
        return false;
    }
}

From source file:ve.ucv.ciens.ccg.nxtar.states.AutomaticActionState.java

License:Apache License

@Override
public boolean buttonUp(Controller controller, int buttonCode) {
    if (stateActive) {
        if (buttonCode == Ouya.BUTTON_O && oButtonPressed) {
            if (oButtonPressed) {
                oButtonPressed = false;//from w  w  w.  j a v  a 2 s.  c om
                startButton.setChecked(false);
                startButton.setDisabled(true);
                ignoreBackKey = true;
                automaticActionEnabled = true;
            }
        } else if (buttonCode == Ouya.BUTTON_A && aButtonPressed) {
            core.nextState = game_states_t.MAIN_MENU;
        }

        return true;
    } else {
        return false;
    }
}

From source file:ve.ucv.ciens.ccg.nxtar.states.InGameState.java

License:Apache License

@Override
public boolean buttonDown(Controller controller, int buttonCode) {
    MotorEvent event;//  ww w  .  ja v a 2 s  . co m
    GamepadUserInput userInput;

    if (stateActive) {
        Gdx.app.log(TAG, CLASS_NAME + ".buttonDown() :: " + controller.getName() + " :: "
                + Integer.toString(buttonCode));

        if (buttonCode == Ouya.BUTTON_L1) {
            gamepadButtonPressed[0] = true;

            if (!gamepadButtonPressed[4]) {
                event = new MotorEvent();
                event.setMotor(motor_t.MOTOR_A);
                event.setPower((byte) -100);
                queue.addEvent(event);
            }

        } else if (buttonCode == Ouya.BUTTON_R1) {
            gamepadButtonPressed[1] = true;

            if (!gamepadButtonPressed[5]) {
                event = new MotorEvent();
                event.setMotor(motor_t.MOTOR_C);
                event.setPower((byte) -100);
                queue.addEvent(event);
            }

        } else if (buttonCode == Ouya.BUTTON_DPAD_LEFT) {
            gamepadButtonPressed[2] = false;

            if (!gamepadButtonPressed[3]) {
                event = new MotorEvent();
                event.setMotor(motor_t.MOTOR_B);
                event.setPower((byte) -25);
                queue.addEvent(event);
            }

        } else if (buttonCode == Ouya.BUTTON_DPAD_RIGHT) {
            gamepadButtonPressed[3] = false;

            if (!gamepadButtonPressed[2]) {
                event = new MotorEvent();
                event.setMotor(motor_t.MOTOR_B);
                event.setPower((byte) 25);
                queue.addEvent(event);
            }

        } else if (buttonCode == Ouya.BUTTON_L2) {
            gamepadButtonPressed[4] = false;

            if (!gamepadButtonPressed[0]) {
                event = new MotorEvent();
                event.setMotor(motor_t.MOTOR_A);
                event.setPower((byte) 100);
                queue.addEvent(event);
            }

        } else if (buttonCode == Ouya.BUTTON_R2) {
            gamepadButtonPressed[5] = false;

            if (!gamepadButtonPressed[1]) {
                event = new MotorEvent();
                event.setMotor(motor_t.MOTOR_C);
                event.setPower((byte) 100);
                queue.addEvent(event);
            }

        } else if (buttonCode == Ouya.BUTTON_Y) {
            gamepadButtonPressed[6] = true;

            event = new MotorEvent();
            event.setMotor(motor_t.RECENTER);
            event.setPower((byte) 0x00);
            queue.addEvent(event);

        } else if (buttonCode == Ouya.BUTTON_O) {
            userInput = new GamepadUserInput();
            userInput.oButton = true;
            robotArmPositioningSystem.setUserInput(userInput);
            robotArmPositioningSystem.process();

        } else if (buttonCode == Ouya.BUTTON_U) {
            core.nextState = game_states_t.HINTS;
        } else if (buttonCode == Ouya.BUTTON_A || buttonCode == Ouya.BUTTON_MENU) {
            core.nextState = game_states_t.MAIN_MENU;
        }

        return true;
    } else {
        return false;
    }
}