Checking user presence via CommonUsages on Rift

Hey there,

I got a warning saying that checking user presence via XRDevice.userPresence is obsolete and to use CommonUsages.userPresence instead. So I implemented it like this.

InputDevice headDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head);
if (headDevice.isValid == false) return;

bool presenceFeatureSupported = headDevice.TryGetFeatureValue(CommonUsages.userPresence, out bool userPresent);

However, presenceFeatureSupported is always false on Oculus Rift. Do I need to use the new XR Management system to get this work ?

I’m running Unity 2019.3.0f3 and Oculus integration 1.43

1 Like

bump

Hello!

Sorry for the delay, Oculus Integration is their own plugin, and it doesn’t affect the InputDevice APIs. What you are going to want to use to get the latest InputDevice data (that user presence feature was added in September), is to include the new XR Plugin Architecture Oculus package. In Window->Package Manager, be sure to install ‘Oculus XR Plugin’, anything above 1.0.3. This will require XR Management and XR Loaders. See this Forum post for info on our new XR Plugin setup: XR Plugins and Subsystems

After that, it should ‘just work’ in that HMD devices should contain a userPresence feature.

If you are on the Oculus XR Plugin and at a current version, ping back, something must have gone wrong.

Ah gotcha. So to get this to work I need to:

  1. Uninstall the Oculus Desktop & Android packages
  2. Install the XR Management package
  3. Install Oculus loader from project settings.
  4. Install the Oculus XR Plugin.

@Solovykh
Yeah.
We’ve swapped over to a more extensible backend in 2019.3, which will help us with cross-platform support, and mix & match SDK parts, but it does require a bit more initial setup.

But that new plugin will be sending the user Presence data on the HMD, as long as it is above 1.0.3 (or 1.1.x).

I had the same problem to detect when the user removes the device.
I’ve used the code above, but I did a little change in order to detect the right value.
This is my contribution

InputDevice headDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head);
            if (headDevice.isValid == false) return;
            bool userPresent = false;
            bool presenceFeatureSupported = headDevice.TryGetFeatureValue(CommonUsages.userPresence, out userPresent);

            Debug.Log(headDevice.isValid + " ** " + presenceFeatureSupported + " ** " + userPresent);

The variable userPresent is true when user is wearing the device and false otherwise.

4 Likes

@StayTalm_Unity
I did this to my project and now although that allows me to use perform the userPresence check using the commonusage and now have a UI that looks horrendous. The UI is being updated without ever removing the previously loaded frames. To exemplify this I have a loading sequence where 2 dots orbit a middle dot clockwise. The picture below illustrates what happens since previous frames are not removed:

Text also becomes overexposed etc as the same word is written over and over again.

Any ideas?

@SteenPetersen
Forwarded it along to our Oculus-specific devs, but please report a bug if you can, that shouldn’t be happening.