Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GripButton vs GripPressed discrepancy

Discussion in 'AR/VR (XR) Discussion' started by kenlange314, May 16, 2020.

  1. kenlange314

    kenlange314

    Joined:
    May 31, 2019
    Posts:
    3
    I'm having trouble getting XR Grab Interaction to work on a device that only has a "GripButton" (Binary) and not a "Grip" (Axis1D) feature (Vive Cosmos). It works with Trigger but not with "Grip" or "GripPressed".

    I think that it comes down to the device reporting the button name as "GripButton" while the code in "InputHelpers.cs" is using the name "GripPressed".

    Perhaps the name changed between versions and I've got a wrong version?

    Anyone else run into this?

    com.unity.xr.interaction.toolkit@0.9.4-preview\Runtime\XR\InputHelpers.cs


    static ButtonInfo[] s_ButtonData = new ButtonInfo[]
    {
    new ButtonInfo("", ButtonReadType.None),
    new ButtonInfo("MenuButton", ButtonReadType.Binary),
    new ButtonInfo("Trigger", ButtonReadType.Axis1D),
    new ButtonInfo("Grip", ButtonReadType.Axis1D),
    new ButtonInfo("TriggerPressed", ButtonReadType.Binary),
    new ButtonInfo("GripPressed", ButtonReadType.Binary),
    new ButtonInfo("PrimaryButton", ButtonReadType.Binary),
    new ButtonInfo("PrimaryTouch", ButtonReadType.Binary),
    new ButtonInfo("SecondaryButton", ButtonReadType.Binary),
    new ButtonInfo("SecondaryTouch", ButtonReadType.Binary),
    new ButtonInfo("Primary2DAxisTouch", ButtonReadType.Binary),
    new ButtonInfo("Primary2DAxisClick", ButtonReadType.Binary),
    new ButtonInfo("Secondary2DAxisTouch", ButtonReadType.Binary),
    new ButtonInfo("Secondary2DAxisClick", ButtonReadType.Binary),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DUp),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DDown),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DLeft),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DRight),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DUp),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DDown),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DLeft),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DRight),
    };

    Oculus Quest also reports a "GripButton" Binary feature and I can't grab with that. But, since it has a "Grip" Axis1D feature as well, I can use that instead (and it works)
     

    Attached Files:

  2. kenlange314

    kenlange314

    Joined:
    May 31, 2019
    Posts:
    3
    Changing the names in this file resolved the issue for me:

    Packages/XR Interaction Toolkit/Runtime/XR/InputHelper.cs

    public enum Button
    {
    None = 0,
    MenuButton,
    Trigger,
    Grip,
    // TriggerPressed,
    TriggerButton,
    // GripPressed,
    GripButton,
    PrimaryButton,
    PrimaryTouch,
    SecondaryButton,
    SecondaryTouch,
    Primary2DAxisTouch,
    Primary2DAxisClick,
    Secondary2DAxisTouch,
    Secondary2DAxisClick,
    PrimaryAxis2DUp,
    PrimaryAxis2DDown,
    PrimaryAxis2DLeft,
    PrimaryAxis2DRight,
    SecondaryAxis2DUp,
    SecondaryAxis2DDown,
    SecondaryAxis2DLeft,
    SecondaryAxis2DRight
    };


    ...


    static ButtonInfo[] s_ButtonData = new ButtonInfo[]
    {
    new ButtonInfo("", ButtonReadType.None),
    new ButtonInfo("MenuButton", ButtonReadType.Binary),
    new ButtonInfo("Trigger", ButtonReadType.Axis1D),
    new ButtonInfo("Grip", ButtonReadType.Axis1D),
    // new ButtonInfo("TriggerPressed", ButtonReadType.Binary),
    new ButtonInfo("TriggerButton", ButtonReadType.Binary),
    // new ButtonInfo("GripPressed", ButtonReadType.Binary),
    new ButtonInfo("GripButton", ButtonReadType.Binary),
    new ButtonInfo("PrimaryButton", ButtonReadType.Binary),
    new ButtonInfo("PrimaryTouch", ButtonReadType.Binary),
    new ButtonInfo("SecondaryButton", ButtonReadType.Binary),
    new ButtonInfo("SecondaryTouch", ButtonReadType.Binary),
    new ButtonInfo("Primary2DAxisTouch", ButtonReadType.Binary),
    new ButtonInfo("Primary2DAxisClick", ButtonReadType.Binary),
    new ButtonInfo("Secondary2DAxisTouch", ButtonReadType.Binary),
    new ButtonInfo("Secondary2DAxisClick", ButtonReadType.Binary),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DUp),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DDown),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DLeft),
    new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DRight),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DUp),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DDown),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DLeft),
    new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DRight),
    };
     
  3. kenlange314

    kenlange314

    Joined:
    May 31, 2019
    Posts:
    3
    For anyone else running into this issue, I built a "Monkey Patch" to correct this issue at runtime by directly changing the static "ButtonInfo" values in memory at startup.

    This allows you to avoid keeping your own custom copy of the XR ITK package.

    I hope it is useful to someone else until Unity get's this fixed.

    Just put this script on a game object in your first scene.
     

    Attached Files:

  4. harti177

    harti177

    Joined:
    Nov 5, 2018
    Posts:
    12