Search Unity

Oculus GO BackButton with Unity.XR has issues...

Discussion in 'AR/VR (XR) Discussion' started by josrodes, Mar 25, 2020.

  1. josrodes

    josrodes

    Joined:
    Nov 15, 2017
    Posts:
    10
    :(
    I'm having issues with the BackButton for the Oculus GO.

    Code (CSharp):
    1. Controller.TryGetFeatureValue(CommonUsages.menuButton, out backButtonPressed);
    It is not being reliable, it returns false intermittently and I can't figure out how to get around it.

    Here is the code I'm using to test it( this works great on the Oculus Quest BTW) so it seems to be something specific to the GO controller, even if I change it to lefthand I see the same issue.

    Code (CSharp):
    1.  
    2.    void Update()
    3.     {
    4.         if (rightController.isValid)
    5.         {
    6.             bool backButtonPressed;
    7.             if (rightController.TryGetFeatureValue(CommonUsages.menuButton, out backButtonPressed) && backButtonPressed)
    8.             {
    9.                 buttonPressed.text = "MenuButton Pressed";
    10.             }
    11.             bool triggerButtonPressed;
    12.             if (rightController.TryGetFeatureValue(CommonUsages.triggerButton, out triggerButtonPressed) && triggerButtonPressed)
    13.             {
    14.                 //reset the text with the trigger
    15.                 buttonPressed.text = "";
    16.             }
    17.         }
    18.  
    19.         if (leftController.isValid)
    20.         {
    21.             bool backButtonPressed;
    22.             if (leftController.TryGetFeatureValue(CommonUsages.menuButton, out backButtonPressed) && backButtonPressed)
    23.             {
    24.                 buttonPressed.text = "MenuButton Pressed";
    25.             }
    26.             bool triggerButtonPressed;
    27.             if (leftController.TryGetFeatureValue(CommonUsages.triggerButton, out triggerButtonPressed) && triggerButtonPressed)
    28.             {
    29.                 //reset the text with the trigger
    30.                 buttonPressed.text = "";
    31.             }
    32.         }
    33.     }
    34.  
    Any idea how to get around this issue? Maybe a higher-level event I can hook into?

    Really appreciate any help here :)
    Thanks!
     
    Last edited: Mar 25, 2020
  2. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,161
    Minor point, but your code is wrong: you should't be sharing the booleans like that. (this probably isn't causing the strange behaviour you're seeing, but it could cause bugs in the future and it'll be hard to spot them).

    Should be something like:

    Code (CSharp):
    1. if( TryGetFeatureValue( ... out bool B1 ) )
    2. {
    3. if( B1 )
    4.    ... do something
    5. }
    ...otherwise you're ignoring the API's primaray error reporting (where it returns false - but you're not even reading the API's bool right now), and your code is rolling-over the value of a previous bool to a next bool, poisoining the second with the first.

    If you want to reduce the number of lines of code, a neat trick is:

    Code (CSharp):
    1. if( TryGetFeatureValue( ... out bool B1 ) && B1 )
    2. {
    3.    ... do something
    4. }
    ...which I prefer. Keeps the code 1-line and cleaner to read. Although it's a bit alarming to peopel who aren't comfortable with how the latest C# compiler handles on-demand "out" declarations. And, of course, it also discards the error reporting - but at least it only takes action at the correct times!
     
  3. josrodes

    josrodes

    Joined:
    Nov 15, 2017
    Posts:
    10
    Good point, I updated the snippet to include your suggestion. Thanks.

    Still looking for an answer...
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,753
    Where are you polling it, in which loop?
     
  5. josrodes

    josrodes

    Joined:
    Nov 15, 2017
    Posts:
    10
    I have tried in the Update and FixedUpdate, no luck.
     
  6. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    637
    Old post, but we have some issues with the backbutton as well. Using the XR Input the "menu button" is stated as valid input usage. But the out value is often not set to true while it should be because it is pressed. This is indeed only for the Oculus GO controller back button. Holding the button doesn't set it to true either.

    I'm not even sure when this bug got introduced as it worked before.
    We're testing less and less for the Oculus GO since it has been abandoned by Oculus. But this bug was reported by one of our clients as they still use the Oculus GO.

    Our quick fix is going to be checking whether the Escape key is being pressed. Because the backbutton of the Oculus GO also sends out the Escape key in the regular old Input class.

    For Oculus Quest the XR Input works perfectly fine...
     
    josrodes likes this.
  7. josrodes

    josrodes

    Joined:
    Nov 15, 2017
    Posts:
    10
unityunity