Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
lgrant's avatar
lgrant
Honored Guest
12 years ago

Cannonical way to determine if Rift is present?

I am trying to make one project that I can build for Windows with the Rift, Windows without the Rift, Android, and the web player. I have separate player controllers for Android, Rift, and non-Rift, and a Start() function that turns off the controllers that are not needed for a particular platform.

I am having great difficulty determining whether or not the Rift is attached. I have checked OVRDevice.IsInitialized() and OVRDevice.IsHMDPresent(), and both seem to be true if I have the OVRPlayerController, regardless of whether the device is actually present.

What should I be checking?

Thanks,

Lynn Grant
Cross Design Group LTD

5 Replies

Replies have been turned off for this discussion
  • That sound strange. Let me see if this is a bug or if there is a work around.
  • owenwp's avatar
    owenwp
    Expert Protege
    This is a little ambiguous even when it works. Everything seems to report that the Rift is there and functional as long as it is plugged in via USB, even if the display cable is unplugged or the power is off.

    It would be nice to have an easy way to know if the Rift is actually in a usable state. Not as much for Unity right now because you can't change the display adapter at runtime, but in general it makes sense from a user perspective to toggle VR on and off using the hardware button.

    While we are on the subject, it would be nice if the display adapter disconnected itself when the power is turned off, like a TV would.
  • Which is what it does. Only that "power" button only affects the display. The rest of electronics is permanently on and powered via USB. And thus you can't tell if it's on or off, neither it really should matter - I don't want to turn my Rift on just to test if some app actually works.

    There should be a menu switch.
  • You can try taking a look at the events that get fired from OVRDevice (check around line 294 in function Update()).

    I believe this should be enough to detect whether the Rift it plugged in or not.
  • "lgrant" wrote:
    I am trying to make one project that I can build for Windows with the Rift, Windows without the Rift, Android, and the web player. I have separate player controllers for Android, Rift, and non-Rift, and a Start() function that turns off the controllers that are not needed for a particular platform.

    I am having great difficulty determining whether or not the Rift is attached. I have checked OVRDevice.IsInitialized() and OVRDevice.IsHMDPresent(), and both seem to be true if I have the OVRPlayerController, regardless of whether the device is actually present.

    What should I be checking?

    Thanks,

    Lynn Grant
    Cross Design Group LTD


    If the rift is disconnected from the USB there will be no sensors.


    if (OVRDevice.SensorCount > 0) // Rift is present


    I made a post about this a few months ago:
    viewtopic.php?f=37&t=1648

    There probably should be a nicer way to do this by checking some SDK flag that makes the code nicer to read.