Search Unity

Detect What Headset Is Connected (Gear Vr or Oculus Go)

Discussion in 'AR/VR (XR) Discussion' started by Gus_NoiseT, Jun 14, 2018.

  1. Gus_NoiseT

    Gus_NoiseT

    Joined:
    Aug 30, 2017
    Posts:
    4
    Hi,

    I'm currently developing an app for the Gear VR and Oculus Go. I'm sure this is just me being daft but is there any way to detect which headset the application is running on (Oculus Go or VR)?
    Code (CSharp):
    1. UnityEngine.XR.XRDevice.model
    gives me Samsung S8 for a phone and
    Code (CSharp):
    1. UnityEngine.XR.XRSettings.loadedDeviceName
    only seems to provide info about which sdk is being (i.e. it only says Oculus for both).

    Many thanks for any help! :)
     
  2. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    If you're in a pinch and you need this right *now*, then you can do something like:

    Code (CSharp):
    1. if (OVRManager.tiledMultiResSupported)
    2. {
    3.     // This is an Oculus Go
    4. }
    5. else
    6. {
    7.     // This is a phone
    8. }
    But of course that will break in the future when some phone also rolls out support for fixed foveated rendering, if any of them ever do. So it's not ideal.
     
    ViewportAU likes this.
  3. Gus_NoiseT

    Gus_NoiseT

    Joined:
    Aug 30, 2017
    Posts:
    4
    That's a bummer! Are you aware of any official list of supported devices or is there a doc somewhere with Oculus guidelines for how to best support multiple devices ?
     
  4. Gus_NoiseT

    Gus_NoiseT

    Joined:
    Aug 30, 2017
    Posts:
    4
    @Claytonious I've been digging around the OVR stuff and found something interesting.
    The OVRGearVrController has this:

    Code (CSharp):
    1. private bool m_isOculusGo;
    2.  
    3. void Start ()
    4. {
    5. m_isOculusGo = (OVRPlugin.productName == "Oculus Go");
    6. }
    Which I would assume is a safer way of dealing with this issue :)
    However once again my google-fu is failing me, but I can't seem to find a complete productName list online?
     
  5. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    I think you'll find that there isn't a complete product list anywhere by design, because the day after your game ships, 5 new devices might hit the market, right? So there is no way to bake knowledge of every future device into your build.
     
    guneyozsan likes this.
  6. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    904
    For sure! That's much better!
     
  7. camerontynespnnl

    camerontynespnnl

    Joined:
    Dec 11, 2017
    Posts:
    2
    Been trying to figure this out as well. Developing for both is practically the same thing from a code standpoint, and all I want is to be able to differentiate between the two at runtime so I can do specific things. Really hoping Unity updates the return values of XRDevice.model. That'd solve this whole issue instead of having to do these workarounds which could instantly be broken as soon as Oculus updates OVRManager or some other core script in their utilities.

    Regardless, been keeping an eye on this thread since it popped up. Thanks for the ideas you two! the OVRPlugin.productName seems like a solid bet ;)
     
    Last edited: Jun 15, 2018
  8. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Given that they're both Android wouldn't systeminfo.devicemodel work?
     
  9. mechaghost

    mechaghost

    Joined:
    Feb 1, 2013
    Posts:
    2
    I use XRDevice.model.ToLower().Contains("oculus go") to detect the model type

    XRDevice.model will return "Oculus Go"
     
    ROBYER1 likes this.
  10. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    I know this post comes late but there's
    OVRPlugin.GetSystemHeadsetType()


    which returns the exact type of headset as enum. In the case of Oculus Go
    SystemHeadset.Oculus_Go
     
  11. guneyozsan

    guneyozsan

    Joined:
    Feb 1, 2012
    Posts:
    99
    I would add a removal for whitespace and non-alphanumeric characters to make sure nothing breaks in the future in case someone changes it to OculusGo, oculus-go, or oculus_go. You know, things like that happen.

    @spacefrog's suggestion to use
    OVRPlugin.GetSystemHeadsetType()
    seems to be the most robust one as it is provided by the SDK itself. Just note that GearVR versions are enumerated by version, so use something like
    OVRPlugin.GetSystemHeadsetType().ToString().Contains("GearVR")
    to include future GearVR versions.

    Here is the current list:

    Code (CSharp):
    1. public enum SystemHeadset
    2. {
    3.     None = 0,
    4.     GearVR_R320, // Note4 Innovator
    5.     GearVR_R321, // S6 Innovator
    6.     GearVR_R322, // Commercial 1
    7.     GearVR_R323, // Commercial 2 (USB Type C)
    8.     GearVR_R324, // Commercial 3 (USB Type C)
    9.     GearVR_R325, // Commercial 4 (USB Type C)
    10.     Oculus_Go,
    11.  
    12.     Rift_DK1 = 0x1000,
    13.     Rift_DK2,
    14.     Rift_CV1,
    15. }
     
    ssojyeti2, Jelmer123 and Untoldecay like this.