Search Unity

Question Check if the device is Oculus Quest 1 or Quest 2

Discussion in 'VR' started by saifshk17, Apr 19, 2021.

  1. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    How do I detect which headset (android) the application is running on?

    I am using XR plugin with Oculus XR. Is there a way to detect which device (Oculus Quest 1 or Oculus Quest 2) the app is running on?
    Code (CSharp):
    1. if (isQuest1 == true) {
    2.            //Quest 1 code
    3.        } else {
    4.            Quest 2 code
    5.        }
     
  2. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    105
    Hi,

    Currently, there is no public API available to detect App is running on Quest 1 or 2 in Oculus XR Plugin.
    Could you please share the use cases for it? So we could evaluate to add this support in future Oculus XR plugin release. And maybe there are some alternative available now that I could suggest.

    If you also have Oculus Integration Asset install in your project, you could use API below:
    OVRPlugin.GetSystemHeadsetType()

    Thanks
     
  3. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Hi the actual case for this is due to the eye resolution scale property. Oculus Quest 2 supports higher eye resolution scale whereas Oculus Quest 1 supports not as strong as Oculus Quest 2. So it is very important that when I make a build, the application selects the resolution value depending on the Quest device.
     
  4. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    eye resolution scale?

    ...AFAIK the Quest and Quest 2 do that stuff internally and automatically, there's no need to worry about it.
     
  5. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Yeah but incase of my application, I set them manually as per scene requirements. So it is very much necessary for me to have this feature of checking which device it is.
     
  6. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    Do you just want to change the Render Pipeline Resolution depending on hardware?

    if you're using OVRPlugin, check
    OVRPlugin.GetSystemHeadsetType()
    A quest 2 should show up as "Miramar", I believe.

    EDIT: A.K.A Listen to what the unity Rep said lol
     
  7. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Ah yes just saw it. It was not there before :)
     
  8. ImreT01

    ImreT01

    Joined:
    Jun 13, 2016
    Posts:
    5
  9. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    476
    Does anyone know how to detect a Quest Pro? It's not in that list of enums.
     
  10. Skibitsky

    Skibitsky

    Joined:
    Mar 22, 2016
    Posts:
    24
  11. Armegalo

    Armegalo

    Joined:
    May 14, 2018
    Posts:
    30
  12. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
  13. FantiniMotionandStrategy

    FantiniMotionandStrategy

    Joined:
    Sep 3, 2021
    Posts:
    5
    upload_2023-6-29_13-59-16.png
    A little hint, if you are using a Quest Pro and the method GetSystemHeadsetType() is still returning "Quest_2" instead of "Meta_Quest_Pro", be sure to check Quest Pro as a Target Device in your Project Settings -> XR Plug-in Management->Oculus.
     
  14. Armegalo

    Armegalo

    Joined:
    May 14, 2018
    Posts:
    30

    not any more, for whatever insane reason my quest 2 now calls itself "Standalone HMD". Great. I'm using SystemInfo.deviceModel, which tells me it's Oculus Quest... mmm, thanks.

    I think I can't use GetSystemHeadsetType() because I'm not using the OVR plugin, unless I'm getting very confused somewhere...
     
  15. egutentag

    egutentag

    Joined:
    Nov 27, 2020
    Posts:
    14
    Did you find a work around?
     
  16. FantiniMotionandStrategy

    FantiniMotionandStrategy

    Joined:
    Sep 3, 2021
    Posts:
    5
    Code (CSharp):
    1. var headsetType = OVRPlugin.GetSystemHeadsetType();
     
  17. AndreasWang

    AndreasWang

    Joined:
    Jul 31, 2019
    Posts:
    23
    If you dont want to depend on the oculus plugin you can also use AndroidJavaClass to access the android.os.Build constants, which lets you get the internal codename for the headset:

    Code (CSharp):
    1. public enum HeadsetType { Quest2, Quest3 }
    2.  
    3. var build = new AndroidJavaClass("android.os.Build");
    4. var device = build.GetStatic<string>("DEVICE");
    5. var headsetType = device.Contains("eureka") ? HeadsetType.Quest3 : HeadsetType.Quest2;
    If I remember correctly, Quest 2 devices should contain "miramar" in the same constant so that could be used to differentiate between Quest 1 and Quest 2 as well.
     
  18. TheDiscoRainbow

    TheDiscoRainbow

    Joined:
    Jan 20, 2016
    Posts:
    3
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class QuestHeadsetDetector: MonoBehaviour
    5. {
    6.     public TextMeshProUGUI textDeviceName;
    7.     public TextMeshProUGUI textHeadset;
    8.  
    9.     public enum HeadsetType { Quest1, Quest2, Quest3 }
    10.  
    11.     private void Start()
    12.     {
    13.         Dictionary<string, HeadsetType> headsetDictionary = new() {
    14.             { "miramar", HeadsetType.Quest1 },
    15.             { "hollywood", HeadsetType.Quest2 },
    16.             { "eureka", HeadsetType.Quest3 } };
    17.  
    18.         if (Application.platform == RuntimePlatform.Android)
    19.         {
    20.             textDeviceName.text = SystemInfo.deviceModel;
    21.  
    22.             if (SystemInfo.deviceModel == "Oculus Quest")
    23.             {
    24.                 var build = new AndroidJavaClass("android.os.Build");
    25.                 var device = build.GetStatic<string>("DEVICE");
    26.  
    27.                 HeadsetType headsetType = HeadsetType.Quest2;
    28.  
    29.                 if (headsetDictionary.ContainsKey(device))
    30.                 {
    31.                     headsetType = headsetDictionary[device];
    32.                 }
    33.  
    34.                 textHeadset.text = headsetType.ToString();
    35.             }
    36.  
    37.         }
    38.     }
    39. }
     
  19. SpeakBeaver

    SpeakBeaver

    Joined:
    Jul 8, 2015
    Posts:
    6
    Worked like a charm ! Thx mate