mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 03:33:25 +02:00
Disable OpenVR plugin when Oculus HMD is connected
This commit is contained in:
parent
25c8a3a0f3
commit
cde56d6fa2
4 changed files with 20 additions and 2 deletions
|
@ -38,7 +38,7 @@ static mat4 _sensorResetMat;
|
|||
static std::array<vr::Hmd_Eye, 2> VR_EYES { { vr::Eye_Left, vr::Eye_Right } };
|
||||
|
||||
bool OpenVrDisplayPlugin::isSupported() const {
|
||||
return vr::VR_IsHmdPresent();
|
||||
return !isOculusPresent() && vr::VR_IsHmdPresent();
|
||||
}
|
||||
|
||||
void OpenVrDisplayPlugin::internalActivate() {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QLoggingCategory>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(displayplugins)
|
||||
Q_LOGGING_CATEGORY(displayplugins, "hifi.plugins.display")
|
||||
|
@ -27,6 +28,22 @@ static vr::IVRSystem* activeHmd { nullptr };
|
|||
|
||||
static const uint32_t RELEASE_OPENVR_HMD_DELAY_MS = 5000;
|
||||
|
||||
bool isOculusPresent() {
|
||||
bool result = false;
|
||||
#if defined(Q_OS_WIN32)
|
||||
HANDLE oculusServiceEvent = ::OpenEventW(SYNCHRONIZE, FALSE, L"OculusHMDConnected");
|
||||
// The existence of the service indicates a running Oculus runtime
|
||||
if (oculusServiceEvent) {
|
||||
// A signaled event indicates a connected HMD
|
||||
if (WAIT_OBJECT_0 == ::WaitForSingleObject(oculusServiceEvent, 0)) {
|
||||
result = true;
|
||||
}
|
||||
::CloseHandle(oculusServiceEvent);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
vr::IVRSystem* acquireOpenVrSystem() {
|
||||
bool hmdPresent = vr::VR_IsHmdPresent();
|
||||
if (hmdPresent) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
bool isOculusPresent();
|
||||
vr::IVRSystem* acquireOpenVrSystem();
|
||||
void releaseOpenVrSystem();
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ static const QString RENDER_CONTROLLERS = "Render Hand Controllers";
|
|||
const QString ViveControllerManager::NAME = "OpenVR";
|
||||
|
||||
bool ViveControllerManager::isSupported() const {
|
||||
return vr::VR_IsHmdPresent();
|
||||
return !isOculusPresent() && vr::VR_IsHmdPresent();
|
||||
}
|
||||
|
||||
void ViveControllerManager::activate() {
|
||||
|
|
Loading…
Reference in a new issue