Search Unity

Question Oculus Quest 2: OpenXR headset mounted/unmounted (userPresence) state, should it work?

Discussion in 'VR' started by jorrit-ijsfontein, Jun 22, 2023.

  1. jorrit-ijsfontein

    jorrit-ijsfontein

    Joined:
    Jan 26, 2015
    Posts:
    6
    Using XR Plugin Management and the OpenXR plugin I'm trying to get whether an Oculus Quest 2 headset is mounted or not. I have tried several things:
    1. Use InputDevice.TryGetFeatureValue for feature CommonUsages.userPresence querying for the headset device using InputDevices.GetDeviceAtXRNode(XRNode.Head). This doesn't give any proper result in the editor nor in the player on the Quest.
    2. Use an OpenXRFeature in which I keep track of the XrSessionState value, and assume `XR_SESSION_STATE_FOCUSED` is when the user is present. This works with Quest Link in the editor, but in the player on the Quest there is a 15 second delay between the actual unmounting of the headset and the change in session state.
    3. Don't use the OpenXR plugin loader, but the Oculus plugin loader for Android based devices (probably need another loader for other than Meta devices). This works, using the first method.
    My question is: is there a way to retrieve the Oculus userPresence state with the OpenXR plugin, or is using the Oculus XR plugin the only option?
     
    npatsiouras_ntua likes this.
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,050
    Ive heard application focus and unfocus could work for this, but haven't tried myself
     
    ShelbyJ likes this.
  3. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    There's ongoing discussions within the OpenXR working group to get user presence to be part of the spec. Right now it's not so we infer based on session state I think but it's not exactly user presence as you've found. We've seen other developers get close by inferring with more signals such as timing when the headset isn't moving.

    There's another thread on this here (and probably a few others .. maybe they'll give you some options): https://forum.unity.com/threads/openxr-new-input-system-detect-hmd-removed.1096345
     
    jorrit-ijsfontein and DevDunk like this.
  4. jorrit-ijsfontein

    jorrit-ijsfontein

    Joined:
    Jan 26, 2015
    Posts:
    6
    Thanks for the link. I have used most of the suggestions in that thread, and it seems there is currently no viable option other than to use the Oculus XR loader instead of the OpenXR loader. That's unfortunate, but I can work with that.
     
  5. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Yeah I think the Oculus XR loader uses a private extension that exposes the sensor state which we don't have access to .. I'll keep pushing the working group on this missing signal and get it in the spec.
     
  6. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    82
    Hey there @thep3000, I was searching for a similar solution and Google sent me to this thread. Appreciate you looking into it! Any update about a standard way in OpenXR to determine whether the headset is currently being worn or not?

    I have a similar use-case where I am building a high-throughput experience where the app needs to auto-reset when the headset is removed, and do an auto-recenter once the headset is worn (driven by my own C# logic). Currently, on an older version of Unity, this works great using the native Oculus SDK which allows me to check whether or not the headset is worn. But soon I'll be upgrading the project it to the newest LTS version of Unity and converting everything to OpenXR, so I need to have feature parity via OpenXR.

    Any thoughts for how to achieve this? Thanks!
     
    Last edited: Oct 6, 2023
  7. MaxwellLovellWPS

    MaxwellLovellWPS

    Joined:
    Jan 4, 2023
    Posts:
    9
    Have you found anything for this? We recently swapped to using OpenXR and have a similar use case
     
    Foreman_Dev likes this.
  8. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    82
    No, unfortunately I haven't gotten further into it. In the short term I'm still using the "Oculus" option in the XR settings instead of "OpenXR".

    Please let us know when you have any update about this @thep3000 - sounds like a decent amount of people want/need this functionality.
     
  9. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    The OpenXR working group is currently having a quarterly meetup and we discussed this issue today coincidentally. I reiterated the importance and even linked them to this thread. I think we've all reached agreement and should be merging this functionality to the spec very soon and it will make its way out to runtimes and we'll hook up our Unity implementation of it. When we have our implementation I'll share details here.
     
  10. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    82
    Thank you so much @thep3000 (and anyone else advocating for & contributing to this feature)!

    Our team greatly appreciates it, since knowing when the headset is removed and then worn again is utterly essential for high-throughput VR installations, where I need the app to reset itself (when removed from the user's head) and then begin the experience again as soon as the headset is disinfected and worn by the next person.

    It is also a nice feature for other things, such as fading out background music when the headset is removed. The app TRIPP does this, and it really adds a nice touch.
     
  11. djhatvr

    djhatvr

    Joined:
    Sep 22, 2019
    Posts:
    53
    Thank you, I've been fighting with this all day today and just came across this thread.
    Any idea what a possible time frame might be and if there is a workaround in the meantime?
    Can't use OVRManager since I'm trying to make it multiplatform...
     
    Foreman_Dev likes this.
  12. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    82
    @thep3000 Any update about the timeline for merging this functionality to the spec and hooking up the Unity implementation of it?
     
    Last edited: Jan 19, 2024
  13. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    862
    Still no update on this?
     
  14. hodafarhat

    hodafarhat

    Unity Technologies

    Joined:
    Dec 4, 2023
    Posts:
    1
    XR_EXT_user_presence was made available as a multi-vendor extension with the latest release of the Open XR SDK. It will be available through the existing CommonUsages.userPresence value. We are targeting the next Unity OpenXR package release which will be version 1.11.0.

    We are aware that updating this value will affect existing apps, so we are working on a solution that will not impact existing application functionality.
     
    cecarlsen and Foreman_Dev like this.
  15. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    82
    Amazing, thank you for the update @hodafarhat! :D

    This is currently the main issue preventing me from using OpenXR for the Quest 2 and 3, so I am grateful that this will be supported soon!