Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Bug OpenXR: Oculus doesn't recognize menuButton in script

Discussion in 'XR Interaction Toolkit and Input' started by Leoss, Feb 13, 2022.

  1. Leoss

    Leoss

    Joined:
    Apr 18, 2013
    Posts:
    9
    When using OpenXR with Oculus, the left menu button doesn't register when I use in code:

    Code (CSharp):
    1. controller.inputDevice.TryGetFeatureValue(CommonUsages.menuButton, out bool testVal);
    testVal is always false even when I press the menu button.

    It should work since:

    1) Every other buttons work just fine
    2) When using the Oculus Plugin, that line of code works fine
    3) When using OpenXR but with vive controllers, that line of code also works.

    Can you please advise?
     
  2. brgishy

    brgishy

    Joined:
    Jul 9, 2013
    Posts:
    31
  3. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    101
    Hey,

    Thanks for reporting this bug. We looked into it and have a fix for now. It will be included in our next OpenXR release soon. I can update this thread when next release is out, so you could try it out.

    Thanks
     
    brgishy likes this.
  4. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    101
    Update: The fix for this menu button issue was released in OpenXR SDK 1.4.1.
     
  5. lazylukey

    lazylukey

    Joined:
    May 26, 2017
    Posts:
    35
    Hi, after upgrading to OpenXR SDK 1.4.1 it appears to have broken the ability to use path "<XRController>{LeftHand}/{menu}" to recognise the menu button on oculus touch controllers. Is this a bug?

    Edit: will mention that the specific bind "<XRInputV1::Oculus::OculusTouchControllerOpenXR>{LeftHand}/menu" works fine
     
    Last edited: May 27, 2022
  6. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    254
    Hey @lazylukey,
    It looks like your syntax may be a little off. Here are the 2 options

    "<XRController>{LeftHand}/{menuButton}"

    or
    "<XRController>{LeftHand}/menu"


    This is because {menuButton} is part of the usages list but menu is not. Let us know if either of these works for you or if you are still having problems.
     
  7. AndrewLaBoyXR

    AndrewLaBoyXR

    Joined:
    Sep 23, 2016
    Posts:
    9
    I upgraded OpenXR to 1.4.1 and 1.4.2 and Oculus to 3.0.1 and 3.0.2 and am not getting anything from the menu button, if I set this same code's action map to something like grip pressed it works. I am on Unity 2021.2.18f1 and an Oculus Quest 2. (Standalone, not Quest 2, building from Apple Silicon MacBook Pro). I tried so many different menu button options.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.InputSystem;

    public class MenuToggle : MonoBehaviour
    {
    [SerializeField] InputActionAsset inputActions;
    InputAction menuToggle;
    bool menuActive;
    [SerializeField] GameObject menuPanel;

    // Start is called before the first frame update
    private void Start()
    {
    var inputActionMap = inputActions.FindActionMap("XRI LeftHand Interaction");
    menuToggle = inputActionMap.FindAction("Menu Toggle");
    menuToggle.performed += ToggleMenu;
    menuToggle.Enable();
    }

    public void ToggleMenu(InputAction.CallbackContext context)
    {
    if (menuActive)
    {
    menuActive = false;
    menuPanel.SetActive(false);
    }
    else
    {
    menuActive = true;
    menuPanel.SetActive(true);
    }
    }
    }
     
    Last edited: Jun 12, 2022
    HolovisionCB likes this.
  8. lazylukey

    lazylukey

    Joined:
    May 26, 2017
    Posts:
    35
    Hi thanks for the reply, can confirm `<XRController>{LeftHand}/menu` does work OK, thanks! :)
     
  9. HolovisionCB

    HolovisionCB

    Joined:
    Oct 13, 2021
    Posts:
    1
    I have the same issue, the following line works for everything except CommonUsages.menuButton
    Example:
    targetDevice.TryGetFeatureValue(CommonUsages.menuButton, out bool menuBtn);
     
  10. SimonFireproof

    SimonFireproof

    Joined:
    May 20, 2013
    Posts:
    16
    Just chiming in to say I'm also having this menu button problem. I just updated my OpenXR from 1.3.1 to to 1.4.2 hoping it would fix the issue, but it doesn't seem to.
     
  11. SimonFireproof

    SimonFireproof

    Joined:
    May 20, 2013
    Posts:
    16
    OK I've got it working now:
    "<XRController>{LeftHand}/menu"
    Does NOT Work
    "<XRController>{LeftHand}/{menuButton}"
    Works

    But unfortunately, adding menuButton through the InputActions UI adds
    "<XRController>{LeftHand}/menuButton"
    , which does NOT work. So you need to press the T and manually add the curly brackets
     
    VRDave_Unity likes this.
  12. AndrewLaBoyXR

    AndrewLaBoyXR

    Joined:
    Sep 23, 2016
    Posts:
    9
    @Tanya_Li this is still an issue if you are using the Oculus Android build setting with OpenXR, at least on Quest 2 anyway. It would be nice to get this fixed as I'd like to be able to use features such as Oculus hand tracking and passthrough AR. @HolovisionCB if you don't need Oculus features, switch your Android setting to OpenXR, don't use Oculus libraries.