21539: Allow HMD to turned off in Desktop Mode

This commit is contained in:
Menithal 2017-11-05 00:18:48 +02:00
parent 9c1a33c826
commit ac1df7b815
3 changed files with 69 additions and 6 deletions

View file

@ -36,7 +36,9 @@ Rectangle {
readonly property bool hmdHead: headBox.checked readonly property bool hmdHead: headBox.checked
readonly property bool headPuck: headPuckBox.checked readonly property bool headPuck: headPuckBox.checked
readonly property bool handController: handBox.checked readonly property bool handController: handBox.checked
readonly property bool handPuck: handPuckBox.checked readonly property bool handPuck: handPuckBox.checked
readonly property bool hmdDesktop: hmdInDesktop.checked
property int state: buttonState.disabled property int state: buttonState.disabled
property var lastConfiguration: null property var lastConfiguration: null
@ -789,6 +791,7 @@ Rectangle {
verticalCenter: viveInDesktop.verticalCenter verticalCenter: viveInDesktop.verticalCenter
} }
} }
NumberAnimation { NumberAnimation {
id: numberAnimation id: numberAnimation
@ -797,6 +800,35 @@ Rectangle {
to: 0 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) { function logAction(action, status) {
console.log("calibrated from ui"); console.log("calibrated from ui");
var data = { var data = {
@ -877,6 +909,7 @@ Rectangle {
var HmdHead = settings["HMDHead"]; var HmdHead = settings["HMDHead"];
var viveController = settings["handController"]; var viveController = settings["handController"];
var desktopMode = settings["desktopMode"]; var desktopMode = settings["desktopMode"];
var hmdDesktopPosition = settings["hmdDesktopTracking"];
armCircumference.value = settings.armCircumference; armCircumference.value = settings.armCircumference;
shoulderWidth.value = settings.shoulderWidth; shoulderWidth.value = settings.shoulderWidth;
@ -898,6 +931,7 @@ Rectangle {
} }
viveInDesktop.checked = desktopMode; viveInDesktop.checked = desktopMode;
hmdInDesktop.checked = hmdDesktopPosition;
initializeButtonState(); initializeButtonState();
updateCalibrationText(); updateCalibrationText();
@ -1058,7 +1092,8 @@ Rectangle {
"handConfiguration": handObject, "handConfiguration": handObject,
"armCircumference": armCircumference.value, "armCircumference": armCircumference.value,
"shoulderWidth": shoulderWidth.value, "shoulderWidth": shoulderWidth.value,
"desktopMode": viveInDesktop.checked "desktopMode": viveInDesktop.checked,
"hmdDesktopTracking": hmdInDesktop.checked
} }
return settingsObject; return settingsObject;

View file

@ -166,6 +166,12 @@ void ViveControllerManager::setConfigurationSettings(const QJsonObject configura
_resetMatCalculated = false; _resetMatCalculated = false;
} }
} }
if (configurationSettings.contains("hmdDesktopTracking")) {
_hmdDesktopTracking = configurationSettings["hmdDesktopTracking"].toBool();
}
_inputDevice->configureCalibrationSettings(configurationSettings); _inputDevice->configureCalibrationSettings(configurationSettings);
saveSettings(); saveSettings();
} }
@ -175,6 +181,7 @@ QJsonObject ViveControllerManager::configurationSettings() {
if (isSupported()) { if (isSupported()) {
QJsonObject configurationSettings = _inputDevice->configurationSettings(); QJsonObject configurationSettings = _inputDevice->configurationSettings();
configurationSettings["desktopMode"] = _desktopMode; configurationSettings["desktopMode"] = _desktopMode;
configurationSettings["hmdDesktopTracking"] = _hmdDesktopTracking;
return configurationSettings; return configurationSettings;
} }
@ -414,6 +421,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso
if (!configurationSettings.empty()) { if (!configurationSettings.empty()) {
auto iter = configurationSettings.begin(); auto iter = configurationSettings.begin();
auto end = configurationSettings.end(); auto end = configurationSettings.end();
bool hmdDesktopTracking = true;
bool hmdDesktopMode = false;
while (iter != end) { while (iter != end) {
if (iter.key() == "bodyConfiguration") { if (iter.key() == "bodyConfiguration") {
setConfigFromString(iter.value().toString()); setConfigFromString(iter.value().toString());
@ -441,9 +450,17 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso
_armCircumference = (float)iter.value().toDouble() * CM_TO_M; _armCircumference = (float)iter.value().toDouble() * CM_TO_M;
} else if (iter.key() == "shoulderWidth") { } else if (iter.key() == "shoulderWidth") {
_shoulderWidth = (float)iter.value().toDouble() * CM_TO_M; _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++; 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 && _system->GetTrackedDeviceClass(deviceIndex) == vr::TrackedDeviceClass_HMD &&
_nextSimPoseData.vrPoses[deviceIndex].bPoseIsValid) { _nextSimPoseData.vrPoses[deviceIndex].bPoseIsValid) {
const mat4& mat = _nextSimPoseData.poses[deviceIndex]; if (_hmdTrackingEnabled){
const vec3 linearVelocity = _nextSimPoseData.linearVelocities[deviceIndex]; const mat4& mat = _nextSimPoseData.poses[deviceIndex];
const vec3 angularVelocity = _nextSimPoseData.angularVelocities[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);
}
} }
} }

View file

@ -113,7 +113,6 @@ private:
void emitCalibrationStatus(); void emitCalibrationStatus();
void calibrateNextFrame(); void calibrateNextFrame();
class FilteredStick { class FilteredStick {
public: public:
glm::vec2 process(float deltaTime, const glm::vec2& stick) { glm::vec2 process(float deltaTime, const glm::vec2& stick) {
@ -195,6 +194,8 @@ private:
bool _overrideHands { false }; bool _overrideHands { false };
mutable std::recursive_mutex _lock; mutable std::recursive_mutex _lock;
bool _hmdTrackingEnabled{ false };
QString configToString(Config config); QString configToString(Config config);
friend class ViveControllerManager; friend class ViveControllerManager;
}; };
@ -204,7 +205,10 @@ private:
bool _registeredWithInputMapper { false }; bool _registeredWithInputMapper { false };
bool _modelLoaded { false }; bool _modelLoaded { false };
bool _resetMatCalculated { false }; bool _resetMatCalculated { false };
bool _desktopMode { false }; bool _desktopMode { false };
bool _hmdDesktopTracking{ false };
glm::mat4 _resetMat { glm::mat4() }; glm::mat4 _resetMat { glm::mat4() };
model::Geometry _modelGeometry; model::Geometry _modelGeometry;
gpu::TexturePointer _texture; gpu::TexturePointer _texture;