From cc73528d0b7948fc52f7128d2a0729459e84d339 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 29 Jun 2020 11:12:22 +1200 Subject: [PATCH] Make Vive PRO Eye code Windows-only --- plugins/openvr/CMakeLists.txt | 4 ++-- plugins/openvr/src/ViveControllerManager.cpp | 19 +++++++++++++++++-- plugins/openvr/src/ViveControllerManager.h | 14 +++++++++++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/plugins/openvr/CMakeLists.txt b/plugins/openvr/CMakeLists.txt index fe46fbc209..4573715899 100644 --- a/plugins/openvr/CMakeLists.txt +++ b/plugins/openvr/CMakeLists.txt @@ -15,9 +15,9 @@ if ((WIN32 OR UNIX AND NOT APPLE) AND NOT USE_GLES) include_hifi_library_headers(octree) target_openvr() - target_sranipal() - target_aristo() if (WIN32) + target_sranipal() + target_aristo() target_link_libraries(${TARGET_NAME} Winmm.lib) endif() endif() diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 53452807e6..bf8f9db45d 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -19,10 +19,12 @@ #pragma warning( disable : 4334 ) #endif +#ifdef VIVE_PRO_EYE #include #include #include #include +#endif #ifdef _WIN32 #pragma warning( pop ) @@ -74,6 +76,7 @@ static const int SECOND_FOOT = 1; static const int HIP = 2; static const int CHEST = 3; +#ifdef VIVE_PRO_EYE enum ViveHandJointIndex { HAND = 0, THUMB_1, @@ -99,6 +102,7 @@ enum ViveHandJointIndex { Size }; +#endif const char* ViveControllerManager::NAME { "OpenVR" }; @@ -168,6 +172,7 @@ static glm::mat4 calculateResetMat() { return glm::mat4(); } +#ifdef VIVE_PRO_EYE class ViveProEyeReadThread : public QThread { public: ViveProEyeReadThread() { @@ -211,6 +216,7 @@ public: QMutex eyeDataMutex; EyeDataBuffer eyeDataBuffer; }; +#endif static QString outOfRangeDataStrategyToString(ViveControllerManager::OutOfRangeDataStrategy strategy) { @@ -323,7 +329,7 @@ bool areBothHandControllersActive(vr::IVRSystem*& system) { isHandControllerActive(system, vr::TrackedControllerRole_RightHand); } - +#ifdef VIVE_PRO_EYE void ViveControllerManager::enableGestureDetection() { if (_viveCameraHandTracker) { return; @@ -368,6 +374,7 @@ void ViveControllerManager::disableGestureDetection() { StopGestureDetection(); _viveCameraHandTracker = false; } +#endif bool ViveControllerManager::activate() { InputPlugin::activate(); @@ -389,6 +396,7 @@ bool ViveControllerManager::activate() { userInputMapper->registerDevice(_inputDevice); _registeredWithInputMapper = true; +#ifdef VIVE_PRO_EYE if (ViveSR::anipal::Eye::IsViveProEye()) { qDebug() << "Vive Pro eye-tracking detected"; @@ -409,6 +417,7 @@ bool ViveControllerManager::activate() { _viveProEyeReadThread->start(QThread::HighPriority); } } +#endif return true; } @@ -431,12 +440,14 @@ void ViveControllerManager::deactivate() { userInputMapper->removeDevice(_inputDevice->_deviceID); _registeredWithInputMapper = false; +#ifdef VIVE_PRO_EYE if (_viveProEyeReadThread) { _viveProEyeReadThread->quit = true; _viveProEyeReadThread->wait(); _viveProEyeReadThread = nullptr; ViveSR::anipal::Release(ViveSR::anipal::Eye::ANIPAL_TYPE_EYE); } +#endif saveSettings(); } @@ -449,6 +460,7 @@ bool ViveControllerManager::isHeadControllerMounted() const { return activityLevel == vr::k_EDeviceActivityLevel_UserInteraction; } +#ifdef VIVE_PRO_EYE void ViveControllerManager::invalidateEyeInputs() { _inputDevice->_poseStateMap[controller::LEFT_EYE].valid = false; _inputDevice->_poseStateMap[controller::RIGHT_EYE].valid = false; @@ -456,7 +468,6 @@ void ViveControllerManager::invalidateEyeInputs() { _inputDevice->_axisStateMap[controller::EYEBLINK_R].valid = false; } - void ViveControllerManager::updateEyeTracker(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { if (!isHeadControllerMounted()) { invalidateEyeInputs(); @@ -758,6 +769,7 @@ void ViveControllerManager::updateCameraHandTracker(float deltaTime, } _lastHandTrackerFrameIndex = handTrackerFrameIndex; } +#endif void ViveControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { @@ -796,11 +808,14 @@ void ViveControllerManager::pluginUpdate(float deltaTime, const controller::Inpu _registeredWithInputMapper = true; } +#ifdef VIVE_PRO_EYE if (_viveProEye) { updateEyeTracker(deltaTime, inputCalibrationData); } updateCameraHandTracker(deltaTime, inputCalibrationData); +#endif + } void ViveControllerManager::loadSettings() { diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 053e4bec54..06c58e2d97 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -25,12 +25,18 @@ #include #include "OpenVrHelpers.h" +#ifdef Q_OS_WIN +#define VIVE_PRO_EYE +#endif + using PuckPosePair = std::pair; namespace vr { class IVRSystem; } + +#ifdef VIVE_PRO_EYE class ViveProEyeReadThread; class EyeDataBuffer { @@ -45,7 +51,7 @@ public: float leftEyeOpenness { 0.0f }; float rightEyeOpenness { 0.0f }; }; - +#endif class ViveControllerManager : public InputPlugin { @@ -66,8 +72,10 @@ public: bool isHeadController() const override { return true; } bool isHeadControllerMounted() const; +#ifdef VIVE_PRO_EYE void enableGestureDetection(); void disableGestureDetection(); +#endif bool activate() override; void deactivate() override; @@ -75,9 +83,11 @@ public: QString getDeviceName() override { return QString::fromStdString(_inputDevice->_headsetName); } void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); } +#ifdef VIVE_PRO_EYE void invalidateEyeInputs(); void updateEyeTracker(float deltaTime, const controller::InputCalibrationData& inputCalibrationData); void updateCameraHandTracker(float deltaTime, const controller::InputCalibrationData& inputCalibrationData); +#endif void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override; virtual void saveSettings() const override; @@ -252,6 +262,7 @@ private: vr::IVRSystem* _system { nullptr }; std::shared_ptr _inputDevice { std::make_shared(_system) }; +#ifdef VIVE_PRO_EYE bool _viveProEye { false }; std::shared_ptr _viveProEyeReadThread; EyeDataBuffer _prevEyeData; @@ -268,6 +279,7 @@ private: void trackFinger(int hand, int jointIndex1, int jointIndex2, int jointIndex3, int jointIndex4, controller::StandardPoseChannel joint1, controller::StandardPoseChannel joint2, controller::StandardPoseChannel joint3, controller::StandardPoseChannel joint4); +#endif static const char* NAME; };