Is there a way to know if a VR device is connected ?

Hello,

I am currently working on an application using OpenXR. I wanted to be able to start the appliation in desktop mode when no VR device is found. I tried to achieve that using UnityEngine.XR.InputDevices.

        var inputDevices = new List<UnityEngine.XR.InputDevice>();
        UnityEngine.XR.InputDevices.GetDevices(inputDevices);
        Debug.Log(inputDevices.Count);


        foreach (var device in inputDevices)
        {
           Debug.Log(string.Format("Device found with name '{0}' and role '{1}'", device.name, device.characteristics.ToString()));
        }

Problem is that when I start the application in the Editor whith my HP Reverb G2 connected it starts correctly using the headset but my list of input device is empty. Did I miss something or is there a simpler way to do that ?

The easiest may be to start XR manually and then fallback to desktop if it fails to start.

Some docs here on that subject:
https://docs.unity3d.com/Packages/com.unity.xr.management@4.0/manual/EndUser.html

Hey, just checking if you resolved this issue? I’m currently having the same problem

The post from @the_real_apoxol is the way to do this. There is no way to know if a device is connected without starting XR in some way and seeing if it succeeds or not.

Is there an easy way to get a list of devices just in the Editor? For some reason HP Reverb G2 works fine but I can’t manage to listen to button pressing because the device list is always empty

The G2 reverb requires a special interaction profile for input that can be found in microsofts openxr package.

https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/unity-reverb-g2-controllers