diff --git a/BUILD.md b/BUILD.md index c8d4785d08..db81ecb30d 100644 --- a/BUILD.md +++ b/BUILD.md @@ -21,8 +21,8 @@ These dependencies need not be installed manually. They are automatically downloaded on the platforms where they are required. - [Bullet Physics Engine](https://github.com/bulletphysics/bullet3/releases): 2.83 - [glm](https://glm.g-truc.net/0.9.8/index.html): 0.9.8 -- [Oculus SDK](https://developer.oculus.com/downloads/): 1.11 (Win32) / 0.5 (Mac) -- [OpenVR](https://github.com/ValveSoftware/openvr): 1.11.11 (Win32 only) +- [Oculus SDK](https://developer.oculus.com/downloads/): 1.11 (Windows) / 0.5 (Mac) +- [OpenVR](https://github.com/ValveSoftware/openvr): 1.11.11 (Windows, Linux) - [Polyvox](http://www.volumesoffun.com/): 0.2.1 - [QuaZip](https://sourceforge.net/projects/quazip/files/quazip/): 0.7.3 - [SDL2](https://www.libsdl.org/download-2.0.php): 2.0.3 diff --git a/cmake/ports/hifi-client-deps/CONTROL b/cmake/ports/hifi-client-deps/CONTROL index 7070cb6fb9..4a8a2bc44e 100644 --- a/cmake/ports/hifi-client-deps/CONTROL +++ b/cmake/ports/hifi-client-deps/CONTROL @@ -1,4 +1,4 @@ Source: hifi-client-deps Version: 0.1 Description: Collected dependencies for High Fidelity applications -Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr (windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator +Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr (linux|windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator diff --git a/cmake/ports/openvr/portfile.cmake b/cmake/ports/openvr/portfile.cmake index b91bdd1d54..bcbac8613a 100644 --- a/cmake/ports/openvr/portfile.cmake +++ b/cmake/ports/openvr/portfile.cmake @@ -11,15 +11,23 @@ vcpkg_from_github( set(VCPKG_LIBRARY_LINKAGE dynamic) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(ARCH_PATH "win64") + if(WIN32) + set(ARCH_PATH "win64") + else() + set(ARCH_PATH "linux64") + endif() elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - set(ARCH_PATH "win32") + if(WIN32) + set(ARCH_PATH "win32") + else() + set(ARCH_PATH "linux32") + endif() else() - message(FATAL_ERROR "Package only supports x64 and x86 windows.") + message(FATAL_ERROR "Package only supports x64 and x86 Windows and Linux.") endif() -if(VCPKG_CMAKE_SYSTEM_NAME) - message(FATAL_ERROR "Package only supports windows desktop.") +if(VCPKG_CMAKE_SYSTEM_NAME AND NOT (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux")) + message(FATAL_ERROR "Package only supports Windows or Linux desktop.") endif() file(MAKE_DIRECTORY @@ -28,18 +36,35 @@ file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib ${CURRENT_PACKAGES_DIR}/debug/bin ) -file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib) -file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) -file(COPY - ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll - ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/bin -) -file(COPY - ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll - ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin -) + +if(WIN32) + file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + file(COPY + ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll + ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin + ) + file(COPY + ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll + ${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin + ) +else() + file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/libopenvr_api.so DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/libopenvr_api.so DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + file(COPY + ${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so + ${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so.dbg + DESTINATION ${CURRENT_PACKAGES_DIR}/bin + ) + file(COPY + ${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so + ${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so.dbg + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin + ) +endif() + file(COPY ${SOURCE_PATH}/headers DESTINATION ${CURRENT_PACKAGES_DIR}) file(RENAME ${CURRENT_PACKAGES_DIR}/headers ${CURRENT_PACKAGES_DIR}/include) diff --git a/plugins/openvr/CMakeLists.txt b/plugins/openvr/CMakeLists.txt index e80b2215bf..9690ee3fb5 100644 --- a/plugins/openvr/CMakeLists.txt +++ b/plugins/openvr/CMakeLists.txt @@ -1,12 +1,13 @@ # # Created by Bradley Austin Davis on 2015/11/18 # Copyright 2015 High Fidelity, Inc. +# Copyright 2020 Vircadia contributors. # # Distributed under the Apache License, Version 2.0. # See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html # -if (WIN32 AND (NOT USE_GLES)) +if ((WIN32 OR UNIX AND NOT APPLE) AND NOT USE_GLES) set(TARGET_NAME openvr) setup_hifi_plugin(Gui Qml Multimedia) link_hifi_libraries(shared task gl qml networking controllers ui @@ -15,7 +16,9 @@ if (WIN32 AND (NOT USE_GLES)) include_hifi_library_headers(octree) target_openvr() - target_sranipal() - target_aristo() - target_link_libraries(${TARGET_NAME} Winmm.lib) + if (WIN32) + target_sranipal() + target_aristo() + target_link_libraries(${TARGET_NAME} Winmm.lib) + endif() endif() diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 7691d2ab70..c5eb740325 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -1,6 +1,7 @@ // // Created by Bradley Austin Davis on 2015/05/12 // Copyright 2015 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -739,6 +740,8 @@ int OpenVrDisplayPlugin::getRequiredThreadCount() const { QString OpenVrDisplayPlugin::getPreferredAudioInDevice() const { QString device = getVrSettingString(vr::k_pch_audio_Section, vr::k_pch_audio_RecordingDeviceOverride_String); + // FIXME: Address Linux. +#ifdef Q_OS_WIN if (!device.isEmpty()) { static const WCHAR INIT = 0; size_t size = device.size() + 1; @@ -748,11 +751,14 @@ QString OpenVrDisplayPlugin::getPreferredAudioInDevice() const { // FIXME: This may not be necessary if vr::k_pch_audio_RecordingDeviceOverride_StringName is used above. device = AudioClient::getWinDeviceName(deviceW.data()); } +#endif return device; } QString OpenVrDisplayPlugin::getPreferredAudioOutDevice() const { QString device = getVrSettingString(vr::k_pch_audio_Section, vr::k_pch_audio_PlaybackDeviceOverride_String); + // FIXME: Address Linux. +#ifdef Q_OS_WIN if (!device.isEmpty()) { static const WCHAR INIT = 0; size_t size = device.size() + 1; @@ -762,6 +768,7 @@ QString OpenVrDisplayPlugin::getPreferredAudioOutDevice() const { // FIXME: This may not be necessary if vr::k_pch_audio_PlaybackDeviceOverride_StringName is used above. device = AudioClient::getWinDeviceName(deviceW.data()); } +#endif return device; } diff --git a/plugins/openvr/src/OpenVrHelpers.cpp b/plugins/openvr/src/OpenVrHelpers.cpp index e55e7feaf4..ce7625eedb 100644 --- a/plugins/openvr/src/OpenVrHelpers.cpp +++ b/plugins/openvr/src/OpenVrHelpers.cpp @@ -1,6 +1,7 @@ // // Created by Bradley Austin Davis on 2015/11/01 // Copyright 2015 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -18,8 +19,6 @@ #include #include -#include -#include #include #include #include @@ -51,7 +50,7 @@ static const uint32_t RELEASE_OPENVR_HMD_DELAY_MS = 5000; bool isOculusPresent() { bool result = false; -#if defined(Q_OS_WIN32) +#ifdef Q_OS_WIN HANDLE oculusServiceEvent = ::OpenEventW(SYNCHRONIZE, FALSE, L"OculusHMDConnected"); // The existence of the service indicates a running Oculus runtime if (oculusServiceEvent) { @@ -208,8 +207,10 @@ void finishOpenVrKeyboardInput() { updateFromOpenVrKeyboardInput(); // Simulate an enter press on the top level window to trigger the action if (0 == (_currentHints & Qt::ImhMultiLine)) { - qApp->sendEvent(offscreenUi->getWindow(), &QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::KeyboardModifiers(), QString("\n"))); - qApp->sendEvent(offscreenUi->getWindow(), &QKeyEvent(QEvent::KeyRelease, Qt::Key_Return, Qt::KeyboardModifiers())); + auto keyPress = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::KeyboardModifiers(), QString("\n")); + auto keyRelease = QKeyEvent(QEvent::KeyRelease, Qt::Key_Return, Qt::KeyboardModifiers()); + qApp->sendEvent(offscreenUi->getWindow(), &keyPress); + qApp->sendEvent(offscreenUi->getWindow(), &keyRelease); } } @@ -293,11 +294,20 @@ void handleOpenVrEvents() { ulong promitySensorFlag = (1UL << ((int)vr::k_EButton_ProximitySensor)); _headInHeadset = (controllerState.ulButtonPressed & promitySensorFlag) == promitySensorFlag; } - } #if DEV_BUILD - qDebug() << "OpenVR: Event " << activeHmd->GetEventTypeNameFromEnum((vr::EVREventType)event.eventType) << "(" << event.eventType << ")"; + //qDebug() << "OpenVR: Event " << activeHmd->GetEventTypeNameFromEnum((vr::EVREventType)event.eventType) << "(" << event.eventType << ")"; + // FIXME: Reinstate the line above and remove the following lines once the problem with excessive occurrences of + // VREvent_ActionBindingReloaded events is fixed in SteamVR for Linux. + // https://github.com/ValveSoftware/SteamVR-for-Linux/issues/307 + #ifdef Q_OS_LINUX + if (event.eventType != vr::VREvent_ActionBindingReloaded) { + qDebug() << "OpenVR: Event " << activeHmd->GetEventTypeNameFromEnum((vr::EVREventType)event.eventType) << "(" << event.eventType << ")"; + }; + #else + qDebug() << "OpenVR: Event " << activeHmd->GetEventTypeNameFromEnum((vr::EVREventType)event.eventType) << "(" << event.eventType << ")"; + #endif #endif } @@ -407,9 +417,32 @@ void showMinSpecWarning() { qFatal("Unable to create overlay"); } - // Needed here for PathUtils +#ifdef Q_OS_LINUX + QFile cmdlineFile("/proc/self/cmdline"); + if (!cmdlineFile.open(QIODevice::ReadOnly)) { + qFatal("Unable to open /proc/self/cmdline"); + } + + auto contents = cmdlineFile.readAll(); + auto arguments = contents.split('\0'); + arguments.pop_back(); // Last element is empty. + cmdlineFile.close(); + + int __argc = arguments.count(); + char** __argv = new char* [__argc]; + for (int i = 0; i < __argc; i++) { + __argv[i] = arguments[i].data(); + } +#endif + QCoreApplication miniApp(__argc, __argv); +#ifdef Q_OS_LINUX + QObject::connect(&miniApp, &QCoreApplication::destroyed, [=] { + delete[] __argv; + }); +#endif + vrSystem->ResetSeatedZeroPose(); QString imagePath = PathUtils::resourcesPath() + "/images/steam-min-spec-failed.png"; vrOverlay->SetOverlayFromFile(minSpecFailedOverlay, imagePath.toLocal8Bit().toStdString().c_str()); @@ -487,7 +520,12 @@ bool checkMinSpecImpl() { } extern "C" { +#if defined(Q_OS_WIN32) __declspec(dllexport) int __stdcall CheckMinSpec() { +#else + __attribute__((visibility("default"))) int CheckMinSpec() { +#endif return checkMinSpecImpl() ? 1 : 0; } + } diff --git a/plugins/openvr/src/OpenVrHelpers.h b/plugins/openvr/src/OpenVrHelpers.h index b0960a03eb..23bd9f39de 100644 --- a/plugins/openvr/src/OpenVrHelpers.h +++ b/plugins/openvr/src/OpenVrHelpers.h @@ -1,6 +1,7 @@ // // Created by Bradley Austin Davis on 2015/06/12 // Copyright 2015 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -76,7 +77,7 @@ struct PoseData { } void update(const glm::mat4& resetMat) { - for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) { + for (uint32_t i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) { if (!vrPoses[i].bPoseIsValid) { continue; } @@ -87,7 +88,7 @@ struct PoseData { } void resetToInvalid() { - for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) { + for (uint32_t i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) { vrPoses[i].bPoseIsValid = false; } } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 2c9eb296ab..37871a8c4c 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -1,9 +1,9 @@ // // ViveControllerManager.cpp -// input-plugins/src/input-plugins // // Created by Sam Gondelman on 6/29/15. // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -19,10 +19,12 @@ #pragma warning( disable : 4334 ) #endif +#ifdef VIVE_PRO_EYE #include #include #include #include +#endif #ifdef _WIN32 #pragma warning( pop ) @@ -49,7 +51,7 @@ #include #include -#include +#include #include #include "OpenVrDisplayPlugin.h" @@ -60,13 +62,8 @@ vr::IVRSystem* acquireOpenVrSystem(); void releaseOpenVrSystem(); static const QString OPENVR_LAYOUT = QString("OpenVrConfiguration.qml"); -static const char* CONTROLLER_MODEL_STRING = "vr_controller_05_wireless_b"; const quint64 CALIBRATION_TIMELAPSE = 1 * USECS_PER_SECOND; -static const char* MENU_PARENT = "Avatar"; -static const char* MENU_NAME = "Vive Controllers"; -static const char* MENU_PATH = "Avatar" ">" "Vive Controllers"; - static const int MIN_HEAD = 1; static const int MIN_PUCK_COUNT = 2; static const int MIN_FEET_AND_HIPS = 3; @@ -79,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, @@ -104,6 +102,7 @@ enum ViveHandJointIndex { Size }; +#endif const char* ViveControllerManager::NAME { "OpenVR" }; @@ -157,22 +156,7 @@ static QString deviceTrackingResultToString(vr::ETrackingResult trackingResult) return result; } -static glm::mat4 calculateResetMat() { - auto chaperone = vr::VRChaperone(); - if (chaperone) { - float const UI_RADIUS = 1.0f; - float const UI_HEIGHT = 1.6f; - float const UI_Z_OFFSET = 0.5; - - float xSize, zSize; - chaperone->GetPlayAreaSize(&xSize, &zSize); - glm::vec3 uiPos(0.0f, UI_HEIGHT, UI_RADIUS - (0.5f * zSize) - UI_Z_OFFSET); - - return glm::inverse(createMatFromQuatAndPos(glm::quat(), uiPos)); - } - return glm::mat4(); -} - +#ifdef VIVE_PRO_EYE class ViveProEyeReadThread : public QThread { public: ViveProEyeReadThread() { @@ -216,6 +200,7 @@ public: QMutex eyeDataMutex; EyeDataBuffer eyeDataBuffer; }; +#endif static QString outOfRangeDataStrategyToString(ViveControllerManager::OutOfRangeDataStrategy strategy) { @@ -328,7 +313,7 @@ bool areBothHandControllersActive(vr::IVRSystem*& system) { isHandControllerActive(system, vr::TrackedControllerRole_RightHand); } - +#ifdef VIVE_PRO_EYE void ViveControllerManager::enableGestureDetection() { if (_viveCameraHandTracker) { return; @@ -373,6 +358,7 @@ void ViveControllerManager::disableGestureDetection() { StopGestureDetection(); _viveCameraHandTracker = false; } +#endif bool ViveControllerManager::activate() { InputPlugin::activate(); @@ -394,6 +380,7 @@ bool ViveControllerManager::activate() { userInputMapper->registerDevice(_inputDevice); _registeredWithInputMapper = true; +#ifdef VIVE_PRO_EYE if (ViveSR::anipal::Eye::IsViveProEye()) { qDebug() << "Vive Pro eye-tracking detected"; @@ -414,6 +401,7 @@ bool ViveControllerManager::activate() { _viveProEyeReadThread->start(QThread::HighPriority); } } +#endif return true; } @@ -436,12 +424,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(); } @@ -454,6 +444,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; @@ -461,7 +452,6 @@ void ViveControllerManager::invalidateEyeInputs() { _inputDevice->_axisStateMap[controller::EYEBLINK_R].valid = false; } - void ViveControllerManager::updateEyeTracker(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { if (!isHeadControllerMounted()) { invalidateEyeInputs(); @@ -763,6 +753,7 @@ void ViveControllerManager::updateCameraHandTracker(float deltaTime, } _lastHandTrackerFrameIndex = handTrackerFrameIndex; } +#endif void ViveControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { @@ -801,11 +792,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() { @@ -879,7 +873,7 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle handleHandController(deltaTime, rightHandDeviceIndex, inputCalibrationData, false); // collect poses for all generic trackers - for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) { + for (uint32_t i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) { handleTrackedObject(i, inputCalibrationData); handleHmd(i, inputCalibrationData); } @@ -954,8 +948,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso bool overrideHead = headObject["override"].toBool(); if (overrideHead) { _headConfig = HeadConfig::Puck; - _headPuckYOffset = headObject["Y"].toDouble() * CM_TO_M; - _headPuckZOffset = headObject["Z"].toDouble() * CM_TO_M; + _headPuckYOffset = (float)headObject["Y"].toDouble() * CM_TO_M; + _headPuckZOffset = (float)headObject["Z"].toDouble() * CM_TO_M; } else { _headConfig = HeadConfig::HMD; } @@ -964,8 +958,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso bool overrideHands = handsObject["override"].toBool(); if (overrideHands) { _handConfig = HandConfig::Pucks; - _handPuckYOffset = handsObject["Y"].toDouble() * CM_TO_M; - _handPuckZOffset = handsObject["Z"].toDouble() * CM_TO_M; + _handPuckYOffset = (float)handsObject["Y"].toDouble() * CM_TO_M; + _handPuckZOffset = (float)handsObject["Z"].toDouble() * CM_TO_M; } else { _handConfig = HandConfig::HandController; } @@ -999,8 +993,8 @@ QJsonObject ViveControllerManager::InputDevice::configurationSettings() { configurationSettings["HMDHead"] = (_headConfig == HeadConfig::HMD); configurationSettings["handController"] = (_handConfig == HandConfig::HandController); configurationSettings["puckCount"] = (int)_validTrackedObjects.size(); - configurationSettings["armCircumference"] = (double)_armCircumference * M_TO_CM; - configurationSettings["shoulderWidth"] = (double)_shoulderWidth * M_TO_CM; + configurationSettings["armCircumference"] = (double)(_armCircumference * M_TO_CM); + configurationSettings["shoulderWidth"] = (double)(_shoulderWidth * M_TO_CM); configurationSettings["outOfRangeDataStrategy"] = outOfRangeDataStrategyToString(_outOfRangeDataStrategy); return configurationSettings; } @@ -1217,8 +1211,6 @@ bool ViveControllerManager::InputDevice::configureHead(const glm::mat4& defaultT bool ViveControllerManager::InputDevice::configureBody(const glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksYPosition); int puckCount = (int)_validTrackedObjects.size(); - glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); - glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); if (_config == Config::None) { return true; } else if (_config == Config::Feet && puckCount >= MIN_PUCK_COUNT) { @@ -1316,8 +1308,6 @@ controller::Pose ViveControllerManager::InputDevice::addOffsetToPuckPose(const c } void ViveControllerManager::InputDevice::handleHmd(uint32_t deviceIndex, const controller::InputCalibrationData& inputCalibrationData) { - uint32_t poseIndex = controller::TRACKED_OBJECT_00 + deviceIndex; - if (_system->IsTrackedDeviceConnected(deviceIndex) && _system->GetTrackedDeviceClass(deviceIndex) == vr::TrackedDeviceClass_HMD && _nextSimPoseData.vrPoses[deviceIndex].bPoseIsValid) { @@ -1491,11 +1481,11 @@ void ViveControllerManager::InputDevice::printDeviceTrackingResultChange(uint32_ } bool ViveControllerManager::InputDevice::checkForCalibrationEvent() { - auto& endOfMap = _buttonPressedMap.end(); - auto& leftTrigger = _buttonPressedMap.find(controller::LT); - auto& rightTrigger = _buttonPressedMap.find(controller::RT); - auto& leftAppButton = _buttonPressedMap.find(LEFT_APP_MENU); - auto& rightAppButton = _buttonPressedMap.find(RIGHT_APP_MENU); + auto endOfMap = _buttonPressedMap.end(); + auto leftTrigger = _buttonPressedMap.find(controller::LT); + auto rightTrigger = _buttonPressedMap.find(controller::RT); + auto leftAppButton = _buttonPressedMap.find(LEFT_APP_MENU); + auto rightAppButton = _buttonPressedMap.find(RIGHT_APP_MENU); return ((leftTrigger != endOfMap && leftAppButton != endOfMap) && (rightTrigger != endOfMap && rightAppButton != endOfMap)); } @@ -1846,10 +1836,74 @@ void ViveControllerManager::InputDevice::setConfigFromString(const QString& valu * Hipsnumber{@link Pose}Hips pose. * Spine2number{@link Pose}Spine2 pose. * Headnumber{@link Pose}Head pose. + * LeftEyenumber{@link Pose}Left eye pose. + * RightEyenumber{@link Pose}Right eye pose. + * EyeBlink_LnumbernumberLeft eyelid blink. + * EyeBlink_RnumbernumberRight eyelid blink. * LeftArmnumber{@link Pose}Left arm pose. * RightArmnumber{@link Pose}Right arm pose * LeftHandnumber{@link Pose}Left hand pose. + * LeftHandThumb1number{@link Pose}Left thumb 1 finger joint pose. + * LeftHandThumb2number{@link Pose}Left thumb 2 finger joint pose. + * LeftHandThumb3number{@link Pose}Left thumb 3 finger joint pose. + * LeftHandThumb4number{@link Pose}Left thumb 4 finger joint pose. + * LeftHandIndex1number{@link Pose}Left index 1 finger joint pose. + * LeftHandIndex2number{@link Pose}Left index 2 finger joint pose. + * LeftHandIndex3number{@link Pose}Left index 3 finger joint pose. + * LeftHandIndex4number{@link Pose}Left index 4 finger joint pose. + * LeftHandMiddle1number{@link Pose}Left middle 1 finger joint pose. + * + * LeftHandMiddle2number{@link Pose}Left middle 2 finger joint pose. + * + * LeftHandMiddle3number{@link Pose}Left middle 3 finger joint pose. + * + * LeftHandMiddle4number{@link Pose}Left middle 4 finger joint pose. + * + * LeftHandRing1number{@link Pose}Left ring 1 finger joint pose. + * LeftHandRing2number{@link Pose}Left ring 2 finger joint pose. + * LeftHandRing3number{@link Pose}Left ring 3 finger joint pose. + * LeftHandRing4number{@link Pose}Left ring 4 finger joint pose. + * LeftHandPinky1number{@link Pose}Left pinky 1 finger joint pose. + * LeftHandPinky2number{@link Pose}Left pinky 2 finger joint pose. + * LeftHandPinky3number{@link Pose}Left pinky 3 finger joint pose. + * LeftHandPinky4number{@link Pose}Left pinky 4 finger joint pose. * RightHandnumber{@link Pose}Right hand pose. + * RightHandThumb1number{@link Pose}Right thumb 1 finger joint pose. + * + * RightHandThumb2number{@link Pose}Right thumb 2 finger joint pose. + * + * RightHandThumb3number{@link Pose}Right thumb 3 finger joint pose. + * + * RightHandThumb4number{@link Pose}Right thumb 4 finger joint pose. + * + * RightHandIndex1number{@link Pose}Right index 1 finger joint pose. + * + * RightHandIndex2number{@link Pose}Right index 2 finger joint pose. + * + * RightHandIndex3number{@link Pose}Right index 3 finger joint pose. + * + * RightHandIndex4number{@link Pose}Right index 4 finger joint pose. + * + * RightHandMiddle1number{@link Pose}Right middle 1 finger joint pose. + * + * RightHandMiddle2number{@link Pose}Right middle 2 finger joint pose. + * + * RightHandMiddle3number{@link Pose}Right middle 3 finger joint pose. + * + * RightHandMiddle4number{@link Pose}Right middle 4 finger joint pose. + * + * RightHandRing1number{@link Pose}Right ring 1 finger joint pose. + * RightHandRing2number{@link Pose}Right ring 2 finger joint pose. + * RightHandRing3number{@link Pose}Right ring 3 finger joint pose. + * RightHandRing4number{@link Pose}Right ring 4 finger joint pose. + * RightHandPinky1number{@link Pose}Right pinky 1 finger joint pose. + * + * RightHandPinky2number{@link Pose}Right pinky 2 finger joint pose. + * + * RightHandPinky3number{@link Pose}Right pinky 3 finger joint pose. + * + * RightHandPinky4number{@link Pose}Right pinky 4 finger joint pose. + * * Trackers * TrackedObject00number{@link Pose}Tracker 0 pose. * TrackedObject01number{@link Pose}Tracker 1 pose. diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 714be87842..4cd1f46dfb 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -1,9 +1,9 @@ // // ViveControllerManager.h -// input-plugins/src/input-plugins // // Created by Sam Gondelman on 6/29/15. // Copyright 2013 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -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,18 +72,22 @@ 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; - QString getDeviceName() { return QString::fromStdString(_inputDevice->_headsetName); } + 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; };