diff --git a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp index 0be66bab67..cadb4a2e40 100644 --- a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp +++ b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp @@ -39,6 +39,7 @@ glm::mat4 OculusBaseDisplayPlugin::getHeadPose(uint32_t frameIndex) const { bool OculusBaseDisplayPlugin::isSupported() const { if (!OVR_SUCCESS(ovr_Initialize(nullptr))) { + qDebug() << "OculusBaseDisplayPlugin : ovr_Initialize() failed"; return false; } @@ -48,6 +49,7 @@ bool OculusBaseDisplayPlugin::isSupported() const { if (!OVR_SUCCESS(result)) { ovrErrorInfo error; ovr_GetLastErrorInfo(&error); + qDebug() << "OculusBaseDisplayPlugin : ovr_Create() failed" << result << error.Result << error.ErrorString; ovr_Shutdown(); return false; } diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 3f159eb916..508c89803d 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -72,10 +72,7 @@ mat4 toGlm(const vr::HmdMatrix34_t& m) { } bool OpenVrDisplayPlugin::isSupported() const { - auto hmd = acquireOpenVrSystem(); - bool success = nullptr != hmd; - releaseOpenVrSystem(); - return success; + return vr::VR_IsHmdPresent(); } void OpenVrDisplayPlugin::activate() { diff --git a/plugins/openvr/src/OpenVrHelpers.cpp b/plugins/openvr/src/OpenVrHelpers.cpp index 249643c73e..66a886b90e 100644 --- a/plugins/openvr/src/OpenVrHelpers.cpp +++ b/plugins/openvr/src/OpenVrHelpers.cpp @@ -23,11 +23,11 @@ using Lock = std::unique_lock<Mutex>; static int refCount { 0 }; static Mutex mutex; static vr::IVRSystem* activeHmd { nullptr }; -static bool hmdPresent = vr::VR_IsHmdPresent(); static const uint32_t RELEASE_OPENVR_HMD_DELAY_MS = 5000; vr::IVRSystem* acquireOpenVrSystem() { + bool hmdPresent = vr::VR_IsHmdPresent(); if (hmdPresent) { Lock lock(mutex); if (!activeHmd) { @@ -53,24 +53,7 @@ void releaseOpenVrSystem() { --refCount; if (0 == refCount) { qCDebug(displayplugins) << "openvr: zero refcount, deallocate VR system"; - // Avoid spamming the VR system with activate/deactivate calls at system startup by - // putting in a delay before we destory the shutdown the VR subsystem - - // FIXME releasing the VR system at all seems to trigger an exception deep inside the Oculus DLL. - // disabling for now. - //QTimer* releaseTimer = new QTimer(); - //releaseTimer->singleShot(RELEASE_OPENVR_HMD_DELAY_MS, [releaseTimer] { - // Lock lock(mutex); - // qDebug() << "Delayed openvr destroy activated"; - // if (0 == refCount && nullptr != activeHmd) { - // qDebug() << "Delayed openvr destroy: releasing resources"; - // activeHmd = nullptr; - // vr::VR_Shutdown(); - // } else { - // qDebug() << "Delayed openvr destroy: HMD still in use"; - // } - // releaseTimer->deleteLater(); - //}); + vr::VR_Shutdown(); } } } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index e1bda007bc..522c7f9c3d 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -48,10 +48,7 @@ static const QString RENDER_CONTROLLERS = "Render Hand Controllers"; const QString ViveControllerManager::NAME = "OpenVR"; bool ViveControllerManager::isSupported() const { - auto hmd = acquireOpenVrSystem(); - bool success = hmd != nullptr; - releaseOpenVrSystem(); - return success; + return vr::VR_IsHmdPresent(); } void ViveControllerManager::activate() {