OuyaInputManager.GetAxis not working for LT and RT

FREEZXXFREEZXX Posts: 12Member
Hi,
I wanted to get the axis values of the trigger buttons of the ouya controllers, and i have noticed they're not working because there is no code to handle it in the CheckInput function in OuyaInputManager like there is for the xbox: if(atype.Equals(AnalogTypes.LTRT))
wtf?

Comments

  • FREEZXXFREEZXX Posts: 12Member
    Alright, fixed it by doing the following:

    Modified the ControllerType class in OuyaControllerMapping to be as follows:

    public class ControllerType{
    public string name;
    public int leftAnalogH;
    public int leftAnalogV;
    public int leftTrigger;
    public int rightAnalogH;
    public int rightAnalogV;
    public int rightTrigger;
    public int dpadH;
    public int dpadV;
    public int triggers = -1;
    }



    Modified the OUYA mapping region beginning as follows:

    ControllerType ouya = new ControllerType();
            ouya.name = "ouya";
            ouya.leftAnalogH = 1;
            ouya.leftAnalogV = 2;
    ouya.leftTrigger = 3;
            ouya.rightAnalogH = 4;
            ouya.rightAnalogV = 5;
            ouya.rightTrigger = 6;
            ouya.dpadH = 9;
            ouya.dpadV = 10;
            joystickType = JoystickType.ouya;


    In OuyaInputManager add this below the last else if  inside the region OUYA - Not Tested :
    else if (atype.Equals(AnalogTypes.LTRT))
                    {
    if(axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftTrigger; } else { axisNumber = cType.rightTrigger; }
                        return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                    }

    Tried it out and works as expected for me.
    Hope this helps someone that doesn't want to use any additional "Example" code like that OuyaExampleCommon file.

    IMHO much of the code should be refactored starting from moving all this
         ControllerType cType = OuyaControllerMapping.getController("xbox360");
    just before the if statements, reducing clutter in the code and sticking to the DRY principle,
    to eliminating as much as possible from the OuyaExampleCommon used for getting input (Isn't this making the existence of OuyaInputManager useless?)

         Also, just switching the bundle name shouldn't be giving people headaches. Make the plugin detect changes to the player settings or so in order to make it more usable.
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    That's all high latency-legacy input. I should remove this code to prevent folks from using it at this point.

    Here's the latest Unity input docs:

    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • FREEZXXFREEZXX Posts: 12Member
    So if i understand this right, OuyaExampleCommon must be used in order to get low latency input?
    If so, that class name does not sound as being an official core SDK thing.
  • FREEZXXFREEZXX Posts: 12Member
    Noticed a similar issue in the OuyaExampleCommon as well.

    Line 207 - case "OUYA GAME CONTROLLER":

    case OuyaSDK.KeyEnum.BUTTON_LT:
                            axisName = string.Format("Joy{0} Axis 9", (int)player);
                            break;
                        case OuyaSDK.KeyEnum.BUTTON_RT:
                            axisName = string.Format("Joy{0} Axis 10", (int)player);

    Isn't this actually supposed to be axises 3 and 6?
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA

    FREEZXX said:
    So if i understand this right, OuyaExampleCommon must be used in order to get low latency input?
    If so, that class name does not sound as being an official core SDK thing.
    You're right it doesn't sound official. It's just the input mappings that I used for the examples as an example to do it. Since now the recommended way is to use the Unity Input API.

    The fact that OuyaExampleCommon has GetButton  and GetAxis I don't like either. I want to add an official class like:

    OuyaSDK.GetAxis(axisEnum, playerNumber) and it would return the string axis name. You wouldn't get axis or button values directly from the OuyaSDK. That would force users to take the result and use in the Unity Input API.

    String axisName = OuyaSDK.GetAxis(axisEnum, playerNumber);

    and then if the axisName isn't blank you can get the value with:

    Input.GetAxis(axisName) or 
    Input.GetAxisRaw(axisName).

    Same for buttons:

    KeyCode key = OuyaSDK.GetButton(buttonEnum, playerNumber);

    and if the KeyCode is valid:

    Input.GetButton(keyCode)
    Input.GetButtonDown(keyCode)
    Input.GetButtonUp(keyCode)
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    FREEZXX said:
    Noticed a similar issue in the OuyaExampleCommon as well.

    Line 207 - case "OUYA GAME CONTROLLER":

    case OuyaSDK.KeyEnum.BUTTON_LT:
                            axisName = string.Format("Joy{0} Axis 9", (int)player);
                            break;
                        case OuyaSDK.KeyEnum.BUTTON_RT:
                            axisName = string.Format("Joy{0} Axis 10", (int)player);

    Isn't this actually supposed to be axises 3 and 6?
    The mappings depend on the platform which changes the keycodes and axis mappings.
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • lyanappslyanapps Posts: 4Member
    edited July 2013
    This may be a different question, but I did get trigger input working. My issue is when I put in the line:

    Debug.Log("Triggers: " + OuyaInputManager.GetAxis("RT", player) +","+ OuyaInputManager.GetAxis("LT", player)); 

    The output for "RT" and "LT" are equal. I did see this once before where you use axis 3 on an xbox controller giving you a positive number or a negative number for which trigger is pressed. However, I want to get the input for when both triggers are jammed down. For this I switched to axis 9 and axis 10 which both read out the triggers separately and positive. Is this possible with the OuyaInputManager? For now it seems not.

    Post edited by lyanapps on
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    Ah right sometimes the triggers can share an axis. But there's usually a secondary axis where they are independent.
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
Sign In or Register to comment.