From ac1df7b8150fe0fbe0b044ea681f53026134c351 Mon Sep 17 00:00:00 2001 From: Menithal Date: Sun, 5 Nov 2017 00:18:48 +0200 Subject: [PATCH 1/5] 21539: Allow HMD to turned off in Desktop Mode --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 37 ++++++++++++++++++- plugins/openvr/src/ViveControllerManager.cpp | 32 ++++++++++++++-- plugins/openvr/src/ViveControllerManager.h | 6 ++- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 78c10e2ffa..5e9bf40d41 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -36,7 +36,9 @@ Rectangle { readonly property bool hmdHead: headBox.checked readonly property bool headPuck: headPuckBox.checked readonly property bool handController: handBox.checked + readonly property bool handPuck: handPuckBox.checked + readonly property bool hmdDesktop: hmdInDesktop.checked property int state: buttonState.disabled property var lastConfiguration: null @@ -789,6 +791,7 @@ Rectangle { verticalCenter: viveInDesktop.verticalCenter } } + NumberAnimation { id: numberAnimation @@ -797,6 +800,35 @@ Rectangle { to: 0 } + HifiControls.CheckBox { + id: hmdInDesktop + width: 15 + height: 15 + boxRadius: 7 + + anchors.top: viveInDesktop.bottom + anchors.topMargin: 5 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 10 + + onClicked: { + sendConfigurationSettings(); + } + } + + RalewayBold { + id: hmdDesktopText + size: 10 + text: "Use HMD in desktop mode" + color: hifi.colors.white + + anchors { + left: hmdInDesktop.right + leftMargin: 5 + verticalCenter: hmdInDesktop.verticalCenter + } + } + function logAction(action, status) { console.log("calibrated from ui"); var data = { @@ -877,6 +909,7 @@ Rectangle { var HmdHead = settings["HMDHead"]; var viveController = settings["handController"]; var desktopMode = settings["desktopMode"]; + var hmdDesktopPosition = settings["hmdDesktopTracking"]; armCircumference.value = settings.armCircumference; shoulderWidth.value = settings.shoulderWidth; @@ -898,6 +931,7 @@ Rectangle { } viveInDesktop.checked = desktopMode; + hmdInDesktop.checked = hmdDesktopPosition; initializeButtonState(); updateCalibrationText(); @@ -1058,7 +1092,8 @@ Rectangle { "handConfiguration": handObject, "armCircumference": armCircumference.value, "shoulderWidth": shoulderWidth.value, - "desktopMode": viveInDesktop.checked + "desktopMode": viveInDesktop.checked, + "hmdDesktopTracking": hmdInDesktop.checked } return settingsObject; diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 430dc193a3..6b24aa0b5b 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -166,6 +166,12 @@ void ViveControllerManager::setConfigurationSettings(const QJsonObject configura _resetMatCalculated = false; } } + + if (configurationSettings.contains("hmdDesktopTracking")) { + + _hmdDesktopTracking = configurationSettings["hmdDesktopTracking"].toBool(); + } + _inputDevice->configureCalibrationSettings(configurationSettings); saveSettings(); } @@ -175,6 +181,7 @@ QJsonObject ViveControllerManager::configurationSettings() { if (isSupported()) { QJsonObject configurationSettings = _inputDevice->configurationSettings(); configurationSettings["desktopMode"] = _desktopMode; + configurationSettings["hmdDesktopTracking"] = _hmdDesktopTracking; return configurationSettings; } @@ -414,6 +421,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso if (!configurationSettings.empty()) { auto iter = configurationSettings.begin(); auto end = configurationSettings.end(); + bool hmdDesktopTracking = true; + bool hmdDesktopMode = false; while (iter != end) { if (iter.key() == "bodyConfiguration") { setConfigFromString(iter.value().toString()); @@ -441,9 +450,17 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso _armCircumference = (float)iter.value().toDouble() * CM_TO_M; } else if (iter.key() == "shoulderWidth") { _shoulderWidth = (float)iter.value().toDouble() * CM_TO_M; + } else if (iter.key() == "hmdDesktopTracking") { + hmdDesktopTracking = iter.value().toBool(); + } else if (iter.key() == "desktopMode") { + hmdDesktopMode = iter.value().toBool(); } iter++; } + + _hmdTrackingEnabled = !(hmdDesktopMode && !hmdDesktopTracking); + + qDebug() << "HMD desktop tracking Enabled" << _hmdTrackingEnabled << "-" << hmdDesktopMode << "-" << hmdDesktopTracking << !(hmdDesktopMode && !hmdDesktopTracking); } } @@ -735,11 +752,18 @@ void ViveControllerManager::InputDevice::handleHmd(uint32_t deviceIndex, const c _system->GetTrackedDeviceClass(deviceIndex) == vr::TrackedDeviceClass_HMD && _nextSimPoseData.vrPoses[deviceIndex].bPoseIsValid) { - const mat4& mat = _nextSimPoseData.poses[deviceIndex]; - const vec3 linearVelocity = _nextSimPoseData.linearVelocities[deviceIndex]; - const vec3 angularVelocity = _nextSimPoseData.angularVelocities[deviceIndex]; + if (_hmdTrackingEnabled){ + const mat4& mat = _nextSimPoseData.poses[deviceIndex]; + const vec3 linearVelocity = _nextSimPoseData.linearVelocities[deviceIndex]; + const vec3 angularVelocity = _nextSimPoseData.angularVelocities[deviceIndex]; - handleHeadPoseEvent(inputCalibrationData, mat, linearVelocity, angularVelocity); + handleHeadPoseEvent(inputCalibrationData, mat, linearVelocity, angularVelocity); + } else { + const mat4& mat = mat4(); + const vec3 zero = vec3(); + + handleHeadPoseEvent(inputCalibrationData, mat, zero, zero); + } } } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 4a7fcaf85e..cbe331feb3 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -113,7 +113,6 @@ private: void emitCalibrationStatus(); void calibrateNextFrame(); - class FilteredStick { public: glm::vec2 process(float deltaTime, const glm::vec2& stick) { @@ -195,6 +194,8 @@ private: bool _overrideHands { false }; mutable std::recursive_mutex _lock; + bool _hmdTrackingEnabled{ false }; + QString configToString(Config config); friend class ViveControllerManager; }; @@ -204,7 +205,10 @@ private: bool _registeredWithInputMapper { false }; bool _modelLoaded { false }; bool _resetMatCalculated { false }; + bool _desktopMode { false }; + bool _hmdDesktopTracking{ false }; + glm::mat4 _resetMat { glm::mat4() }; model::Geometry _modelGeometry; gpu::TexturePointer _texture; From e28f80401f32760006489a1b021489343fee1bb4 Mon Sep 17 00:00:00 2001 From: Menithal Date: Sun, 5 Nov 2017 01:05:35 +0200 Subject: [PATCH 2/5] 21539: Removed debug, added whitespace for format --- plugins/openvr/src/ViveControllerManager.cpp | 2 -- plugins/openvr/src/ViveControllerManager.h | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 6b24aa0b5b..4e1f8717c6 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -459,8 +459,6 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso } _hmdTrackingEnabled = !(hmdDesktopMode && !hmdDesktopTracking); - - qDebug() << "HMD desktop tracking Enabled" << _hmdTrackingEnabled << "-" << hmdDesktopMode << "-" << hmdDesktopTracking << !(hmdDesktopMode && !hmdDesktopTracking); } } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index cbe331feb3..6767aafad2 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -194,7 +194,7 @@ private: bool _overrideHands { false }; mutable std::recursive_mutex _lock; - bool _hmdTrackingEnabled{ false }; + bool _hmdTrackingEnabled { false }; QString configToString(Config config); friend class ViveControllerManager; @@ -207,7 +207,7 @@ private: bool _resetMatCalculated { false }; bool _desktopMode { false }; - bool _hmdDesktopTracking{ false }; + bool _hmdDesktopTracking { false }; glm::mat4 _resetMat { glm::mat4() }; model::Geometry _modelGeometry; From ba1cd74ffed6c93ce19f8ab46e63c701ab54c3a4 Mon Sep 17 00:00:00 2001 From: Menithal Date: Sun, 26 Nov 2017 21:58:16 +0200 Subject: [PATCH 3/5] 21539: Moved Desktop HMD to None --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 5e9bf40d41..292a33f4c5 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -55,10 +55,6 @@ Rectangle { } - - - - MouseArea { id: mouseArea @@ -101,6 +97,7 @@ Rectangle { onClicked: { if (checked) { headPuckBox.checked = false; + hmdInDesktop.checked = false; } else { checked = true; } @@ -123,6 +120,7 @@ Rectangle { onClicked: { if (checked) { headBox.checked = false; + hmdInDesktop.checked = false; } else { checked = true; } @@ -135,6 +133,37 @@ Rectangle { text: "Tracker" color: hifi.colors.lightGrayText } + + HifiControls.CheckBox { + id: hmdInDesktop + width: 15 + height: 15 + boxRadius: 7 + visible: viveInDesktop.checked + + anchors.top: viveInDesktop.bottom + anchors.topMargin: 5 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 10 + + onClicked: { + if (checked) { + headBox.checked = false; + headPuckBox.checked = false; + } else { + checked = true; + } + sendConfigurationSettings(); + } + } + + RalewayBold { + id: hmdInDesktopLabel + size: 12 + visible: viveInDesktop.checked + text: "None" + color: hifi.colors.lightGrayText + } } Row { @@ -800,34 +829,6 @@ Rectangle { to: 0 } - HifiControls.CheckBox { - id: hmdInDesktop - width: 15 - height: 15 - boxRadius: 7 - - anchors.top: viveInDesktop.bottom - anchors.topMargin: 5 - anchors.left: openVrConfiguration.left - anchors.leftMargin: leftMargin + 10 - - onClicked: { - sendConfigurationSettings(); - } - } - - RalewayBold { - id: hmdDesktopText - size: 10 - text: "Use HMD in desktop mode" - color: hifi.colors.white - - anchors { - left: hmdInDesktop.right - leftMargin: 5 - verticalCenter: hmdInDesktop.verticalCenter - } - } function logAction(action, status) { console.log("calibrated from ui"); From 5d52b9936b45dd2086d5f02a079a7559d6084071 Mon Sep 17 00:00:00 2001 From: Menithal Date: Mon, 27 Nov 2017 07:42:18 +0200 Subject: [PATCH 4/5] 21539: Updated Logic to match request --- interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml | 1 - plugins/openvr/src/ViveControllerManager.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 292a33f4c5..075b4637b2 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -158,7 +158,6 @@ Rectangle { } RalewayBold { - id: hmdInDesktopLabel size: 12 visible: viveInDesktop.checked text: "None" diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 4e1f8717c6..8889e58f0c 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -168,7 +168,6 @@ void ViveControllerManager::setConfigurationSettings(const QJsonObject configura } if (configurationSettings.contains("hmdDesktopTracking")) { - _hmdDesktopTracking = configurationSettings["hmdDesktopTracking"].toBool(); } @@ -458,7 +457,7 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso iter++; } - _hmdTrackingEnabled = !(hmdDesktopMode && !hmdDesktopTracking); + _hmdTrackingEnabled = !(hmdDesktopMode && hmdDesktopTracking); } } From 693da50a6849bf03d9c196835f6c6bd67d5de911 Mon Sep 17 00:00:00 2001 From: Menithal Date: Mon, 27 Nov 2017 07:59:04 +0200 Subject: [PATCH 5/5] 21539: Fixed None Checkmark being on Desktop mode --- interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 075b4637b2..0978f23013 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -803,6 +803,11 @@ Rectangle { anchors.leftMargin: leftMargin + 10 onClicked: { + if (!checked & hmdInDesktop.checked) { + headBox.checked = true; + headPuckBox.checked = false; + hmdInDesktop.checked = false; + } sendConfigurationSettings(); } }