Search Unity

Detect which Monitor is VR device

Discussion in 'AR/VR (XR) Discussion' started by tgraupmann, Mar 22, 2016.

  1. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    Let's start with the manual section on multiple displays.
    http://docs.unity3d.com/Manual/MultiDisplay.html

    When a standalone Unity app runs on Windows, the resolution chooser dialog lets the user pick a monitor that hopefully corresponds to the VR device. From the docs, there are 8 monitor slots and the user has to guess which one is the VR device.

    Is there an easy way through script to determine which device is the VR device and activate that one?

    Through Mono and Windows.Forms script will only return a single screen (one of the limits of Mono 2.X) even though multiple displays are present.
    "Mono MWF Primary Display"

    Using a Windows.Form app, Screen.AllScreens just reports \\DISPLAY1 through \\DISPLAY8 with no real information about the monitors to determine which device might be a VR device.

    Maybe there's even https://slimdx.org/ which could enumerate the DX devices to get details about the connected monitors to find a ProductId or VendorId that would identify the VR device.

    Also, I'm curious about the Unity display enumeration. I'd like to know if the command-line `-adapter N (Windows only)` takes an adapter number that corresponds to the monitor number on the camera? Or can they be in a different order?
    http://docs.unity3d.com/Manual/CommandLineArguments.html

    Anyway, just curious what the community or Unity has to say about how a script might be able to automatically detect which display is connected to a VR device.

    Use Case 1) A user needs an easy way to select the connected VR device.

    Use Case 2) A user needs an easy way to pick from multiple connected VR devices.

    Feedback is appreciated.

    Thanks,

    ~Tim Graupmann
     
    Last edited: Mar 22, 2016
  2. xhonzi

    xhonzi

    Joined:
    Apr 2, 2013
    Posts:
    205
    Are you working with a dev kit? In my experience, Unity always auto selects the VR headset display (in this case- a DK2 with SDK 0.8 and in Direct mode) and the resolution picker only speaks to how it appears on the main monitor(s).

    i.e. If you choose 800x600 and windowed- it's in full VR quality on the headset, but windowed at 800x600 on whichever desktop you chose.

    As far as multiple devices- I agree that this will one day be a concern. Is it today?
     
  3. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    I'm using an Oculus DK1 and a Razer OSVR. I'm also using a desktop with two graphics cards with 8 potential HDMI connections. I think it's possible for game developers who are into VR will be testing against multiple VR headsets.
     
  4. xhonzi

    xhonzi

    Joined:
    Apr 2, 2013
    Posts:
    205
    Yes, but we expect developers to do things like unplug their other VR devices, even if they have a dozen. Once PCs support multiple simultaneous VR systems, I imagine we'll see switchers/selectors then.
     
    ian_umemoto likes this.
  5. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    I'm also experimenting with new VR headsets. In which case I need to be see the attached device info to identify vendor/product ids to activate the corresponding display.

    For the time being, I'll use a native plugin for a workaround which will have access to the device details that can make the information accessible to script.

    Let's say I have a native plugin that identifies which display the VR device is connected to. What order does Unity sort the display indexes with? Is the order determined by Windows.Forms in Screen order? Are the display indexes sorted by device name? Are the indexes in device manager order? Are they sorted by VID/PID?

    The documentation doesn't have much info about what order the displays are in the array.
    http://docs.unity3d.com/ScriptReference/Display-displays.html

    The API seems to only be able to identify the primary display.
    http://docs.unity3d.com/ScriptReference/Display.html

    This looks similar to the C# Windows Form .Net API....

    An ideal thing to add is a name, description, product id, and vendor id field to the Display API.
     
    Last edited: Mar 25, 2016
  6. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    Also another odd thing. In a standalone build sometimes the monitor chooser shows 8. And then after the VR display connects and the program ends, the monitor chooser is only showing 6 monitors.

    I know sometimes the drivers can kick in and a monitor turns into a VR device. The behaviour is just not right yet...
     
  7. xhonzi

    xhonzi

    Joined:
    Apr 2, 2013
    Posts:
    205
    Last edited: May 2, 2016