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

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

Introduction

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

Prototype

int BUTTON_DPAD_DOWN

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

Click Source Link

Usage

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);
                }/*  ww w . j a v  a  2 s .c  o  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;
    }
}