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

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

Introduction

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

Prototype

int BUTTON_O

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

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;//w  ww.j  a  v  a 2 s  .  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;/*  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.AutomaticActionSummaryState.java

License:Apache License

@Override
public boolean buttonDown(Controller controller, int buttonCode) {
    if (stateActive) {
        if (buttonCode == Ouya.BUTTON_O && !continueButton.isDisabled()) {
            Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button pressed.");
            oButtonPressed = true;/*from www . j a va 2  s .  c om*/
            continueButton.setChecked(true);
        }
        return true;
    } else {
        return false;
    }
}

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

License:Apache License

@Override
public boolean buttonUp(Controller controller, int buttonCode) {
    if (stateActive) {
        if (buttonCode == Ouya.BUTTON_O) {
            Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button released.");
            if (oButtonPressed) {
                oButtonPressed = false;/*from w  w w  .ja v a  2  s  .  com*/
                continueButton.setChecked(false);
                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;/*from w w w . j a  v  a  2 s  .  c om*/
    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;
    }
}

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

License:Apache License

@Override
public boolean buttonUp(Controller controller, int buttonCode) {
    if (stateActive) {
        if (buttonCode == Ouya.BUTTON_O) {
            Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button released.");
            if (oButtonPressed) {
                oButtonPressed = false;// w  w  w  .  ja  va 2s . com
                continueButton.setChecked(false);
                core.nextState = game_states_t.IN_GAME;
            }
        }
        return true;
    } else {
        return false;
    }
}

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

License:Apache License

@Override
public boolean buttonDown(Controller controller, int buttonCode) {
    if (stateActive) {
        if (buttonCode == Ouya.BUTTON_O) {
            Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button pressed.");

            if (oButtonSelection == 0) {
                if (!clientConnected) {
                    core.toast("Can't start the game. No client is connected.", true);
                } else if (!core.cvProc.isCameraCalibrated()) {
                    core.toast("Can't start the game. Camera is not calibrated.", true);
                } else {
                    oButtonPressed = true;
                    startButton.setChecked(true);
                }//from   w  w w. ja  v  a 2  s  . co m
            } else if (oButtonSelection == 1) {
                if (!clientConnected) {
                    core.toast("Can't calibrate the camera. No client is connected.", true);
                } else {
                    oButtonPressed = true;
                    calibrationButton.setChecked(true);
                }
            } else if (oButtonSelection == 2) {
                if (!clientConnected) {
                    core.toast("Can't launch automatic action. No client is connected.", true);
                } else {
                    oButtonPressed = true;
                    autoButton.setChecked(true);
                }
            }
        } else if (buttonCode == Ouya.BUTTON_DPAD_UP) {
            Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad up button pressed.");
            oButtonSelection = (oButtonSelection + 1) % NUM_MENU_BUTTONS;
        } else if (buttonCode == Ouya.BUTTON_DPAD_DOWN) {
            Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad down button pressed.");
            oButtonSelection = oButtonSelection - 1 < 0 ? NUM_MENU_BUTTONS - 1 : oButtonSelection - 1;
        }

        return true;
    } else {
        return false;
    }
}

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

License:Apache License

@Override
public boolean buttonUp(Controller controller, int buttonCode) {
    if (stateActive) {
        if (buttonCode == Ouya.BUTTON_O) {
            Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button released.");

            if (oButtonPressed) {
                oButtonPressed = false;//w ww . ja v  a2 s  .  c  o  m

                if (oButtonSelection == 0) {
                    startButton.setChecked(false);
                    core.nextState = game_states_t.IN_GAME;
                } else if (oButtonSelection == 1) {
                    calibrationButton.setChecked(false);
                    core.nextState = game_states_t.CALIBRATION;
                } else if (oButtonSelection == 2) {
                    autoButton.setChecked(false);
                    core.nextState = game_states_t.AUTOMATIC_ACTION;
                }
            }
        }

        return true;
    } else {
        return false;
    }
}