Forum Discussion
sh0v0r
13 years agoProtege
Correct Way To Detect The Hardware
I'm trying to make my game automatically switch to OVR mode when the Hardware is detected but I'm unsure as to how to do that correctly?
I have tried doing this:
But it seems to be true even when the headset is unplugged, I can only assume that it's because there is an OVRCameraController in the scene, what is the correct way to do this?
I have tried doing this:
if (OVRDevice.IsHMDPresent())
But it seems to be true even when the headset is unplugged, I can only assume that it's because there is an OVRCameraController in the scene, what is the correct way to do this?
21 Replies
Replies have been turned off for this discussion
- sh0v0rProtegeOK, just did some testing and it turns out that if there is an OVRCameraController enabled in the scene it will return true. If I disable it, then it returns false. What I want to do is check if the hardware is present regardless of there being a controller in the scene. That way I can enable the controller if the hardware is detected and chose the correct code path.
- sh0v0rProtegeWell on further inspection I realised the error of my ways, disabling the OVRCameraController disables the OVRDevice component.
So what I have done is created an 'Enabled' empty GameObject with just the OVRDevice Component and removed the OVRDevice Component from the 'Disabled' OVRCameraController.
Then in Start() I do this:
if (OVRDevice.SensorCount > 0)
{
normalCamera.SetActive(false);
riftCamera.SetActive(true); // OVRCameraController
}
I tested this works by pulling the USB cable out and restarting it and vice versa. - MikeArms24Honored GuestAwesome. Thanks for posting your outcome with this.
- cyberealityGrand ChampionThanks for sharing the solution.
- BLACKISHHonored GuestOVRDevice.SensorCount doesn't seem to exist anymore in 0.3.2, but OVRDevice.IsSensorPresent() works for me!
- BoffExplorerGood to know. Thanks for sharing sh0v0r and Blackish!
- drashHeroic ExplorerJust checked on this for clarity:
OVRDevice.IsHMDPresent() tells you whether the DVI/HDMI cable is connected/recognized between the control box and the PC. Didn't check if it's hot-swappable.
OVRDevice.IsSensorPresent() tells you whether the USB cable is connected between the control box and the PC. Seems to be hot-swappable.
If you're able to toggle between Rift mode and monitor mode on the fly, the logic could be simply "any time either HMD or Sensor is not present, revert to standard monitor mode".
Warning: It does not appear you can rely on these values returning the correct value until after Awake()/Start(). Either fiddle with script execution order, or put your Rift-detection logic in Update(). - konsnosHonored GuestThanks for the info guys.
I confirm that OVRDevice.IsSensorPresent() is hot-swappable while OVRDevice.IsHMDPresent() is not! - blank0Honored GuestI'm starting to integrate the Oculus Rift to a simple scene in unity.
I have two cameras in the scene, one is the main camera from Unity and the second one is the camera controller of the Oculus rift. I detach the OVRDevice script from the camera controller but the behavior hasn't change. If the empty object that contains the OVRDevice script is enabled, the OVRDevice.IsSensorPresent() will always return true. The same happens with the IsHMDPresent(). I'm using the DK1 with the 0.4 SDK, I don't know if that has something to do with it.
Is there any other way to detect the actual hardware device? - excelynxHonored Guest
"blank0" wrote:
I'm starting to integrate the Oculus Rift to a simple scene in unity.
I have two cameras in the scene, one is the main camera from Unity and the second one is the camera controller of the Oculus rift. I detach the OVRDevice script from the camera controller but the behavior hasn't change. If the empty object that contains the OVRDevice script is enabled, the OVRDevice.IsSensorPresent() will always return true. The same happens with the IsHMDPresent(). I'm using the DK1 with the 0.4 SDK, I don't know if that has something to do with it.
Is there any other way to detect the actual hardware device?
I noted the same issue in my post here: https://developer.oculusvr.com/forums/viewtopic.php?f=37&t=10892#p143830Warning: It does not appear you can rely on these values returning the correct value until after Awake()/Start(). Either fiddle with script execution order, or put your Rift-detection logic in Update().
drash might be right here, it's possible they've recently changed this behaviour in 0.4. I'm calling IsHMDPresent() in the exact same place where it worked in 0.2 and 0.3, and it doesn't seem to be working correctly in 0.4 - but I'll see if delaying the check makes any difference.
Edit: IsHMDPresent(), IsSensorPresent() and IsCameraPresent() do appear to be returning true regardless of the device state even with OVRDevice earlier in execution order and/or in an Update loop. I think this is just an issue with 0.4.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 years ago
- 11 months agoAnonymous