Search Unity

Detailed XR InputDevice names?

Discussion in 'AR/VR (XR) Discussion' started by justdizzy, Aug 2, 2019.

  1. justdizzy

    justdizzy

    Joined:
    Mar 8, 2016
    Posts:
    89
    In Unity 2019.x, if I only have the OpenVR and Oculus packages via Package Manager (no SteamVR or Oculus integrations from Asset Store), is there a way to differentiate what input device (Vive Wand, Oculus Touch, whatever Knuckles are called now) the player is using with just UnityEngine.XR methods? XR.InputDevices seems to only return generic names.
     
  2. justdizzy

    justdizzy

    Joined:
    Mar 8, 2016
    Posts:
    89
    I guess the answer is Input.GetJoystickNames() does provide detailed names, but for some reason my calls to it were returning empty strings till a second in.
     
  3. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    In 2019.1 and onwards we are migrating to a new set of hopefully easier to use APIs for XR inputs.
    See: https://forum.unity.com/threads/any-example-of-the-new-2019-1-xr-input-system.629824/

    If you move to those APIs, then you have this handy property:
    https://docs.unity3d.com/ScriptReference/XR.InputDevice-name.html
    And in 2019.3 you will also get:
    https://docs.unity3d.com/2019.3/Documentation/ScriptReference/XR.InputDevice-serialNumber.html
    and
    https://docs.unity3d.com/2019.3/Documentation/ScriptReference/XR.InputDevice-manufacturer.html
    as well.

    The name property should correspond with GetJoystickNames, but I think this new API will help you more easily look for a specific device, as well as get names for things like HMDs.
     
  4. justdizzy

    justdizzy

    Joined:
    Mar 8, 2016
    Posts:
    89
    Aha! I tried XRDevices.getDevices() but it was returning a single empty item. When I added it to the XRInputTests GetJoystickNames test scene which calls the display method, ShowJoystickNames(), every 3 seconds, I found that it was working, but just not on the first call from Start(). Sounds like when I tested the very first time (which caused me to start this post) I was running into a race condition between the headset/controllers loading and the data becoming readable.

    On further testing, I also found:
    XRDevice.deviceLoaded never got called, which I set in Start(), maybe I should try it in OnEnable() instead.
    I added a test of XRDevice.isPresent to the beginning of ShowJoystickNames(), and it always returned true, even the first time when getDevices() returned empty objects.
    In Start(), if I check XRSettings.loadedDeviceName before calling ShowJoystickNames(), getDevices() returned the devices correctly on the first call.

    Sounds like some user error on my part, but maybe also a bug in the software. Also, this was only tested in editor, not on a built application.
     
  5. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    I bet it's a dirty timing thing.

    So Start is called *right* before the first frame's Update call, and depending on the SDK we can be in a bit of a tricky situation in VR.

    Due to tracking, VR inputs are heavily tied to the rendering cycle. We often poll for inputs for both rendering AND the next frame before rendering the previous frame. This is to make sure that the tracking data we have for rendering the scene is as current as possible. The most obvious example of that is OpenVR, where we are actually polling our tracking data inside the graphics loop.

    What can happen is that we load the xrDevice before the first frame (and so before that frame's Start or OnEnable calls), and so your XRDevice.deviceLoaded call has already been sent, and so you won't see a new one. This is also why XRDevice.isPresent is true.
    But because we've not actually rendered out a frame, all we know is that devices exist and the SDK is polling. We don't yet know the names of those devices.

    This however looks very strange, and looks like a bug in the software:
    And I think I missed this the first time (and feel a little bad for suggesting you use InputDevices after you said it didn't suffice):
    Can you clarify?
    Testing in the office, we should be reporting names such as:
    `OpenVR Controller(VIVE Tracker Pro PVT)`
    `OpenVR Controller(Knuckles EV3.0 Left) - Left`
    `VIVE Tracker Pro PVT S/N LHR-OBDAA26C`
    `Oculus Touch Controller`
    etc...

    Can you give an example of a device name that is generic and the SDK it's reported from? I can make sure we provide as much detail as the SDK lets us.
     
  6. ixikos

    ixikos

    Joined:
    Jun 21, 2013
    Posts:
    26
    Could we possibly get a list of the current names of the devices? We are doing some custom controllers and variable setting and this seems like the best way to determine whats going on.
     
    andyman404 likes this.
  7. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    @StayTalm_Unity with Unity 2019.3.3 and latest Oculus (v14), I'm currently getting:

    Oculus Quest / Link:
    InputDevice.name = "Oculus Rift S" (!)
    InputDevice.manufacturer = (NULL)
    InputDevice.serialNumber = "__SerialNumber__"
     
  8. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @StayTalm_Unity At least on the Oculus platform, I'm getting incorrect results using InputDevice.name versus the old XRDevice.model and GetJoysticks techniques. So for a Rift-S, for example, the new APIs for InputDevice report it as being named "Oculus Rift". And for the controllers, they're reported as "Oculus Touch Controller - Left/Right". The joystick name was reporting Rift S (forgot the exact name). So using the new system, I'm unable to distinguish between an actual Rift and a Rift-S, which I need to be able to do. Especially the controllers, since they have different orientations.
     
  9. czeberesco

    czeberesco

    Joined:
    Aug 29, 2012
    Posts:
    1
    @Brady I've been developing VR games in Unity for some time now and making a proper distinction between devices of different brands and manufacturers is a real struggle every freakin time.
    I've recently discovered that the same controllers names differs depending on used SDK with InputDevice.name call.
    For instance controllers for Oculus Rift S - when using Oculus SDK - left controller is seen as "Oculus Touch Controller - Left", but switching to OpenVR causes the same controller to be seen as "OpenVR Controller(Oculus Rift S (Left Controller)) - Left".

    Moreover when using Oculus SDK there is no distinguish between Oculus Rift and Oculus Rift S controllers - they're both named "Oculus Touch Controller - Left" (OpenVR seems to distinguish them pretty well, but still the name differs between SDK's) and some dirty hacks are needed to find the proper one.
    This makes really hard to develop to different devices if you don't have them physically in your studio.
    You can just guess the names developers setup as a hardware description.
    Another really misleading example is Vive Focus Plus mobile device - headset is detected as "HMD Test Mock". Try to guess that one without checking!

    It would be incredibly helpful to have a table of all supported devices and all hardware names for all SDK's as seen when calling InputDevice.name. And iclude controllers orientations and offsets.
     
    Last edited: Sep 3, 2020
    robert_unity323, jotamaza and Brady like this.
  10. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    +1 I'd really love to see a table of the different names too. It's already awkward to have to explicitly try out multiple different headsets to find these names - but I don't own all the different headsets to be able to do this for everything.

    Really I wish there was a better designed API that assigned controllers, manufacturers and platform vendors numeric IDs somehow. I find it hard to trust that a string like "OpenVR Controller(Oculus Rift S (Left Controller)) - Left" isn't going to randomly change one day and break a ton of applications that are forced to relying on string comparisons to figure out what controllers are in use.

    Extra metadata about orientations would be really helpful as @czeberesco mentioned. In my application I'm having to calculate a rotation for each different controller for showing the controller placed on the floor, as an icon for asking users to put the controllers down. It would be great if I could query a suitable orientation for displaying a controller as if it were placed on a hard surface.
     
  11. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Agreed. I'm trying to handle Vive input with having limited buttons, but I don't know the controller name to check for. You should have enum supported entries for common headsets, and fallback to the name option for other headsets.
     
  12. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    +1 for table of device names (per-device AND per-platform, such as OpenVR vs. Oculus SDK, etc).

    ALSO +1 for orientation information. It's a pain-in-the-ass to manually set orientations on a per-device basis, and that's only possible if you HAVE one of those devices. For devs who don't have a sample of every kind of hardware, it's impossible to correctly orient a hand, for example, to the controller.
     
    kittik and unity_qeSHaIY6kVQeFw like this.
  13. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    Searching for that wished for table of device names brought me here... :(
     
  14. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    Yeah, I'm _again_ looking and wishing for a table of device names as I add support for yet another set of controllers :(
     
  15. ShasO_Terra_Kias

    ShasO_Terra_Kias

    Joined:
    Jun 27, 2018
    Posts:
    1
    I feel like a lot of people have been ending up like I did at the end of this thread dissapointed that there is no official list. While we wait to see if there is an official one I made a Spreadsheet of devices with names which has a form where people can add to it if they don't see their headset listed.
    https://docs.google.com/spreadsheets/d/1N3yxn_ieW8Cab3QoPiZAaHDS7ppwyQvmSNRVB7gniKg/edit?usp=sharing
    It'd be greatly appriciated if everyone could add their devices, before long I am sure we'll be able to have all values for common headsets!
     
  16. Cloudwalker_

    Cloudwalker_

    Joined:
    Jan 3, 2014
    Posts:
    140
    I suggest you add a drop down option (if it's possible??) asking which sdk is in use. As that may affect the value returned by the API, especially in the case of OpenXR which by the way device names can be pulled from the package code.

    Legacy / XRPlugin
    SteamVR
    OpenXR
     
    Last edited: Apr 26, 2021
  17. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    Any news on that? The provided google docs file is outdated and has only one entry.

    @StayTalm_Unity
    Maybe unity can provide a list, that would be really useful!
     
  18. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    53
    Welp, this thread isn't very useful. It seems like we lost a working solution with no good replacement. I'd love to hear if there's a better solution since this thread was last active.
     
    Last edited: Oct 18, 2023
  19. terencetao

    terencetao

    Joined:
    Dec 15, 2023
    Posts:
    1
    In Unity 2019.x, if you only have the OpenVR and Oculus packages via Package Manager, without SteamVR or Oculus integrations from the Asset Store, it may be challenging to differentiate specific input devices using just UnityEngine.XR methods. The XR.InputDevices may only return generic names in this context. You may need to implement additional platform-specific code to differentiate between input devices accurately.