Esempio n. 1
0
 public InputAxisEvent(InputAction inputAction, OuyaSDK.AxisEnum axisEnum, float axis, OuyaPlayer player)
 {
     m_inputAction = inputAction;
     m_axisCode    = axisEnum;
     m_axis        = axis;
     m_player      = player;
 }
Esempio n. 2
0
 public static bool GetButton(GenericButton button, OuyaPlayer p = OuyaPlayer.P01)
 {
     switch (button)
     {
         case GenericButton.O:
             return OuyaInput.GetButton(OuyaButton.O, p) || Input.GetButton("O");
             break;
         case GenericButton.U:
             return OuyaInput.GetButton(OuyaButton.U, p) || Input.GetButton("U");
             break;
         case GenericButton.Y:
             return OuyaInput.GetButton(OuyaButton.Y, p) || Input.GetButton("Y");
             break;
         case GenericButton.A:
             return OuyaInput.GetButton(OuyaButton.A, p) || Input.GetButton("A");
             break;
         case GenericButton.LB:
             return OuyaInput.GetButton(OuyaButton.LB, p) || Input.GetButton("LB");
             break;
         case GenericButton.RB:
             return OuyaInput.GetButton(OuyaButton.RB, p) || Input.GetButton("RB");
             break;
         case GenericButton.L3:
             return OuyaInput.GetButton(OuyaButton.L3, p) || Input.GetButton("L3");
             break;
         case GenericButton.R3:
             return OuyaInput.GetButton(OuyaButton.R3, p) || Input.GetButton("R3");
             break;
         case GenericButton.LT:
             return OuyaInput.GetButton(OuyaButton.LT, p) || Input.GetButton("LT");
             break;
         case GenericButton.RT:
             return OuyaInput.GetButton(OuyaButton.RT, p) || Input.GetButton("RT");
             break;
         case GenericButton.DU:
             return OuyaInput.GetButton(OuyaButton.DU, p) || Input.GetButton("DU");
             break;
         case GenericButton.DD:
             return OuyaInput.GetButton(OuyaButton.DD, p) || Input.GetButton("DD");
             break;
         case GenericButton.DL:
             return OuyaInput.GetButton(OuyaButton.DL, p) || Input.GetButton("DL");
             break;
         case GenericButton.DR:
             return OuyaInput.GetButton(OuyaButton.DR, p) || Input.GetButton("DR");
             break;
         case GenericButton.START:
             return OuyaInput.GetButton(OuyaButton.START, p) || Input.GetButton("START");
             break;
         case GenericButton.SELECT:
             return OuyaInput.GetButton(OuyaButton.SELECT, p) || Input.GetButton("SELECT");
             break;
         case GenericButton.SYSTEM:
             return OuyaInput.GetButton(OuyaButton.SYSTEM, p) || Input.GetButton("SYSTEM");
             break;
         default:
             return false;
             break;
     }
 }
Esempio n. 3
0
 public static float GetAxis(GenericAxis axis, OuyaPlayer p = OuyaPlayer.P01)
 {
     switch (axis)
     {
         case GenericAxis.LX:
             return OuyaInput.GetAxis(OuyaAxis.LX, p) + Input.GetAxis("LX");
             break;
         case GenericAxis.LY:
             return OuyaInput.GetAxis(OuyaAxis.LY, p) + Input.GetAxis("LY");
             break;
         case GenericAxis.RX:
             return OuyaInput.GetAxis(OuyaAxis.RX, p) + Input.GetAxis("RX");
             break;
         case GenericAxis.RY:
             return OuyaInput.GetAxis(OuyaAxis.RY, p) + Input.GetAxis("RY");
             break;
         case GenericAxis.LT:
             return OuyaInput.GetAxis(OuyaAxis.LT, p) + Input.GetAxis("LT");
             break;
         case GenericAxis.RT:
             return OuyaInput.GetAxis(OuyaAxis.RT, p) + Input.GetAxis("RT");
             break;
         case GenericAxis.DX:
             return OuyaInput.GetAxis(OuyaAxis.DX, p) + Input.GetAxis("DX");
             break;
         case GenericAxis.DY:
             return OuyaInput.GetAxis(OuyaAxis.DY, p) + Input.GetAxis("DY");
             break;
         default:
             return 0;
             break;
     }
 }
Esempio n. 4
0
 public static OuyaMapType GetControllerType(OuyaPlayer player)
 {
     /* returns the controller type (enum) for a designated player
      */
     int index = (int)player - 1;
     if (controllerCount == 0) return OuyaMapType.None;
     else return mapTypes[index];
 }
Esempio n. 5
0
 public static string GetControllerName(OuyaPlayer player)
 {
     /* returns the Unity name of the controller for a designated player
      */
     int index = (int)player - 1;
     if (controllerNames == null || index >= controllerCount) return "No controller found!";
     else return controllerNames[index];
 }
Esempio n. 6
0
 public static bool GetButtonUp(OuyaButton button, OuyaPlayer player)
 {
     /* this serves as the OUYA eguivalent to UNITY's Input.GetButtonUp()
      * returns true for the frame the button actually goes up
      */
     // return the button state for the frame it goes down (down event)
     return GetButton(button, ButtonAction.UpFrame, player);
 }
Esempio n. 7
0
 public static bool GetButton(OuyaButton button, OuyaPlayer player)
 {
     /* this serves as the OUYA eguivalent to UNITY's Input.GetButton()
      * returns true if the button is pressed
      */
     // return the button state for pressed (down state)
     return GetButton(button, ButtonAction.Pressed, player);
 }
Esempio n. 8
0
    public static float GetAxis(OuyaAxis axis, OuyaPlayer player)
    {
        /* for retreiving joystick axis values from mapped Unity Input
         */

        /* NULL SECURITY */
        // check if there is no joystick connected
        if (controllerCount == 0) return 0f;

        // check if there have more players than controllers
        // we consider that the array position is starting at 0 for player 1
        int playerIndex = (int)player - 1;
        if (playerIndex < 0 || playerIndex >= controllerCount) return 0f;

        // finally check if we really found a controller for the player
        OuyaMapType mapType = mapTypes[playerIndex];

        /* GET MAPPED AXIS NAME */
        // prepare fields for storing the results
        string axisName = null; bool invert = false;

        // get the controller mapping for the player
        PlayerController playerController = playerControllers[playerIndex];
        // secure that we have found a mapping
        if (playerController == null) return 0f;
        else
        {
            /* JOYSTICKS */
            // get the axis name for the player controller
            switch (axis)
            {
                case OuyaAxis.LX: axisName = playerController.map_LX; invert = playerController.invert_LX; break;
                case OuyaAxis.LY: axisName = playerController.map_LY; invert = playerController.invert_LY; break;
                case OuyaAxis.RX: axisName = playerController.map_RX; invert = playerController.invert_RX; break;
                case OuyaAxis.RY: axisName = playerController.map_RY; invert = playerController.invert_RY; break;

                /* TRIGGERS & D-PAD */
                // the dpad and triggers are sometimes treated like an axis joystick
                // sometimes however it is just a set of buttons and the pressure senitivity is missing
                // this was observed for MacOS XBOX360 (TattieBogle) / Android Ouya / Android + MacOS PS3
                /* LT-TRIGGER */
                case OuyaAxis.LT: axisName = playerController.map_LT; invert = playerController.invert_LT;
                    // if the trigger is treated like a button we convert button press bool flags into axis values
                    if (axisName == null)
                    {
                        switch (mapType)
                        {
                            case OuyaMapType.MotionInJoy_WIN:
                            case OuyaMapType.PS3_ANDROID:
                            case OuyaMapType.PS3_OSX:
                                if (GetButton(OuyaButton.LT, player)) return 1f;
                                else return 0f;
                        }
                    }
                    break;
                /* RT-TRIGGER */
                case OuyaAxis.RT: axisName = playerController.map_RT; invert = playerController.invert_RT;
                    // if the trigger is treated like a button we convert button press bool flags into axis values
                    if (axisName == null)
                    {
                        switch (mapType)
                        {
                            case OuyaMapType.MotionInJoy_WIN:
                            case OuyaMapType.PS3_ANDROID:
                            case OuyaMapType.PS3_OSX:
                                if (GetButton(OuyaButton.RT, player)) return 1f;
                                else return 0f;
                        }
                    }
                    break;
                /* DX-AXIS */
                case OuyaAxis.DX: axisName = playerController.map_DX; invert = playerController.invert_DX;
                    // if the dpad is treated like a button we convert button press bool flags into axis values
                    if (axisName == null)
                    {
                        switch (mapType)
                        {
        #if !UNITY_EDITOR && UNITY_ANDROID
                        case OuyaMapType.Generic_ANDROID:
                        case OuyaMapType.Broadcom_ANDROID:
                        case OuyaMapType.Ouya_CONSOLE:
                        case OuyaMapType.PS3_ANDROID:
                        case OuyaMapType.XBOX360_ANDROID_wireless:
                        if (GetButton(OuyaButton.DL, player)) return -1f;
                        else if (GetButton(OuyaButton.DR, player)) return 1f;
                        break;
        #endif
        #if UNITY_EDITOR || UNITY_STANDALONE_WIN
                            case OuyaMapType.Ouya_WIN:
                            case OuyaMapType.MotionInJoy_WIN:
                                if (GetButton(OuyaButton.DL, player)) return -1f;
                                else if (GetButton(OuyaButton.DR, player)) return 1f;
                                break;
        #endif
        #if UNITY_EDITOR || UNITY_STANDALONE_OSX
                            case OuyaMapType.PS3_OSX:
                            case OuyaMapType.TattieBogle_OSX:
                                if (GetButton(OuyaButton.DL, player)) return -1f;
                                else if (GetButton(OuyaButton.DR, player)) return 1f;
                                break;
        #endif
                        }
                    } break;
                /* DY-AXIS */
                case OuyaAxis.DY: axisName = playerController.map_DY; invert = playerController.invert_DY;
                    // if the dpad is treated like a button we convert button press bool flags into axis values
                    if (axisName == null)
                    {
                        switch (mapType)
                        {
        #if !UNITY_EDITOR && UNITY_ANDROID
                        case OuyaMapType.Generic_ANDROID:
                        case OuyaMapType.Broadcom_ANDROID:
                        case OuyaMapType.Ouya_CONSOLE:
                        case OuyaMapType.PS3_ANDROID:
                        case OuyaMapType.XBOX360_ANDROID_wireless:
                        if (GetButton(OuyaButton.DD, player)) return -1f;
                        else if (GetButton(OuyaButton.DU, player)) return 1f;
                        break;
        #endif
        #if UNITY_EDITOR || UNITY_STANDALONE_WIN
                            case OuyaMapType.Ouya_WIN:
                            case OuyaMapType.MotionInJoy_WIN:
                                if (GetButton(OuyaButton.DD, player)) return -1f;
                                else if (GetButton(OuyaButton.DU, player)) return 1f;
                                break;
        #endif
        #if UNITY_EDITOR || UNITY_STANDALONE_OSX
                            case OuyaMapType.PS3_OSX:
                            case OuyaMapType.TattieBogle_OSX:
                                if (GetButton(OuyaButton.DD, player)) return -1f;
                                else if (GetButton(OuyaButton.DU, player)) return 1f;
                                break;
        #endif
                        }
                    } break;

                default: return 0f;
            }
        }
        /* FINAL SECURITY CHECK */
        // we return 0 if we didn't find a valid axis
        if (axisName == null) return 0f;

        /* TRIGGER AXIS RANGE MAPPING */
        if (axis == OuyaAxis.LT || axis == OuyaAxis.RT)
        {
            // some trigger axis need to be remapped inrange before we can return the Unity Input
            if (invert) return playerController.rangeMapTriggerAxis(-Input.GetAxisRaw(axisName), axis);
            else return playerController.rangeMapTriggerAxis(Input.GetAxisRaw(axisName), axis);
        }
        /* AXIS FLOAT RESULT FROM UNITY INPUT */
        if (invert) return -Input.GetAxisRaw(axisName);
        else return Input.GetAxisRaw(axisName);
    }
Esempio n. 9
0
    private static bool GetButton(OuyaButton button, ButtonAction buttonAction, OuyaPlayer player)
    {
        /* for retreiving joystick button values from mapped Unity Input
         */

        /* NULL SECURITY */
        // check if there is no joystick connected
        if (controllerNames == null) return false;

        // check if there are more players than joysticks
        // this is not really needed in CLARK – just framework coherence
        int playerIndex = (int) player - 1;
        if (playerIndex >= controllerCount) return false;

        // finally check if we really found a joystick for the player
        OuyaControllerType controllerType = controllerTypes[playerIndex];

        // get the controller mapping for the player
        PlayerController playerController = playerControllers[playerIndex];

        // secure that we have found a mapping
        if (playerController != null) {

        /* FIND THE CORRECT MAPPED BUTTON KEY */
            switch (controllerType) {
        #if !UNITY_EDITOR && UNITY_ANDROID
            case OuyaControllerType.Broadcom:
            case OuyaControllerType.MogaPro:
                // this device was not tested yet
                // the setting were just extracted from some examples I found
                // please feedback if you find a way to test it
                switch (button)
                {
                // shoulder buttons
                case OuyaButton.LB:		return GetButton(6, buttonAction, player);
                case OuyaButton.RB:		return GetButton(7, buttonAction, player);

                // OUYA buttons
                case OuyaButton.O:		return GetButton(0, buttonAction, player);
                case OuyaButton.U:		return GetButton(3, buttonAction, player);
                case OuyaButton.Y:		return GetButton(4, buttonAction, player);
                case OuyaButton.A:		return GetButton(1, buttonAction, player);

                // stick buttons
                case OuyaButton.L3:		return GetButton(13, buttonAction, player);
                case OuyaButton.R3:		return GetButton(14, buttonAction, player);

                // d-pad buttons and trigger buttons
                // these buttons are two axis and do not give out UP or DOWN events natively
                // we use button state management and continious scanning to provide these
                case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.LT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.RT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);

                // not defined so far
                case OuyaButton.START: 	return false;
                case OuyaButton.SELECT: return false;
                case OuyaButton.SYSTEM:	return false;
                default: return false;
                }

            case OuyaControllerType.GameStick:
                // tested on the real GameStick DevKit
                // never succeded in pairing the controller with the Ouya, Mac, Windows
                // strangely enough the flat d-pad has pressure sensitive axis output
                // triggers do not exist at all on this controller
                switch (button)
                {
                // OUYA buttons
                case OuyaButton.O: 		return GetButton(0, buttonAction, player);		// checked
                case OuyaButton.U: 		return GetButton(3, buttonAction, player);		// checked
                case OuyaButton.Y: 		return GetButton(4, buttonAction, player);		// checked
                case OuyaButton.A: 		return GetButton(1, buttonAction, player);		// checked

                // shoulder buttons
                case OuyaButton.LB: 	return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.RB: 	return GetButton(7, buttonAction, player);		// checked

                // stick buttons
                case OuyaButton.L3: 	return GetButton(13, buttonAction, player);		// checked
                case OuyaButton.R3: 	return GetButton(14, buttonAction, player);		// checked

                // center buttons
                case OuyaButton.SELECT: return GetButton(27, buttonAction, player);		// checked
                case OuyaButton.START: 	return GetButton(11, buttonAction, player);		// checked

                // d-pad buttons
                // these buttons are two axis and do not give out UP or DOWN events natively
                // we use button state management and continious scanning to provide these
                case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                // the GameStick has no triggers
                case OuyaButton.LT: return false;
                case OuyaButton.RT: return false;

                // SYSTEN is according to GameStick documents: joystick button 20
                // but this is not valid in Unity (see script reference Keycode)
                case OuyaButton.SYSTEM: return false;
                default: return false;
                }
        #endif
            case OuyaControllerType.Ouya:
        #if !UNITY_EDITOR && UNITY_ANDROID
                // tested on the real Ouya Developers Console
                // the d-pad has no pressure sensitive output although the hardware looks like it
                // triggers have both: pressure sensitive axis and button event output (nice)
                switch (button)
                {
                // shoulder buttons
                case OuyaButton.LB: 	return GetButton(4, buttonAction, player);		// checked
                case OuyaButton.RB: 	return GetButton(5, buttonAction, player);		// checked

                // OUYA buttons
                case OuyaButton.O:		return GetButton(0, buttonAction, player);		// checked
                case OuyaButton.U:		return GetButton(1, buttonAction, player);		// checked
                case OuyaButton.Y:		return GetButton(2, buttonAction, player);		// checked
                case OuyaButton.A:		return GetButton(3, buttonAction, player);		// checked

                // stick buttons
                case OuyaButton.L3:		return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.R3:		return GetButton(7, buttonAction, player);		// checked

                // d-pad buttons
                case OuyaButton.DU:		return GetButton(8, buttonAction, player);		// checked
                case OuyaButton.DD:		return GetButton(9, buttonAction, player);		// checked
                case OuyaButton.DL:		return GetButton(10, buttonAction, player);		// checked
                case OuyaButton.DR:		return GetButton(11, buttonAction, player);		// checked

                // trigger buttons
                case OuyaButton.LT:		return GetButton(12, buttonAction, player);		// checked
                case OuyaButton.RT:		return GetButton(13, buttonAction, player);		// checked

                // not defined so far – or don't exist on OUYA
                case OuyaButton.START: return false;
                case OuyaButton.SYSTEM: return false;
                case OuyaButton.SELECT: return false;
                default: return false;
                }
        #else
                // tested on Windows8 64bit (standalone player) – pairing via OS Bluetooth driver
                // the d-pad has no pressure sensitive output although the hardware looks like it
                // triggers have both: pressure sensitive axis and button event output
                // however trigger buttons only react on full pullthrough
                // therefore we prefer to use axis conversion
                switch (button)
                {
                // shoulder buttons
                case OuyaButton.LB: 	return GetButton(4, buttonAction, player);		// checked
                case OuyaButton.RB: 	return GetButton(5, buttonAction, player);		// checked

                // OUYA buttons
                case OuyaButton.O:		return GetButton(0, buttonAction, player);		// checked
                case OuyaButton.U:		return GetButton(1, buttonAction, player);		// checked
                case OuyaButton.Y:		return GetButton(2, buttonAction, player);		// checked
                case OuyaButton.A:		return GetButton(3, buttonAction, player);		// checked

                // stick buttons
                case OuyaButton.L3:		return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.R3:		return GetButton(7, buttonAction, player);		// checked

                // d-pad buttons
                case OuyaButton.DU:		return GetButton(8, buttonAction, player);		// checked
                case OuyaButton.DD:		return GetButton(9, buttonAction, player);		// checked
                case OuyaButton.DL:		return GetButton(10, buttonAction, player);		// checked
                case OuyaButton.DR:		return GetButton(11, buttonAction, player);		// checked

                // trigger buttons
                // although button states are natively supported we use axis conversion
                // this is because trigger buttons will natively only react on full pullthrough
                // these buttons then are two axis and do not give out UP or DOWN events natively
                // we use button state management and continious scanning to provide these
                case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                // not defined so far – or don't exist on OUYA
                case OuyaButton.START: return false;
                case OuyaButton.SYSTEM: return false;
                case OuyaButton.SELECT: return false;
                default: return false;
                }
        #endif
            case OuyaControllerType.XBox360:
        #if !UNITY_EDITOR && UNITY_ANDROID
                // tested with the XBOX360 standard controller connected to the OUYA via USB
                // hopefully wireless XBOX controllers connected via Bluetooth have the same values
                // the d-pad has sensitive pressure axis output – however we won't get button events
                // we need to use continious input scanning for managing Buttonup or ButtonDown events
                // the same is true for the pressure sensitive axis triggers
                switch (button)
                {
                // OUYA buttons
                case OuyaButton.O: 		return GetButton(0, buttonAction, player);		// checked
                case OuyaButton.U: 		return GetButton(3, buttonAction, player);		// checked
                case OuyaButton.Y: 		return GetButton(4, buttonAction, player);		// checked
           		case OuyaButton.A: 		return GetButton(1, buttonAction, player);		// checked

                // shoulder buttons
                case OuyaButton.LB:		return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.RB:		return GetButton(7, buttonAction, player);		// checked

                // center buttons
                case OuyaButton.START: 	return GetButton(11, buttonAction, player);		// checked
                case OuyaButton.SELECT:	return GetButton(27, buttonAction, player);

                // stick buttons
                case OuyaButton.L3: 	return GetButton(13, buttonAction, player);		// checked
                case OuyaButton.R3: 	return GetButton(14, buttonAction, player);		// checked

                // d-pad buttons and trigger buttons
                // these buttons are two axis and do not give out UP or DOWN events natively
                // we use button state management and continious scanning to provide these
                case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.LT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.RT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);

                // not defined so far
                case OuyaButton.SYSTEM: return false;
                default: return false;
                }
        #else
                switch (button)
                // tested with the XBOX360 standard controller connected to a Win64 machine via USB and official driver
                // hopefully wireless XBOX controllers connected via Bluetooth have the same values
                // the d-pad has sensitive pressure axis output – however we won't get button events
                // we need to use continious input scanning for managing Buttonup or ButtonDown events
                // the same is true for the pressure sensitive axis triggers
                // this block won't treat the XBOX360 controller running on MacOSX
                // on MacOSX we use the TattieBogle driver which leads to a different controller type
                {
                // OUYA buttons
                case OuyaButton.O:		return GetButton(0, buttonAction, player);		// checked
                case OuyaButton.U:		return GetButton(2, buttonAction, player);		// checked
                case OuyaButton.Y:		return GetButton(3, buttonAction, player);		// checked
                case OuyaButton.A:		return GetButton(1, buttonAction, player);		// checked

                // shoulder buttons
                case OuyaButton.LB:		return GetButton(4, buttonAction, player);		// checked
                case OuyaButton.RB:		return GetButton(5, buttonAction, player);		// checked

                // center buttons
                case OuyaButton.START:	return GetButton(7, buttonAction, player);		// checked
                case OuyaButton.SELECT: return GetButton(6, buttonAction, player);		// checked

                // stick buttons
                case OuyaButton.L3: 	return GetButton(8, buttonAction, player);		// checked
                case OuyaButton.R3: 	return GetButton(9, buttonAction, player);		// checked

                // d-pad buttons and trigger buttons
                // these buttons are two axis and do not give out UP or DOWN events natively
                // we use button state management and continious scanning to provide these
                case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.LT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.RT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);

                //  not defined so far
                case OuyaButton.SYSTEM: return false;
                default: return false;
                }
        #endif
            case OuyaControllerType.PS3:
        #if !UNITY_EDITOR && UNITY_ANDROID
                // tested with the PS3 standard controller connected to the OUYA via Bluetooth
                // pairing was achieved using a temporary USB cable connection to the OUYA
                // the d-pad uses simple button events – there is no pressure sensitivity here
                // triggers have both: pressure sentive axis output as well as button events
                switch (button)
                {
               	// stick buttons
                case OuyaButton.L3: 	return GetButton(1, buttonAction, player);		// checked
                case OuyaButton.R3: 	return GetButton(2, buttonAction, player);		// checked

                // center buttons
                case OuyaButton.START: 	return GetButton(3, buttonAction, player);		// checked
                case OuyaButton.SELECT: return GetButton(27, buttonAction, player);		// checked

                // d-pad buttons
                case OuyaButton.DU:		return GetButton(4, buttonAction, player);		// checked
                case OuyaButton.DR:		return GetButton(5, buttonAction, player);		// checked
                case OuyaButton.DD:		return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.DL:		return GetButton(7, buttonAction, player);		// checked

                // trigger buttons
                case OuyaButton.LT: 	return GetButton(8, buttonAction, player);		// checked
                case OuyaButton.RT: 	return GetButton(9, buttonAction, player);		// checked

                // shoulder buttons
                case OuyaButton.LB:		return GetButton(10, buttonAction, player);		// checked
                case OuyaButton.RB:		return GetButton(11, buttonAction, player);		// checked

                // OUYA buttons
                case OuyaButton.O:		return GetButton(14, buttonAction, player);		// checked
                case OuyaButton.U:		return GetButton(15, buttonAction, player);		// checked
                case OuyaButton.Y:		return GetButton(12, buttonAction, player);		// checked
                case OuyaButton.A:		return GetButton(13, buttonAction, player);		// checked

                // not defined do far
                case OuyaButton.SYSTEM: return false;
                default: return false;
                }
        #elif !UNITY_EDITOR && UNITY_STANDALONE_OSX
                // tested with the PS3 standard controller connected to the MacOSX via Bluetooth
                // pairing was achieved using a temporary USB cable connection to the Mac
                // the d-pad and triggers use simple button events – there is no pressure sensitivity here
                // this is because the standard Mac connection doesn't show all the features of the controller
                // we would need a designated 3rd party driver for that
                switch (button)
                {
               	// stick buttons
                case OuyaButton.L3: 	return GetButton(1, buttonAction, player);		// checked
                case OuyaButton.R3: 	return GetButton(2, buttonAction, player);		// checked

                // center buttons
                case OuyaButton.START: 	return GetButton(3, buttonAction, player);		// checked
                case OuyaButton.SELECT: return GetButton(0, buttonAction, player);		// checked

                // d-pad buttons
                case OuyaButton.DU:		return GetButton(4, buttonAction, player);		// checked
                case OuyaButton.DR:		return GetButton(5, buttonAction, player);		// checked
                case OuyaButton.DD:		return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.DL:		return GetButton(7, buttonAction, player);		// checked

                // trigger buttons
                case OuyaButton.LT: 	return GetButton(8, buttonAction, player);		// checked
                case OuyaButton.RT: 	return GetButton(9, buttonAction, player);		// checked

                // shoulder buttons
                case OuyaButton.LB:		return GetButton(10, buttonAction, player);		// checked
                case OuyaButton.RB:		return GetButton(11, buttonAction, player);		// checked

                // OUYA buttons
                case OuyaButton.O:		return GetButton(14, buttonAction, player);		// checked
                case OuyaButton.U:		return GetButton(15, buttonAction, player);		// checked
                case OuyaButton.Y:		return GetButton(12, buttonAction, player);		// checked
                case OuyaButton.A:		return GetButton(13, buttonAction, player);		// checked

                // not defined do far
                case OuyaButton.SYSTEM: return false;
                default: return false;
                }
        #elif !UNITY_EDITOR && UNITY_STANDALONE_WIN
                // tested with the PS3 standard controller connected to Win7 64 via USB
                // custom setup was done using the most popular but crappy driver: MotionInJoy
                // this needs a CUSTOM button mapping setup in the driver tools to work (see documentation)
                // default sets could not be used as they do not make sense (gyro's and sticks share the same axis)
                // the d-pad use simple button events – there is no pressure sensitivity here
                // the triggers provide both: pressure sensitive axis output and button events
                // READ THE DOCUMENTATION to make this work !!!
                switch (button)
                {
                // OUYA buttons
                case OuyaButton.O:		return GetButton(2, buttonAction, player);		// checked
                case OuyaButton.U:		return GetButton(3, buttonAction, player);		// checked
                case OuyaButton.Y:		return GetButton(0, buttonAction, player);		// checked
                case OuyaButton.A:		return GetButton(1, buttonAction, player);		// checked

                // shoulder buttons
                case OuyaButton.LB:		return GetButton(4, buttonAction, player);		// checked
                case OuyaButton.RB:		return GetButton(5, buttonAction, player);		// checked

                // trigger buttons
                case OuyaButton.LT: 	return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.RT: 	return GetButton(7, buttonAction, player);		// checked

               	// stick buttons
                case OuyaButton.L3: 	return GetButton(8, buttonAction, player);		// checked
                case OuyaButton.R3: 	return GetButton(9, buttonAction, player);		// checked

                // center buttons
                case OuyaButton.SELECT: return GetButton(10, buttonAction, player);		// checked
                case OuyaButton.START: 	return GetButton(11, buttonAction, player);		// checked
                case OuyaButton.SYSTEM: return GetButton(12, buttonAction, player);		// checked

                // d-pad buttons
                case OuyaButton.DU:		return GetButton(13, buttonAction, player);		// checked
                case OuyaButton.DR:		return GetButton(14, buttonAction, player);		// checked
                case OuyaButton.DD:		return GetButton(15, buttonAction, player);		// checked
                case OuyaButton.DL:		return GetButton(16, buttonAction, player);		// checked

                // not defined do far
                default: return false;
                }
        #elif UNITY_EDITOR
                // the editor receives platform specific inputs which are not covered by the procompile macros
                // therefore the testing developer will have to set the Editor Working Platform
                // otherwise this code copies the data of the Windows and MacOSX platforms
                if (editorWorkPlatform == EditorWorkPlatform.MacOS) {
                    // MacOSX via standard Bluetooth connection
                    switch (button)
                    {
                   	// stick buttons
                    case OuyaButton.L3: 	return GetButton(1, buttonAction, player);		// checked
                    case OuyaButton.R3: 	return GetButton(2, buttonAction, player);		// checked

                    // center buttons
                    case OuyaButton.START: 	return GetButton(3, buttonAction, player);		// checked
                    case OuyaButton.SELECT: return GetButton(0, buttonAction, player);		// checked

                    // d-pad buttons
                    case OuyaButton.DU:		return GetButton(4, buttonAction, player);		// checked
                    case OuyaButton.DR:		return GetButton(5, buttonAction, player);		// checked
                    case OuyaButton.DD:		return GetButton(6, buttonAction, player);		// checked
                    case OuyaButton.DL:		return GetButton(7, buttonAction, player);		// checked

                    // trigger buttons
                    case OuyaButton.LT: 	return GetButton(8, buttonAction, player);		// checked
                    case OuyaButton.RT: 	return GetButton(9, buttonAction, player);		// checked

                    // shoulder buttons
                    case OuyaButton.LB:		return GetButton(10, buttonAction, player);		// checked
                    case OuyaButton.RB:		return GetButton(11, buttonAction, player);		// checked

                    // OUYA buttons
                    case OuyaButton.O:		return GetButton(14, buttonAction, player);		// checked
                    case OuyaButton.U:		return GetButton(15, buttonAction, player);		// checked
                    case OuyaButton.Y:		return GetButton(12, buttonAction, player);		// checked
                    case OuyaButton.A:		return GetButton(13, buttonAction, player);		// checked

                    // not defined do far
                    case OuyaButton.SYSTEM: return false;
                    default: return false;
                    }
                } else {
                    // Windows7 via USB and MotionInJoy driver
                    switch (button)
                    {
                    // OUYA buttons
                    case OuyaButton.O:		return GetButton(2, buttonAction, player);		// checked
                    case OuyaButton.U:		return GetButton(3, buttonAction, player);		// checked
                    case OuyaButton.Y:		return GetButton(0, buttonAction, player);		// checked
                    case OuyaButton.A:		return GetButton(1, buttonAction, player);		// checked

                    // shoulder buttons
                    case OuyaButton.LB:		return GetButton(4, buttonAction, player);		// checked
                    case OuyaButton.RB:		return GetButton(5, buttonAction, player);		// checked

                    // trigger buttons
                    case OuyaButton.LT: 	return GetButton(6, buttonAction, player);		// checked
                    case OuyaButton.RT: 	return GetButton(7, buttonAction, player);		// checked

                   	// stick buttons
                    case OuyaButton.L3: 	return GetButton(8, buttonAction, player);		// checked
                    case OuyaButton.R3: 	return GetButton(9, buttonAction, player);		// checked

                    // center buttons
                    case OuyaButton.SELECT: return GetButton(10, buttonAction, player);		// checked
                    case OuyaButton.START: 	return GetButton(11, buttonAction, player);		// checked
                    case OuyaButton.SYSTEM: return GetButton(12, buttonAction, player);		// checked

                    // d-pad buttons
                    case OuyaButton.DU:		return GetButton(13, buttonAction, player);		// checked
                    case OuyaButton.DR:		return GetButton(14, buttonAction, player);		// checked
                    case OuyaButton.DD:		return GetButton(15, buttonAction, player);		// checked
                    case OuyaButton.DL:		return GetButton(16, buttonAction, player);		// checked

                    default: return false;
                    }
                }
        #endif
        #if UNITY_EDITOR || UNITY_STANDALONE_OSX
            case OuyaControllerType.TattieBogle:
                // this is for the XBOX360 standard controller running on MacOSX using the TattieBogle driver
                // hopefully wireless XBOX controllers connected via Bluetooth have the same values
                // the d-pad has no pressure sensitivity but gives us button events
                // triggers provide only pressure sensitive axis output therefore
                // we need to use continious input scanning for managing Buttonup or ButtonDown events
                switch (button)
                {
                // shoulder buttons
                case OuyaButton.LB: 		return GetButton(13, buttonAction, player);		// checked
                case OuyaButton.RB: 		return GetButton(14, buttonAction, player);		// checked

                // OUYA buttons
                case OuyaButton.O: 			return GetButton(16, buttonAction, player);		// checked
                case OuyaButton.U:			return GetButton(18, buttonAction, player);		// checked
                case OuyaButton.Y: 			return GetButton(19, buttonAction, player);		// checked
                case OuyaButton.A: 			return GetButton(17, buttonAction, player);		// checked

                // stick buttons
                case OuyaButton.L3:			return GetButton(11, buttonAction, player);		// checked
                case OuyaButton.R3:			return GetButton(12, buttonAction, player);		// checked

                // center buttons
                case OuyaButton.SELECT:		return GetButton(10, buttonAction, player);		// checked
                case OuyaButton.START:		return GetButton(9, buttonAction, player);		// checked
                case OuyaButton.SYSTEM:		return GetButton(15, buttonAction, player);		// checked

                // d-pad buttons
                case OuyaButton.DU:			return GetButton(5, buttonAction, player);		// checked
                case OuyaButton.DD:			return GetButton(6, buttonAction, player);		// checked
                case OuyaButton.DL:			return GetButton(7, buttonAction, player);		// checked
                case OuyaButton.DR:			return GetButton(8, buttonAction, player);		// checked

                // trigger buttons
                // the triggers are axis and do not give out UP or DOWN events natively
                // we use button state management and continious scanning to provide these
                case OuyaButton.LT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                default: return false;
                }
        #endif
           		case OuyaControllerType.Unknown:
        #if !UNITY_EDITOR && UNITY_ANDROID
                // we hope to catch any unkown bluetooth controllers on Android here (wild card)
                // there can't be any testing for that as it's just a random try
                switch (button)
                {
                // ouya buttons
                case OuyaButton.O:		return GetButton(0, buttonAction, player);
                case OuyaButton.U:		return GetButton(3, buttonAction, player);
                case OuyaButton.Y:		return GetButton(4, buttonAction, player);
                case OuyaButton.A:		return GetButton(1, buttonAction, player);

                // shoulder buttons
                case OuyaButton.LB:		return GetButton(6, buttonAction, player);
                case OuyaButton.RB:		return GetButton(7, buttonAction, player);

                // stick buttons
                case OuyaButton.L3:		return GetButton(13, buttonAction, player);
                case OuyaButton.R3:		return GetButton(14, buttonAction, player);

                // d-pad buttons and trigger buttons
                // tese buttons are axis and do not give out UP or DOWN events natively
                // we use button state management and continious scanning to provide these
                case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.LT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);
                case OuyaButton.RT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);

                // not defined so far
                default: return false;
                }
        #endif
                break;
            }
        }
        /* SECURITY FALL THROUGH RETURN */
        return false;
    }
Esempio n. 10
0
    public static float GetTrigger(OuyaTrigger trigger, OuyaPlayer player)
    {
        /* returns the trigger axis value after clipping by trigger deadzone
         * this is needed if the "Dead" value in the Input Manager Settings were set to 0
         * it allows allows to get high precision trigger input with deadzone remapping
         */
        // create a field to store the results
        float triggerInput;

        // get the raw trigger input
        switch (trigger)
        {
            case OuyaTrigger.Left: triggerInput = GetAxis(OuyaAxis.LT, player); break;
            case OuyaTrigger.Right: triggerInput = GetAxis(OuyaAxis.RT, player); break;
            default: triggerInput = 0f; break;
        }
        // check for deadzone clipping
        if (triggerInput < triggerThreshold) return 0f;
        else
        {
            switch (deadzoneType)
            {
                case DeadzoneType.AxialClip: return triggerInput;
                case DeadzoneType.CircularClip: return triggerInput;
                case DeadzoneType.CircularMap:
                    // remap the values to allow full range input
                    return (triggerInput - triggerThreshold) / (1f - triggerThreshold);
            }
        }
        // we should never arrive here
        return 0f;
    }
Esempio n. 11
0
 private static int GetOuyaKeyCode(int buttonNum, OuyaPlayer player)
 {
     /* calculates the OuyKeyCodefor a given player and button number
      * depends on the stability of the int chosen in OuyaKeyCodes
      * the advantage is that is much faster than parsing for joystick names
      */
     // the buttons numbers 0 to 19 map to player dependent joystick buttons
     if (buttonNum < 20)
     {
         // the calculations derive from the pattern of the integers assigned in OuyaKeyCodes
         // joystick buttons start at 330 with player = 0 (None)
         // every player has 20 keys
         return (330 + buttonNum + ((int)player * 20));
     }
     // othet buttons map directly to keys
     else return buttonNum;
 }
Esempio n. 12
0
    private static bool GetButton(int buttonNum, ButtonAction action, OuyaPlayer player)
    {
        /* gets Unity Input from Ouya key codes derived from plaer and button number (0-19)
         */
        // get the correct Ouya key code
        int key = GetOuyaKeyCode(buttonNum, player);

        // return the mapped Unity input for the correct button action
        switch (action)
        {
            case ButtonAction.Pressed: return Input.GetKey((KeyCode)key);
            case ButtonAction.DownFrame: return Input.GetKeyDown((KeyCode)key);
            case ButtonAction.UpFrame: return Input.GetKeyUp((KeyCode)key);
            default: return Input.GetKey((KeyCode)key);
        }
    }
Esempio n. 13
0
 public InputButtonEvent(InputAction inputAction, KeyEnum keyCode, OuyaPlayer player)
 {
     m_inputAction = inputAction;
     m_keyCode     = keyCode;
     m_player      = player;
 }
Esempio n. 14
0
 public static Vector2 GetJoystick(OuyaJoystick joystick, OuyaPlayer player)
 {
     /* allows to easily get the input of a joystick
      * the input will already be checked by a preset deadzone
      */
     switch (joystick)
     {
         case OuyaJoystick.LeftStick:
             switch (deadzoneType)
             {
                 case DeadzoneType.AxialClip:
                     return CheckDeadzoneAxial(GetAxis(OuyaAxis.LX, player), GetAxis(OuyaAxis.LY, player), deadzoneRadius);
                 case DeadzoneType.CircularClip:
                     return CheckDeadzoneCircular(GetAxis(OuyaAxis.LX, player), GetAxis(OuyaAxis.LY, player), deadzoneRadius);
                 case DeadzoneType.CircularMap:
                     return CheckDeadzoneRescaled(GetAxis(OuyaAxis.LX, player), GetAxis(OuyaAxis.LY, player), deadzoneRadius);
                 default:
                     return Vector2.zero;
             }
         case OuyaJoystick.RightStick:
             switch (deadzoneType)
             {
                 case DeadzoneType.AxialClip:
                     return CheckDeadzoneAxial(GetAxis(OuyaAxis.RX, player), GetAxis(OuyaAxis.RY, player), deadzoneRadius);
                 case DeadzoneType.CircularClip:
                     return CheckDeadzoneCircular(GetAxis(OuyaAxis.RX, player), GetAxis(OuyaAxis.RY, player), deadzoneRadius);
                 case DeadzoneType.CircularMap:
                     return CheckDeadzoneRescaled(GetAxis(OuyaAxis.RX, player), GetAxis(OuyaAxis.RY, player), deadzoneRadius);
                 default:
                     return Vector2.zero;
             }
         case OuyaJoystick.DPad:
             switch (deadzoneType)
             {
                 case DeadzoneType.AxialClip:
                     return CheckDeadzoneAxial(GetAxis(OuyaAxis.DX, player), GetAxis(OuyaAxis.DY, player), deadzoneRadius);
                 case DeadzoneType.CircularClip:
                     return CheckDeadzoneCircular(GetAxis(OuyaAxis.DX, player), GetAxis(OuyaAxis.DY, player), deadzoneRadius);
                 case DeadzoneType.CircularMap:
                     Vector2 dpadInput = CheckDeadzoneRescaled(GetAxis(OuyaAxis.DX, player), GetAxis(OuyaAxis.DY, player), deadzoneRadius);
                     if (dpadInput.x > 1f) dpadInput.x = 1; else if (dpadInput.x < -1) dpadInput.x = -1;
                     if (dpadInput.y > 1f) dpadInput.y = 1; else if (dpadInput.y < -1) dpadInput.y = -1;
                     return dpadInput;
                 default:
                     return Vector2.zero;
             }
         default:
             return Vector2.zero;
     }
 }
Esempio n. 15
0
 public PlayerController(OuyaPlayer player, OuyaMapType controllerType)
 {
     /* constructor
      */
     this.mapType = controllerType;
     this.player = player;
 }
Esempio n. 16
0
 public static float GetJoystickAngle(OuyaJoystick joystick, OuyaPlayer player)
 {
     /* returns the angle of a joystick
      * This is a convenience method allowing to get the joystick input and
      * calculate the angle at the same call
      * angles start at the positive joystick-x-axis and then increase conterclockwise
      * (x-positive-axis is 0° / y-positive axis is 90° / x-negative axis is 180° / y-negative-axis is 270°)
      * no joystrick input leads to return of -1 (as 0 is a real value used for the x-positive input)
      */
     return CalculateJoystickAngle(GetJoystick(joystick, player));
 }
Esempio n. 17
0
 public void setController(OuyaPlayer player, OuyaMapType mapType)
 {
     /* allows to reinitialize the ID of an existing controller mapping
      */
     this.mapType = mapType;
     this.player = player;
 }
Esempio n. 18
0
    private static bool GetButton(OuyaButton button, ButtonAction buttonAction, OuyaPlayer player)
    {
        /* for retreiving joystick button values from mapped Unity Input
         */

        /* NULL SECURITY */
        // check if there is no joystick connected
        if (controllerNames == null) return false;

        // check if there are more players than joysticks
        // this is not really needed in CLARK – just framework coherence
        int playerIndex = (int)player - 1;
        if (playerIndex >= controllerCount) return false;

        // finally check if we really found a joystick for the player
        OuyaMapType mapType = mapTypes[playerIndex];

        // get the controller mapping for the player
        PlayerController playerController = playerControllers[playerIndex];

        // this twisted recursive move is used for switch-mapped players
        OuyaPlayer mapPlayer = playerController.player;

        // secure that we have found a mapping
        if (playerController != null)
        {

            /* FIND THE CORRECT MAPPED BUTTON KEY */
            switch (mapType)
            {
                /* ANDROID MAPPINGS */
        #if !UNITY_EDITOR && UNITY_ANDROID
                case OuyaMapType.Broadcom_ANDROID:
                // tested mapping for: OuyaGameController connected to Nexus7
                // connected via standard Bluetooth connection
                case OuyaMapType.Generic_ANDROID:
                // tested mapping for: OuyaGameController connected to HTCOne
                // connected via standard Bluetooth connection
                switch (button)
                {
                    // ouya buttons
                    case OuyaButton.O:		return GetButton(0, buttonAction, mapPlayer);		// checked
                    case OuyaButton.U:		return GetButton(1, buttonAction, mapPlayer);		// checked
                    case OuyaButton.Y:		return GetButton(2, buttonAction, mapPlayer);		// checked
                    case OuyaButton.A:		return GetButton(3, buttonAction, mapPlayer);		// checked

                    // shoulder buttons
                    case OuyaButton.LB:		return GetButton(4, buttonAction, mapPlayer);		// checked
                    case OuyaButton.RB:		return GetButton(5, buttonAction, mapPlayer);		// checked

                    // stick buttons
                    case OuyaButton.L3:		return GetButton(6, buttonAction, mapPlayer);		// checked
                    case OuyaButton.R3:		return GetButton(7, buttonAction, mapPlayer);		// checked

                    // d-pad buttons
                    case OuyaButton.DU:		return GetButton(8, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DD:		return GetButton(9, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DL:		return GetButton(10, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DR:		return GetButton(11, buttonAction, mapPlayer);		// checked

                    // trigger buttons
                    // although button states are natively supported we use axis conversion
                    // this is because trigger buttons will natively only react on full pullthrough
                    // these buttons then are two axis and do not give out UP or DOWN events natively
                    // we use button state management and continious scanning to provide these
                    case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                    // not defined so far – or don't exist
                    case OuyaButton.START: 	return false;
                    case OuyaButton.SYSTEM: return false;
                    case OuyaButton.SELECT: return false;
                    default: return false;
                }

                case OuyaMapType.MogaPro_ANDROID:
                // this device was not tested yet
                // the setting were just extracted from some examples I found
                // please feedback if you find a way to test it
                switch (button)
                {
                    // OUYA buttons
                    case OuyaButton.O:		return GetButton(0, buttonAction, mapPlayer);
                    case OuyaButton.U:		return GetButton(3, buttonAction, mapPlayer);
                    case OuyaButton.Y:		return GetButton(4, buttonAction, mapPlayer);
                    case OuyaButton.A:		return GetButton(1, buttonAction, mapPlayer);

                    // shoulder buttons
                    case OuyaButton.LB:		return GetButton(6, buttonAction, mapPlayer);
                    case OuyaButton.RB:		return GetButton(7, buttonAction, mapPlayer);

                    // stick buttons
                    case OuyaButton.L3:		return GetButton(13, buttonAction, mapPlayer);
                    case OuyaButton.R3:		return GetButton(14, buttonAction, mapPlayer);

                    // d-pad buttons and trigger buttons
                    // these buttons are two axis and do not give out UP or DOWN events natively
                    // we use button state management and continious scanning to provide these
                    case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.LT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.RT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);

                    // not defined so far
                    case OuyaButton.START: 	return false;
                    case OuyaButton.SELECT: return false;
                    case OuyaButton.SYSTEM:	return false;
                    default: return false;
                }

                case OuyaMapType.GameStick_CONSOLE:
                // tested mapping for: GameStick console with native controller
                // connected via standard Bluetooth
                // triggers do not exist at all on this controller
                switch (button)
                {
                    // OUYA buttons
                    case OuyaButton.O: 		return GetButton(0, buttonAction, mapPlayer);		// checked
                    case OuyaButton.U: 		return GetButton(3, buttonAction, mapPlayer);		// checked
                    case OuyaButton.Y: 		return GetButton(4, buttonAction, mapPlayer);		// checked
                    case OuyaButton.A: 		return GetButton(1, buttonAction, mapPlayer);		// checked

                    // shoulder buttons
                    case OuyaButton.LB: 	return GetButton(6, buttonAction, mapPlayer);		// checked
                    case OuyaButton.RB: 	return GetButton(7, buttonAction, mapPlayer);		// checked

                    // stick buttons
                    case OuyaButton.L3: 	return GetButton(13, buttonAction, mapPlayer);		// checked
                    case OuyaButton.R3: 	return GetButton(14, buttonAction, mapPlayer);		// checked

                    // center buttons
                    case OuyaButton.SELECT: return GetButton(27, buttonAction, mapPlayer);		// checked
                    case OuyaButton.START: 	return GetButton(11, buttonAction, mapPlayer);		// checked

                    // d-pad buttons
                    // these buttons are two axis and do not give out UP or DOWN events natively
                    // we use button state management and continious scanning to provide these
                    case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                    // the GameStick has no triggers
                    case OuyaButton.LT: return false;
                    case OuyaButton.RT: return false;

                    // SYSTEN is according to GameStick documents: joystick button 20
                    // but this is not valid in Unity (see script reference KeyCode)
                    case OuyaButton.SYSTEM: return false;
                    default: return false;
                }

                case OuyaMapType.Ouya_CONSOLE:
                // tested mapping for: OUYA console with native controller
                // connected via standard Bluetooth
                switch (button)
                {
                    // OUYA buttons
                    case OuyaButton.O:		return GetButton(0, buttonAction, mapPlayer);		// checked
                    case OuyaButton.U:		return GetButton(1, buttonAction, mapPlayer);		// checked
                    case OuyaButton.Y:		return GetButton(2, buttonAction, mapPlayer);		// checked
                    case OuyaButton.A:		return GetButton(3, buttonAction, mapPlayer);		// checked

                    // shoulder buttons
                    case OuyaButton.LB: 	return GetButton(4, buttonAction, mapPlayer);		// checked
                    case OuyaButton.RB: 	return GetButton(5, buttonAction, mapPlayer);		// checked

                    // stick buttons
                    case OuyaButton.L3:		return GetButton(6, buttonAction, mapPlayer);		// checked
                    case OuyaButton.R3:		return GetButton(7, buttonAction, mapPlayer);		// checked

                    // d-pad buttons
                    case OuyaButton.DU:		return GetButton(8, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DD:		return GetButton(9, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DL:		return GetButton(10, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DR:		return GetButton(11, buttonAction, mapPlayer);		// checked

                    // trigger buttons
                    // although button states are natively supported we use axis conversion
                    // the button numbers we do not use are: LT 12 / RR 13
                    // this is because trigger buttons will natively only react on full pullthrough
                    // this feels very unresponsive and can be solved by evaluating the axis input values
                    // these two axis and do not give out UP or DOWN events natively
                    // we use button state management and continious scanning to provide these
                    case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                    // not defined so far – or don't exist on OUYA
                    case OuyaButton.START: 	return false;
                    case OuyaButton.SYSTEM: return false;
                    case OuyaButton.SELECT: return false;
                    default: return false;
                }

                case OuyaMapType.XBOX360_ANDROID:
                // tested mapping for: XBOX360 USB controller connnected to OUYA, Nexus7
                // connected via USB cable (with USBToGo adapter cable for Nexus7)
                switch (button)
                {
                    // OUYA buttons
                    case OuyaButton.O: 		return GetButton(0, buttonAction, mapPlayer);		// checked
                    case OuyaButton.U: 		return GetButton(3, buttonAction, mapPlayer);		// checked
                    case OuyaButton.Y: 		return GetButton(4, buttonAction, mapPlayer);		// checked
                    case OuyaButton.A: 		return GetButton(1, buttonAction, mapPlayer);		// checked

                    // shoulder buttons
                    case OuyaButton.LB:		return GetButton(6, buttonAction, mapPlayer);		// checked
                    case OuyaButton.RB:		return GetButton(7, buttonAction, mapPlayer);		// checked

                    // center buttons
                    case OuyaButton.START: 	return GetButton(11, buttonAction, mapPlayer);		// checked
                    // this mapping for the select button works on OUYA but not on Nexus7
                    // Is it worth a complete new mapping section?
                    case OuyaButton.SELECT:	return GetButton(27, buttonAction, mapPlayer);

                    // stick buttons
                    case OuyaButton.L3: 	return GetButton(13, buttonAction, mapPlayer);		// checked
                    case OuyaButton.R3: 	return GetButton(14, buttonAction, mapPlayer);		// checked

                    // d-pad buttons and trigger buttons
                    // these buttons are two axis and do not give out UP or DOWN events natively
                    // we use button state management and continious scanning to provide these
                    case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.LT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.RT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);

                    // not defined so far
                    case OuyaButton.SYSTEM: return false;
                    default: return false;
                }

                case OuyaMapType.XBOX360_ANDROID_wireless:
                // tested mapping for: XBOX360 Wireless controller connected to OUYA
                // connected via MicrosoftWirelessReceiver which connects via USB cable
                switch (button)
                {
                    // OUYA buttons
                    case OuyaButton.O: 		return GetButton(0, buttonAction, mapPlayer);		// checked
                    case OuyaButton.U: 		return GetButton(3, buttonAction, mapPlayer);		// checked
                    case OuyaButton.Y: 		return GetButton(4, buttonAction, mapPlayer);		// checked
                    case OuyaButton.A: 		return GetButton(1, buttonAction, mapPlayer);		// checked

                    // shoulder buttons
                    case OuyaButton.LB:		return GetButton(6, buttonAction, mapPlayer);		// checked
                    case OuyaButton.RB:		return GetButton(7, buttonAction, mapPlayer);		// checked

                    // center buttons
                    case OuyaButton.START: 	return GetButton(11, buttonAction, mapPlayer);		// checked
                    case OuyaButton.SELECT:	return GetButton(27, buttonAction, mapPlayer);

                    // stick buttons
                    case OuyaButton.L3: 	return GetButton(13, buttonAction, mapPlayer);		// checked
                    case OuyaButton.R3: 	return GetButton(14, buttonAction, mapPlayer);		// checked

                    // d-pad buttons
                    // these buttons are very strange as they run on the same KeyCodes as O U (Y) A buttons
                    // so if we eant to work fine on Android we can't really use the d-pad
                    // that's why we partly deactivate these buttons via a flag
                    // pressing a d-pad button will still lead to [O U Y A] action button events
                    // this can't be helped – at leas we won't fire d-pad input when pressing action buttons
                    case OuyaButton.DU:
                    if (XBOX360W_ANDROID_DPAD) return GetButton(2, buttonAction, mapPlayer); else return false;
                    case OuyaButton.DD:
                    if (XBOX360W_ANDROID_DPAD) return GetButton(3, buttonAction, mapPlayer); else return false;
                    case OuyaButton.DL:
                    if (XBOX360W_ANDROID_DPAD) return GetButton(0, buttonAction, mapPlayer); else return false;
                    case OuyaButton.DR:
                    if (XBOX360W_ANDROID_DPAD) return GetButton(1, buttonAction, mapPlayer); else return false;

                    // trigger buttons
                    // these buttons are two axis and do not give out UP or DOWN events natively
                    // we use button state management and continious scanning to provide these
                    case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                    case OuyaButton.RT:	return GetCachedButtonEvent(button, buttonAction, playerIndex);

                    // not defined so far
                    case OuyaButton.SYSTEM: return false;
                    default: return false;
                }

                case OuyaMapType.PS3_ANDROID:
                // tested mapping for: PS3 DS controller connected to OUYA
                // connection via standard Bluetooth
                // pairing achieved using a temporary USB cable connection
                switch (button)
                {
                    // stick buttons
                    case OuyaButton.L3: 	return GetButton(1, buttonAction, mapPlayer);		// checked
                    case OuyaButton.R3: 	return GetButton(2, buttonAction, mapPlayer);		// checked

                    // center buttons
                    case OuyaButton.START: 	return GetButton(3, buttonAction, mapPlayer);		// checked
                    case OuyaButton.SELECT: return GetButton(27, buttonAction, mapPlayer);		// checked

                    // d-pad buttons
                    case OuyaButton.DU:		return GetButton(4, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DR:		return GetButton(5, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DD:		return GetButton(6, buttonAction, mapPlayer);		// checked
                    case OuyaButton.DL:		return GetButton(7, buttonAction, mapPlayer);		// checked

                    // trigger buttons
                    case OuyaButton.LT: 	return GetButton(8, buttonAction, mapPlayer);		// checked
                    case OuyaButton.RT: 	return GetButton(9, buttonAction, mapPlayer);		// checked

                    // shoulder buttons
                    case OuyaButton.LB:		return GetButton(10, buttonAction, mapPlayer);		// checked
                    case OuyaButton.RB:		return GetButton(11, buttonAction, mapPlayer);		// checked

                    // OUYA buttons
                    case OuyaButton.O:		return GetButton(14, buttonAction, mapPlayer);		// checked
                    case OuyaButton.U:		return GetButton(15, buttonAction, mapPlayer);		// checked
                    case OuyaButton.Y:		return GetButton(12, buttonAction, mapPlayer);		// checked
                    case OuyaButton.A:		return GetButton(13, buttonAction, mapPlayer);		// checked

                    // not defined do far
                    case OuyaButton.SYSTEM: return false;
                    default: return false;
                }
        #endif

                /* WINDOWS MAPPINGS */
        #if UNITY_EDITOR || UNITY_STANDALONE_WIN
                case OuyaMapType.Ouya_WIN:
                    // tested mapping for: OUYA Game Controller connected to Windows 7+8 64bit
                    // connection via standard Bluetooth (preinstalled OS drivers)
                    switch (button)
                    {
                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(4, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RB: return GetButton(5, buttonAction, mapPlayer);		// checked

                        // OUYA buttons
                        case OuyaButton.O: return GetButton(0, buttonAction, mapPlayer);		// checked
                        case OuyaButton.U: return GetButton(1, buttonAction, mapPlayer);		// checked
                        case OuyaButton.Y: return GetButton(2, buttonAction, mapPlayer);		// checked
                        case OuyaButton.A: return GetButton(3, buttonAction, mapPlayer);		// checked

                        // stick buttons
                        case OuyaButton.L3: return GetButton(6, buttonAction, mapPlayer);		// checked
                        case OuyaButton.R3: return GetButton(7, buttonAction, mapPlayer);		// checked

                        // d-pad buttons
                        case OuyaButton.DU: return GetButton(8, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DD: return GetButton(9, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DL: return GetButton(10, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DR: return GetButton(11, buttonAction, mapPlayer);		// checked

                        // trigger buttons
                        // although button states are natively supported we use axis conversion
                        // the button numbers we do not use are: LT 12 / RR 13
                        // this is because trigger buttons will natively only react on full pullthrough
                        // this feels very unresponsive and can be solved by evaluating the axis input values
                        // these two axis and do not give out UP or DOWN events natively
                        // we use button state management and continious scanning to provide these
                        case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                        // not defined so far – or don't exist on OUYA
                        case OuyaButton.START: return false;
                        case OuyaButton.SYSTEM: return false;
                        case OuyaButton.SELECT: return false;
                        default: return false;
                    }

                case OuyaMapType.XBox360_WIN:
                    switch (button)
                    // tested mapping for XBOX360 USB controller connected to Windows 7+8 64bit
                    // connection via USB cable (official Microsoft XBOX360 Drivers on Windows 7)
                    // connection via USB cable (preinstalled OS drivers on Windows 8)
                    {
                        // OUYA buttons
                        case OuyaButton.O: return GetButton(0, buttonAction, mapPlayer);		// checked
                        case OuyaButton.U: return GetButton(2, buttonAction, mapPlayer);		// checked
                        case OuyaButton.Y: return GetButton(3, buttonAction, mapPlayer);		// checked
                        case OuyaButton.A: return GetButton(1, buttonAction, mapPlayer);		// checked

                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(4, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RB: return GetButton(5, buttonAction, mapPlayer);		// checked

                        // center buttons
                        case OuyaButton.START: return GetButton(7, buttonAction, mapPlayer);		// checked
                        case OuyaButton.SELECT: return GetButton(6, buttonAction, mapPlayer);		// checked

                        // stick buttons
                        case OuyaButton.L3: return GetButton(8, buttonAction, mapPlayer);		// checked
                        case OuyaButton.R3: return GetButton(9, buttonAction, mapPlayer);		// checked

                        // d-pad buttons and trigger buttons
                        // these buttons are two axis and do not give out UP or DOWN events natively
                        // we use button state management and continious scanning to provide these
                        case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                        //  not defined so far
                        case OuyaButton.SYSTEM: return false;
                        default: return false;
                    }

                case OuyaMapType.PS3_WIN:
                    // tested mapping for: PS3 DS controller connected to Windows 8 64bit
                    // connection via standard Bluetooth (preinstalled OS drivers)
                    // pairing achieved using a temporary USB cable connection
                    switch (button)
                    {
                        // stick buttons
                        case OuyaButton.L3: return GetButton(1, buttonAction, mapPlayer);		// checked
                        case OuyaButton.R3: return GetButton(2, buttonAction, mapPlayer);		// checked

                        // center buttons
                        case OuyaButton.START: return GetButton(3, buttonAction, mapPlayer);		// checked
                        case OuyaButton.SELECT: return GetButton(0, buttonAction, mapPlayer);		// checked

                        // d-pad buttons
                        case OuyaButton.DU: return GetButton(4, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DR: return GetButton(5, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DD: return GetButton(6, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DL: return GetButton(7, buttonAction, mapPlayer);		// checked

                        // trigger buttons
                        case OuyaButton.LT: return GetButton(8, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RT: return GetButton(9, buttonAction, mapPlayer);		// checked

                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(10, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RB: return GetButton(11, buttonAction, mapPlayer);		// checked

                        // OUYA buttons
                        case OuyaButton.O: return GetButton(14, buttonAction, mapPlayer);		// checked
                        case OuyaButton.U: return GetButton(15, buttonAction, mapPlayer);		// checked
                        case OuyaButton.Y: return GetButton(12, buttonAction, mapPlayer);		// checked
                        case OuyaButton.A: return GetButton(13, buttonAction, mapPlayer);		// checked

                        // not defined do far
                        case OuyaButton.SYSTEM: return false;
                        default: return false;
                    }

                case OuyaMapType.MotionInJoy_WIN:
                    // tested mapping for: PS3 DS controller connected to Windows 7 64bit
                    // connection via USB cable (custom setup using the most popular but crappy driver: MotionInJoy)
                    // this needs a CUSTOM button mapping setup in the driver tools to work (see documentation)
                    // default sets could not be used as they do not make sense (gyro's and sticks share the same axis)
                    // READ THE DOCUMENTATION to make this work !!!
                    switch (button)
                    {
                        // OUYA buttons
                        case OuyaButton.O: return GetButton(2, buttonAction, mapPlayer);		// checked
                        case OuyaButton.U: return GetButton(3, buttonAction, mapPlayer);		// checked
                        case OuyaButton.Y: return GetButton(0, buttonAction, mapPlayer);		// checked
                        case OuyaButton.A: return GetButton(1, buttonAction, mapPlayer);		// checked

                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(4, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RB: return GetButton(5, buttonAction, mapPlayer);		// checked

                        // trigger buttons
                        case OuyaButton.LT: return GetButton(6, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RT: return GetButton(7, buttonAction, mapPlayer);		// checked

                        // stick buttons
                        case OuyaButton.L3: return GetButton(8, buttonAction, mapPlayer);		// checked
                        case OuyaButton.R3: return GetButton(9, buttonAction, mapPlayer);		// checked

                        // center buttons
                        case OuyaButton.SELECT: return GetButton(10, buttonAction, mapPlayer);		// checked
                        case OuyaButton.START: return GetButton(11, buttonAction, mapPlayer);		// checked
                        case OuyaButton.SYSTEM: return GetButton(12, buttonAction, mapPlayer);		// checked

                        // d-pad buttons
                        case OuyaButton.DU: return GetButton(13, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DR: return GetButton(14, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DD: return GetButton(15, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DL: return GetButton(16, buttonAction, mapPlayer);		// checked

                        // not defined do far
                        default: return false;
                    }

                case OuyaMapType.GameStick_WIN:
                    // the GameStick has no working driver on Windows
                    // so far we can't support the device although we know it's name at least
                    // this is just a placeholder where real mapping should be once we find a driver
                    switch (button)
                    {
                        // OUYA buttons
                        case OuyaButton.O: return GetButton(0, buttonAction, mapPlayer);
                        case OuyaButton.U: return GetButton(3, buttonAction, mapPlayer);
                        case OuyaButton.Y: return GetButton(4, buttonAction, mapPlayer);
                        case OuyaButton.A: return GetButton(1, buttonAction, mapPlayer);

                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(6, buttonAction, mapPlayer);
                        case OuyaButton.RB: return GetButton(7, buttonAction, mapPlayer);

                        // stick buttons
                        case OuyaButton.L3: return GetButton(13, buttonAction, mapPlayer);
                        case OuyaButton.R3: return GetButton(14, buttonAction, mapPlayer);

                        // center buttons
                        case OuyaButton.SELECT: return GetButton(27, buttonAction, mapPlayer);
                        case OuyaButton.START: return GetButton(11, buttonAction, mapPlayer);

                        // d-pad buttons
                        // these buttons are two axis and do not give out UP or DOWN events natively
                        // we use button state management and continious scanning to provide these
                        case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                        // the GameStick has no triggers
                        case OuyaButton.LT: return false;
                        case OuyaButton.RT: return false;

                        // SYSTEN is according to GameStick documents: joystick button 20
                        // but this is not valid in Unity (see script reference Keycode)
                        case OuyaButton.SYSTEM: return false;
                        default: return false;
                    }
        #endif

                /* MACOSX MAPPINGS */
        #if UNITY_EDITOR || UNITY_STANDALONE_OSX
                case OuyaMapType.PS3_OSX:
                    // tested mapping for PS3 DS controller connected to the MacOSX
                    // connection via standard Bluetooth (prinstalled drivers)
                    // pairing achieved using a temporary USB cable connection
                    switch (button)
                    {
                        // stick buttons
                        case OuyaButton.L3: return GetButton(1, buttonAction, mapPlayer);		// checked
                        case OuyaButton.R3: return GetButton(2, buttonAction, mapPlayer);		// checked

                        // center buttons
                        case OuyaButton.START: return GetButton(3, buttonAction, mapPlayer);		// checked
                        case OuyaButton.SELECT: return GetButton(0, buttonAction, mapPlayer);		// checked

                        // d-pad buttons
                        case OuyaButton.DU: return GetButton(4, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DR: return GetButton(5, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DD: return GetButton(6, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DL: return GetButton(7, buttonAction, mapPlayer);		// checked

                        // trigger buttons
                        case OuyaButton.LT: return GetButton(8, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RT: return GetButton(9, buttonAction, mapPlayer);		// checked

                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(10, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RB: return GetButton(11, buttonAction, mapPlayer);		// checked

                        // OUYA buttons
                        case OuyaButton.O: return GetButton(14, buttonAction, mapPlayer);		// checked
                        case OuyaButton.U: return GetButton(15, buttonAction, mapPlayer);		// checked
                        case OuyaButton.Y: return GetButton(12, buttonAction, mapPlayer);		// checked
                        case OuyaButton.A: return GetButton(13, buttonAction, mapPlayer);		// checked

                        // not defined do far
                        case OuyaButton.SYSTEM: return false;
                        default: return false;
                    }

                case OuyaMapType.TattieBogle_OSX:
                    // tested mapping for: XBOX360 USB controller connected to MacOSX
                    // tested mapping for: XBOX360 Wireless controller connected to MacOSX
                    // connection via USB cable (with the free to dowload TattieBogle driver)
                    // NOTE: disconnecting a XBOX360 USB controller using Tattie can lead to full system reboot
                    switch (button)
                    {
                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(13, buttonAction, mapPlayer);		// checked
                        case OuyaButton.RB: return GetButton(14, buttonAction, mapPlayer);		// checked

                        // OUYA buttons
                        case OuyaButton.O: return GetButton(16, buttonAction, mapPlayer);		// checked
                        case OuyaButton.U: return GetButton(18, buttonAction, mapPlayer);		// checked
                        case OuyaButton.Y: return GetButton(19, buttonAction, mapPlayer);		// checked
                        case OuyaButton.A: return GetButton(17, buttonAction, mapPlayer);		// checked

                        // stick buttons
                        case OuyaButton.L3: return GetButton(11, buttonAction, mapPlayer);		// checked
                        case OuyaButton.R3: return GetButton(12, buttonAction, mapPlayer);		// checked

                        // center buttons
                        case OuyaButton.SELECT: return GetButton(10, buttonAction, mapPlayer);		// checked
                        case OuyaButton.START: return GetButton(9, buttonAction, mapPlayer);		// checked
                        case OuyaButton.SYSTEM: return GetButton(15, buttonAction, mapPlayer);		// checked

                        // d-pad buttons
                        case OuyaButton.DU: return GetButton(5, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DD: return GetButton(6, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DL: return GetButton(7, buttonAction, mapPlayer);		// checked
                        case OuyaButton.DR: return GetButton(8, buttonAction, mapPlayer);		// checked

                        // trigger buttons
                        // the triggers are axis and do not give out UP or DOWN events natively
                        // we use button state management and continious scanning to provide these
                        case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        default: return false;
                    }

                case OuyaMapType.GameStick_OSX:
                    // the GameStick has no working driver on MacOSX
                    // so far we can't support the device although we know it's name at least
                    // this is just a placeholder where real mapping should be once we find a driver
                    switch (button)
                    {
                        // OUYA buttons
                        case OuyaButton.O: return GetButton(0, buttonAction, mapPlayer);
                        case OuyaButton.U: return GetButton(3, buttonAction, mapPlayer);
                        case OuyaButton.Y: return GetButton(4, buttonAction, mapPlayer);
                        case OuyaButton.A: return GetButton(1, buttonAction, mapPlayer);

                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(6, buttonAction, mapPlayer);
                        case OuyaButton.RB: return GetButton(7, buttonAction, mapPlayer);

                        // stick buttons
                        case OuyaButton.L3: return GetButton(13, buttonAction, mapPlayer);
                        case OuyaButton.R3: return GetButton(14, buttonAction, mapPlayer);

                        // center buttons
                        case OuyaButton.SELECT: return GetButton(27, buttonAction, mapPlayer);
                        case OuyaButton.START: return GetButton(11, buttonAction, mapPlayer);

                        // d-pad buttons
                        // these buttons are two axis and do not give out UP or DOWN events natively
                        // we use button state management and continious scanning to provide these
                        case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                        // the GameStick has no triggers
                        case OuyaButton.LT: return false;
                        case OuyaButton.RT: return false;

                        // SYSTEN is according to GameStick documents: joystick button 20
                        // but this is not valid in Unity (see script reference Keycode)
                        case OuyaButton.SYSTEM: return false;
                        default: return false;
                    }
        #endif

                /* UNKNOWN MAPPINGS */
                case OuyaMapType.Unknown:
                    // we hope to catch any unkown bluetooth controllers here (wild card)
                    // there can't be any testing for that as it's just a random try
                    switch (button)
                    {
                        // ouya buttons
                        case OuyaButton.O: return GetButton(0, buttonAction, mapPlayer);
                        case OuyaButton.U: return GetButton(3, buttonAction, mapPlayer);
                        case OuyaButton.Y: return GetButton(4, buttonAction, mapPlayer);
                        case OuyaButton.A: return GetButton(1, buttonAction, mapPlayer);

                        // shoulder buttons
                        case OuyaButton.LB: return GetButton(6, buttonAction, mapPlayer);
                        case OuyaButton.RB: return GetButton(7, buttonAction, mapPlayer);

                        // stick buttons
                        case OuyaButton.L3: return GetButton(13, buttonAction, mapPlayer);
                        case OuyaButton.R3: return GetButton(14, buttonAction, mapPlayer);

                        // d-pad buttons and trigger buttons
                        // tese buttons are axis and do not give out UP or DOWN events natively
                        // we use button state management and continious scanning to provide these
                        case OuyaButton.DU: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DD: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DL: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.DR: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.LT: return GetCachedButtonEvent(button, buttonAction, playerIndex);
                        case OuyaButton.RT: return GetCachedButtonEvent(button, buttonAction, playerIndex);

                        // not defined so far
                        default: return false;
                    }
            }
        }
        /* SECURITY FALL THROUGH RETURN */
        return false;
    }
Esempio n. 19
0
    public static float GetAxis(OuyaAxis axis, OuyaPlayer player)
    {
        /* for retreiving joystick axis values from mapped Unity Input
         */

        /* NULL SECURITY */
        // check if there is no joystick connected
        if (controllerCount == 0) return 0f;

        // check if there have more players than controllers
        // we consider that the array position is starting at 0 for player 1
        int playerIndex = (int)player - 1;
        if (playerIndex < 0 || playerIndex >= controllerCount) return 0f;

        // finally check if we really found a controller for the player
        OuyaControllerType controllerType = controllerTypes[playerIndex];

        /* GET MAPPED AXIS NAME */
        // prepare fields for storing the results
        string axisName = null; bool invert = false;

        // get the controller mapping for the player
        PlayerController playerController = playerControllers[playerIndex];
        // secure that we have found a mapping
        if (playerController == null) return 0f;
        else
        {
            /* JOYSTICKS */
            // get the axis name for the player controller
            switch (axis) {
            case OuyaAxis.LX: axisName = playerController.map_LX; invert = playerController.invert_LX; break;
           	case OuyaAxis.LY: axisName = playerController.map_LY; invert = playerController.invert_LY; break;
            case OuyaAxis.RX: axisName = playerController.map_RX; invert = playerController.invert_RX; break;
           	case OuyaAxis.RY: axisName = playerController.map_RY; invert = playerController.invert_RY; break;

            /* TRIGGERS & D-PAD */
            // the dpad and triggers are sometimes treated like an axis joystick
            // sometimes however it is just a set of buttons and the pressure senitivity is missing
            // this was observed for MacOS XBOX360 (TattieBogle) / Android Ouya / Android + MacOS PS3
            /* LT-TRIGGER */
            case OuyaAxis.LT: axisName = playerController.map_LT; invert = playerController.invert_LT;
                // if the trigger is treated like a button we convert button press bool flags into axis values
                if (axisName == null)
                {
                    switch (controllerType) {
                    case OuyaControllerType.PS3:
                        if (GetButton(8, ButtonAction.Pressed, player)) return 1f; else return 0f;
                    }
                }
                break;
            /* RT-TRIGGER */
            case OuyaAxis.RT: axisName = playerController.map_RT; invert = playerController.invert_RT;
                // if the trigger is treated like a button we convert button press bool flags into axis values
                if (axisName == null)
                {
                    switch (controllerType) {
                    case OuyaControllerType.PS3:
                        if (GetButton(9, ButtonAction.Pressed, player)) return 1f; else return 0f;
                    }
                }
                break;
            /* DX-AXIS */
            case OuyaAxis.DX: axisName = playerController.map_DX; invert = playerController.invert_DX;
                // if the dpad is treated like a button we convert button press bool flags into axis values
                if (axisName == null)
                {
                    switch (controllerType) {
                    case OuyaControllerType.Ouya:
                        if (GetButton(10, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(11, ButtonAction.Pressed, player)) return 1f;
                        break;
                    case OuyaControllerType.PS3:
        #if !UNITY_EDITOR && UNITY_ANDROID
                        if (GetButton(7, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(5, ButtonAction.Pressed, player)) return 1f;
        #elif !UNITY_EDITOR && UNITY_STANDALONE_OSX
                        if (GetButton(7, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(5, ButtonAction.Pressed, player)) return 1f;
        #elif !UNITY_EDITOR && UNITY_STANDALONE_WIN
                        if (GetButton(16, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(14, ButtonAction.Pressed, player)) return 1f;
        #elif UNITY_EDITOR
                        // in the editor we have to set on which platform we are working
                        // different editor working environments are not covered by Unity's macros
                        if (editorWorkPlatform == EditorWorkPlatform.MacOS)
                        {
                            if (GetButton(7, ButtonAction.Pressed, player)) return -1f;
                            else if (GetButton(5, ButtonAction.Pressed, player)) return 1f;
                        }
                        else {
                            if (GetButton(16, ButtonAction.Pressed, player)) return -1f;
                            else if (GetButton(14, ButtonAction.Pressed, player)) return 1f;
                        }
        #endif
                        break;
        #if UNITY_EDITOR || UNITY_STANDALONE_OSX
                    case OuyaControllerType.TattieBogle:
                        if (GetButton(7, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(8, ButtonAction.Pressed, player)) return 1f;
                        break;
        #endif
                    }
                } break;
            /* DY-AXIS */
            case OuyaAxis.DY: axisName = playerController.map_DY; invert = playerController.invert_DY;
                // if the dpad is treated like a button we convert button press bool flags into axis values
                if (axisName == null)
                {
                    switch (controllerType) {
                    case OuyaControllerType.Ouya:
                        if (GetButton(8, ButtonAction.Pressed, player)) return 1f;
                        else if (GetButton(9, ButtonAction.Pressed, player)) return -1f;
                        break;
                    case OuyaControllerType.PS3:
        #if !UNITY_EDITOR && UNITY_ANDROID
                        if (GetButton(6, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(4, ButtonAction.Pressed, player)) return 1f;
        #elif !UNITY_EDITOR && UNITY_STANDALONE_OSX
                        if (GetButton(6, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(4, ButtonAction.Pressed, player)) return 1f;
        #elif !UNITY_EDITOR && UNITY_STANDALONE_WIN
                        if (GetButton(15, ButtonAction.Pressed, player)) return -1f;
                        else if (GetButton(16, ButtonAction.Pressed, player)) return 1f;
        #elif UNITY_EDITOR
                        // in the editor we have to set on which platform we are working (Win or MacOS)
                        // different editor working environments are not covered by Unity's macros
                        if (editorWorkPlatform == EditorWorkPlatform.MacOS)
                        {
                            if (GetButton(6, ButtonAction.Pressed, player)) return -1f;
                            else if (GetButton(4, ButtonAction.Pressed, player)) return 1f;
                        }
                        else {
                            if (GetButton(15, ButtonAction.Pressed, player)) return -1f;
                            else if (GetButton(16, ButtonAction.Pressed, player)) return 1f;
                        }
        #endif
                        break;
        #if UNITY_EDITOR || UNITY_STANDALONE_OSX
                    case OuyaControllerType.TattieBogle:
                        if (GetButton(5, ButtonAction.Pressed, player)) return 1f;
                        else if (GetButton(6, ButtonAction.Pressed, player)) return -1f;
                        break;
        #endif
                    }
                } break;

            default: return 0f;
            }
        }
        /* FINAL SECURITY CHECK */
        // we return 0 if we didn't find a valid axis
        if (axisName == null) return 0f;

        /* TRIGGER AXIS RANGE MAPPING */
        if (axis == OuyaAxis.LT || axis == OuyaAxis.RT) {
            // some trigger axis need to be remapped inrange before we can return the Unity Input
            if (invert) return playerController.rangeMapTriggerAxis(-Input.GetAxisRaw(axisName), axis);
            else return playerController.rangeMapTriggerAxis(Input.GetAxisRaw(axisName), axis);
        }
        /* AXIS FLOAT RESULT FROM UNITY INPUT */
        if (invert) return -Input.GetAxisRaw(axisName);
        else return Input.GetAxisRaw(axisName);
    }