From e1d37f21670aa7531bf1fb5d8add5edf7195057d Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 1 Jun 2017 23:29:22 +0100 Subject: [PATCH 01/31] saving work --- .../src/controllers/InputConfiguration.cpp | 17 ++++++++++++ .../src/controllers/InputConfiguration.h | 26 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 libraries/controllers/src/controllers/InputConfiguration.cpp create mode 100644 libraries/controllers/src/controllers/InputConfiguration.h diff --git a/libraries/controllers/src/controllers/InputConfiguration.cpp b/libraries/controllers/src/controllers/InputConfiguration.cpp new file mode 100644 index 0000000000..863bdbf675 --- /dev/null +++ b/libraries/controllers/src/controllers/InputConfiguration.cpp @@ -0,0 +1,17 @@ +// +// Created by Dante Ruiz on 6/1/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + + +#include "InputConfiguration.h" + +namespace controller { + + InputConfiguration::InputConfiguration() { + + } +} diff --git a/libraries/controllers/src/controllers/InputConfiguration.h b/libraries/controllers/src/controllers/InputConfiguration.h new file mode 100644 index 0000000000..0a7f01a7a1 --- /dev/null +++ b/libraries/controllers/src/controllers/InputConfiguration.h @@ -0,0 +1,26 @@ +// +// Created by Dante Ruiz on 6/1/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_InputConfiguration_h +#define hifi_InputConfiguration_h + +#include + +#include +#include + +namespace controller { + + class InputConfiguration : public QObject, public Dependency { + public: + InputConfiguration(); + ~InputConfiguration() {} + }; +} + +#endif From f0f10f74c69b82850c4075aa25c5e4c46069bd6a Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 3 Jun 2017 00:30:00 +0100 Subject: [PATCH 02/31] inpput configutration stub --- .../qml/hifi/tablet/InputConfiguration.qml | 95 ++++++++++++++++++ .../resources/qml/styles-uit/Separator.qml | 26 +++++ interface/src/Application.cpp | 2 + interface/src/Menu.cpp | 7 ++ interface/src/ui/overlays/Web3DOverlay.cpp | 3 +- .../plugins/src/plugins/.#PluginManager.h | Bin 0 -> 78 bytes .../src/plugins}/InputConfiguration.cpp | 15 ++- .../src/plugins}/InputConfiguration.h | 19 ++-- 8 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 interface/resources/qml/hifi/tablet/InputConfiguration.qml create mode 100644 interface/resources/qml/styles-uit/Separator.qml create mode 100644 libraries/plugins/src/plugins/.#PluginManager.h rename libraries/{controllers/src/controllers => plugins/src/plugins}/InputConfiguration.cpp (50%) rename libraries/{controllers/src/controllers => plugins/src/plugins}/InputConfiguration.h (63%) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml new file mode 100644 index 0000000000..fc65f8a3d4 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -0,0 +1,95 @@ +// +// Created by Dante Ruiz on 6/1/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtGraphicalEffects 1.0 +import "../../styles-uit" +import "../../controls" +import "../../controls-uit" as HifiControls + +Rectangle { + id: inputConfiguration + anchors.fill: parent + + HifiConstants { id: hifi } + + color: hifi.colors.baseGray + + Rectangle { + width: inputConfiguration.width + height: 1 + color: hifi.colors.baseGrayShadow + x: -hifi.dimensions.contentMargin.x + } + + RalewayBold { + id: header + text: "Controller Settings" + size: 22 + color: "white" + + anchors.top: inputConfiguration.top + anchors.left: inputConfiguration.left + anchors.leftMargin: 20 + anchors.topMargin: 20 + } + + + Separator { + id: headerSeparator + width: inputConfiguration.width + anchors.top: header.bottom + anchors.topMargin: 10 + } + + RalewayBold { + id: configuration + text: "SELECT DEVICE" + size: 18 + color: hifi.colors.lightGray + + + anchors.top: headerSeparator.bottom + anchors.left: inputConfiguration.left + anchors.leftMargin: 20 + anchors.topMargin: 20 + } + + Row { + id: configRow + + anchors.top: configuration.bottom + anchors.topMargin: 20 + anchors.left: configuration.left + anchors.leftMargin: 40 + spacing: 10 + HifiControls.ComboBox { + id: box + width: 160 + + colorScheme: hifi.colorSchemes.dark + model: inputPlugins() + } + + HifiControls.CheckBox { + onClicked: { + if (checked) { + console.log("button checked"); + Tablet.getTablet(""); + InputConfiguration.inputPlugins(); + } + } + } + + } + + function inputPlugins() { + var plugins = ["temp"]; + return plugins + } +} diff --git a/interface/resources/qml/styles-uit/Separator.qml b/interface/resources/qml/styles-uit/Separator.qml new file mode 100644 index 0000000000..1067de3b29 --- /dev/null +++ b/interface/resources/qml/styles-uit/Separator.qml @@ -0,0 +1,26 @@ +// +// Created by Dante Ruiz on 6/1/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtGraphicalEffects 1.0 + +Item { + Rectangle { + id: shadows + width: parent.width + height: 2 + color: hifi.colors.baseGrayShadow + } + + Rectangle { + width: parent.width + height: 1 + anchors.top: shadows.bottom + color: hifi.colors.baseGrayHighlight + } +} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 46c4c0bd4e..eda3a14533 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -79,6 +79,7 @@ #include #include #include +#include #include #include #include @@ -522,6 +523,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_THIRD_PERSON, STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT, STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED } }); DependencyManager::set(); + DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); DependencyManager::set(true, qApp, qApp); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 4138798484..8fd560dcf3 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -311,6 +312,12 @@ Menu::Menu() { QString("../../hifi/tablet/TabletLodPreferences.qml"), "LodPreferencesDialog"); }); + action = addActionToQMenuAndActionHash(settingsMenu, "InputConfiguration"); + connect(action, &QAction::triggered, [] { + auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); + tablet->loadQMLSource("InputConfiguration.qml"); + }); + // Settings > Control with Speech [advanced] #if defined(Q_OS_MAC) || defined(Q_OS_WIN) auto speechRecognizer = DependencyManager::get(); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 75c793bf77..8dcbc254f6 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -51,6 +51,7 @@ #include "ui/AvatarInputs.h" #include "avatar/AvatarManager.h" #include "scripting/GlobalServicesScriptingInterface.h" +#include #include "ui/Snapshot.h" static const float DPI = 30.47f; @@ -201,7 +202,7 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getRootContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); _webSurface->getRootContext()->setContextProperty("AvatarList", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance()); - + _webSurface->getRootContext()->setContextProperty("InputConfiguration", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data()); diff --git a/libraries/plugins/src/plugins/.#PluginManager.h b/libraries/plugins/src/plugins/.#PluginManager.h new file mode 100644 index 0000000000000000000000000000000000000000..6d0a3bdbacae8dd149c37fa40847309629686543 GIT binary patch literal 78 zcmW;5F$#iE007W;6gxn|2aN`i1jWIjNIgJ0u`2k(%*Kd)(=pZUI(9%hR{ c +#include #include -#include -namespace controller { - - class InputConfiguration : public QObject, public Dependency { - public: - InputConfiguration(); - ~InputConfiguration() {} - }; -} +class InputConfiguration : public QObject, public Dependency { + Q_OBJECT +public: + InputConfiguration(); + + void inputPlugins(); +public slots: + void enabledInputPlugins(); +}; #endif From 016cf45d0f1b4f2ecd6b37abbaff628d741e36ae Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 3 Jun 2017 00:35:19 +0100 Subject: [PATCH 03/31] removed emacs garbage files --- libraries/plugins/src/plugins/.#PluginManager.h | Bin 78 -> 0 bytes libraries/plugins/src/plugins/InputConfiguration.h | 1 - 2 files changed, 1 deletion(-) delete mode 100644 libraries/plugins/src/plugins/.#PluginManager.h diff --git a/libraries/plugins/src/plugins/.#PluginManager.h b/libraries/plugins/src/plugins/.#PluginManager.h deleted file mode 100644 index 6d0a3bdbacae8dd149c37fa40847309629686543..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 78 zcmW;5F$#iE007W;6gxn|2aN`i1jWIjNIgJ0u`2k(%*Kd)(=pZUI(9%hR{ c Date: Tue, 6 Jun 2017 00:32:20 +0100 Subject: [PATCH 04/31] base ui working --- .../resources/qml/controls-uit/ComboBox.qml | 1 + .../qml/hifi/tablet/InputConfiguration.qml | 18 ++++++--- .../src/plugins/InputConfiguration.cpp | 40 +++++++++++++++---- .../plugins/src/plugins/InputConfiguration.h | 11 +++-- libraries/plugins/src/plugins/InputPlugin.h | 3 +- plugins/hifiCodec/CMakeLists.txt | 2 +- plugins/hifiNeuron/CMakeLists.txt | 2 +- plugins/hifiSdl2/CMakeLists.txt | 2 +- plugins/hifiSixense/CMakeLists.txt | 2 +- plugins/openvr/src/ViveControllerManager.cpp | 3 ++ plugins/openvr/src/ViveControllerManager.h | 3 ++ plugins/pcmCodec/CMakeLists.txt | 2 +- 12 files changed, 66 insertions(+), 23 deletions(-) diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index be6a439e57..3ce297ef80 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -20,6 +20,7 @@ FocusScope { HifiConstants { id: hifi } property alias model: comboBox.model; + property alias editable: comboBox.editable property alias comboBox: comboBox readonly property alias currentText: comboBox.currentText; property alias currentIndex: comboBox.currentIndex; diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index fc65f8a3d4..10f03f9edf 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -20,6 +20,8 @@ Rectangle { color: hifi.colors.baseGray + property var pluginSettings: null + Rectangle { width: inputConfiguration.width height: 1 @@ -71,17 +73,22 @@ Rectangle { HifiControls.ComboBox { id: box width: 160 - + editable: true colorScheme: hifi.colorSchemes.dark model: inputPlugins() + + onCurrentIndexChanged: { + var object = {"Test": "hello"}; + InputConfiguration.configurationSettings(object, box.currentText); + } } HifiControls.CheckBox { onClicked: { if (checked) { - console.log("button checked"); - Tablet.getTablet(""); - InputConfiguration.inputPlugins(); + box.model = InputConfiguration.activeInputPlugins(); + } else { + box.model = InputConfiguration.inputPlugins(); } } } @@ -89,7 +96,6 @@ Rectangle { } function inputPlugins() { - var plugins = ["temp"]; - return plugins + return InputConfiguration.inputPlugins(); } } diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index c15316406b..8f8daf716a 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -8,19 +8,43 @@ #include "InputConfiguration.h" - +#include "DisplayPlugin.h" +#include "InputPlugin.h" #include "PluginManager.h" InputConfiguration::InputConfiguration() { - } -void InputConfiguration::inputPlugins() { - PluginManager* inputPlugin = PluginManager::getInstance(); -} - -void InputConfiguration::enabledInputPlugins() { - qDebug() << "getting enabled plugins"; +QStringList InputConfiguration::inputPlugins() { + QStringList inputPlugins; + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { + inputPlugins << QString(plugin->getName()); + } + return inputPlugins; } +QStringList InputConfiguration::activeInputPlugins() { + QStringList activePlugins; + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { + if (plugin->isActive()) { + activePlugins << QString(plugin->getName()); + } + } + return activePlugins; +} + +QString InputConfiguration::configurationLayout(QString pluginName) { + QString sourcePath; + + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { + if (plugin->getName() == pluginName) { + qDebug() << "------------> testing <----------"; + } + } + return sourcePath; +} + +void InputConfiguration::configurationSettings(QJsonObject configurationSettings, QString pluginName) { + qDebug() << configurationSettings["Test"]; +} diff --git a/libraries/plugins/src/plugins/InputConfiguration.h b/libraries/plugins/src/plugins/InputConfiguration.h index d8174737cf..2a0093d5b2 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.h +++ b/libraries/plugins/src/plugins/InputConfiguration.h @@ -12,15 +12,20 @@ #include #include +#include +#include +#include #include class InputConfiguration : public QObject, public Dependency { Q_OBJECT public: InputConfiguration(); - - void inputPlugins(); - void enabledInputPlugins(); + + Q_INVOKABLE QStringList inputPlugins(); + Q_INVOKABLE QStringList activeInputPlugins(); + Q_INVOKABLE QString configurationLayout(QString pluginName); + Q_INVOKABLE void configurationSettings(QJsonObject configurationSettings, QString pluginName); }; #endif diff --git a/libraries/plugins/src/plugins/InputPlugin.h b/libraries/plugins/src/plugins/InputPlugin.h index 0db0b24420..eb8aca660b 100644 --- a/libraries/plugins/src/plugins/InputPlugin.h +++ b/libraries/plugins/src/plugins/InputPlugin.h @@ -11,6 +11,7 @@ #pragma once #include "Plugin.h" +#include namespace controller { struct InputCalibrationData; @@ -25,5 +26,5 @@ public: // If an input plugin is only a single device, it will only return it's primary name. virtual QStringList getSubdeviceNames() { return { getName() }; }; virtual bool isHandController() const = 0; + virtual void inputPluginConfigurationSettings(const QJsonObject configurationSettings) { } }; - diff --git a/plugins/hifiCodec/CMakeLists.txt b/plugins/hifiCodec/CMakeLists.txt index 28c1dc3807..15572e8266 100644 --- a/plugins/hifiCodec/CMakeLists.txt +++ b/plugins/hifiCodec/CMakeLists.txt @@ -8,7 +8,7 @@ set(TARGET_NAME hifiCodec) setup_hifi_client_server_plugin() -link_hifi_libraries(audio plugins) +link_hifi_libraries(audio plugins input-plugins display-plugins) add_dependency_external_projects(hifiAudioCodec) target_include_directories(${TARGET_NAME} PRIVATE ${HIFIAUDIOCODEC_INCLUDE_DIRS}) target_link_libraries(${TARGET_NAME} ${HIFIAUDIOCODEC_LIBRARIES}) diff --git a/plugins/hifiNeuron/CMakeLists.txt b/plugins/hifiNeuron/CMakeLists.txt index a9ed8cca6e..e3a725ca2f 100644 --- a/plugins/hifiNeuron/CMakeLists.txt +++ b/plugins/hifiNeuron/CMakeLists.txt @@ -10,7 +10,7 @@ if (APPLE OR WIN32) set(TARGET_NAME hifiNeuron) setup_hifi_plugin(Script Qml Widgets) - link_hifi_libraries(shared controllers ui plugins input-plugins) + link_hifi_libraries(shared controllers ui plugins input-plugins display-plugins) target_neuron() endif() diff --git a/plugins/hifiSdl2/CMakeLists.txt b/plugins/hifiSdl2/CMakeLists.txt index 7e499e314a..86bda5a15d 100644 --- a/plugins/hifiSdl2/CMakeLists.txt +++ b/plugins/hifiSdl2/CMakeLists.txt @@ -8,5 +8,5 @@ set(TARGET_NAME hifiSdl2) setup_hifi_plugin(Script Qml Widgets) -link_hifi_libraries(shared controllers ui plugins input-plugins script-engine) +link_hifi_libraries(shared controllers ui plugins input-plugins script-engine display-plugins) target_sdl2() diff --git a/plugins/hifiSixense/CMakeLists.txt b/plugins/hifiSixense/CMakeLists.txt index 14676217db..54884bddff 100644 --- a/plugins/hifiSixense/CMakeLists.txt +++ b/plugins/hifiSixense/CMakeLists.txt @@ -9,6 +9,6 @@ if (NOT ANDROID) set(TARGET_NAME hifiSixense) setup_hifi_plugin(Script Qml Widgets) - link_hifi_libraries(shared controllers ui plugins ui-plugins input-plugins) + link_hifi_libraries(shared controllers ui plugins ui-plugins input-plugins display-plugins) target_sixense() endif () diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 53500a3353..d505e91511 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -94,6 +94,9 @@ bool ViveControllerManager::isSupported() const { return openVrSupported(); } +void ViveControllerManager::inputPluginConfigurationSettings(const QJsonObject configurationSettings) { +} + bool ViveControllerManager::activate() { InputPlugin::activate(); diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index a76adaa8f9..1ac920228a 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -42,6 +42,8 @@ public: bool isHandController() const override { return true; } + void inputPluginConfigurationSettings(const QJsonObject configurationSettings) override; + bool activate() override; void deactivate() override; @@ -145,6 +147,7 @@ private: bool _triggersPressedHandled { false }; bool _calibrated { false }; bool _timeTilCalibrationSet { false }; + bool _calibrate { false }; mutable std::recursive_mutex _lock; QString configToString(Config config); diff --git a/plugins/pcmCodec/CMakeLists.txt b/plugins/pcmCodec/CMakeLists.txt index 900a642a88..5e52705033 100644 --- a/plugins/pcmCodec/CMakeLists.txt +++ b/plugins/pcmCodec/CMakeLists.txt @@ -8,6 +8,6 @@ set(TARGET_NAME pcmCodec) setup_hifi_client_server_plugin() -link_hifi_libraries(shared plugins) +link_hifi_libraries(shared plugins input-plugins display-plugins) install_beside_console() From bb7c424d47396d310f4198419efa1df532b30984 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 6 Jun 2017 21:09:09 +0100 Subject: [PATCH 05/31] get ui working --- .../resources/qml/controls-uit/CheckBox.qml | 2 +- .../qml/hifi/tablet/InputConfiguration.qml | 43 ++- .../qml/hifi/tablet/OpenVrConfiguration.qml | 253 ++++++++++++++++++ .../src/plugins/InputConfiguration.cpp | 2 +- libraries/plugins/src/plugins/InputPlugin.h | 3 +- plugins/openvr/src/ViveControllerManager.cpp | 8 +- plugins/openvr/src/ViveControllerManager.h | 3 +- 7 files changed, 305 insertions(+), 9 deletions(-) create mode 100644 interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml diff --git a/interface/resources/qml/controls-uit/CheckBox.qml b/interface/resources/qml/controls-uit/CheckBox.qml index 916a7d4889..5c49a0775d 100644 --- a/interface/resources/qml/controls-uit/CheckBox.qml +++ b/interface/resources/qml/controls-uit/CheckBox.qml @@ -21,7 +21,7 @@ Original.CheckBox { readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light property bool isRedCheck: false property int boxSize: 14 - readonly property int boxRadius: 3 + property int boxRadius: 3 readonly property int checkSize: Math.max(boxSize - 8, 10) readonly property int checkRadius: 2 activeFocusOnPress: true diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index 10f03f9edf..56f0e0fe14 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -64,7 +64,7 @@ Rectangle { Row { id: configRow - + z: 999 anchors.top: configuration.bottom anchors.topMargin: 20 anchors.left: configuration.left @@ -73,13 +73,14 @@ Rectangle { HifiControls.ComboBox { id: box width: 160 + z: 999 editable: true colorScheme: hifi.colorSchemes.dark model: inputPlugins() onCurrentIndexChanged: { - var object = {"Test": "hello"}; - InputConfiguration.configurationSettings(object, box.currentText); + loader.source = "" + loader.source = InputConfiguration.configurationLayout(box.currentText); } } @@ -95,6 +96,42 @@ Rectangle { } + + Separator { + id: configurationSeperator + z: 0 + width: inputConfiguration.width + anchors.top: configRow.bottom + anchors.topMargin: 10 + } + + Row { + z: 0 + id: configurationHeader + anchors.top: configurationSeperator.bottom + anchors.topMargin: 20 + anchors.left: inputConfiguration.left + anchors.leftMargin: 40 + spacing: 10 + RalewayBold { + text: "CONFIGURATION" + size: 18 + color: hifi.colors.lightGray + } + } + + Loader { + id: loader + asynchronous: false + + width: configurationHeader.width + anchors.left: inputConfiguration.left + anchors.right: inputConfiguration.right + anchors.top: configurationHeader.bottom + anchors.topMargin: 10 + anchors.bottom: inputConfiguration.bottom + } + function inputPlugins() { return InputConfiguration.inputPlugins(); } diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml new file mode 100644 index 0000000000..c20f01ad6e --- /dev/null +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -0,0 +1,253 @@ +// +// Created by Dante Ruiz on 6/5/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtGraphicalEffects 1.0 +import "../../styles-uit" +import "../../controls" +import "../../controls-uit" as HifiControls + + +Rectangle { + id: openVrConfiguration + + width: parent.width + height: parent.height + anchors.fill: parent + + property int leftMargin: 55 + + HifiConstants { id: hifi } + + color: hifi.colors.baseGray + + RalewayBold { + id: head + + text: "Head:" + size: 15 + + color: "white" + + anchors.left: parent.left + anchors.leftMargin: leftMargin + } + + Row { + id: headConfig + anchors.top: head.bottom + anchors.topMargin: 5 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 20 + spacing: 10 + + HifiControls.CheckBox { + id: headBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Vive HMD" + color: hifi.colors.lightGrayText + } + + HifiControls.CheckBox { + id: headPuckBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Tracker" + color: hifi.colors.lightGrayText + } + } + + RalewayBold { + id: hands + + text: "Hands:" + size: 15 + + color: "white" + + anchors.top: headConfig.bottom + anchors.topMargin: 10 + anchors.left: parent.left + anchors.leftMargin: leftMargin + } + + Row { + id: handConfig + anchors.top: hands.bottom + anchors.topMargin: 5 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 20 + spacing: 10 + + HifiControls.CheckBox { + id: handBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Controllers" + color: hifi.colors.lightGrayText + } + + HifiControls.CheckBox { + id: handPuckBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Trackers" + color: hifi.colors.lightGrayText + } + } + + RalewayBold { + id: additional + + text: "Additional Trackers" + size: 15 + + color: hifi.colors.white + + anchors.top: handConfig.bottom + anchors.topMargin: 10 + anchors.left: parent.left + anchors.leftMargin: leftMargin + } + + Row { + id: feetConfig + anchors.top: additional.bottom + anchors.topMargin: 15 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 20 + spacing: 10 + + HifiControls.CheckBox { + id: feetBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Feet" + color: hifi.colors.lightGrayText + } + } + + Row { + id: hipConfig + anchors.top: feetConfig.bottom + anchors.topMargin: 15 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 20 + spacing: 10 + + HifiControls.CheckBox { + id: hipBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Hips" + color: hifi.colors.lightGrayText + } + + RalewayBold { + size: 12 + text: "requires feet" + color: hifi.colors.lightGray + } + } + + + Row { + id: chestConfig + anchors.top: hipConfig.bottom + anchors.topMargin: 15 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 20 + spacing: 10 + + HifiControls.CheckBox { + id: chestBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Chest" + color: hifi.colors.lightGrayText + } + + RalewayBold { + size: 12 + text: "requires hips" + color: hifi.colors.lightGray + } + } + + + Row { + id: shoulderConfig + anchors.top: chestConfig.bottom + anchors.topMargin: 15 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 20 + spacing: 10 + + HifiControls.CheckBox { + id: shoulderBox + width: 15 + height: 15 + boxRadius: 7 + } + + RalewayBold { + size: 15 + text: "Shoulders" + color: hifi.colors.lightGrayText + } + + RalewayBold { + size: 12 + text: "requires hips" + color: hifi.colors.lightGray + } + } + + Separator { + id: bottomSeperator + width: parent.width + anchors.top: shoulderConfig.bottom + anchors.topMargin: 10 + } +} diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 8f8daf716a..14472a5ec7 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -39,7 +39,7 @@ QString InputConfiguration::configurationLayout(QString pluginName) { for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->getName() == pluginName) { - qDebug() << "------------> testing <----------"; + return plugin->configurationLayout(); } } return sourcePath; diff --git a/libraries/plugins/src/plugins/InputPlugin.h b/libraries/plugins/src/plugins/InputPlugin.h index eb8aca660b..94c7595eb9 100644 --- a/libraries/plugins/src/plugins/InputPlugin.h +++ b/libraries/plugins/src/plugins/InputPlugin.h @@ -26,5 +26,6 @@ public: // If an input plugin is only a single device, it will only return it's primary name. virtual QStringList getSubdeviceNames() { return { getName() }; }; virtual bool isHandController() const = 0; - virtual void inputPluginConfigurationSettings(const QJsonObject configurationSettings) { } + virtual void configurationSettings(const QJsonObject configurationSettings) { } + virtual QString configurationLayout() { return QString(); } }; diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index c33dd30360..2337c6161b 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -39,7 +39,7 @@ extern PoseData _nextSimPoseData; 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; @@ -120,7 +120,11 @@ bool ViveControllerManager::isSupported() const { return openVrSupported(); } -void ViveControllerManager::inputPluginConfigurationSettings(const QJsonObject configurationSettings) { +void ViveControllerManager::configurationSettings(const QJsonObject configurationSettings) { +} + +QString ViveControllerManager::configurationLayout() { + return OPENVR_LAYOUT; } bool ViveControllerManager::activate() { diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index bf3a7af3fb..b8a6206d60 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -42,7 +42,8 @@ public: bool isHandController() const override { return true; } - void inputPluginConfigurationSettings(const QJsonObject configurationSettings) override; + QString configurationLayout() override; + void configurationSettings(const QJsonObject configurationSettings) override; bool activate() override; void deactivate() override; From 70ba344f1bc5107f737af5a4de0120ded42c91fc Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 7 Jun 2017 00:25:08 +0100 Subject: [PATCH 06/31] finished openvr ui --- .../qml/hifi/tablet/InputConfiguration.qml | 78 +++++++++++----- .../qml/hifi/tablet/OpenVrConfiguration.qml | 90 +++++++++++++++---- .../qml/styles-uit/HifiConstants.qml | 1 + .../src/plugins/InputConfiguration.cpp | 8 ++ .../plugins/src/plugins/InputConfiguration.h | 1 + libraries/plugins/src/plugins/InputPlugin.h | 2 + 6 files changed, 138 insertions(+), 42 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index 56f0e0fe14..9393906b06 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -29,7 +29,7 @@ Rectangle { x: -hifi.dimensions.contentMargin.x } - RalewayBold { + RalewayRegular { id: header text: "Controller Settings" size: 22 @@ -49,25 +49,38 @@ Rectangle { anchors.topMargin: 10 } - RalewayBold { - id: configuration - text: "SELECT DEVICE" - size: 18 - color: hifi.colors.lightGray - + HiFiGlyphs { + id: sourceGlyph + text: hifi.glyphs.source + size: 36 + color: hifi.colors.blueHighlight anchors.top: headerSeparator.bottom anchors.left: inputConfiguration.left - anchors.leftMargin: 20 + anchors.leftMargin: 40 anchors.topMargin: 20 } + RalewayRegular { + id: configuration + text: "SELECT DEVICE" + size: 15 + color: hifi.colors.lightGrayText + + + anchors.top: headerSeparator.bottom + anchors.left: sourceGlyph.right + anchors.leftMargin: 10 + anchors.topMargin: 30 + anchors.verticalCenter: sourceGlyph.horizontalCenter + } + Row { id: configRow z: 999 - anchors.top: configuration.bottom + anchors.top: sourceGlyph.bottom anchors.topMargin: 20 - anchors.left: configuration.left + anchors.left: sourceGlyph.left anchors.leftMargin: 40 spacing: 10 HifiControls.ComboBox { @@ -98,38 +111,57 @@ Rectangle { Separator { - id: configurationSeperator + id: configurationSeparator z: 0 width: inputConfiguration.width anchors.top: configRow.bottom anchors.topMargin: 10 } - Row { - z: 0 - id: configurationHeader - anchors.top: configurationSeperator.bottom - anchors.topMargin: 20 + + HiFiGlyphs { + id: sliderGlyph + text: hifi.glyphs.sliders + size: 36 + color: hifi.colors.blueHighlight + + anchors.top: configurationSeparator.bottom anchors.left: inputConfiguration.left anchors.leftMargin: 40 - spacing: 10 - RalewayBold { - text: "CONFIGURATION" - size: 18 - color: hifi.colors.lightGray - } + anchors.topMargin: 20 + } + + RalewayRegular { + id: configurationHeader + text: "CONFIGURATION" + size: 15 + color: hifi.colors.lightGrayText + + + anchors.top: configurationSeparator.bottom + anchors.left: sliderGlyph.right + anchors.leftMargin: 10 + anchors.topMargin: 30 + anchors.verticalCenter: sliderGlyph.horizontalCenter } Loader { id: loader asynchronous: false - width: configurationHeader.width + width: inputConfiguration.width anchors.left: inputConfiguration.left anchors.right: inputConfiguration.right anchors.top: configurationHeader.bottom anchors.topMargin: 10 anchors.bottom: inputConfiguration.bottom + + + onLoaded: { + if (loader.item.hasOwnProeprty("pluginName")) { + loader.item.pluginName = box.currentText + } + } } function inputPlugins() { diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index c20f01ad6e..434ee12f28 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -7,6 +7,7 @@ // import QtQuick 2.5 +import QtQuick.Controls 1.4 import QtGraphicalEffects 1.0 import "../../styles-uit" import "../../controls" @@ -20,7 +21,8 @@ Rectangle { height: parent.height anchors.fill: parent - property int leftMargin: 55 + property int leftMargin: 75 + property string pluginName: "" HifiConstants { id: hifi } @@ -30,7 +32,7 @@ Rectangle { id: head text: "Head:" - size: 15 + size: 12 color: "white" @@ -54,7 +56,7 @@ Rectangle { } RalewayBold { - size: 15 + size: 12 text: "Vive HMD" color: hifi.colors.lightGrayText } @@ -67,7 +69,7 @@ Rectangle { } RalewayBold { - size: 15 + size: 12 text: "Tracker" color: hifi.colors.lightGrayText } @@ -77,7 +79,7 @@ Rectangle { id: hands text: "Hands:" - size: 15 + size: 12 color: "white" @@ -103,20 +105,20 @@ Rectangle { } RalewayBold { - size: 15 + size: 12 text: "Controllers" color: hifi.colors.lightGrayText } HifiControls.CheckBox { id: handPuckBox - width: 15 + width: 12 height: 15 boxRadius: 7 } RalewayBold { - size: 15 + size: 12 text: "Trackers" color: hifi.colors.lightGrayText } @@ -126,7 +128,7 @@ Rectangle { id: additional text: "Additional Trackers" - size: 15 + size: 12 color: hifi.colors.white @@ -152,7 +154,7 @@ Rectangle { } RalewayBold { - size: 15 + size: 12 text: "Feet" color: hifi.colors.lightGrayText } @@ -174,12 +176,12 @@ Rectangle { } RalewayBold { - size: 15 + size: 12 text: "Hips" color: hifi.colors.lightGrayText } - RalewayBold { + RalewayRegular { size: 12 text: "requires feet" color: hifi.colors.lightGray @@ -203,12 +205,12 @@ Rectangle { } RalewayBold { - size: 15 + size: 12 text: "Chest" color: hifi.colors.lightGrayText } - RalewayBold { + RalewayRegular { size: 12 text: "requires hips" color: hifi.colors.lightGray @@ -216,7 +218,7 @@ Rectangle { } - Row { + Row { id: shoulderConfig anchors.top: chestConfig.bottom anchors.topMargin: 15 @@ -232,22 +234,72 @@ Rectangle { } RalewayBold { - size: 15 + size: 12 text: "Shoulders" color: hifi.colors.lightGrayText } - RalewayBold { + RalewayRegular { size: 12 text: "requires hips" color: hifi.colors.lightGray } - } - + } + Separator { id: bottomSeperator width: parent.width anchors.top: shoulderConfig.bottom anchors.topMargin: 10 } + + + Rectangle { + id: calibrationButton + width: 200 + height: 35 + radius: 6 + + color: hifi.colors.blueHighlight + + anchors.top: bottomSeperator.bottom + anchors.topMargin: 10 + anchors.left: parent.left + anchors.leftMargin: leftMargin + + + HiFiGlyphs { + id: calibrationGlyph + text: hifi.glyphs.sliders + size: 36 + color: hifi.colors.white + + anchors.horizontalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 30 + + } + + RalewayRegular { + id: calibrate + text: "CALIBRATE" + size: 17 + color: hifi.colors.white + + anchors.left: calibrationGlyph.right + anchors.top: parent.top + anchors.topMargin: 8 + } + + MouseArea { + anchors.fill: parent + + onClicked: { + InputCalibration.calibratePlugin(pluginName); + } + } + } + + + } diff --git a/interface/resources/qml/styles-uit/HifiConstants.qml b/interface/resources/qml/styles-uit/HifiConstants.qml index 7b6efbd573..12bbb09fba 100644 --- a/interface/resources/qml/styles-uit/HifiConstants.qml +++ b/interface/resources/qml/styles-uit/HifiConstants.qml @@ -333,5 +333,6 @@ Item { readonly property string vol_x_2: "\ue015" readonly property string vol_x_3: "\ue016" readonly property string vol_x_4: "\ue017" + readonly property string source: "\ue01c" } } diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 14472a5ec7..051bb3281c 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -48,3 +48,11 @@ QString InputConfiguration::configurationLayout(QString pluginName) { void InputConfiguration::configurationSettings(QJsonObject configurationSettings, QString pluginName) { qDebug() << configurationSettings["Test"]; } + +void InputConfiguration::calibratePlugin(QString pluginName) { + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { + if (plugin->getName() == pluginName) { + //calibrtate plugin + } + } +} diff --git a/libraries/plugins/src/plugins/InputConfiguration.h b/libraries/plugins/src/plugins/InputConfiguration.h index 2a0093d5b2..a560c02e5a 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.h +++ b/libraries/plugins/src/plugins/InputConfiguration.h @@ -26,6 +26,7 @@ public: Q_INVOKABLE QStringList activeInputPlugins(); Q_INVOKABLE QString configurationLayout(QString pluginName); Q_INVOKABLE void configurationSettings(QJsonObject configurationSettings, QString pluginName); + Q_INVOKABLE void calibratePlugin(QString pluginName); }; #endif diff --git a/libraries/plugins/src/plugins/InputPlugin.h b/libraries/plugins/src/plugins/InputPlugin.h index 94c7595eb9..1850dcbc18 100644 --- a/libraries/plugins/src/plugins/InputPlugin.h +++ b/libraries/plugins/src/plugins/InputPlugin.h @@ -28,4 +28,6 @@ public: virtual bool isHandController() const = 0; virtual void configurationSettings(const QJsonObject configurationSettings) { } virtual QString configurationLayout() { return QString(); } + virtual void calibrate() {} + virtual bool configurable() { return false; } }; From 4ba1fdc323cc526165dffea7163a77536797e3c0 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 7 Jun 2017 00:48:12 +0100 Subject: [PATCH 07/31] elimated uncofigurable items from the list --- interface/resources/qml/hifi/tablet/InputConfiguration.qml | 4 ++++ libraries/plugins/src/plugins/InputConfiguration.cpp | 2 +- plugins/openvr/src/ViveControllerManager.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index 9393906b06..8c183986b2 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -101,8 +101,12 @@ Rectangle { onClicked: { if (checked) { box.model = InputConfiguration.activeInputPlugins(); + loader.source = ""; + loader.source = InputConfiguration.configurationLayout(box.currentText); } else { box.model = InputConfiguration.inputPlugins(); + loader.source = ""; + loader.source = InputConfiguration.configurationLayout(box.currentText); } } } diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 051bb3281c..fcafb51c35 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -27,7 +27,7 @@ QStringList InputConfiguration::inputPlugins() { QStringList InputConfiguration::activeInputPlugins() { QStringList activePlugins; for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { - if (plugin->isActive()) { + if (plugin->configurable()) { activePlugins << QString(plugin->getName()); } } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index b8a6206d60..a4ec35c400 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -41,6 +41,7 @@ public: const QString getName() const override { return NAME; } bool isHandController() const override { return true; } + bool configurable() override { return true; } QString configurationLayout() override; void configurationSettings(const QJsonObject configurationSettings) override; From 11409aae9b33cd7d632a547d15150917da74a2ed Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 8 Jun 2017 00:34:52 +0100 Subject: [PATCH 08/31] connect the ui with the input plugins --- .../qml/hifi/tablet/InputConfiguration.qml | 2 +- .../qml/hifi/tablet/OpenVrConfiguration.qml | 133 ++++++++++++++++++ .../src/plugins/InputConfiguration.cpp | 17 ++- .../plugins/src/plugins/InputConfiguration.h | 4 +- libraries/plugins/src/plugins/InputPlugin.h | 5 +- plugins/openvr/src/ViveControllerManager.cpp | 51 ++++++- plugins/openvr/src/ViveControllerManager.h | 21 ++- 7 files changed, 223 insertions(+), 10 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index 8c183986b2..b26134c7fd 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -162,7 +162,7 @@ Rectangle { onLoaded: { - if (loader.item.hasOwnProeprty("pluginName")) { + if (loader.item.hasOwnProperty("pluginName")) { loader.item.pluginName = box.currentText } } diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 434ee12f28..26ca0c644f 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -24,6 +24,15 @@ Rectangle { property int leftMargin: 75 property string pluginName: "" + readonly property bool feetChecked: feetBox.checked + readonly property bool hipsChecked: hipBox.checked + readonly property bool chestChecked: chestBox.checked + readonly property bool shouldersChecked: shoulderBox.checked + readonly property bool hmdHead: headBox.checked + readonly property bool headPuck: headPuckBox.checked + readonly property bool handController: handBox.checked + readonly property bool handPuck: handPuckBox.checked + HifiConstants { id: hifi } color: hifi.colors.baseGray @@ -53,6 +62,15 @@ Rectangle { width: 15 height: 15 boxRadius: 7 + + onClicked: { + if (checked) { + headPuckBox.checked = false; + } else { + checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -66,6 +84,15 @@ Rectangle { width: 15 height: 15 boxRadius: 7 + + onClicked: { + if (checked) { + headBox.checked = false; + } else { + checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -102,6 +129,15 @@ Rectangle { width: 15 height: 15 boxRadius: 7 + + onClicked: { + if (checked) { + handPuckBox.checked = false; + } else { + checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -115,6 +151,15 @@ Rectangle { width: 12 height: 15 boxRadius: 7 + + onClicked: { + if (checked) { + handBox.checked = false; + } else { + checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -151,6 +196,13 @@ Rectangle { width: 15 height: 15 boxRadius: 7 + + onClicked: { + if (hipsChecked) { + checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -173,6 +225,17 @@ Rectangle { width: 15 height: 15 boxRadius: 7 + + onClicked: { + if (checked) { + feetBox.checked = true; + } + + if (chestChecked) { + checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -202,6 +265,14 @@ Rectangle { width: 15 height: 15 boxRadius: 7 + + onClicked: { + if (checked) { + hipBox.checked = true; + feetBox.checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -231,6 +302,14 @@ Rectangle { width: 15 height: 15 boxRadius: 7 + + onClicked: { + if (checked) { + hipBox.checked = true; + feetBox.checked = true; + } + composeConfigurationSettings(); + } } RalewayBold { @@ -300,6 +379,60 @@ Rectangle { } } + HifiControls.SpinBox { + id: timeToCalibrate + + anchors.top: calibrationButton.bottom + anchors.topMargin: 40 + anchors.left: parent.left + anchors.leftMargin: leftMargin + + label: "Time til calibration ( in seconds )" + colorScheme: hifi.colorSchemes.dark + } + + Component.onCompleted: { + var settings = InputConfiguration.configurationSettings(pluginName); + } + function composeConfigurationSettings() { + var trackerConfiguration = ""; + var overrideHead = false; + var overrideHandController = false; + + if (shouldersChecked && chestChecked) { + trackerConfiguration = "FeetHipsChestAndShoulders"; + } else if (shouldersChecked) { + trackerConfiguration = "FeetHipsAndShoulders"; + } else if (chestChecked) { + trackerConfiguration = "FeetHipsChest"; + } else if (hipsChecked) { + trackerConfiguration = "FeetAndHips"; + } else if (feetChecked) { + trackerConfiguration = "Feet"; + } + + if (headPuck) { + overrideHead = true; + } else if (hmdHead) { + overrideHead = false; + } + + if (handController) { + overrideHandController = false; + } else if (handPuck) { + overrideHandController = true; + } + + + var settingsObject = { + "trackerConfiguration": trackerConfiguration, + "overrideHead": overrideHead, + "overrideHandController": overrideHandController + } + + InputConfiguration.setConfigurationSettings(settingsObject, pluginName); + + } } diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index fcafb51c35..515033bf7b 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -45,14 +45,25 @@ QString InputConfiguration::configurationLayout(QString pluginName) { return sourcePath; } -void InputConfiguration::configurationSettings(QJsonObject configurationSettings, QString pluginName) { - qDebug() << configurationSettings["Test"]; +void InputConfiguration::setConfigurationSettings(QJsonObject configurationSettings, QString pluginName) { + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { + if (plugin->getName() == pluginName) { + plugin->setConfigurationSettings(configurationSettings); + } + } +} + +QJsonObject InputConfiguration::configurationSettings(QString pluginName) { + return QJsonObject(); } void InputConfiguration::calibratePlugin(QString pluginName) { for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->getName() == pluginName) { - //calibrtate plugin + plugin->calibrate(); } } } + +void InputConfiguration::calibrated() { +} diff --git a/libraries/plugins/src/plugins/InputConfiguration.h b/libraries/plugins/src/plugins/InputConfiguration.h index a560c02e5a..2171afca34 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.h +++ b/libraries/plugins/src/plugins/InputConfiguration.h @@ -25,8 +25,10 @@ public: Q_INVOKABLE QStringList inputPlugins(); Q_INVOKABLE QStringList activeInputPlugins(); Q_INVOKABLE QString configurationLayout(QString pluginName); - Q_INVOKABLE void configurationSettings(QJsonObject configurationSettings, QString pluginName); + Q_INVOKABLE void setConfigurationSettings(QJsonObject configurationSettings, QString pluginName); Q_INVOKABLE void calibratePlugin(QString pluginName); + Q_INVOKABLE QJsonObject configurationSettings(QString pluginName); + void calibrated(); }; #endif diff --git a/libraries/plugins/src/plugins/InputPlugin.h b/libraries/plugins/src/plugins/InputPlugin.h index 1850dcbc18..e73a047efa 100644 --- a/libraries/plugins/src/plugins/InputPlugin.h +++ b/libraries/plugins/src/plugins/InputPlugin.h @@ -26,8 +26,9 @@ public: // If an input plugin is only a single device, it will only return it's primary name. virtual QStringList getSubdeviceNames() { return { getName() }; }; virtual bool isHandController() const = 0; - virtual void configurationSettings(const QJsonObject configurationSettings) { } + virtual void setConfigurationSettings(const QJsonObject configurationSettings) { } + virtual QJsonObject configurationSettings() { return QJsonObject(); } virtual QString configurationLayout() { return QString(); } - virtual void calibrate() {} + virtual bool calibrate() { return false; } virtual bool configurable() { return false; } }; diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 2337c6161b..87bd8ac1a5 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -120,7 +120,18 @@ bool ViveControllerManager::isSupported() const { return openVrSupported(); } -void ViveControllerManager::configurationSettings(const QJsonObject configurationSettings) { +void ViveControllerManager::setConfigurationSettings(const QJsonObject configurationSettings) { + if (isSupported()) { + _inputDevice->configureCalibrationSettings(configurationSettings); + } +} + +QJsonObject ViveControllerManager::configurationSettings() { + if (isSupported()) { + return _inputDevice->configurationSettings(); + } + + return QJsonObject(); } QString ViveControllerManager::configurationLayout() { @@ -281,6 +292,44 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle _lastSimPoseData = _nextSimPoseData; } +void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJsonObject configurationSettings) { + Locker locker(_lock); + + if (!configurationSettings.empty()) { + auto iter = configurationSettings.begin(); + auto end = configurationSettings.end(); + while (iter != end) { + if (iter.key() == "trackerConfiguration") { + setConfigFromString(iter.value().toString()); + } else if (iter.key() == "overrideHead") { + bool overrideHead = iter.value().toBool(); + if (overrideHead) { + _headConfig = HeadConfig::Puck; + } else { + _headConfig = HeadConfig::HMD; + } + } else if (iter.key() == "overrideHandController") { + bool overrideHands = iter.value().toBool(); + if (overrideHands) { + _handConfig = HandConfig::Pucks; + } else { + _handConfig = HandConfig::HandController; + } + } + iter++; + } + } +} + +QJsonObject ViveControllerManager::InputDevice::configurationSettings() { + Locker locker(_lock); + QJsonObject configurationSettings; + configurationSettings["trackerConfiguration"] = configToString(_config); + configurationSettings["HMDHead"] = (_headConfig == HeadConfig::HMD) ? true : false; + configurationSettings["handController"] = (_handConfig == HandConfig::HandController) ? true : false; + return configurationSettings; +} + void ViveControllerManager::InputDevice::handleTrackedObject(uint32_t deviceIndex, const controller::InputCalibrationData& inputCalibrationData) { uint32_t poseIndex = controller::TRACKED_OBJECT_00 + deviceIndex; printDeviceTrackingResultChange(deviceIndex); diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index a4ec35c400..257baf9fb5 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -44,7 +44,8 @@ public: bool configurable() override { return true; } QString configurationLayout() override; - void configurationSettings(const QJsonObject configurationSettings) override; + void setConfigurationSettings(const QJsonObject configurationSettings) override; + QJsonObject configurationSettings() override; bool activate() override; void deactivate() override; @@ -70,6 +71,8 @@ private: void calibrateOrUncalibrate(const controller::InputCalibrationData& inputCalibration); void calibrate(const controller::InputCalibrationData& inputCalibration); void uncalibrate(); + void configureCalibrationSettings(const QJsonObject configurationSettings); + QJsonObject configurationSettings(); controller::Pose addOffsetToPuckPose(int joint) const; glm::mat4 recalculateDefaultToReferenceForHeadPuck(const controller::InputCalibrationData& inputCalibration); void updateCalibratedLimbs(); @@ -128,10 +131,23 @@ private: FeetHipsAndChest, FeetHipsAndShoulders, FeetHipsChestAndHead, - FeetHipsAndHead + FeetHipsAndHead, }; + + enum class HeadConfig { + HMD, + Puck + }; + + enum class HandConfig { + HandController, + Pucks + }; + Config _config { Config::Auto }; Config _preferedConfig { Config::Auto }; + HeadConfig _headConfig { HeadConfig::HMD }; + HandConfig _handConfig { HandConfig::HandController }; FilteredStick _filteredLeftStick; FilteredStick _filteredRightStick; @@ -157,6 +173,7 @@ private: bool _timeTilCalibrationSet { false }; bool _calibrate { false }; bool _overrideHead { false }; + bool _overrideHands { false }; mutable std::recursive_mutex _lock; QString configToString(Config config); From c97ea84cbf549d0101653cadaaa268dedea9a138 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 8 Jun 2017 17:44:55 +0100 Subject: [PATCH 09/31] saving work --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 45 +++++++++++++++++++ .../src/plugins/InputConfiguration.cpp | 5 +++ plugins/openvr/src/ViveControllerManager.cpp | 1 + 3 files changed, 51 insertions(+) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 26ca0c644f..3679ffe919 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -393,6 +393,51 @@ Rectangle { Component.onCompleted: { var settings = InputConfiguration.configurationSettings(pluginName); + + var configurationType = settings["trackerConfiguration"]; + displayTrackerConfiguration(configurationType); + + + var HmdHead = settings["HMDHead"]; + var viveController = settings["handController"]; + + console.log(HmdHead); + console.log(viveController); + if (HmdHead) { + headBox.checked = true; + } else { + headPuckBox.checked = true; + } + + if (viveController) { + handBox.checked = true; + } else { + handPuckBox.checked = true; + } + } + + + function displayTrackerConfiguration(type) { + + if (type === "Feet") { + feetBox.checked = true; + } else if (type === "FeetAndHips") { + feetBox.checked = true; + hipBox.checked = true; + } else if (type === "FeetHipsChest") { + feetBox.checked = true; + hipBox.checked = true; + chestBox.checked = true; + } else if (type === "FeetHipsAndShoulders") { + feetBox.checked = true; + hipBox.checked = true; + shoulderBox.checked = true; + } else if (type === "FeetHipsChestAndShoulders") { + feetBox.checked = true; + hipBox.checked = true; + chestBox.checked = true; + shoulderBox.checked = true; + } } diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 515033bf7b..78a20653f4 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -54,6 +54,11 @@ void InputConfiguration::setConfigurationSettings(QJsonObject configurationSetti } QJsonObject InputConfiguration::configurationSettings(QString pluginName) { + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { + if (plugin->getName() == pluginName) { + return plugin->configurationSettings(); + } + } return QJsonObject(); } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 87bd8ac1a5..d1087c5cc0 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -123,6 +123,7 @@ bool ViveControllerManager::isSupported() const { void ViveControllerManager::setConfigurationSettings(const QJsonObject configurationSettings) { if (isSupported()) { _inputDevice->configureCalibrationSettings(configurationSettings); + qDebug() << "sending back information"; } } From 73e628461e4189f8ffb4b5a607de9cf70feb1a05 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 9 Jun 2017 00:44:05 +0100 Subject: [PATCH 10/31] confiration update status --- .../qml/hifi/tablet/InputConfiguration.qml | 43 ++++++++++--------- .../qml/hifi/tablet/OpenVrConfiguration.qml | 23 +++++++--- .../src/plugins/InputConfiguration.cpp | 3 +- .../plugins/src/plugins/InputConfiguration.h | 5 ++- plugins/openvr/src/ViveControllerManager.cpp | 13 ++++-- plugins/openvr/src/ViveControllerManager.h | 2 + 6 files changed, 57 insertions(+), 32 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index b26134c7fd..d556247b9d 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -72,7 +72,6 @@ Rectangle { anchors.left: sourceGlyph.right anchors.leftMargin: 10 anchors.topMargin: 30 - anchors.verticalCenter: sourceGlyph.horizontalCenter } Row { @@ -96,21 +95,6 @@ Rectangle { loader.source = InputConfiguration.configurationLayout(box.currentText); } } - - HifiControls.CheckBox { - onClicked: { - if (checked) { - box.model = InputConfiguration.activeInputPlugins(); - loader.source = ""; - loader.source = InputConfiguration.configurationLayout(box.currentText); - } else { - box.model = InputConfiguration.inputPlugins(); - loader.source = ""; - loader.source = InputConfiguration.configurationLayout(box.currentText); - } - } - } - } @@ -146,7 +130,6 @@ Rectangle { anchors.left: sliderGlyph.right anchors.leftMargin: 10 anchors.topMargin: 30 - anchors.verticalCenter: sliderGlyph.horizontalCenter } Loader { @@ -160,15 +143,35 @@ Rectangle { anchors.topMargin: 10 anchors.bottom: inputConfiguration.bottom - + source: InputConfiguration.configurationLayout(box.currentText); onLoaded: { if (loader.item.hasOwnProperty("pluginName")) { loader.item.pluginName = box.currentText + + if (loader.item.hasOwnProperty("displayInformation")) { + loader.item.displayInformation(); + } } } } - + function inputPlugins() { - return InputConfiguration.inputPlugins(); + return InputConfiguration.activeInputPlugins(); + } + + function initialize() { + loader.source = ""; + loader.source = InputConfiguration.configurationLayout(box.currentText); + } + + Timer { + id: timer + repeat: false + interval: 300 + onTriggered: initialize() + } + + Component.onCompleted: { + timer.start(); } } diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 3679ffe919..958e115bb0 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -23,6 +23,7 @@ Rectangle { property int leftMargin: 75 property string pluginName: "" + property var displayInformation: openVrConfiguration.displayConfiguration() readonly property bool feetChecked: feetBox.checked readonly property bool hipsChecked: hipBox.checked @@ -353,7 +354,6 @@ Rectangle { size: 36 color: hifi.colors.white - anchors.horizontalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: 30 @@ -379,6 +379,10 @@ Rectangle { } } + Component.onCompleted: { + InputConfiguration.calibrationStatus.connect(calibrationStatus); + } + HifiControls.SpinBox { id: timeToCalibrate @@ -391,34 +395,39 @@ Rectangle { colorScheme: hifi.colorSchemes.dark } - Component.onCompleted: { - var settings = InputConfiguration.configurationSettings(pluginName); + function calibrationStatus(status) { + console.log("getting calibration status"); + } + function displayConfiguration() { + var settings = InputConfiguration.configurationSettings(pluginName); var configurationType = settings["trackerConfiguration"]; displayTrackerConfiguration(configurationType); var HmdHead = settings["HMDHead"]; var viveController = settings["handController"]; - - console.log(HmdHead); - console.log(viveController); + if (HmdHead) { headBox.checked = true; + headPuckBox.checked = false; } else { headPuckBox.checked = true; + headBox.checked = false; } if (viveController) { handBox.checked = true; + handPuckBox.checked = false; } else { handPuckBox.checked = true; + handBox.checked = false; } } function displayTrackerConfiguration(type) { - + console.log(type); if (type === "Feet") { feetBox.checked = true; } else if (type === "FeetAndHips") { diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 78a20653f4..3414350bf1 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -70,5 +70,6 @@ void InputConfiguration::calibratePlugin(QString pluginName) { } } -void InputConfiguration::calibrated() { +void InputConfiguration::calibrated(const QJsonObject& status) { + emit calibrationStatus(status); } diff --git a/libraries/plugins/src/plugins/InputConfiguration.h b/libraries/plugins/src/plugins/InputConfiguration.h index 2171afca34..fddf858c64 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.h +++ b/libraries/plugins/src/plugins/InputConfiguration.h @@ -28,7 +28,10 @@ public: Q_INVOKABLE void setConfigurationSettings(QJsonObject configurationSettings, QString pluginName); Q_INVOKABLE void calibratePlugin(QString pluginName); Q_INVOKABLE QJsonObject configurationSettings(QString pluginName); - void calibrated(); + void calibrated(const QJsonObject& status); + +signals: + void calibrationStatus(const QJsonObject& status); }; #endif diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index d1087c5cc0..e7a8e87ef3 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -30,7 +30,7 @@ #include #include - +#include #include @@ -123,7 +123,6 @@ bool ViveControllerManager::isSupported() const { void ViveControllerManager::setConfigurationSettings(const QJsonObject configurationSettings) { if (isSupported()) { _inputDevice->configureCalibrationSettings(configurationSettings); - qDebug() << "sending back information"; } } @@ -325,12 +324,18 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso QJsonObject ViveControllerManager::InputDevice::configurationSettings() { Locker locker(_lock); QJsonObject configurationSettings; - configurationSettings["trackerConfiguration"] = configToString(_config); + configurationSettings["trackerConfiguration"] = configToString(_preferedConfig); configurationSettings["HMDHead"] = (_headConfig == HeadConfig::HMD) ? true : false; configurationSettings["handController"] = (_handConfig == HandConfig::HandController) ? true : false; return configurationSettings; } +void ViveControllerManager::InputDevice::emitCalibrationStatus() { + auto inputConfiguration = DependencyManager::get(); + QJsonObject status = QJsonObject(); + inputConfiguration->calibrated(status); +} + void ViveControllerManager::InputDevice::handleTrackedObject(uint32_t deviceIndex, const controller::InputCalibrationData& inputCalibrationData) { uint32_t poseIndex = controller::TRACKED_OBJECT_00 + deviceIndex; printDeviceTrackingResultChange(deviceIndex); @@ -463,6 +468,7 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr return; } _calibrated = true; + emitCalibrationStatus(); qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful"; } @@ -860,6 +866,7 @@ QString ViveControllerManager::InputDevice::configToString(Config config) { } void ViveControllerManager::InputDevice::setConfigFromString(const QString& value) { + qDebug() << "------------> setConfigFromString" << value; if (value == "Auto") { _preferedConfig = Config::Auto; } else if (value == "Feet") { diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 257baf9fb5..5547c29213 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -100,6 +100,8 @@ private: int firstShoulderIndex, int secondShoulderIndex); void calibrateHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); + void emitCalibrationStatus(); + class FilteredStick { public: From ef1be931dc4f5983ed6bd22f55c520473261c4c7 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 10 Jun 2017 00:50:32 +0100 Subject: [PATCH 11/31] preparing to clean code --- .../qml/hifi/tablet/InputConfiguration.qml | 2 +- .../qml/hifi/tablet/OpenVrConfiguration.qml | 167 +++++++++++++++++- .../src/plugins/InputConfiguration.cpp | 1 + libraries/plugins/src/plugins/InputPlugin.h | 2 +- plugins/openvr/src/ViveControllerManager.cpp | 45 ++++- plugins/openvr/src/ViveControllerManager.h | 7 +- 6 files changed, 210 insertions(+), 14 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index d556247b9d..e97c5a9841 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -156,7 +156,7 @@ Rectangle { } function inputPlugins() { - return InputConfiguration.activeInputPlugins(); + return InputConfiguration.inputPlugins(); } function initialize() { diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 958e115bb0..58abc4252e 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -22,6 +22,7 @@ Rectangle { anchors.fill: parent property int leftMargin: 75 + property int countDown: 0 property string pluginName: "" property var displayInformation: openVrConfiguration.displayConfiguration() @@ -36,6 +37,16 @@ Rectangle { HifiConstants { id: hifi } + MouseArea { + id: mouseArea + + anchors.fill: parent + propagateComposedEvents: true + onPressed: { + parent.forceActiveFocus() + mouse.accepted = false; + } + } color: hifi.colors.baseGray RalewayBold { @@ -374,13 +385,43 @@ Rectangle { anchors.fill: parent onClicked: { - InputCalibration.calibratePlugin(pluginName); + console.log("calibration button pressed..."); + openVrConfiguration.countDown = timeToCalibrate.value; + numberAnimation.start(); + calibrationTimer.start(); + info.visible = true; + info.showCountDown = true; } } } + Timer { + id: calibrationTimer + repeat: false + interval: 20 + onTriggered: { + InputConfiguration.calibratePlugin(pluginName) + info.visible = false; + info.showCountDown = false; + console.log("calibration started"); + } + } + + Timer { + id: displayTimer + repeat: false + interval: 3000 + onTriggered: { + info.showCountDown = false; + info.calibrationFailed = false + info.calibrationSucceed = false; + info.showCalibrationStatus = false; + info.visible = false; + } + } + Component.onCompleted: { - InputConfiguration.calibrationStatus.connect(calibrationStatus); + InputConfiguration.calibrationStatus.connect(calibrationStatusInfo); } HifiControls.SpinBox { @@ -393,10 +434,63 @@ Rectangle { label: "Time til calibration ( in seconds )" colorScheme: hifi.colorSchemes.dark + + onEditingFinished: { + calibrationTimer.interval = value * 1000; + openVrConfiguration.countDown = value; + numberAnimation.duration = calibrationTimer.interval; + } + } + + NumberAnimation { + id: numberAnimation + target: openVrConfiguration + property: "countDown" + to: 0 } - function calibrationStatus(status) { - console.log("getting calibration status"); + function calibrationStatusInfo(status) { + if (status["calibrated"]) { + info.visible = true; + info.showCalibrationStatus = true; + info.calibrationSucceed = true; + } else if (!status["calibrated"]) { + var uncalibrated = status["success"]; + if (uncalibrated) { + } else { + info.visible = true; + info.showCalibrationStatus = true; + info.calibrationFailed = true; + } + } + displayTimer.start(); + } + + + function trackersForConfiguration() { + var pucksNeeded = 0; + + if (headPuckBox.checked) { + pucksNeeded++; + } + + if (feetBox.checked) { + pucksNeeded++; + } + + if (hipBox.checked) { + pucksNeeded++; + } + + if (chestBox.checked) { + pucksNeeded++; + } + + if (shoulderBox.checked) { + pucksNeeded++; + } + + return pucksNeeded; } function displayConfiguration() { @@ -426,8 +520,70 @@ Rectangle { } + Rectangle { + id: info + property bool showCountDown: false + property bool showCalibrationStatus: false + property bool calibrationFailed: false + property bool calibrationSucceed: false + + visible: false + color: hifi.colors.baseGray + anchors.top: openVrConfiguration.top + anchors.bottom: bottomSeperator.bottom + anchors.left: openVrConfiguration.left + anchors.right: openVrConfiguration.right + + Item { + id: countDownContainer + visible: info.showCountDown + anchors.centerIn: parent + RalewayBold { + id: countDownText + + text: openVrConfiguration.countDown + size: 92 + + color: hifi.colors.blueHighlight + + anchors.centerIn: parent + } + } + + Item { + id: calibrationStatus + visible: info.showCalibrationStatus + anchors.centerIn: parent + Item { + id: successInfo + visible: info.calibrationSucceed + anchors.centerIn: parent + RalewayBold { + id: successText + text: "Calibration Successful" + size: 42 + color: hifi.colors.greenHighlight + anchors.centerIn: parent + } + } + + Item { + id: failedInfo + visible: info.calibrationFailed + anchors.fill: parent + RalewayBold { + id: failedText + text: "Calibration Failed" + size: 42 + color: hifi.colors.redAccent + anchors.centerIn: parent + } + } + } + } + + function displayTrackerConfiguration(type) { - console.log(type); if (type === "Feet") { feetBox.checked = true; } else if (type === "FeetAndHips") { @@ -449,7 +605,6 @@ Rectangle { } } - function composeConfigurationSettings() { var trackerConfiguration = ""; var overrideHead = false; diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 3414350bf1..3482810448 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -71,5 +71,6 @@ void InputConfiguration::calibratePlugin(QString pluginName) { } void InputConfiguration::calibrated(const QJsonObject& status) { + qDebug() << "-----------> emitting configuration status <------------"; emit calibrationStatus(status); } diff --git a/libraries/plugins/src/plugins/InputPlugin.h b/libraries/plugins/src/plugins/InputPlugin.h index e73a047efa..3c5bd433f2 100644 --- a/libraries/plugins/src/plugins/InputPlugin.h +++ b/libraries/plugins/src/plugins/InputPlugin.h @@ -29,6 +29,6 @@ public: virtual void setConfigurationSettings(const QJsonObject configurationSettings) { } virtual QJsonObject configurationSettings() { return QJsonObject(); } virtual QString configurationLayout() { return QString(); } - virtual bool calibrate() { return false; } + virtual void calibrate() {} virtual bool configurable() { return false; } }; diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index e7a8e87ef3..a7e7b4ae32 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -272,6 +272,14 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle } _trackedControllers = numTrackedControllers; + calibrateFromHandController(inputCalibrationData); + calibrateFromUI(inputCalibrationData); + + updateCalibratedLimbs(); + _lastSimPoseData = _nextSimPoseData; +} + +void ViveControllerManager::InputDevice::calibrateFromHandController(const controller::InputCalibrationData& inputCalibrationData) { if (checkForCalibrationEvent()) { quint64 currentTime = usecTimestampNow(); if (!_timeTilCalibrationSet) { @@ -287,9 +295,14 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle _triggersPressedHandled = false; _timeTilCalibrationSet = false; } +} - updateCalibratedLimbs(); - _lastSimPoseData = _nextSimPoseData; +void ViveControllerManager::InputDevice::calibrateFromUI(const controller::InputCalibrationData& inputCalibrationData) { + if (_calibrate) { + calibrateOrUncalibrate(inputCalibrationData); + _calibrate = false; + qDebug() << "------------> calibrateFromUI <-------------"; + } } void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJsonObject configurationSettings) { @@ -321,6 +334,12 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso } } +void ViveControllerManager::InputDevice::calibrateNextFrame() { + Locker locker(_lock); + _calibrate = true; + qDebug() << "---------> calibrateNextFrame <----------"; +} + QJsonObject ViveControllerManager::InputDevice::configurationSettings() { Locker locker(_lock); QJsonObject configurationSettings; @@ -330,9 +349,23 @@ QJsonObject ViveControllerManager::InputDevice::configurationSettings() { return configurationSettings; } -void ViveControllerManager::InputDevice::emitCalibrationStatus() { +void ViveControllerManager::InputDevice::emitCalibrationStatus(const bool success) { auto inputConfiguration = DependencyManager::get(); QJsonObject status = QJsonObject(); + + if (_calibrated && success) { + status["calibrated"] = _calibrated; + status["configuration"] = configToString(_preferedConfig); + } else if (!_calibrated && !success) { + status["calibrated"] = _calibrated; + status["success"] = success; + } else if (!_calibrated && success) { + status["calibrated"] = _calibrated; + status["success"] = success; + status["configuration"] = configToString(_preferedConfig); + status["puckCount"] = (int)_validTrackedObjects.size(); + } + inputConfiguration->calibrated(status); } @@ -381,6 +414,7 @@ void ViveControllerManager::InputDevice::calibrateOrUncalibrate(const controller calibrate(inputCalibration); } else { uncalibrate(); + emitCalibrationStatus(true); } } @@ -410,6 +444,7 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr if (_config != Config::Auto && puckCount < MIN_PUCK_COUNT) { qDebug() << "Puck Calibration: Failed: Could not meet the minimal # of pucks"; uncalibrate(); + emitCalibrationStatus(false); return; } else if (_config == Config::Auto){ if (puckCount == MIN_PUCK_COUNT) { @@ -424,6 +459,7 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr } else { qDebug() << "Puck Calibration: Auto Config Failed: Could not meet the minimal # of pucks"; uncalibrate(); + emitCalibrationStatus(false); return; } } @@ -465,10 +501,11 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr } else { qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks"; uncalibrate(); + emitCalibrationStatus(false); return; } _calibrated = true; - emitCalibrationStatus(); + emitCalibrationStatus(true); qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful"; } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 5547c29213..1ec7d129c3 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -46,6 +46,7 @@ public: QString configurationLayout() override; void setConfigurationSettings(const QJsonObject configurationSettings) override; QJsonObject configurationSettings() override; + void calibrate() override { _inputDevice->calibrateNextFrame(); } bool activate() override; void deactivate() override; @@ -99,8 +100,10 @@ private: void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, int firstShoulderIndex, int secondShoulderIndex); void calibrateHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); - - void emitCalibrationStatus(); + void calibrateFromHandController(const controller::InputCalibrationData& inputCalibrationData); + void calibrateFromUI(const controller::InputCalibrationData& inputCalibrationData); + void emitCalibrationStatus(const bool success); + void calibrateNextFrame(); class FilteredStick { From f6ef1443c8d7b3d96c0f7085c17e248b813b97fc Mon Sep 17 00:00:00 2001 From: druiz17 Date: Sun, 11 Jun 2017 12:08:45 -0700 Subject: [PATCH 12/31] some more clean up --- .../qml/hifi/tablet/InputConfiguration.qml | 36 ++++++++++++++++--- .../qml/hifi/tablet/OpenVrConfiguration.qml | 2 -- .../src/plugins/InputConfiguration.cpp | 1 - plugins/openvr/src/ViveControllerManager.cpp | 3 -- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index e97c5a9841..b89df4fa3e 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -89,12 +89,24 @@ Rectangle { editable: true colorScheme: hifi.colorSchemes.dark model: inputPlugins() + label: "" onCurrentIndexChanged: { - loader.source = "" - loader.source = InputConfiguration.configurationLayout(box.currentText); + changeSource(); } } + + HifiControls.CheckBox { + id: checkBox + colorScheme: hifi.colorSchemes.dark + text: "show all input plugins" + + onClicked: { + console.log("clicked"); + inputPlugins(); + changeSource(); + } + } } @@ -156,12 +168,26 @@ Rectangle { } function inputPlugins() { - return InputConfiguration.inputPlugins(); + if (checkBox.checked) { + return InputConfiguration.inputPlugins(); + } else { + return InputConfiguration.activeInputPlugins(); + } } function initialize() { - loader.source = ""; - loader.source = InputConfiguration.configurationLayout(box.currentText); + chanageSource(); + } + + function changeSource() { + loader.source = ""; + var source = InputConfiguration.configurationLayout(box.currentText); + loader.source = "OpenVrConfiguration.qml"; + if (source === "") { + box.label = "(not configurable)"; + } else { + box.label = ""; + } } Timer { diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 58abc4252e..e00ee17228 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -385,7 +385,6 @@ Rectangle { anchors.fill: parent onClicked: { - console.log("calibration button pressed..."); openVrConfiguration.countDown = timeToCalibrate.value; numberAnimation.start(); calibrationTimer.start(); @@ -403,7 +402,6 @@ Rectangle { InputConfiguration.calibratePlugin(pluginName) info.visible = false; info.showCountDown = false; - console.log("calibration started"); } } diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 3482810448..3414350bf1 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -71,6 +71,5 @@ void InputConfiguration::calibratePlugin(QString pluginName) { } void InputConfiguration::calibrated(const QJsonObject& status) { - qDebug() << "-----------> emitting configuration status <------------"; emit calibrationStatus(status); } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index a7e7b4ae32..cb789c724d 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -301,7 +301,6 @@ void ViveControllerManager::InputDevice::calibrateFromUI(const controller::Input if (_calibrate) { calibrateOrUncalibrate(inputCalibrationData); _calibrate = false; - qDebug() << "------------> calibrateFromUI <-------------"; } } @@ -337,7 +336,6 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso void ViveControllerManager::InputDevice::calibrateNextFrame() { Locker locker(_lock); _calibrate = true; - qDebug() << "---------> calibrateNextFrame <----------"; } QJsonObject ViveControllerManager::InputDevice::configurationSettings() { @@ -903,7 +901,6 @@ QString ViveControllerManager::InputDevice::configToString(Config config) { } void ViveControllerManager::InputDevice::setConfigFromString(const QString& value) { - qDebug() << "------------> setConfigFromString" << value; if (value == "Auto") { _preferedConfig = Config::Auto; } else if (value == "Feet") { From 1b13cd6d45aee1d13d3be1f37941eabca1efabcc Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 12 Jun 2017 17:31:02 +0100 Subject: [PATCH 13/31] saving work --- .../qml/hifi/tablet/InputConfiguration.qml | 4 +- interface/src/Application.cpp | 2 +- interface/src/ui/overlays/Web3DOverlay.cpp | 44 +++++++++---------- .../src/plugins/InputConfiguration.cpp | 1 + 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index b89df4fa3e..e62576b6cf 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -176,13 +176,13 @@ Rectangle { } function initialize() { - chanageSource(); + changeSource(); } function changeSource() { loader.source = ""; var source = InputConfiguration.configurationLayout(box.currentText); - loader.source = "OpenVrConfiguration.qml"; + loader.source = source; if (source === "") { box.label = "(not configurable)"; } else { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 531847ce7f..7d56022e1d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -508,6 +508,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); + DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); @@ -528,7 +529,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_THIRD_PERSON, STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT, STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED } }); DependencyManager::set(); - DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); DependencyManager::set(true, qApp, qApp); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 6f1d266597..7585aafc9b 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -183,28 +183,28 @@ void Web3DOverlay::loadSourceURL() { if (_webSurface->getRootItem() && _webSurface->getRootItem()->objectName() == "tabletRoot") { auto tabletScriptingInterface = DependencyManager::get(); auto flags = tabletScriptingInterface->getFlags(); - - _webSurface->getRootContext()->setContextProperty("offscreenFlags", flags); - _webSurface->getRootContext()->setContextProperty("AddressManager", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Account", AccountScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); - _webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("fileDialogHelper", new FileDialogHelper()); - _webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); - _webSurface->getRootContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Tablet", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Assets", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("LODManager", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("OctreeStats", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("DCModel", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); - _webSurface->getRootContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AvatarList", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("InputConfiguration", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); - + + _webSurface->getSurfaceContext()->setContextProperty("offscreenFlags", flags); + _webSurface->getSurfaceContext()->setContextProperty("AddressManager", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Account", AccountScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); + _webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("fileDialogHelper", new FileDialogHelper()); + _webSurface->getSurfaceContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); + _webSurface->getSurfaceContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Tablet", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Assets", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("LODManager", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("OctreeStats", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("DCModel", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("AvatarList", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("InputConfiguration", DependencyManager::get().data()); + + _webSurface->getSurfaceContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data()); // mark the TabletProxy object as cpp ownership. diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 3414350bf1..f1ff93f361 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -65,6 +65,7 @@ QJsonObject InputConfiguration::configurationSettings(QString pluginName) { void InputConfiguration::calibratePlugin(QString pluginName) { for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->getName() == pluginName) { + qDebug() << "calibrating plauin " << pluginName; plugin->calibrate(); } } From bbe675ab72018ea4c1fc1da5d61ff00c344a6cc0 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 12 Jun 2017 22:01:41 +0100 Subject: [PATCH 14/31] making final changes --- .../qml/hifi/tablet/InputConfiguration.qml | 52 +++++------ .../qml/hifi/tablet/OpenVrConfiguration.qml | 86 +++++++++++-------- .../src/plugins/InputConfiguration.cpp | 51 +++++++++-- .../plugins/src/plugins/InputConfiguration.h | 1 - plugins/openvr/src/ViveControllerManager.cpp | 3 +- 5 files changed, 124 insertions(+), 69 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml index e62576b6cf..10181480f0 100644 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/InputConfiguration.qml @@ -89,24 +89,24 @@ Rectangle { editable: true colorScheme: hifi.colorSchemes.dark model: inputPlugins() - label: "" - + label: "" + onCurrentIndexChanged: { - changeSource(); + changeSource(); } } - HifiControls.CheckBox { - id: checkBox - colorScheme: hifi.colorSchemes.dark - text: "show all input plugins" + HifiControls.CheckBox { + id: checkBox + colorScheme: hifi.colorSchemes.dark + text: "show all input plugins" - onClicked: { - console.log("clicked"); - inputPlugins(); - changeSource(); - } - } + onClicked: { + console.log("clicked"); + inputPlugins(); + changeSource(); + } + } } @@ -166,13 +166,13 @@ Rectangle { } } } - + function inputPlugins() { - if (checkBox.checked) { + if (checkBox.checked) { return InputConfiguration.inputPlugins(); - } else { - return InputConfiguration.activeInputPlugins(); - } + } else { + return InputConfiguration.activeInputPlugins(); + } } function initialize() { @@ -180,14 +180,14 @@ Rectangle { } function changeSource() { - loader.source = ""; - var source = InputConfiguration.configurationLayout(box.currentText); - loader.source = source; - if (source === "") { - box.label = "(not configurable)"; - } else { - box.label = ""; - } + loader.source = ""; + var source = InputConfiguration.configurationLayout(box.currentText); + loader.source = source; + if (source === "") { + box.label = "(not configurable)"; + } else { + box.label = ""; + } } Timer { diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index e00ee17228..51bf3f60cd 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -84,13 +84,13 @@ Rectangle { composeConfigurationSettings(); } } - + RalewayBold { size: 12 text: "Vive HMD" color: hifi.colors.lightGrayText } - + HifiControls.CheckBox { id: headPuckBox width: 15 @@ -116,10 +116,10 @@ Rectangle { RalewayBold { id: hands - + text: "Hands:" size: 12 - + color: "white" anchors.top: headConfig.bottom @@ -135,7 +135,7 @@ Rectangle { anchors.left: openVrConfiguration.left anchors.leftMargin: leftMargin + 20 spacing: 10 - + HifiControls.CheckBox { id: handBox width: 15 @@ -151,13 +151,13 @@ Rectangle { composeConfigurationSettings(); } } - + RalewayBold { size: 12 text: "Controllers" color: hifi.colors.lightGrayText } - + HifiControls.CheckBox { id: handPuckBox width: 12 @@ -173,7 +173,7 @@ Rectangle { composeConfigurationSettings(); } } - + RalewayBold { size: 12 text: "Trackers" @@ -183,10 +183,10 @@ Rectangle { RalewayBold { id: additional - + text: "Additional Trackers" size: 12 - + color: hifi.colors.white anchors.top: handConfig.bottom @@ -202,7 +202,7 @@ Rectangle { anchors.left: openVrConfiguration.left anchors.leftMargin: leftMargin + 20 spacing: 10 - + HifiControls.CheckBox { id: feetBox width: 15 @@ -216,7 +216,7 @@ Rectangle { composeConfigurationSettings(); } } - + RalewayBold { size: 12 text: "Feet" @@ -231,7 +231,7 @@ Rectangle { anchors.left: openVrConfiguration.left anchors.leftMargin: leftMargin + 20 spacing: 10 - + HifiControls.CheckBox { id: hipBox width: 15 @@ -249,7 +249,7 @@ Rectangle { composeConfigurationSettings(); } } - + RalewayBold { size: 12 text: "Hips" @@ -271,7 +271,7 @@ Rectangle { anchors.left: openVrConfiguration.left anchors.leftMargin: leftMargin + 20 spacing: 10 - + HifiControls.CheckBox { id: chestBox width: 15 @@ -286,7 +286,7 @@ Rectangle { composeConfigurationSettings(); } } - + RalewayBold { size: 12 text: "Chest" @@ -308,7 +308,7 @@ Rectangle { anchors.left: openVrConfiguration.left anchors.leftMargin: leftMargin + 20 spacing: 10 - + HifiControls.CheckBox { id: shoulderBox width: 15 @@ -323,7 +323,7 @@ Rectangle { composeConfigurationSettings(); } } - + RalewayBold { size: 12 text: "Shoulders" @@ -336,7 +336,7 @@ Rectangle { color: hifi.colors.lightGray } } - + Separator { id: bottomSeperator width: parent.width @@ -367,9 +367,9 @@ Rectangle { anchors.left: parent.left anchors.leftMargin: 30 - + } - + RalewayRegular { id: calibrate text: "CALIBRATE" @@ -413,6 +413,7 @@ Rectangle { info.showCountDown = false; info.calibrationFailed = false info.calibrationSucceed = false; + info.calibrationSucceed = false; info.showCalibrationStatus = false; info.visible = false; } @@ -439,7 +440,7 @@ Rectangle { numberAnimation.duration = calibrationTimer.interval; } } - + NumberAnimation { id: numberAnimation target: openVrConfiguration @@ -455,6 +456,9 @@ Rectangle { } else if (!status["calibrated"]) { var uncalibrated = status["success"]; if (uncalibrated) { + info.visible = true; + info.showCalibrationStatus = true; + info.uncalibrationSucceed = true; } else { info.visible = true; info.showCalibrationStatus = true; @@ -496,10 +500,10 @@ Rectangle { var configurationType = settings["trackerConfiguration"]; displayTrackerConfiguration(configurationType); - + var HmdHead = settings["HMDHead"]; var viveController = settings["handController"]; - + if (HmdHead) { headBox.checked = true; headPuckBox.checked = false; @@ -524,7 +528,8 @@ Rectangle { property bool showCalibrationStatus: false property bool calibrationFailed: false property bool calibrationSucceed: false - + property bool uncalibrationSucceed: false + visible: false color: hifi.colors.baseGray anchors.top: openVrConfiguration.top @@ -538,12 +543,12 @@ Rectangle { anchors.centerIn: parent RalewayBold { id: countDownText - + text: openVrConfiguration.countDown size: 92 - + color: hifi.colors.blueHighlight - + anchors.centerIn: parent } } @@ -576,11 +581,24 @@ Rectangle { color: hifi.colors.redAccent anchors.centerIn: parent } - } + } + + Item { + id: uncalibrateInfo + visible: info.uncalibrationSucceed + anchors.centerIn: parent + RalewayBold { + id: uncalibrateText + text: "Uncalibration Successful" + size: 42 + color: hifi.colors.greenHighlight + anchors.centerIn: parent + } + } } } - - + + function displayTrackerConfiguration(type) { if (type === "Feet") { feetBox.checked = true; @@ -631,8 +649,8 @@ Rectangle { } else if (handPuck) { overrideHandController = true; } - - + + var settingsObject = { "trackerConfiguration": trackerConfiguration, "overrideHead": overrideHead, @@ -640,6 +658,6 @@ Rectangle { } InputConfiguration.setConfigurationSettings(settingsObject, pluginName); - + } } diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index f1ff93f361..d20678b972 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -8,6 +8,9 @@ #include "InputConfiguration.h" + +#include + #include "DisplayPlugin.h" #include "InputPlugin.h" #include "PluginManager.h" @@ -16,6 +19,13 @@ InputConfiguration::InputConfiguration() { } QStringList InputConfiguration::inputPlugins() { + if (QThread::currentThread() != thread()) { + QStringList result; + QMetaObject::invokeMethod(this, "inputPlugins", Qt::BlockingQueuedConnection, + Q_RETURN_ARG(QStringList, result)); + return result; + } + QStringList inputPlugins; for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { inputPlugins << QString(plugin->getName()); @@ -25,6 +35,13 @@ QStringList InputConfiguration::inputPlugins() { QStringList InputConfiguration::activeInputPlugins() { + if (QThread::currentThread() != thread()) { + QStringList result; + QMetaObject::invokeMethod(this, "activeInputPlugins", Qt::BlockingQueuedConnection, + Q_RETURN_ARG(QStringList, result)); + return result; + } + QStringList activePlugins; for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->configurable()) { @@ -35,8 +52,15 @@ QStringList InputConfiguration::activeInputPlugins() { } QString InputConfiguration::configurationLayout(QString pluginName) { - QString sourcePath; + if (QThread::currentThread() != thread()) { + QString result; + QMetaObject::invokeMethod(this, "configurationLayout", Qt::BlockingQueuedConnection, + Q_RETURN_ARG(QString, result), + Q_ARG(QString, pluginName)); + return result; + } + QString sourcePath; for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->getName() == pluginName) { return plugin->configurationLayout(); @@ -46,6 +70,13 @@ QString InputConfiguration::configurationLayout(QString pluginName) { } void InputConfiguration::setConfigurationSettings(QJsonObject configurationSettings, QString pluginName) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "setConfigurationSettings", Qt::BlockingQueuedConnection, + Q_ARG(QJsonObject, configurationSettings), + Q_ARG(QString, pluginName)); + return; + } + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->getName() == pluginName) { plugin->setConfigurationSettings(configurationSettings); @@ -54,6 +85,14 @@ void InputConfiguration::setConfigurationSettings(QJsonObject configurationSetti } QJsonObject InputConfiguration::configurationSettings(QString pluginName) { + if (QThread::currentThread() != thread()) { + QJsonObject result; + QMetaObject::invokeMethod(this, "configurationSettings", Qt::BlockingQueuedConnection, + Q_RETURN_ARG(QJsonObject, result), + Q_ARG(QString, pluginName)); + return result; + } + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->getName() == pluginName) { return plugin->configurationSettings(); @@ -63,14 +102,14 @@ QJsonObject InputConfiguration::configurationSettings(QString pluginName) { } void InputConfiguration::calibratePlugin(QString pluginName) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "calibratePlugin", Qt::BlockingQueuedConnection); + return; + } + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->getName() == pluginName) { - qDebug() << "calibrating plauin " << pluginName; plugin->calibrate(); } } } - -void InputConfiguration::calibrated(const QJsonObject& status) { - emit calibrationStatus(status); -} diff --git a/libraries/plugins/src/plugins/InputConfiguration.h b/libraries/plugins/src/plugins/InputConfiguration.h index fddf858c64..abf0c89ab4 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.h +++ b/libraries/plugins/src/plugins/InputConfiguration.h @@ -28,7 +28,6 @@ public: Q_INVOKABLE void setConfigurationSettings(QJsonObject configurationSettings, QString pluginName); Q_INVOKABLE void calibratePlugin(QString pluginName); Q_INVOKABLE QJsonObject configurationSettings(QString pluginName); - void calibrated(const QJsonObject& status); signals: void calibrationStatus(const QJsonObject& status); diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 07436c194b..9e723d2a10 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -314,7 +314,6 @@ void ViveControllerManager::InputDevice::calibrateFromUI(const controller::Input void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJsonObject configurationSettings) { Locker locker(_lock); - if (!configurationSettings.empty()) { auto iter = configurationSettings.begin(); auto end = configurationSettings.end(); @@ -372,7 +371,7 @@ void ViveControllerManager::InputDevice::emitCalibrationStatus(const bool succes status["puckCount"] = (int)_validTrackedObjects.size(); } - inputConfiguration->calibrated(status); + emit inputConfiguration->calibrationStatus(status); //inputConfiguration->calibrated(status); } void ViveControllerManager::InputDevice::handleTrackedObject(uint32_t deviceIndex, const controller::InputCalibrationData& inputCalibrationData) { From 89b0e31edca001430e6d5cf2f467122fccd94c61 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 12 Jun 2017 22:21:46 +0100 Subject: [PATCH 15/31] update calibrate button glyph --- interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 51bf3f60cd..52c18ddff8 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -361,7 +361,7 @@ Rectangle { HiFiGlyphs { id: calibrationGlyph - text: hifi.glyphs.sliders + text: hifi.glyphs.avatar1 size: 36 color: hifi.colors.white From f9f9aeac0116b43617a4d5527abefea767bdca29 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 13 Jun 2017 00:29:45 +0100 Subject: [PATCH 16/31] saving work --- plugins/openvr/src/ViveControllerManager.cpp | 105 +++++++++---------- plugins/openvr/src/ViveControllerManager.h | 11 +- 2 files changed, 55 insertions(+), 61 deletions(-) diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 9e723d2a10..23b8e72963 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -222,7 +222,7 @@ void ViveControllerManager::pluginUpdate(float deltaTime, const controller::Inpu ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) : controller::InputDevice("Vive"), _system(system) { - _configStringMap[Config::Auto] = QString("Auto"); + _configStringMap[Config::None] = QString("None"); _configStringMap[Config::Feet] = QString("Feet"); _configStringMap[Config::FeetAndHips] = QString("FeetAndHips"); _configStringMap[Config::FeetHipsAndChest] = QString("FeetHipsAndChest"); @@ -425,49 +425,17 @@ void ViveControllerManager::InputDevice::calibrateOrUncalibrate(const controller void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibrationData& inputCalibration) { qDebug() << "Puck Calibration: Starting..."; - // convert the hmd head from sensor space to avatar space - glm::mat4 hmdSensorFlippedMat = inputCalibration.hmdSensorMat * Matrices::Y_180; - glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; - glm::mat4 hmdAvatarMat = sensorToAvatarMat * hmdSensorFlippedMat; - // cancel the roll and pitch for the hmd head - glm::quat hmdRotation = cancelOutRollAndPitch(glmExtractRotation(hmdAvatarMat)); - glm::vec3 hmdTranslation = extractTranslation(hmdAvatarMat); - glm::mat4 currentHmd = createMatFromQuatAndPos(hmdRotation, hmdTranslation); - - // calculate the offset from the centerOfEye to defaultHeadMat - glm::mat4 defaultHeadOffset = glm::inverse(inputCalibration.defaultCenterEyeMat) * inputCalibration.defaultHeadMat; - - glm::mat4 currentHead = currentHmd * defaultHeadOffset; - - // calculate the defaultToRefrenceXform - glm::mat4 defaultToReferenceMat = currentHead * glm::inverse(inputCalibration.defaultHeadMat); + glm::mat4 defaultToReferenceMat = glm::mat4(); + if (_headConfig == HeadConfig::HMD) { + defaultToReferenceMat = calculateDefaultToReferenceForHmd(inputCalibration); + } else if (_headConfig == HeadConfig::Puck) { + defaultToReferenceMat = calculateDefaultToReferenceForHeadPuck(inputCalibration); + } int puckCount = (int)_validTrackedObjects.size(); qDebug() << "Puck Calibration: " << puckCount << " pucks found for calibration"; _config = _preferedConfig; - if (_config != Config::Auto && puckCount < MIN_PUCK_COUNT) { - qDebug() << "Puck Calibration: Failed: Could not meet the minimal # of pucks"; - uncalibrate(); - emitCalibrationStatus(false); - return; - } else if (_config == Config::Auto){ - if (puckCount == MIN_PUCK_COUNT) { - _config = Config::Feet; - qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration"; - } else if (puckCount == MIN_FEET_AND_HIPS) { - _config = Config::FeetAndHips; - qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration"; - } else if (puckCount >= MIN_FEET_HIPS_CHEST) { - _config = Config::FeetHipsAndChest; - qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration"; - } else { - qDebug() << "Puck Calibration: Auto Config Failed: Could not meet the minimal # of pucks"; - uncalibrate(); - emitCalibrationStatus(false); - return; - } - } std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksYPosition); @@ -487,21 +455,19 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr int secondShoulderIndex = 4; calibrateShoulders(defaultToReferenceMat, inputCalibration, firstShoulderIndex, secondShoulderIndex); } else if (_config == Config::FeetHipsAndHead && puckCount == MIN_FEET_HIPS_HEAD) { - glm::mat4 headPuckDefaultToReferenceMat = recalculateDefaultToReferenceForHeadPuck(inputCalibration); - glm::vec3 headXAxis = getReferenceHeadXAxis(headPuckDefaultToReferenceMat, inputCalibration.defaultHeadMat); - glm::vec3 headPosition = getReferenceHeadPosition(headPuckDefaultToReferenceMat, inputCalibration.defaultHeadMat); - calibrateFeet(headPuckDefaultToReferenceMat, inputCalibration, headXAxis, headPosition); - calibrateHips(headPuckDefaultToReferenceMat, inputCalibration); - calibrateHead(headPuckDefaultToReferenceMat, inputCalibration); + glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); + glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); + calibrateFeet(defaultToReferenceMat, inputCalibration, headXAxis, headPosition); + calibrateHips(defaultToReferenceMat, inputCalibration); + calibrateHead(defaultToReferenceMat, inputCalibration); _overrideHead = true; } else if (_config == Config::FeetHipsChestAndHead && puckCount == MIN_FEET_HIPS_CHEST_HEAD) { - glm::mat4 headPuckDefaultToReferenceMat = recalculateDefaultToReferenceForHeadPuck(inputCalibration); - glm::vec3 headXAxis = getReferenceHeadXAxis(headPuckDefaultToReferenceMat, inputCalibration.defaultHeadMat); - glm::vec3 headPosition = getReferenceHeadPosition(headPuckDefaultToReferenceMat, inputCalibration.defaultHeadMat); - calibrateFeet(headPuckDefaultToReferenceMat, inputCalibration, headXAxis, headPosition); - calibrateHips(headPuckDefaultToReferenceMat, inputCalibration); - calibrateChest(headPuckDefaultToReferenceMat, inputCalibration); - calibrateHead(headPuckDefaultToReferenceMat, inputCalibration); + glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); + glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); + calibrateFeet(defaultToReferenceMat, inputCalibration, headXAxis, headPosition); + calibrateHips(defaultToReferenceMat, inputCalibration); + calibrateChest(defaultToReferenceMat, inputCalibration); + calibrateHead(defaultToReferenceMat, inputCalibration); _overrideHead = true; } else { qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks"; @@ -515,7 +481,7 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr } void ViveControllerManager::InputDevice::uncalibrate() { - _config = Config::Auto; + _config = Config::None; _pucksOffset.clear(); _jointToPuckMap.clear(); _calibrated = false; @@ -597,8 +563,29 @@ void ViveControllerManager::InputDevice::handleHandController(float deltaTime, u } } } +glm::mat4 ViveControllerManager::InputDevice::calculateDefaultToReferenceForHmd(const controller::InputCalibrationData& inputCalibration) { + // convert the hmd head from sensor space to avatar space + glm::mat4 hmdSensorFlippedMat = inputCalibration.hmdSensorMat * Matrices::Y_180; + glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; + glm::mat4 hmdAvatarMat = sensorToAvatarMat * hmdSensorFlippedMat; -glm::mat4 ViveControllerManager::InputDevice::recalculateDefaultToReferenceForHeadPuck(const controller::InputCalibrationData& inputCalibration) { + // cancel the roll and pitch for the hmd head + glm::quat hmdRotation = cancelOutRollAndPitch(glmExtractRotation(hmdAvatarMat)); + glm::vec3 hmdTranslation = extractTranslation(hmdAvatarMat); + glm::mat4 currentHmd = createMatFromQuatAndPos(hmdRotation, hmdTranslation); + + // calculate the offset from the centerOfEye to defaultHeadMat + glm::mat4 defaultHeadOffset = glm::inverse(inputCalibration.defaultCenterEyeMat) * inputCalibration.defaultHeadMat; + + glm::mat4 currentHead = currentHmd * defaultHeadOffset; + + // calculate the defaultToRefrenceXform + glm::mat4 defaultToReferenceMat = currentHead * glm::inverse(inputCalibration.defaultHeadMat); + + return defaultToReferenceMat; +} + +glm::mat4 ViveControllerManager::InputDevice::calculateDefaultToReferenceForHeadPuck(const controller::InputCalibrationData& inputCalibration) { glm::mat4 avatarToSensorMat = glm::inverse(inputCalibration.sensorToWorldMat) * inputCalibration.avatarMat; glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; size_t headPuckIndex = _validTrackedObjects.size() - 1; @@ -847,6 +834,10 @@ void ViveControllerManager::InputDevice::calibrateHips(glm::mat4& defaultToRefer _pucksOffset[_validTrackedObjects[HIP].first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultHips, _validTrackedObjects[HIP].second); } + +void ViveControllerManager::InputDevice::calibrateHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, int firstHandIndex, int secondHandIndex) { +} + void ViveControllerManager::InputDevice::calibrateChest(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { _jointToPuckMap[controller::SPINE2] = _validTrackedObjects[CHEST].first; _pucksOffset[_validTrackedObjects[CHEST].first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultSpine2, _validTrackedObjects[CHEST].second); @@ -889,7 +880,7 @@ void ViveControllerManager::InputDevice::loadSettings() { Settings settings; settings.beginGroup("PUCK_CONFIG"); { - _preferedConfig = (Config)settings.value("configuration", QVariant((int)Config::Auto)).toInt(); + _preferedConfig = (Config)settings.value("configuration", QVariant((int)Config::None)).toInt(); } settings.endGroup(); } @@ -908,8 +899,8 @@ QString ViveControllerManager::InputDevice::configToString(Config config) { } void ViveControllerManager::InputDevice::setConfigFromString(const QString& value) { - if (value == "Auto") { - _preferedConfig = Config::Auto; + if (value == "None") { + _preferedConfig = Config::None; } else if (value == "Feet") { _preferedConfig = Config::Feet; } else if (value == "FeetAndHips") { diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 1bb662efbc..ea29d974e9 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -78,7 +78,8 @@ private: void configureCalibrationSettings(const QJsonObject configurationSettings); QJsonObject configurationSettings(); controller::Pose addOffsetToPuckPose(int joint) const; - glm::mat4 recalculateDefaultToReferenceForHeadPuck(const controller::InputCalibrationData& inputCalibration); + glm::mat4 calculateDefaultToReferenceForHeadPuck(const controller::InputCalibrationData& inputCalibration); + glm::mat4 calculateDefaultToReferenceForHmd(const controller::InputCalibrationData& inputCalibration); void updateCalibratedLimbs(); bool checkForCalibrationEvent(); void handleHandController(float deltaTime, uint32_t deviceIndex, const controller::InputCalibrationData& inputCalibrationData, bool isLeftHand); @@ -102,6 +103,8 @@ private: void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, int firstShoulderIndex, int secondShoulderIndex); + void calibrateHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, + int firstHandIndex, int secondHandIndex); void calibrateHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); void calibrateFromHandController(const controller::InputCalibrationData& inputCalibrationData); void calibrateFromUI(const controller::InputCalibrationData& inputCalibrationData); @@ -133,7 +136,7 @@ private: glm::vec2 _stick { 0.0f, 0.0f }; }; enum class Config { - Auto, + None, Feet, FeetAndHips, FeetHipsAndChest, @@ -152,8 +155,8 @@ private: Pucks }; - Config _config { Config::Auto }; - Config _preferedConfig { Config::Auto }; + Config _config { Config::None }; + Config _preferedConfig { Config::None }; HeadConfig _headConfig { HeadConfig::HMD }; HandConfig _handConfig { HandConfig::HandController }; FilteredStick _filteredLeftStick; From e125e1f608230c3129530b77127ab50127dde49f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 13 Jun 2017 00:37:32 +0100 Subject: [PATCH 17/31] fix issue that caused jenkin to fail buiuling code --- plugins/hifiKinect/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hifiKinect/CMakeLists.txt b/plugins/hifiKinect/CMakeLists.txt index fc4c2f6f7c..a7088eb3b4 100644 --- a/plugins/hifiKinect/CMakeLists.txt +++ b/plugins/hifiKinect/CMakeLists.txt @@ -11,7 +11,7 @@ if (WIN32) if (KINECT_FOUND) set(TARGET_NAME hifiKinect) setup_hifi_plugin(Script Qml Widgets) - link_hifi_libraries(shared controllers ui plugins input-plugins) + link_hifi_libraries(shared controllers ui plugins input-plugins display-plugins) # need to setup appropriate externals... target_kinect() From ef9a211f6ee6d0f529e4ca19bcfbb408652375a9 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 13 Jun 2017 21:15:16 +0100 Subject: [PATCH 18/31] adding hand punck --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 2 + plugins/openvr/src/ViveControllerManager.cpp | 172 +++++++++++++++--- plugins/openvr/src/ViveControllerManager.h | 9 +- 3 files changed, 157 insertions(+), 26 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 52c18ddff8..23af4fd93d 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -636,6 +636,8 @@ Rectangle { trackerConfiguration = "FeetAndHips"; } else if (feetChecked) { trackerConfiguration = "Feet"; + } else { + trackerConfiguration = "None"; } if (headPuck) { diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 23b8e72963..43f815c068 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -47,6 +47,7 @@ static const char* MENU_PARENT = "Avatar"; static const char* MENU_NAME = "Vive Controllers"; static const char* MENU_PATH = "Avatar" ">" "Vive Controllers"; static const char* RENDER_CONTROLLERS = "Render Hand Controllers"; +static const int MIN_HEAD = 1; static const int MIN_PUCK_COUNT = 2; static const int MIN_FEET_AND_HIPS = 3; static const int MIN_FEET_HIPS_CHEST = 4; @@ -84,7 +85,7 @@ static bool sortPucksXPosition(PuckPosePair firstPuck, PuckPosePair secondPuck) return (firstPuck.second.translation.x < secondPuck.second.translation.x); } -static bool determineFeetOrdering(const controller::Pose& poseA, const controller::Pose& poseB, glm::vec3 axis, glm::vec3 axisOrigin) { +static bool determineLimbOrdering(const controller::Pose& poseA, const controller::Pose& poseB, glm::vec3 axis, glm::vec3 axisOrigin) { glm::vec3 poseAPosition = poseA.getTranslation(); glm::vec3 poseBPosition = poseB.getTranslation(); @@ -222,13 +223,11 @@ void ViveControllerManager::pluginUpdate(float deltaTime, const controller::Inpu ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) : controller::InputDevice("Vive"), _system(system) { - _configStringMap[Config::None] = QString("None"); - _configStringMap[Config::Feet] = QString("Feet"); - _configStringMap[Config::FeetAndHips] = QString("FeetAndHips"); - _configStringMap[Config::FeetHipsAndChest] = QString("FeetHipsAndChest"); + _configStringMap[Config::None] = QString("None"); + _configStringMap[Config::Feet] = QString("Feet"); + _configStringMap[Config::FeetAndHips] = QString("FeetAndHips"); + _configStringMap[Config::FeetHipsAndChest] = QString("FeetHipsAndChest"); _configStringMap[Config::FeetHipsAndShoulders] = QString("FeetHipsAndShoulders"); - _configStringMap[Config::FeetHipsChestAndHead] = QString("FeetHipsChestAndHead"); - _configStringMap[Config::FeetHipsAndHead] = QString("FeetHipsAndHead"); if (openVrSupported()) { createPreferences(); @@ -436,31 +435,95 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr int puckCount = (int)_validTrackedObjects.size(); qDebug() << "Puck Calibration: " << puckCount << " pucks found for calibration"; _config = _preferedConfig; + + bool headConfigured = configureHead(defaultToReferenceMat, inputCalibration); + bool handsConfigured = configureHands(defaultToReferenceMat, inputCalibration); + bool bodyConfigured = configureBody(defaultToReferenceMat, inputCalibration); + if (!headConfigured || !handsConfigured || !bodyConfigured) { + uncalibrate(); + emitCalibrationStatus(false); + } else { + _calibrated = true; + emitCalibrationStatus(true); + qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful"; + } +} + +bool ViveControllerManager::InputDevice::configureHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { + std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksXPosition); + int puckCount = (int)_validTrackedObjects.size(); + if (_handConfig == HandConfig::Pucks && puckCount >= MIN_PUCK_COUNT) { + glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); + glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); + size_t FIRST_INDEX = 0; + size_t LAST_INDEX = _validTrackedObjects.size() -1; + auto& firstHand = _validTrackedObjects[FIRST_INDEX]; + auto& secondHand = _validTrackedObjects[LAST_INDEX]; + controller::Pose& firstHandPose = firstHand.second; + controller::Pose& secondHandPose = secondHand.second; + + if (determineLimbOrdering(firstHandPose, secondHandPose, headXAxis, headPosition)) { + calibrateLeftHand(defaultToReferenceMat, inputCalibration, firstHand); + calibrateRightHand(defaultToReferenceMat, inputCalibration, secondHand); + _overrideHands = true; + } else { + calibrateLeftHand(defaultToReferenceMat, inputCalibration, secondHand); + calibrateRightHand(defaultToReferenceMat, inputCalibration, firstHand); + _overrideHands = true; + } + } else if (_handConfig == HandConfig::HandController) { + _overrideHands = false; + return true; + } + return false; +} + +bool ViveControllerManager::InputDevice::configureHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksYPosition); + int puckCount = (int)_validTrackedObjects.size(); + if (_headConfig == HeadConfig::Puck && puckCount >= MIN_HEAD) { + calibrateHead(defaultToReferenceMat, inputCalibration); + _validTrackedObjects.erase(_validTrackedObjects.end()); + _overrideHead = true; + return true; + } else if (_headConfig == HeadConfig::HMD) { + return true; + } + return false; +} - if (_config == Config::Feet) { +bool ViveControllerManager::InputDevice::configureBody(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { + int puckCount = (int)_validTrackedObjects.size(); + if (_config == Config::None) { + return true; + } else if (_config == Config::Feet && puckCount >= MIN_PUCK_COUNT) { calibrateFeet(defaultToReferenceMat, inputCalibration); + return true; } else if (_config == Config::FeetAndHips && puckCount >= MIN_FEET_AND_HIPS) { calibrateFeet(defaultToReferenceMat, inputCalibration); calibrateHips(defaultToReferenceMat, inputCalibration); + return true; } else if (_config == Config::FeetHipsAndChest && puckCount >= MIN_FEET_HIPS_CHEST) { calibrateFeet(defaultToReferenceMat, inputCalibration); calibrateHips(defaultToReferenceMat, inputCalibration); calibrateChest(defaultToReferenceMat, inputCalibration); + return true; } else if (_config == Config::FeetHipsAndShoulders && puckCount >= MIN_FEET_HIPS_SHOULDERS) { calibrateFeet(defaultToReferenceMat, inputCalibration); calibrateHips(defaultToReferenceMat, inputCalibration); int firstShoulderIndex = 3; int secondShoulderIndex = 4; calibrateShoulders(defaultToReferenceMat, inputCalibration, firstShoulderIndex, secondShoulderIndex); - } else if (_config == Config::FeetHipsAndHead && puckCount == MIN_FEET_HIPS_HEAD) { + return true; + } /*else if (_config == Config::FeetHipsAndHead && puckCount == MIN_FEET_HIPS_HEAD) { glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); calibrateFeet(defaultToReferenceMat, inputCalibration, headXAxis, headPosition); calibrateHips(defaultToReferenceMat, inputCalibration); calibrateHead(defaultToReferenceMat, inputCalibration); _overrideHead = true; + return true; } else if (_config == Config::FeetHipsChestAndHead && puckCount == MIN_FEET_HIPS_CHEST_HEAD) { glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); @@ -469,15 +532,12 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr calibrateChest(defaultToReferenceMat, inputCalibration); calibrateHead(defaultToReferenceMat, inputCalibration); _overrideHead = true; - } else { - qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks"; - uncalibrate(); - emitCalibrationStatus(false); - return; - } - _calibrated = true; - emitCalibrationStatus(true); - qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful"; + return true; + }*/ + qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks"; + uncalibrate(); + emitCalibrationStatus(false); + return false; } void ViveControllerManager::InputDevice::uncalibrate() { @@ -486,6 +546,7 @@ void ViveControllerManager::InputDevice::uncalibrate() { _jointToPuckMap.clear(); _calibrated = false; _overrideHead = false; + _overrideHands = false; } void ViveControllerManager::InputDevice::updateCalibratedLimbs() { @@ -499,6 +560,11 @@ void ViveControllerManager::InputDevice::updateCalibratedLimbs() { if (_overrideHead) { _poseStateMap[controller::HEAD] = addOffsetToPuckPose(controller::HEAD); } + + if (_overrideHands) { + _poseStateMap[controller::LEFT_HAND] = addOffsetToPuckPose(controller::LEFT_HAND); + _poseStateMap[controller::RIGHT_HAND] = addOffsetToPuckPose(controller::RIGHT_HAND); + } } controller::Pose ViveControllerManager::InputDevice::addOffsetToPuckPose(int joint) const { @@ -809,6 +875,70 @@ void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToRefer } } +void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) { + glm::mat4 avatarToSensorMat = glm::inverse(inputCalibration.sensorToWorldMat) * inputCalibration.avatarMat; + glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; + controller::Pose& handPose = handPair.second; + glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()) * Matrices::Y_180; + glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); + glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); + glm::vec3 avatarHandYAxis = glm::vec3(1.0f, 0.0f, 0.0f); + + const float EPSILON = 1.0e-4f; + if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { + handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); + } + + glm::vec3 yPrime = avatarHandYAxis; + glm::vec3 xPrime = glm::normalize(glm::cross(avatarHandYAxis, handPoseZAxis)); + glm::vec3 zPrime = glm::normalize(glm::cross(xPrime, yPrime)); + + glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f), + glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f)); + + glm::mat4 handPoseOffset = glm::mat4(glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), + glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); + + glm::mat4 finalHandMat = newHandMat * handPoseOffset; + + controller::Pose finalPose(extractTranslation(finalHandMat), glmExtractRotation(finalHandMat)); + + _jointToPuckMap[controller::LEFT_HAND] = handPair.first; + _pucksOffset[handPair.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftHand, finalPose); +} + +void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) { + glm::mat4 avatarToSensorMat = glm::inverse(inputCalibration.sensorToWorldMat) * inputCalibration.avatarMat; + glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; + controller::Pose& handPose = handPair.second; + glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()) * Matrices::Y_180; + glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); + glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); + glm::vec3 avatarHandYAxis = glm::vec3(-1.0f, 0.0f, 0.0f); + + const float EPSILON = 1.0e-4f; + if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { + handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); + } + + glm::vec3 yPrime = avatarHandYAxis; + glm::vec3 xPrime = glm::normalize(glm::cross(avatarHandYAxis, handPoseZAxis)); + glm::vec3 zPrime = glm::normalize(glm::cross(xPrime, yPrime)); + + glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f), + glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f)); + + glm::mat4 handPoseOffset = glm::mat4(glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), + glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); + + glm::mat4 finalHandMat = newHandMat * handPoseOffset; + + controller::Pose finalPose(extractTranslation(finalHandMat), glmExtractRotation(finalHandMat)); + + _jointToPuckMap[controller::RIGHT_HAND] = handPair.first; + _pucksOffset[handPair.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftHand, finalPose); +} + void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, glm::vec3 headXAxis, glm::vec3 headPosition) { auto& firstFoot = _validTrackedObjects[FIRST_FOOT]; @@ -816,7 +946,7 @@ void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToRefer controller::Pose& firstFootPose = firstFoot.second; controller::Pose& secondFootPose = secondFoot.second; - if (determineFeetOrdering(firstFootPose, secondFootPose, headXAxis, headPosition)) { + if (determineLimbOrdering(firstFootPose, secondFootPose, headXAxis, headPosition)) { _jointToPuckMap[controller::LEFT_FOOT] = firstFoot.first; _pucksOffset[firstFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftFoot, firstFootPose); _jointToPuckMap[controller::RIGHT_FOOT] = secondFoot.first; @@ -909,10 +1039,6 @@ void ViveControllerManager::InputDevice::setConfigFromString(const QString& valu _preferedConfig = Config::FeetHipsAndChest; } else if (value == "FeetHipsAndShoulders") { _preferedConfig = Config::FeetHipsAndShoulders; - } else if (value == "FeetHipsChestAndHead") { - _preferedConfig = Config::FeetHipsChestAndHead; - } else if (value == "FeetHipsAndHead") { - _preferedConfig = Config::FeetHipsAndHead; } } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index ea29d974e9..f3b37495cb 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -96,11 +96,15 @@ private: void setConfigFromString(const QString& value); void loadSettings(); void saveSettings() const; + bool configureHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); + bool configureHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); + bool configureBody(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); + void calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair); + void calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair); void calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); void calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, glm::vec3 headXAxis, glm::vec3 headPosition); void calibrateHips(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); void calibrateChest(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); - void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, int firstShoulderIndex, int secondShoulderIndex); void calibrateHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, @@ -141,8 +145,7 @@ private: FeetAndHips, FeetHipsAndChest, FeetHipsAndShoulders, - FeetHipsChestAndHead, - FeetHipsAndHead, + FeetHipsChestAndShoulders, }; enum class HeadConfig { From aa23986618fd27a19350f9c0290c80cc38ab220b Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 14 Jun 2017 00:46:55 +0100 Subject: [PATCH 19/31] finxing rotation problem --- plugins/openvr/src/ViveControllerManager.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 43f815c068..41b0ab0989 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -467,10 +467,12 @@ bool ViveControllerManager::InputDevice::configureHands(glm::mat4& defaultToRefe calibrateLeftHand(defaultToReferenceMat, inputCalibration, firstHand); calibrateRightHand(defaultToReferenceMat, inputCalibration, secondHand); _overrideHands = true; + return true; } else { calibrateLeftHand(defaultToReferenceMat, inputCalibration, secondHand); calibrateRightHand(defaultToReferenceMat, inputCalibration, firstHand); _overrideHands = true; + return true; } } else if (_handConfig == HandConfig::HandController) { _overrideHands = false; @@ -879,7 +881,7 @@ void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToR glm::mat4 avatarToSensorMat = glm::inverse(inputCalibration.sensorToWorldMat) * inputCalibration.avatarMat; glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; controller::Pose& handPose = handPair.second; - glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()) * Matrices::Y_180; + glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()); glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); glm::vec3 avatarHandYAxis = glm::vec3(1.0f, 0.0f, 0.0f); @@ -888,7 +890,7 @@ void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToR if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); } - + glm::vec3 yPrime = avatarHandYAxis; glm::vec3 xPrime = glm::normalize(glm::cross(avatarHandYAxis, handPoseZAxis)); glm::vec3 zPrime = glm::normalize(glm::cross(xPrime, yPrime)); @@ -911,7 +913,7 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo glm::mat4 avatarToSensorMat = glm::inverse(inputCalibration.sensorToWorldMat) * inputCalibration.avatarMat; glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; controller::Pose& handPose = handPair.second; - glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()) * Matrices::Y_180; + glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()); glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); glm::vec3 avatarHandYAxis = glm::vec3(-1.0f, 0.0f, 0.0f); @@ -920,7 +922,7 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); } - + glm::vec3 yPrime = avatarHandYAxis; glm::vec3 xPrime = glm::normalize(glm::cross(avatarHandYAxis, handPoseZAxis)); glm::vec3 zPrime = glm::normalize(glm::cross(xPrime, yPrime)); @@ -929,14 +931,14 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f)); glm::mat4 handPoseOffset = glm::mat4(glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), - glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); + glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.0f, 0.0508f, 0.0f, 1.0f)); glm::mat4 finalHandMat = newHandMat * handPoseOffset; controller::Pose finalPose(extractTranslation(finalHandMat), glmExtractRotation(finalHandMat)); _jointToPuckMap[controller::RIGHT_HAND] = handPair.first; - _pucksOffset[handPair.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftHand, finalPose); + _pucksOffset[handPair.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultRightHand, finalPose); } From ff422153b1126dcc2656668ff9bff9e17113c74d Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 15 Jun 2017 00:26:53 +0100 Subject: [PATCH 20/31] got hand working --- plugins/openvr/src/ViveControllerManager.cpp | 49 ++++++++++---------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 41b0ab0989..62ce97957f 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -878,67 +878,68 @@ void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToRefer } void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) { - glm::mat4 avatarToSensorMat = glm::inverse(inputCalibration.sensorToWorldMat) * inputCalibration.avatarMat; - glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; controller::Pose& handPose = handPair.second; glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()); glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); - glm::vec3 avatarHandYAxis = glm::vec3(1.0f, 0.0f, 0.0f); + glm::vec3 avatarHandYAxis = transformVectorFast(glm::inverse(handPoseAvatarMat), glm::vec3(1.0f, 0.0f, 0.0f)); const float EPSILON = 1.0e-4f; if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); } - - glm::vec3 yPrime = avatarHandYAxis; + + glm::vec3 zPrime = handPoseZAxis; glm::vec3 xPrime = glm::normalize(glm::cross(avatarHandYAxis, handPoseZAxis)); - glm::vec3 zPrime = glm::normalize(glm::cross(xPrime, yPrime)); + glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime)); glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f), glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f)); - glm::mat4 handPoseOffset = glm::mat4(glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), - glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); - - glm::mat4 finalHandMat = newHandMat * handPoseOffset; - controller::Pose finalPose(extractTranslation(finalHandMat), glmExtractRotation(finalHandMat)); + glm::vec3 translationOffset = glm::vec3(0.0f, -0.0508f, 0.0254f); + glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); + glm::quat finalRotation = glmExtractRotation(newHandMat); + + glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation; + + glm::mat4 offset = createMatFromQuatAndPos(rotationOffset, translationOffset); _jointToPuckMap[controller::LEFT_HAND] = handPair.first; - _pucksOffset[handPair.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftHand, finalPose); + _pucksOffset[handPair.first] = offset; } void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) { - glm::mat4 avatarToSensorMat = glm::inverse(inputCalibration.sensorToWorldMat) * inputCalibration.avatarMat; - glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat; controller::Pose& handPose = handPair.second; glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()); glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); - glm::vec3 avatarHandYAxis = glm::vec3(-1.0f, 0.0f, 0.0f); + glm::vec3 avatarHandYAxis = transformVectorFast(glm::inverse(handPoseAvatarMat), glm::vec3(1.0f, 0.0f, 0.0f)); const float EPSILON = 1.0e-4f; if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); } - - glm::vec3 yPrime = avatarHandYAxis; + + glm::vec3 zPrime = handPoseZAxis; glm::vec3 xPrime = glm::normalize(glm::cross(avatarHandYAxis, handPoseZAxis)); - glm::vec3 zPrime = glm::normalize(glm::cross(xPrime, yPrime)); + glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime)); glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f), glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f)); - glm::mat4 handPoseOffset = glm::mat4(glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), - glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.0f, 0.0508f, 0.0f, 1.0f)); - - glm::mat4 finalHandMat = newHandMat * handPoseOffset; - controller::Pose finalPose(extractTranslation(finalHandMat), glmExtractRotation(finalHandMat)); + + glm::vec3 translationOffset = glm::vec3(0.0f, -0.0508f, 0.0254f); + glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); + glm::quat finalRotation = glmExtractRotation(newHandMat); + + glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation; + + glm::mat4 offset = createMatFromQuatAndPos(rotationOffset, translationOffset); _jointToPuckMap[controller::RIGHT_HAND] = handPair.first; - _pucksOffset[handPair.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultRightHand, finalPose); + _pucksOffset[handPair.first] = offset; } From 07102cc98dd476f62f0e24442ea6513b88b0662d Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Jun 2017 00:25:27 +0100 Subject: [PATCH 21/31] improving the ui --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 238 +++++++++++++----- plugins/openvr/src/ViveControllerManager.cpp | 145 ++++------- plugins/openvr/src/ViveControllerManager.h | 4 +- 3 files changed, 222 insertions(+), 165 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 23af4fd93d..30685010ec 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -35,8 +35,21 @@ Rectangle { readonly property bool handController: handBox.checked readonly property bool handPuck: handPuckBox.checked + property int state: buttonState.disabled + property var lastConfiguration: null + HifiConstants { id: hifi } + QtObject { + id: buttonState + readonly property int disabled: 0 + readonly property int apply: 1 + readonly property int applyAndCalibrate: 2 + readonly property int calibrate: 3 + + } + + MouseArea { id: mouseArea @@ -66,7 +79,7 @@ Rectangle { anchors.top: head.bottom anchors.topMargin: 5 anchors.left: openVrConfiguration.left - anchors.leftMargin: leftMargin + 20 + anchors.leftMargin: leftMargin + 10 spacing: 10 HifiControls.CheckBox { @@ -81,7 +94,7 @@ Rectangle { } else { checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -103,7 +116,7 @@ Rectangle { } else { checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -112,8 +125,35 @@ Rectangle { text: "Tracker" color: hifi.colors.lightGrayText } - } + HifiControls.SpinBox { + id: headYOffset + decimals: 4 + width: 110 + label: "Y: offset" + value: -0.0254 + stepSize: 0.0254 + colorScheme: hifi.colorSchemes.dark + + onEditingFinished: { + } + } + + + HifiControls.SpinBox { + id: headZOffset + width: 105 + label: "Z: offset" + value: -0.152 + stepSize: 0.0254 + decimals: 4 + colorScheme: hifi.colorSchemes.dark + + onEditingFinished: { + } + } + } + RalewayBold { id: hands @@ -133,7 +173,7 @@ Rectangle { anchors.top: hands.bottom anchors.topMargin: 5 anchors.left: openVrConfiguration.left - anchors.leftMargin: leftMargin + 20 + anchors.leftMargin: leftMargin + 10 spacing: 10 HifiControls.CheckBox { @@ -148,7 +188,7 @@ Rectangle { } else { checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -170,7 +210,7 @@ Rectangle { } else { checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -179,6 +219,33 @@ Rectangle { text: "Trackers" color: hifi.colors.lightGrayText } + + HifiControls.SpinBox { + id: handYOffset + decimals: 4 + width: 105 + label: "Y: offset" + value: -0.0508 + stepSize: 0.0254 + colorScheme: hifi.colorSchemes.dark + + onEditingFinished: { + } + } + + + HifiControls.SpinBox { + id: handZOffset + width: 105 + label: "Z: offset" + value: -0.0254 + stepSize: 0.0254 + decimals: 4 + colorScheme: hifi.colorSchemes.dark + + onEditingFinished: { + } + } } RalewayBold { @@ -200,7 +267,7 @@ Rectangle { anchors.top: additional.bottom anchors.topMargin: 15 anchors.left: openVrConfiguration.left - anchors.leftMargin: leftMargin + 20 + anchors.leftMargin: leftMargin + 10 spacing: 10 HifiControls.CheckBox { @@ -213,7 +280,7 @@ Rectangle { if (hipsChecked) { checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -229,7 +296,7 @@ Rectangle { anchors.top: feetConfig.bottom anchors.topMargin: 15 anchors.left: openVrConfiguration.left - anchors.leftMargin: leftMargin + 20 + anchors.leftMargin: leftMargin + 10 spacing: 10 HifiControls.CheckBox { @@ -246,7 +313,7 @@ Rectangle { if (chestChecked) { checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -269,7 +336,7 @@ Rectangle { anchors.top: hipConfig.bottom anchors.topMargin: 15 anchors.left: openVrConfiguration.left - anchors.leftMargin: leftMargin + 20 + anchors.leftMargin: leftMargin + 10 spacing: 10 HifiControls.CheckBox { @@ -283,7 +350,7 @@ Rectangle { hipBox.checked = true; feetBox.checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -306,7 +373,7 @@ Rectangle { anchors.top: chestConfig.bottom anchors.topMargin: 15 anchors.left: openVrConfiguration.left - anchors.leftMargin: leftMargin + 20 + anchors.leftMargin: leftMargin + 10 spacing: 10 HifiControls.CheckBox { @@ -320,7 +387,7 @@ Rectangle { hipBox.checked = true; feetBox.checked = true; } - composeConfigurationSettings(); + sendConfigurationSettings(); } } @@ -345,52 +412,23 @@ Rectangle { } - Rectangle { + HifiControls.Button { + id: calibrationButton - width: 200 - height: 35 - radius: 6 - - color: hifi.colors.blueHighlight - + color: hifi.buttons.blue + text: "Calibrate" + //glyph: hifi.glyphs.avatar1 anchors.top: bottomSeperator.bottom anchors.topMargin: 10 anchors.left: parent.left anchors.leftMargin: leftMargin - - - HiFiGlyphs { - id: calibrationGlyph - text: hifi.glyphs.avatar1 - size: 36 - color: hifi.colors.white - - anchors.left: parent.left - anchors.leftMargin: 30 - - } - - RalewayRegular { - id: calibrate - text: "CALIBRATE" - size: 17 - color: hifi.colors.white - - anchors.left: calibrationGlyph.right - anchors.top: parent.top - anchors.topMargin: 8 - } - - MouseArea { - anchors.fill: parent - - onClicked: { - openVrConfiguration.countDown = timeToCalibrate.value; - numberAnimation.start(); - calibrationTimer.start(); - info.visible = true; - info.showCountDown = true; - } + + onClicked: { + openVrConfiguration.countDown = timeToCalibrate.value; + numberAnimation.start(); + calibrationTimer.start(); + info.visible = true; + info.showCountDown = true; } } @@ -421,16 +459,18 @@ Rectangle { Component.onCompleted: { InputConfiguration.calibrationStatus.connect(calibrationStatusInfo); + lastConfiguration = composeConfigurationSettings(); } HifiControls.SpinBox { id: timeToCalibrate - + width: 70 anchors.top: calibrationButton.bottom anchors.topMargin: 40 anchors.left: parent.left anchors.leftMargin: leftMargin + minimumValue: 3 label: "Time til calibration ( in seconds )" colorScheme: hifi.colorSchemes.dark @@ -590,7 +630,7 @@ Rectangle { RalewayBold { id: uncalibrateText text: "Uncalibration Successful" - size: 42 + size: 37 color: hifi.colors.greenHighlight anchors.centerIn: parent } @@ -621,6 +661,58 @@ Rectangle { } } + function updateButtonState() { + var settings = composeConfigurationSettings(); + var bodySetting = settings["bodyConfiguration"]; + var headSetting = settings["headConfiguration"]; + var headOverride = headSetting["override"]; + var handSetting = settings["handConfiguration"]; + var handOverride = settings["override"]; + + var settingsChanged = false; + + if (lastConfiguration["bodyConfiguration"]["override"] !== bodySetting["override"]) { + settingsChanged = true; + } + + var lastHead = lastConfiguration["headConfiguration"]; + if (lastHead["override"] !== headOverride) { + settingsChanged = true; + } + + var lastHand = lastConfiguration["handConfiguration"]; + if (lastHand["override"] !== handOverride) { + settingsChanged = true; + } + + if (settingsChanged) { + if ((!handOverride) && (!headOverride) && (bodySetting === "Auto")) { + state = buttonState.apply; + } else { + state = buttonState.applyAndCalibrate; + } + } else { + if (state == buttonState.apply) { + state = buttonState.disabled; + } + } + + lastConfiguration = settings; + } + + function updateCalibrationText() { + updateButtonState(); + if (buttonState.disabled == state) { + calibrationButton.text = "Apply"; + } else if (buttonState.apply == state) { + calibrationButton.text = "Apply"; + } else if (buttonState.applyAndCalibrate == state) { + calibrationButton.text = "Apply And Calibrate"; + } else if (buttonState.calibrate == state) { + calibrationButton.text = "Calibrate"; + } + } + function composeConfigurationSettings() { var trackerConfiguration = ""; var overrideHead = false; @@ -631,7 +723,7 @@ Rectangle { } else if (shouldersChecked) { trackerConfiguration = "FeetHipsAndShoulders"; } else if (chestChecked) { - trackerConfiguration = "FeetHipsChest"; + trackerConfiguration = "FeetHipsAndChest"; } else if (hipsChecked) { trackerConfiguration = "FeetAndHips"; } else if (feetChecked) { @@ -652,14 +744,30 @@ Rectangle { overrideHandController = true; } - - var settingsObject = { - "trackerConfiguration": trackerConfiguration, - "overrideHead": overrideHead, - "overrideHandController": overrideHandController + var headObject = { + "override": overrideHead, + "Y": headYOffset.value, + "Z": headZOffset.value } - InputConfiguration.setConfigurationSettings(settingsObject, pluginName); + var handObject = { + "override": overrideHandController, + "Y": handYOffset.value, + "Z": handZOffset.value + } + + var settingsObject = { + "bodyConfiguration": trackerConfiguration, + "headConfiguration": headObject, + "handConfiguration": handObject + } + return settingsObject; + } + + function sendConfigurationSettings() { + var settings = composeConfigurationSettings(); + InputConfiguration.setConfigurationSettings(settings, pluginName); + updateCalibrationText(); } } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 69d5fde5d3..e9915934af 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -47,19 +47,23 @@ static const char* MENU_PARENT = "Avatar"; static const char* MENU_NAME = "Vive Controllers"; static const char* MENU_PATH = "Avatar" ">" "Vive Controllers"; static const char* RENDER_CONTROLLERS = "Render Hand Controllers"; + static const int MIN_HEAD = 1; static const int MIN_PUCK_COUNT = 2; static const int MIN_FEET_AND_HIPS = 3; static const int MIN_FEET_HIPS_CHEST = 4; -static const int MIN_FEET_HIPS_HEAD = 4; static const int MIN_FEET_HIPS_SHOULDERS = 5; -static const int MIN_FEET_HIPS_CHEST_HEAD = 5; +static const int MIN_FEET_HIPS_CHEST_SHOULDERS = 6; + static const int FIRST_FOOT = 0; static const int SECOND_FOOT = 1; static const int HIP = 2; static const int CHEST = 3; + static float HEAD_PUCK_Y_OFFSET = -0.0254f; static float HEAD_PUCK_Z_OFFSET = -0.152f; +static float HAND_PUCK_Y_OFFSET = -0.0508f; +static float HAND_PUCK_Z_OFFSET = 0.0254f; const char* ViveControllerManager::NAME { "OpenVR" }; @@ -117,6 +121,12 @@ static QString deviceTrackingResultToString(vr::ETrackingResult trackingResult) return result; } +void ViveControllerManager::calibrate() { + if (isSupported()) { + _inputDevice->calibrateNextFrame(); + } +} + bool ViveControllerManager::isSupported() const { return openVrSupported(); } @@ -233,7 +243,7 @@ ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) : contro _configStringMap[Config::FeetHipsAndShoulders] = QString("FeetHipsAndShoulders"); if (openVrSupported()) { - createPreferences(); + loadSettings(); } } @@ -340,6 +350,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso iter++; } } + + saveSettings(); } void ViveControllerManager::InputDevice::calibrateNextFrame() { @@ -469,11 +481,15 @@ bool ViveControllerManager::InputDevice::configureHands(glm::mat4& defaultToRefe if (determineLimbOrdering(firstHandPose, secondHandPose, headXAxis, headPosition)) { calibrateLeftHand(defaultToReferenceMat, inputCalibration, firstHand); calibrateRightHand(defaultToReferenceMat, inputCalibration, secondHand); + _validTrackedObjects.erase(_validTrackedObjects.begin()); + _validTrackedObjects.erase(_validTrackedObjects.end() - 1); _overrideHands = true; return true; } else { calibrateLeftHand(defaultToReferenceMat, inputCalibration, secondHand); calibrateRightHand(defaultToReferenceMat, inputCalibration, firstHand); + _validTrackedObjects.erase(_validTrackedObjects.begin()); + _validTrackedObjects.erase(_validTrackedObjects.end() - 1); _overrideHands = true; return true; } @@ -489,7 +505,7 @@ bool ViveControllerManager::InputDevice::configureHead(glm::mat4& defaultToRefer int puckCount = (int)_validTrackedObjects.size(); if (_headConfig == HeadConfig::Puck && puckCount >= MIN_HEAD) { calibrateHead(defaultToReferenceMat, inputCalibration); - _validTrackedObjects.erase(_validTrackedObjects.end()); + _validTrackedObjects.erase(_validTrackedObjects.end() - 1); _overrideHead = true; return true; } else if (_headConfig == HeadConfig::HMD) { @@ -499,7 +515,10 @@ bool ViveControllerManager::InputDevice::configureHead(glm::mat4& defaultToRefer } bool ViveControllerManager::InputDevice::configureBody(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) { @@ -521,24 +540,15 @@ bool ViveControllerManager::InputDevice::configureBody(glm::mat4& defaultToRefer int secondShoulderIndex = 4; calibrateShoulders(defaultToReferenceMat, inputCalibration, firstShoulderIndex, secondShoulderIndex); return true; - } /*else if (_config == Config::FeetHipsAndHead && puckCount == MIN_FEET_HIPS_HEAD) { - glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); - glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); - calibrateFeet(defaultToReferenceMat, inputCalibration, headXAxis, headPosition); - calibrateHips(defaultToReferenceMat, inputCalibration); - calibrateHead(defaultToReferenceMat, inputCalibration); - _overrideHead = true; - return true; - } else if (_config == Config::FeetHipsChestAndHead && puckCount == MIN_FEET_HIPS_CHEST_HEAD) { - glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); - glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); - calibrateFeet(defaultToReferenceMat, inputCalibration, headXAxis, headPosition); + } else if (_config == Config::FeetHipsChestAndShoulders && puckCount >= MIN_FEET_HIPS_CHEST_SHOULDERS) { + calibrateFeet(defaultToReferenceMat, inputCalibration); calibrateHips(defaultToReferenceMat, inputCalibration); calibrateChest(defaultToReferenceMat, inputCalibration); - calibrateHead(defaultToReferenceMat, inputCalibration); - _overrideHead = true; + int firstShoulderIndex = 4; + int secondShoulderIndex = 5; + calibrateShoulders(defaultToReferenceMat, inputCalibration, firstShoulderIndex, secondShoulderIndex); return true; - }*/ + } qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks"; uncalibrate(); emitCalibrationStatus(false); @@ -861,25 +871,6 @@ void ViveControllerManager::InputDevice::hapticsHelper(float deltaTime, bool lef } } -void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { - auto& firstFoot = _validTrackedObjects[FIRST_FOOT]; - auto& secondFoot = _validTrackedObjects[SECOND_FOOT]; - controller::Pose& firstFootPose = firstFoot.second; - controller::Pose& secondFootPose = secondFoot.second; - - if (firstFootPose.translation.x < secondFootPose.translation.x) { - _jointToPuckMap[controller::LEFT_FOOT] = firstFoot.first; - _pucksOffset[firstFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftFoot, firstFootPose); - _jointToPuckMap[controller::RIGHT_FOOT] = secondFoot.first; - _pucksOffset[secondFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultRightFoot, secondFootPose); - } else { - _jointToPuckMap[controller::LEFT_FOOT] = secondFoot.first; - _pucksOffset[secondFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultLeftFoot, secondFootPose); - _jointToPuckMap[controller::RIGHT_FOOT] = firstFoot.first; - _pucksOffset[firstFoot.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultRightFoot, firstFootPose); - } -} - void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) { controller::Pose& handPose = handPair.second; glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()); @@ -897,19 +888,19 @@ void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToR glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime)); glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f), - glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f)); + glm::vec4(zPrime, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); - glm::vec3 translationOffset = glm::vec3(0.0f, -0.0508f, 0.0254f); + glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET); glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); glm::quat finalRotation = glmExtractRotation(newHandMat); glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation; - glm::mat4 offset = createMatFromQuatAndPos(rotationOffset, translationOffset); + glm::mat4 offsetMat = createMatFromQuatAndPos(rotationOffset, translationOffset); _jointToPuckMap[controller::LEFT_HAND] = handPair.first; - _pucksOffset[handPair.first] = offset; + _pucksOffset[handPair.first] = offsetMat; } void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair) { @@ -929,24 +920,26 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime)); glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f), - glm::vec4(zPrime, 0.0f), glm::vec4(handPoseTranslation, 1.0f)); + glm::vec4(zPrime, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); - glm::vec3 translationOffset = glm::vec3(0.0f, -0.0508f, 0.0254f); + glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET); glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); glm::quat finalRotation = glmExtractRotation(newHandMat); glm::quat rotationOffset = glm::inverse(initialRotation) * finalRotation; - glm::mat4 offset = createMatFromQuatAndPos(rotationOffset, translationOffset); + glm::mat4 offsetMat = createMatFromQuatAndPos(rotationOffset, translationOffset); _jointToPuckMap[controller::RIGHT_HAND] = handPair.first; - _pucksOffset[handPair.first] = offset; + _pucksOffset[handPair.first] = offsetMat; } -void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, glm::vec3 headXAxis, glm::vec3 headPosition) { +void ViveControllerManager::InputDevice::calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { + glm::vec3 headXAxis = getReferenceHeadXAxis(defaultToReferenceMat, inputCalibration.defaultHeadMat); + glm::vec3 headPosition = getReferenceHeadPosition(defaultToReferenceMat, inputCalibration.defaultHeadMat); auto& firstFoot = _validTrackedObjects[FIRST_FOOT]; auto& secondFoot = _validTrackedObjects[SECOND_FOOT]; controller::Pose& firstFootPose = firstFoot.second; @@ -1016,7 +1009,9 @@ void ViveControllerManager::InputDevice::loadSettings() { Settings settings; settings.beginGroup("PUCK_CONFIG"); { - _preferedConfig = (Config)settings.value("configuration", QVariant((int)Config::None)).toInt(); + _preferedConfig = (Config)settings.value("body configuration", QVariant((int)Config::None)).toInt(); + _headConfig = (HeadConfig)settings.value("head configuration", QVariant((int)HeadConfig::HMD)).toInt(); + _handConfig = (HandConfig)settings.value("hand configuration", QVariant((int)HandConfig::HandController)).toInt(); } settings.endGroup(); } @@ -1025,7 +1020,9 @@ void ViveControllerManager::InputDevice::saveSettings() const { Settings settings; settings.beginGroup("PUCK_CONFIG"); { - settings.setValue(QString("configuration"), (int)_preferedConfig); + settings.setValue(QString("body configuration"), (int)_preferedConfig); + settings.setValue(QString("head configuration"), (int)_headConfig); + settings.setValue(QString("hand configuration"), (int)_handConfig); } settings.endGroup(); } @@ -1045,54 +1042,8 @@ void ViveControllerManager::InputDevice::setConfigFromString(const QString& valu _preferedConfig = Config::FeetHipsAndChest; } else if (value == "FeetHipsAndShoulders") { _preferedConfig = Config::FeetHipsAndShoulders; - } -} - -void ViveControllerManager::InputDevice::createPreferences() { - loadSettings(); - auto preferences = DependencyManager::get(); - static const QString VIVE_PUCKS_CONFIG = "Vive Pucks Configuration"; - - { - static const float MIN_VALUE = -3.0f; - static const float MAX_VALUE = 3.0f; - static const float STEP = 0.01f; - - auto getter = [this]()->float { return HEAD_PUCK_Y_OFFSET; }; - auto setter = [this](const float& value) { HEAD_PUCK_Y_OFFSET = value; }; - - auto preference = new SpinnerPreference(VIVE_PUCKS_CONFIG, "HeadPuckYOffset", getter, setter); - preference->setMin(MIN_VALUE); - preference->setMax(MAX_VALUE); - preference->setDecimals(3); - preference->setStep(STEP); - preferences->addPreference(preference); - } - - { - static const float MIN_VALUE = -3.0f; - static const float MAX_VALUE = 3.0f; - static const float STEP = 0.01f; - - auto getter = [this]()->float { return HEAD_PUCK_Z_OFFSET; }; - auto setter = [this](const float& value) { HEAD_PUCK_Z_OFFSET = value; }; - - auto preference = new SpinnerPreference(VIVE_PUCKS_CONFIG, "HeadPuckXOffset", getter, setter); - preference->setMin(MIN_VALUE); - preference->setMax(MAX_VALUE); - preference->setStep(STEP); - preference->setDecimals(3); - preferences->addPreference(preference); - } - - { - auto getter = [this]()->QString { return _configStringMap[_preferedConfig]; }; - auto setter = [this](const QString& value) { setConfigFromString(value); saveSettings(); }; - auto preference = new ComboBoxPreference(VIVE_PUCKS_CONFIG, "Configuration", getter, setter); - QStringList list = {"Auto", "Feet", "FeetAndHips", "FeetHipsAndChest", "FeetHipsAndShoulders", "FeetHipsAndHead"}; - preference->setItems(list); - preferences->addPreference(preference); - + } else if (value == "FeetHipsChestAndShoulders") { + _preferedConfig = Config::FeetHipsChestAndShoulders; } } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index f3b37495cb..2e9137c4d9 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -46,7 +46,7 @@ public: QString configurationLayout() override; void setConfigurationSettings(const QJsonObject configurationSettings) override; QJsonObject configurationSettings() override; - void calibrate() override { _inputDevice->calibrateNextFrame(); } + void calibrate() override; bool isHeadController() const override { return true; } bool isHeadControllerMounted() const; @@ -69,7 +69,6 @@ private: QString getDefaultMappingConfig() const override; void update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override; void focusOutEvent() override; - void createPreferences(); bool triggerHapticPulse(float strength, float duration, controller::Hand hand) override; void hapticsHelper(float deltaTime, bool leftHand); void calibrateOrUncalibrate(const controller::InputCalibrationData& inputCalibration); @@ -102,7 +101,6 @@ private: void calibrateLeftHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair); void calibrateRightHand(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, PuckPosePair& handPair); void calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); - void calibrateFeet(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, glm::vec3 headXAxis, glm::vec3 headPosition); void calibrateHips(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); void calibrateChest(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, From 2015f059c7dddf89b64c81a120699040e7ca11c1 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 17 Jun 2017 00:37:33 +0100 Subject: [PATCH 22/31] fixed hand calibration --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 2 +- plugins/openvr/src/ViveControllerManager.cpp | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 30685010ec..c0da9e2b6e 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -768,6 +768,6 @@ Rectangle { function sendConfigurationSettings() { var settings = composeConfigurationSettings(); InputConfiguration.setConfigurationSettings(settings, pluginName); - updateCalibrationText(); + //updateCalibrationText(); } } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index e9915934af..44de16a478 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -330,19 +330,22 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso auto iter = configurationSettings.begin(); auto end = configurationSettings.end(); while (iter != end) { - if (iter.key() == "trackerConfiguration") { + if (iter.key() == "bodyConfiguration") { setConfigFromString(iter.value().toString()); - } else if (iter.key() == "overrideHead") { - bool overrideHead = iter.value().toBool(); + } else if (iter.key() == "headConfiguration") { + QJsonObject headObject = iter.value().toObject(); + bool overrideHead = headObject["override"].toBool(); if (overrideHead) { _headConfig = HeadConfig::Puck; } else { _headConfig = HeadConfig::HMD; } - } else if (iter.key() == "overrideHandController") { - bool overrideHands = iter.value().toBool(); + } else if (iter.key() == "handConfiguration") { + QJsonObject handsObject = iter.value().toObject(); + bool overrideHands = handsObject["override"].toBool(); if (overrideHands) { _handConfig = HandConfig::Pucks; + qDebug() << "--------> configure hands <---------"; } else { _handConfig = HandConfig::HandController; } @@ -876,8 +879,7 @@ void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToR glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()); glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); - glm::vec3 avatarHandYAxis = transformVectorFast(glm::inverse(handPoseAvatarMat), glm::vec3(1.0f, 0.0f, 0.0f)); - + glm::vec3 avatarHandYAxis = transformVectorFast(inputCalibration.defaultLeftHand, glm::vec3(0.0f, 1.0f, 0.0f)); const float EPSILON = 1.0e-4f; if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); @@ -891,7 +893,7 @@ void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToR glm::vec4(zPrime, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); - glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET); + glm::vec3 translationOffset = glm::vec3(0.0f, -HAND_PUCK_Y_OFFSET, 0.0f); glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); glm::quat finalRotation = glmExtractRotation(newHandMat); @@ -908,8 +910,7 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo glm::mat4 handPoseAvatarMat = createMatFromQuatAndPos(handPose.getRotation(), handPose.getTranslation()); glm::vec3 handPoseTranslation = extractTranslation(handPoseAvatarMat); glm::vec3 handPoseZAxis = glmExtractRotation(handPoseAvatarMat) * glm::vec3(0.0f, 0.0f, 1.0f); - glm::vec3 avatarHandYAxis = transformVectorFast(glm::inverse(handPoseAvatarMat), glm::vec3(1.0f, 0.0f, 0.0f)); - + glm::vec3 avatarHandYAxis = transformVectorFast(inputCalibration.defaultRightHand, glm::vec3(0.0f, 1.0f, 0.0f)); const float EPSILON = 1.0e-4f; if (fabsf(fabsf(glm::dot(glm::normalize(avatarHandYAxis), glm::normalize(handPoseZAxis))) - 1.0f) < EPSILON) { handPoseZAxis = glm::vec3(0.0f, 0.0f, 1.0f); @@ -924,7 +925,7 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo - glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET); + glm::vec3 translationOffset = glm::vec3(0.0f, 0.0f, 0.0f); glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); glm::quat finalRotation = glmExtractRotation(newHandMat); From 734cde33e733de7005fc2e34d99a324f9d58b177 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 19 Jun 2017 21:40:09 +0100 Subject: [PATCH 23/31] better calibrate button --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 170 +++++++++++++++--- plugins/openvr/src/ViveControllerManager.cpp | 3 +- 2 files changed, 148 insertions(+), 25 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index c0da9e2b6e..62203b811d 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -9,6 +9,8 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 import QtGraphicalEffects 1.0 +import QtQuick.Controls 1.4 as Original +import QtQuick.Controls.Styles 1.4 import "../../styles-uit" import "../../controls" import "../../controls-uit" as HifiControls @@ -125,11 +127,20 @@ Rectangle { text: "Tracker" color: hifi.colors.lightGrayText } + } + Row { + id: headOffsets + anchors.top: headConfig.bottom + anchors.topMargin: 5 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 10 + spacing: 10 + visible: headPuckBox.checked HifiControls.SpinBox { id: headYOffset decimals: 4 - width: 110 + width: 112 label: "Y: offset" value: -0.0254 stepSize: 0.0254 @@ -142,7 +153,7 @@ Rectangle { HifiControls.SpinBox { id: headZOffset - width: 105 + width: 112 label: "Z: offset" value: -0.152 stepSize: 0.0254 @@ -153,6 +164,7 @@ Rectangle { } } } + RalewayBold { id: hands @@ -162,8 +174,8 @@ Rectangle { color: "white" - anchors.top: headConfig.bottom - anchors.topMargin: 10 + anchors.top: (headOffsets.visible ? headOffsets.bottom : headConfig.bottom) + anchors.topMargin: (headOffsets.visible ? 22 : 10) anchors.left: parent.left anchors.leftMargin: leftMargin } @@ -219,11 +231,21 @@ Rectangle { text: "Trackers" color: hifi.colors.lightGrayText } + } + Row { + id: handOffset + visible: handPuckBox.checked + anchors.top: handConfig.bottom + anchors.topMargin: 5 + anchors.left: openVrConfiguration.left + anchors.leftMargin: leftMargin + 10 + spacing: 10 + HifiControls.SpinBox { id: handYOffset decimals: 4 - width: 105 + width: 112 label: "Y: offset" value: -0.0508 stepSize: 0.0254 @@ -236,7 +258,7 @@ Rectangle { HifiControls.SpinBox { id: handZOffset - width: 105 + width: 112 label: "Z: offset" value: -0.0254 stepSize: 0.0254 @@ -256,8 +278,8 @@ Rectangle { color: hifi.colors.white - anchors.top: handConfig.bottom - anchors.topMargin: 10 + anchors.top: (handOffset.visible ? handOffset.bottom : handConfig.bottom) + anchors.topMargin: (handOffset.visible ? 22 : 10) anchors.left: parent.left anchors.leftMargin: leftMargin } @@ -412,23 +434,120 @@ Rectangle { } - HifiControls.Button { - + + Rectangle { id: calibrationButton - color: hifi.buttons.blue - text: "Calibrate" - //glyph: hifi.glyphs.avatar1 + property int color: hifi.buttons.blue + property int colorScheme: hifi.colorSchemes.light + property string glyph: hifi.glyphs.avatar1 + property bool enabled: true + property bool pressed: false + property bool hovered: false + property int size: 32 + property string text: "calibrate" + property int padding: 12 + + width: glyphButton.width + calibrationText.width + padding + height: hifi.dimensions.controlLineHeight anchors.top: bottomSeperator.bottom anchors.topMargin: 10 anchors.left: parent.left anchors.leftMargin: leftMargin + + radius: hifi.buttons.radius - onClicked: { - openVrConfiguration.countDown = timeToCalibrate.value; - numberAnimation.start(); - calibrationTimer.start(); - info.visible = true; - info.showCountDown = true; + gradient: Gradient { + GradientStop { + position: 0.2 + color: { + if (!calibrationButton.enabled) { + hifi.buttons.disabledColorStart[calibrationButton.colorScheme] + } else if (calibrationButton.pressed) { + hifi.buttons.pressedColor[calibrationButton.color] + } else if (calibrationButton.hovered) { + hifi.buttons.hoveredColor[calibrationButton.color] + } else { + hifi.buttons.colorStart[calibrationButton.color] + } + } + } + + GradientStop { + position: 1.0 + color: { + if (!calibrationButton.enabled) { + hifi.buttons.disabledColorFinish[calibrationButton.colorScheme] + } else if (calibrationButton.pressed) { + hifi.buttons.pressedColor[calibrationButton.color] + } else if (calibrationButton.hovered) { + hifi.buttons.hoveredColor[calibrationButton.color] + } else { + hifi.buttons.colorFinish[calibrationButton.color] + } + } + } + } + + + + + HiFiGlyphs { + id: glyphButton + color: enabled ? hifi.buttons.textColor[calibrationButton.color] + : hifi.buttons.disabledTextColor[calibrationButton.colorScheme] + text: calibrationButton.glyph + size: calibrationButton.size + + anchors { + top: parent.top + bottom: parent.bottom + bottomMargin: 1 + verticalCenter: parent.horizontalCenter + } + } + + RalewayBold { + id: calibrationText + font.capitalization: Font.AllUppercase + color: enabled ? hifi.buttons.textColor[calibrationButton.color] + : hifi.buttons.disabledTextColor[calibrationButton.colorScheme] + size: hifi.fontSizes.buttonLabel + text: calibrationButton.text + + anchors { + left: glyphButton.right + top: parent.top + topMargin: 7 + } + } + + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: { + openVrConfiguration.countDown = timeToCalibrate.value; + numberAnimation.start(); + calibrationTimer.start(); + info.visible = true; + info.showCountDown = true; + } + + onPressed: { + calibrationButton.pressed = true; + } + + onReleased: { + calibrationButton.pressed = false; + } + + onEntered: { + calibrationButton.hovered = true; + } + + onExited: { + calibrationButton.hovered = false; + } } } @@ -667,11 +786,11 @@ Rectangle { var headSetting = settings["headConfiguration"]; var headOverride = headSetting["override"]; var handSetting = settings["handConfiguration"]; - var handOverride = settings["override"]; + var handOverride = handSetting["override"]; var settingsChanged = false; - - if (lastConfiguration["bodyConfiguration"]["override"] !== bodySetting["override"]) { + + if (lastConfiguration["bodyConfiguration"] !== bodySetting) { settingsChanged = true; } @@ -686,14 +805,17 @@ Rectangle { } if (settingsChanged) { - if ((!handOverride) && (!headOverride) && (bodySetting === "Auto")) { + if ((!handOverride) && (!headOverride) && (bodySetting === "None")) { state = buttonState.apply; + console.log("apply"); } else { state = buttonState.applyAndCalibrate; + console.log("apply and calibrate"); } } else { if (state == buttonState.apply) { state = buttonState.disabled; + console.log("disable"); } } @@ -768,6 +890,6 @@ Rectangle { function sendConfigurationSettings() { var settings = composeConfigurationSettings(); InputConfiguration.setConfigurationSettings(settings, pluginName); - //updateCalibrationText(); + updateCalibrationText(); } } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 44de16a478..7ffdcb731a 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -345,7 +345,6 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso bool overrideHands = handsObject["override"].toBool(); if (overrideHands) { _handConfig = HandConfig::Pucks; - qDebug() << "--------> configure hands <---------"; } else { _handConfig = HandConfig::HandController; } @@ -354,6 +353,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso } } + qDebug() << configToString(_preferedConfig); + saveSettings(); } From 13dff29bd55781dacfb295b964b90ef46be83cf7 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 20 Jun 2017 01:19:10 +0100 Subject: [PATCH 24/31] adding calibration screen --- .../qml/hifi/tablet/CalibratingScreen.qml | 98 ++++++++ .../qml/hifi/tablet/ControllerSettings.qml | 209 ++++++++++++++++++ .../qml/hifi/tablet/InputConfiguration.qml | 203 ----------------- .../qml/hifi/tablet/OpenVrConfiguration.qml | 136 +++--------- interface/src/Menu.cpp | 2 +- plugins/openvr/src/ViveControllerManager.cpp | 7 +- 6 files changed, 341 insertions(+), 314 deletions(-) create mode 100644 interface/resources/qml/hifi/tablet/CalibratingScreen.qml create mode 100644 interface/resources/qml/hifi/tablet/ControllerSettings.qml delete mode 100644 interface/resources/qml/hifi/tablet/InputConfiguration.qml diff --git a/interface/resources/qml/hifi/tablet/CalibratingScreen.qml b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml new file mode 100644 index 0000000000..43c8b22636 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml @@ -0,0 +1,98 @@ +// +// Created by Dante Ruiz on 6/1/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + + +import QtQuick 2.5 + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtGraphicalEffects 1.0 +import QtQuick.Controls.Styles 1.4 +import "../../styles-uit" +import "../../controls" +import "../../controls-uit" as HifiControls + + +Rectangle { + id: info + + + signal canceled() + signal restart() + + HifiConstants { id: hifi } + visible: true + color: hifi.colors.baseGray + + BusyIndicator { + id: busyIndicator + width: 350 + height: 350 + + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + topMargin: 60 + } + running: true + } + + RalewayBold { + id: directions + + anchors { + top: busyIndicator.bottom + topMargin: 100 + horizontalCenter: parent.horizontalCenter + } + + color: hifi.colors.white + size: hifi.fontSizes.rootMenuDisclosure + text: "please stand in a T-Pose during calibration" + } + + Row { + + spacing: 20 + anchors { + top: directions.bottom + topMargin: 30 + horizontalCenter: parent.horizontalCenter + } + + + HifiControls.Button { + width: 120 + height: 30 + color: hifi.buttons.red + text: "RESTART" + + onClicked: { + restart(); + } + } + + HifiControls.Button { + width: 120 + height: 30 + color: hifi.buttons.black + text: "CANCEL" + + onClicked: { + stack.pop(); + canceled(); + } + } + } + + + + function callingFunction() { + console.log("---------> calling function from parent <----------------"); + } +} diff --git a/interface/resources/qml/hifi/tablet/ControllerSettings.qml b/interface/resources/qml/hifi/tablet/ControllerSettings.qml new file mode 100644 index 0000000000..cc638858e9 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/ControllerSettings.qml @@ -0,0 +1,209 @@ +// +// Created by Dante Ruiz on 6/1/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtGraphicalEffects 1.0 +import "../../styles-uit" +import "../../controls" +import "../../controls-uit" as HifiControls + +StackView { + id: stack + initialItem: inputConfiguration + Rectangle { + id: inputConfiguration + anchors.fill: parent + + HifiConstants { id: hifi } + + color: hifi.colors.baseGray + + property var pluginSettings: null + + Rectangle { + width: inputConfiguration.width + height: 1 + color: hifi.colors.baseGrayShadow + x: -hifi.dimensions.contentMargin.x + } + + RalewayRegular { + id: header + text: "Controller Settings" + size: 22 + color: "white" + + anchors.top: inputConfiguration.top + anchors.left: inputConfiguration.left + anchors.leftMargin: 20 + anchors.topMargin: 20 + } + + + Separator { + id: headerSeparator + width: inputConfiguration.width + anchors.top: header.bottom + anchors.topMargin: 10 + } + + HiFiGlyphs { + id: sourceGlyph + text: hifi.glyphs.source + size: 36 + color: hifi.colors.blueHighlight + + anchors.top: headerSeparator.bottom + anchors.left: inputConfiguration.left + anchors.leftMargin: 40 + anchors.topMargin: 20 + } + + RalewayRegular { + id: configuration + text: "SELECT DEVICE" + size: 15 + color: hifi.colors.lightGrayText + + + anchors.top: headerSeparator.bottom + anchors.left: sourceGlyph.right + anchors.leftMargin: 10 + anchors.topMargin: 30 + } + + Row { + id: configRow + z: 999 + anchors.top: sourceGlyph.bottom + anchors.topMargin: 20 + anchors.left: sourceGlyph.left + anchors.leftMargin: 40 + spacing: 10 + HifiControls.ComboBox { + id: box + width: 160 + z: 999 + editable: true + colorScheme: hifi.colorSchemes.dark + model: inputPlugins() + label: "" + + onCurrentIndexChanged: { + changeSource(); + } + } + + HifiControls.CheckBox { + id: checkBox + colorScheme: hifi.colorSchemes.dark + text: "show all input plugins" + + onClicked: { + console.log("clicked"); + inputPlugins(); + changeSource(); + } + } + } + + + Separator { + id: configurationSeparator + z: 0 + width: inputConfiguration.width + anchors.top: configRow.bottom + anchors.topMargin: 10 + } + + + HiFiGlyphs { + id: sliderGlyph + text: hifi.glyphs.sliders + size: 36 + color: hifi.colors.blueHighlight + + anchors.top: configurationSeparator.bottom + anchors.left: inputConfiguration.left + anchors.leftMargin: 40 + anchors.topMargin: 20 + } + + RalewayRegular { + id: configurationHeader + text: "CONFIGURATION" + size: 15 + color: hifi.colors.lightGrayText + + + anchors.top: configurationSeparator.bottom + anchors.left: sliderGlyph.right + anchors.leftMargin: 10 + anchors.topMargin: 30 + } + + Loader { + id: loader + asynchronous: false + + width: inputConfiguration.width + anchors.left: inputConfiguration.left + anchors.right: inputConfiguration.right + anchors.top: configurationHeader.bottom + anchors.topMargin: 10 + anchors.bottom: inputConfiguration.bottom + + source: InputConfiguration.configurationLayout(box.currentText); + onLoaded: { + if (loader.item.hasOwnProperty("pluginName")) { + loader.item.pluginName = box.currentText + + if (loader.item.hasOwnProperty("displayInformation")) { + loader.item.displayInformation(); + } + } + } + } + } + + + function inputPlugins() { + if (checkBox.checked) { + return InputConfiguration.inputPlugins(); + } else { + return InputConfiguration.activeInputPlugins(); + } + } + + function initialize() { + changeSource(); + } + + function changeSource() { + loader.source = ""; + var source = InputConfiguration.configurationLayout(box.currentText); + loader.source = source; + if (source === "") { + box.label = "(not configurable)"; + } else { + box.label = ""; + } + } + + Timer { + id: timer + repeat: false + interval: 300 + onTriggered: initialize() + } + + Component.onCompleted: { + timer.start(); + } +} diff --git a/interface/resources/qml/hifi/tablet/InputConfiguration.qml b/interface/resources/qml/hifi/tablet/InputConfiguration.qml deleted file mode 100644 index 10181480f0..0000000000 --- a/interface/resources/qml/hifi/tablet/InputConfiguration.qml +++ /dev/null @@ -1,203 +0,0 @@ -// -// Created by Dante Ruiz on 6/1/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtGraphicalEffects 1.0 -import "../../styles-uit" -import "../../controls" -import "../../controls-uit" as HifiControls - -Rectangle { - id: inputConfiguration - anchors.fill: parent - - HifiConstants { id: hifi } - - color: hifi.colors.baseGray - - property var pluginSettings: null - - Rectangle { - width: inputConfiguration.width - height: 1 - color: hifi.colors.baseGrayShadow - x: -hifi.dimensions.contentMargin.x - } - - RalewayRegular { - id: header - text: "Controller Settings" - size: 22 - color: "white" - - anchors.top: inputConfiguration.top - anchors.left: inputConfiguration.left - anchors.leftMargin: 20 - anchors.topMargin: 20 - } - - - Separator { - id: headerSeparator - width: inputConfiguration.width - anchors.top: header.bottom - anchors.topMargin: 10 - } - - HiFiGlyphs { - id: sourceGlyph - text: hifi.glyphs.source - size: 36 - color: hifi.colors.blueHighlight - - anchors.top: headerSeparator.bottom - anchors.left: inputConfiguration.left - anchors.leftMargin: 40 - anchors.topMargin: 20 - } - - RalewayRegular { - id: configuration - text: "SELECT DEVICE" - size: 15 - color: hifi.colors.lightGrayText - - - anchors.top: headerSeparator.bottom - anchors.left: sourceGlyph.right - anchors.leftMargin: 10 - anchors.topMargin: 30 - } - - Row { - id: configRow - z: 999 - anchors.top: sourceGlyph.bottom - anchors.topMargin: 20 - anchors.left: sourceGlyph.left - anchors.leftMargin: 40 - spacing: 10 - HifiControls.ComboBox { - id: box - width: 160 - z: 999 - editable: true - colorScheme: hifi.colorSchemes.dark - model: inputPlugins() - label: "" - - onCurrentIndexChanged: { - changeSource(); - } - } - - HifiControls.CheckBox { - id: checkBox - colorScheme: hifi.colorSchemes.dark - text: "show all input plugins" - - onClicked: { - console.log("clicked"); - inputPlugins(); - changeSource(); - } - } - } - - - Separator { - id: configurationSeparator - z: 0 - width: inputConfiguration.width - anchors.top: configRow.bottom - anchors.topMargin: 10 - } - - - HiFiGlyphs { - id: sliderGlyph - text: hifi.glyphs.sliders - size: 36 - color: hifi.colors.blueHighlight - - anchors.top: configurationSeparator.bottom - anchors.left: inputConfiguration.left - anchors.leftMargin: 40 - anchors.topMargin: 20 - } - - RalewayRegular { - id: configurationHeader - text: "CONFIGURATION" - size: 15 - color: hifi.colors.lightGrayText - - - anchors.top: configurationSeparator.bottom - anchors.left: sliderGlyph.right - anchors.leftMargin: 10 - anchors.topMargin: 30 - } - - Loader { - id: loader - asynchronous: false - - width: inputConfiguration.width - anchors.left: inputConfiguration.left - anchors.right: inputConfiguration.right - anchors.top: configurationHeader.bottom - anchors.topMargin: 10 - anchors.bottom: inputConfiguration.bottom - - source: InputConfiguration.configurationLayout(box.currentText); - onLoaded: { - if (loader.item.hasOwnProperty("pluginName")) { - loader.item.pluginName = box.currentText - - if (loader.item.hasOwnProperty("displayInformation")) { - loader.item.displayInformation(); - } - } - } - } - - function inputPlugins() { - if (checkBox.checked) { - return InputConfiguration.inputPlugins(); - } else { - return InputConfiguration.activeInputPlugins(); - } - } - - function initialize() { - changeSource(); - } - - function changeSource() { - loader.source = ""; - var source = InputConfiguration.configurationLayout(box.currentText); - loader.source = source; - if (source === "") { - box.label = "(not configurable)"; - } else { - box.label = ""; - } - } - - Timer { - id: timer - repeat: false - interval: 300 - onTriggered: initialize() - } - - Component.onCompleted: { - timer.start(); - } -} diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 62203b811d..7fde6c53eb 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -14,6 +14,7 @@ import QtQuick.Controls.Styles 1.4 import "../../styles-uit" import "../../controls" import "../../controls-uit" as HifiControls +import "." Rectangle { @@ -42,6 +43,7 @@ Rectangle { HifiConstants { id: hifi } + Component { id: screen; CalibratingScreen {} } QtObject { id: buttonState readonly property int disabled: 0 @@ -440,11 +442,11 @@ Rectangle { property int color: hifi.buttons.blue property int colorScheme: hifi.colorSchemes.light property string glyph: hifi.glyphs.avatar1 - property bool enabled: true + property bool enabled: false property bool pressed: false property bool hovered: false property int size: 32 - property string text: "calibrate" + property string text: "apply" property int padding: 12 width: glyphButton.width + calibrationText.width + padding @@ -502,7 +504,6 @@ Rectangle { top: parent.top bottom: parent.bottom bottomMargin: 1 - verticalCenter: parent.horizontalCenter } } @@ -526,11 +527,19 @@ Rectangle { anchors.fill: parent hoverEnabled: true onClicked: { - openVrConfiguration.countDown = timeToCalibrate.value; - numberAnimation.start(); - calibrationTimer.start(); - info.visible = true; - info.showCountDown = true; + if (calibrationButton.enabled) { + calibrationTimer.interval = timeToCalibrate.value * 1000 + openVrConfiguration.countDown = timeToCalibrate.value; + numberAnimation.duration = calibrationTimer.interval + numberAnimation.start(); + calibrationTimer.start(); + var calibratingScreen = screen.createObject(); + stack.push(calibratingScreen); + + calibratingScreen.callingFunction(); + calibratingScreen.canceled.connect(cancelCalibration); + calibratingScreen.restart.connect(restartCalibration); + } } onPressed: { @@ -557,8 +566,6 @@ Rectangle { interval: 20 onTriggered: { InputConfiguration.calibratePlugin(pluginName) - info.visible = false; - info.showCountDown = false; } } @@ -567,12 +574,6 @@ Rectangle { repeat: false interval: 3000 onTriggered: { - info.showCountDown = false; - info.calibrationFailed = false - info.calibrationSucceed = false; - info.calibrationSucceed = false; - info.showCalibrationStatus = false; - info.visible = false; } } @@ -590,6 +591,7 @@ Rectangle { anchors.leftMargin: leftMargin minimumValue: 3 + value: 3 label: "Time til calibration ( in seconds )" colorScheme: hifi.colorSchemes.dark @@ -609,19 +611,12 @@ Rectangle { function calibrationStatusInfo(status) { if (status["calibrated"]) { - info.visible = true; - info.showCalibrationStatus = true; - info.calibrationSucceed = true; } else if (!status["calibrated"]) { var uncalibrated = status["success"]; if (uncalibrated) { - info.visible = true; - info.showCalibrationStatus = true; - info.uncalibrationSucceed = true; + } else { - info.visible = true; - info.showCalibrationStatus = true; - info.calibrationFailed = true; + } } displayTimer.start(); @@ -654,6 +649,14 @@ Rectangle { return pucksNeeded; } + function cancelCalibration() { + console.log("canceling calibration"); + } + + function restartCalibration() { + console.log("restating calibration"); + } + function displayConfiguration() { var settings = InputConfiguration.configurationSettings(pluginName); var configurationType = settings["trackerConfiguration"]; @@ -680,84 +683,6 @@ Rectangle { } } - - Rectangle { - id: info - property bool showCountDown: false - property bool showCalibrationStatus: false - property bool calibrationFailed: false - property bool calibrationSucceed: false - property bool uncalibrationSucceed: false - - visible: false - color: hifi.colors.baseGray - anchors.top: openVrConfiguration.top - anchors.bottom: bottomSeperator.bottom - anchors.left: openVrConfiguration.left - anchors.right: openVrConfiguration.right - - Item { - id: countDownContainer - visible: info.showCountDown - anchors.centerIn: parent - RalewayBold { - id: countDownText - - text: openVrConfiguration.countDown - size: 92 - - color: hifi.colors.blueHighlight - - anchors.centerIn: parent - } - } - - Item { - id: calibrationStatus - visible: info.showCalibrationStatus - anchors.centerIn: parent - Item { - id: successInfo - visible: info.calibrationSucceed - anchors.centerIn: parent - RalewayBold { - id: successText - text: "Calibration Successful" - size: 42 - color: hifi.colors.greenHighlight - anchors.centerIn: parent - } - } - - Item { - id: failedInfo - visible: info.calibrationFailed - anchors.fill: parent - RalewayBold { - id: failedText - text: "Calibration Failed" - size: 42 - color: hifi.colors.redAccent - anchors.centerIn: parent - } - } - - Item { - id: uncalibrateInfo - visible: info.uncalibrationSucceed - anchors.centerIn: parent - RalewayBold { - id: uncalibrateText - text: "Uncalibration Successful" - size: 37 - color: hifi.colors.greenHighlight - anchors.centerIn: parent - } - } - } - } - - function displayTrackerConfiguration(type) { if (type === "Feet") { feetBox.checked = true; @@ -825,12 +750,15 @@ Rectangle { function updateCalibrationText() { updateButtonState(); if (buttonState.disabled == state) { - calibrationButton.text = "Apply"; + calibrationButton.enabled = false; } else if (buttonState.apply == state) { + calibrationButton.enabled = true; calibrationButton.text = "Apply"; } else if (buttonState.applyAndCalibrate == state) { + calibrationButton.enabled = true; calibrationButton.text = "Apply And Calibrate"; } else if (buttonState.calibrate == state) { + calibrationButton.enabled = true; calibrationButton.text = "Calibrate"; } } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index f5b0a2e407..5b5480dbfc 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -313,7 +313,7 @@ Menu::Menu() { action = addActionToQMenuAndActionHash(settingsMenu, "InputConfiguration"); connect(action, &QAction::triggered, [] { auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); - tablet->loadQMLSource("InputConfiguration.qml"); + tablet->loadQMLSource("ControllerSettings.qml"); }); // Settings > Control with Speech [advanced] diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 7ffdcb731a..f683ee75de 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -1011,9 +1011,6 @@ void ViveControllerManager::InputDevice::loadSettings() { Settings settings; settings.beginGroup("PUCK_CONFIG"); { - _preferedConfig = (Config)settings.value("body configuration", QVariant((int)Config::None)).toInt(); - _headConfig = (HeadConfig)settings.value("head configuration", QVariant((int)HeadConfig::HMD)).toInt(); - _handConfig = (HandConfig)settings.value("hand configuration", QVariant((int)HandConfig::HandController)).toInt(); } settings.endGroup(); } @@ -1022,9 +1019,7 @@ void ViveControllerManager::InputDevice::saveSettings() const { Settings settings; settings.beginGroup("PUCK_CONFIG"); { - settings.setValue(QString("body configuration"), (int)_preferedConfig); - settings.setValue(QString("head configuration"), (int)_headConfig); - settings.setValue(QString("hand configuration"), (int)_handConfig); + } settings.endGroup(); } From 33b89c9d327be0a61d24cc7c1c0fd10d8aa1e16f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 20 Jun 2017 17:26:17 +0100 Subject: [PATCH 25/31] adding glyph and text --- .../qml/hifi/tablet/CalibratingScreen.qml | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/CalibratingScreen.qml b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml index 43c8b22636..ffd2a80e58 100644 --- a/interface/resources/qml/hifi/tablet/CalibratingScreen.qml +++ b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml @@ -24,6 +24,8 @@ Rectangle { signal canceled() signal restart() + + property int count: 3 HifiConstants { id: hifi } visible: true @@ -42,6 +44,47 @@ Rectangle { running: true } + + HiFiGlyphs { + id: image + text: hifi.glyphs.avatar1 + size: 190 + color: hifi.colors.white + + anchors { + top: busyIndicator.top + topMargin: 40 + horizontalCenter: busyIndicator.horizontalCenter + } + } + + RalewayBold { + id: statusText + text: "CALIBRATION STARTING IN" + size: 16 + color: hifi.colors.blueHighlight + + anchors { + top: image.bottom + topMargin: 15 + horizontalCenter: image.horizontalCenter + } + } + + + RalewayBold { + id: countDown + text: info.count + color: hifi.colors.blueHighlight + + anchors { + top: statusText.bottom + topMargin: 12 + horizontalCenter: statusText.horizontalCenter + } + } + + RalewayBold { id: directions @@ -56,6 +99,13 @@ Rectangle { text: "please stand in a T-Pose during calibration" } + NumberAnimation { + id: numberAnimation + target: info + property: count + to: 0 + } + Row { spacing: 20 @@ -89,10 +139,9 @@ Rectangle { } } } - - + function start() { + } function callingFunction() { - console.log("---------> calling function from parent <----------------"); } } From 2c3db0fb91481176a8c69280e2b867c826148c98 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 21 Jun 2017 01:07:12 +0100 Subject: [PATCH 26/31] finished calibration-ui --- .../images/loader-calibrate-blue.png | Bin 0 -> 7935 bytes .../images/loader-calibrate-white.png | Bin 0 -> 7376 bytes .../qml/hifi/tablet/CalibratingScreen.qml | 82 +++++++++++-- .../qml/hifi/tablet/ControllerSettings.qml | 23 ++-- .../qml/hifi/tablet/OpenVrConfiguration.qml | 110 +++++++++++++----- interface/src/Application.cpp | 2 + interface/src/Menu.cpp | 8 +- .../src/plugins/InputConfiguration.cpp | 30 ++++- .../plugins/src/plugins/InputConfiguration.h | 1 + libraries/plugins/src/plugins/InputPlugin.h | 1 + plugins/openvr/src/ViveControllerManager.cpp | 54 ++++----- plugins/openvr/src/ViveControllerManager.h | 3 +- 12 files changed, 234 insertions(+), 80 deletions(-) create mode 100644 interface/resources/images/loader-calibrate-blue.png create mode 100644 interface/resources/images/loader-calibrate-white.png diff --git a/interface/resources/images/loader-calibrate-blue.png b/interface/resources/images/loader-calibrate-blue.png new file mode 100644 index 0000000000000000000000000000000000000000..808f5fa3d217e7ed4558b72aad5c4e633f31be99 GIT binary patch literal 7935 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 literal 0 HcmV?d00001 diff --git a/interface/resources/qml/hifi/tablet/CalibratingScreen.qml b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml index ffd2a80e58..b8935f5463 100644 --- a/interface/resources/qml/hifi/tablet/CalibratingScreen.qml +++ b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml @@ -25,23 +25,40 @@ Rectangle { signal canceled() signal restart() - property int count: 3 + property int count: 3 + property string calibratingText: "CALIBRATING..." + property string calibratingCountText: "CALIBRATION STARTING IN" + property string calibrationSuccess: "CALIBRATION COMPLETED" + property string calibrationFailed: "CALIBRATION FAILED" HifiConstants { id: hifi } visible: true color: hifi.colors.baseGray - BusyIndicator { + property string whiteIndicator: "../../../images/loader-calibrate-white.png" + property string blueIndicator: "../../../images/loader-calibrate-blue.png" + + Image { id: busyIndicator width: 350 height: 350 + property bool running: true + anchors { horizontalCenter: parent.horizontalCenter top: parent.top topMargin: 60 } - running: true + visible: busyIndicator.running + source: blueIndicator + NumberAnimation on rotation { + id: busyRotation + running: busyIndicator.running + loops: Animation.Infinite + duration: 1000 + from: 0 ; to: 360 + } } @@ -60,7 +77,7 @@ Rectangle { RalewayBold { id: statusText - text: "CALIBRATION STARTING IN" + text: info.calibratingCountText size: 16 color: hifi.colors.blueHighlight @@ -102,10 +119,27 @@ Rectangle { NumberAnimation { id: numberAnimation target: info - property: count + property: "count" to: 0 } + Timer { + id: timer + + repeat: false + interval: 3000 + onTriggered: { + info.calibrating(); + } + } + + Timer { + id: closeWindow + repeat: false + interval: 3000 + onTriggered: stack.pop(); + } + Row { spacing: 20 @@ -124,6 +158,10 @@ Rectangle { onClicked: { restart(); + numberAnimation.stop(); + info.count = (timer.interval / 1000); + numberAnimation.start(); + timer.restart(); } } @@ -134,14 +172,42 @@ Rectangle { text: "CANCEL" onClicked: { - stack.pop(); canceled(); + stack.pop() } } } - function start() { + function start(interval, countNumber) { + countDown.visible = true; + statusText.color = hifi.colors.blueHighlight; + numberAnimation.duration = interval + info.count = countNumber; + timer.interval = interval; + numberAnimation.start(); + timer.start(); } - function callingFunction() { + + function calibrating() { + countDown.visible = false; + busyIndicator.source = whiteIndicator; + busyRotation.from = 360 + busyRotation.to = 0 + statusText.text = info.calibratingText; + statusText.color = hifi.colors.white + } + + function success() { + busyIndicator.running = false; + statusText.text = info.calibrationSuccess + statusText.color = hifi.colors.greenHighlight + closeWindow.start(); + } + + function failure() { + busyIndicator.running = false; + statusText.text = info.calibrationFailed + statusText.color = hifi.colors.redHighlight + closeWindow.start(); } } diff --git a/interface/resources/qml/hifi/tablet/ControllerSettings.qml b/interface/resources/qml/hifi/tablet/ControllerSettings.qml index cc638858e9..e1ba93a840 100644 --- a/interface/resources/qml/hifi/tablet/ControllerSettings.qml +++ b/interface/resources/qml/hifi/tablet/ControllerSettings.qml @@ -103,10 +103,9 @@ StackView { HifiControls.CheckBox { id: checkBox colorScheme: hifi.colorSchemes.dark - text: "show all input plugins" + text: "show all input devices" onClicked: { - console.log("clicked"); inputPlugins(); changeSource(); } @@ -162,12 +161,16 @@ StackView { source: InputConfiguration.configurationLayout(box.currentText); onLoaded: { if (loader.item.hasOwnProperty("pluginName")) { - loader.item.pluginName = box.currentText - - if (loader.item.hasOwnProperty("displayInformation")) { - loader.item.displayInformation(); + if (box.currentText === "Vive") { + loader.item.pluginName = "OpenVR"; + } else { + loader.item.pluginName = box.currentText; } } + + if (loader.item.hasOwnProperty("displayInformation")) { + loader.item.displayConfiguration(); + } } } } @@ -187,7 +190,13 @@ StackView { function changeSource() { loader.source = ""; - var source = InputConfiguration.configurationLayout(box.currentText); + var source = ""; + if (box.currentText == "Vive") { + source = InputConfiguration.configurationLayout("OpenVR"); + } else { + source = InputConfiguration.configurationLayout(box.currentText); + } + loader.source = source; if (source === "") { box.label = "(not configurable)"; diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 7fde6c53eb..9c23cf8677 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -27,7 +27,7 @@ Rectangle { property int leftMargin: 75 property int countDown: 0 property string pluginName: "" - property var displayInformation: openVrConfiguration.displayConfiguration() + property var displayInformation: null readonly property bool feetChecked: feetBox.checked readonly property bool hipsChecked: hipBox.checked @@ -144,7 +144,7 @@ Rectangle { decimals: 4 width: 112 label: "Y: offset" - value: -0.0254 + minimumValue: -10 stepSize: 0.0254 colorScheme: hifi.colorSchemes.dark @@ -157,7 +157,7 @@ Rectangle { id: headZOffset width: 112 label: "Z: offset" - value: -0.152 + minimumValue: -10 stepSize: 0.0254 decimals: 4 colorScheme: hifi.colorSchemes.dark @@ -249,7 +249,7 @@ Rectangle { decimals: 4 width: 112 label: "Y: offset" - value: -0.0508 + minimumValue: -10 stepSize: 0.0254 colorScheme: hifi.colorSchemes.dark @@ -262,7 +262,7 @@ Rectangle { id: handZOffset width: 112 label: "Z: offset" - value: -0.0254 + minimumValue: -10 stepSize: 0.0254 decimals: 4 colorScheme: hifi.colorSchemes.dark @@ -528,17 +528,19 @@ Rectangle { hoverEnabled: true onClicked: { if (calibrationButton.enabled) { - calibrationTimer.interval = timeToCalibrate.value * 1000 - openVrConfiguration.countDown = timeToCalibrate.value; - numberAnimation.duration = calibrationTimer.interval - numberAnimation.start(); - calibrationTimer.start(); - var calibratingScreen = screen.createObject(); - stack.push(calibratingScreen); - - calibratingScreen.callingFunction(); - calibratingScreen.canceled.connect(cancelCalibration); - calibratingScreen.restart.connect(restartCalibration); + if (openVrConfiguration.state === buttonState.apply) { + InputConfiguration.uncalibratePlugin(pluginName); + updateCalibrationButton(); + } else { + calibrationTimer.interval = timeToCalibrate.value * 1000 + openVrConfiguration.countDown = timeToCalibrate.value; + var calibratingScreen = screen.createObject(); + stack.push(calibratingScreen); + calibratingScreen.canceled.connect(cancelCalibration); + calibratingScreen.restart.connect(restartCalibration); + calibratingScreen.start(calibrationTimer.interval, timeToCalibrate.value); + calibrationTimer.start(); + } } } @@ -547,7 +549,7 @@ Rectangle { } onReleased: { - calibrationButton.pressed = false; + calibrationButton.pressed = false; } onEntered: { @@ -592,7 +594,6 @@ Rectangle { minimumValue: 3 value: 3 - label: "Time til calibration ( in seconds )" colorScheme: hifi.colorSchemes.dark onEditingFinished: { @@ -602,6 +603,31 @@ Rectangle { } } + RalewayBold { + id: delayTextInfo + size: 10 + text: "Delay Before Calibration Starts" + color: hifi.colors.white + + anchors { + left: timeToCalibrate.right + leftMargin: 20 + verticalCenter: timeToCalibrate.verticalCenter + } + } + + RalewayRegular { + size: 12 + text: "sec" + color: hifi.colors.lightGray + + anchors { + left: delayTextInfo.right + leftMargin: 10 + verticalCenter: delayTextInfo.verticalCenter + } + } + NumberAnimation { id: numberAnimation target: openVrConfiguration @@ -610,16 +636,17 @@ Rectangle { } function calibrationStatusInfo(status) { + var calibrationScreen = stack.currentItem; if (status["calibrated"]) { + calibrationScreen.success(); } else if (!status["calibrated"]) { var uncalibrated = status["success"]; - if (uncalibrated) { - - } else { - + if (!uncalibrated) { + calibrationScreen.failure(); } } - displayTimer.start(); + + updateCalibrationButton(); } @@ -650,11 +677,11 @@ Rectangle { } function cancelCalibration() { - console.log("canceling calibration"); + calibrationTimer.stop(); } function restartCalibration() { - console.log("restating calibration"); + calibrationTimer.restart(); } function displayConfiguration() { @@ -681,6 +708,9 @@ Rectangle { handPuckBox.checked = true; handBox.checked = false; } + + initializeButtonState(); + updateCalibrationText(); } function displayTrackerConfiguration(type) { @@ -732,25 +762,45 @@ Rectangle { if (settingsChanged) { if ((!handOverride) && (!headOverride) && (bodySetting === "None")) { state = buttonState.apply; - console.log("apply"); } else { state = buttonState.applyAndCalibrate; - console.log("apply and calibrate"); } } else { if (state == buttonState.apply) { state = buttonState.disabled; - console.log("disable"); + } else if (state == buttonState.applyAndCalibrate) { + state = buttonState.calibrate; } } lastConfiguration = settings; } - function updateCalibrationText() { + function initializeButtonState() { + var settings = composeConfigurationSettings(); + var bodySetting = settings["bodyConfiguration"]; + var headSetting = settings["headConfiguration"]; + var headOverride = headSetting["override"]; + var handSetting = settings["handConfiguration"]; + var handOverride = handSetting["override"]; + + + if ((!handOverride) && (!headOverride) && (bodySetting === "None")) { + state = buttonState.disabled; + } else { + state = buttonState.calibrate; + } + } + + function updateCalibrationButton() { updateButtonState(); + updateCalibrationText(); + } + + function updateCalibrationText() { if (buttonState.disabled == state) { calibrationButton.enabled = false; + calibrationButton.text = "Apply"; } else if (buttonState.apply == state) { calibrationButton.enabled = true; calibrationButton.text = "Apply"; @@ -818,6 +868,6 @@ Rectangle { function sendConfigurationSettings() { var settings = composeConfigurationSettings(); InputConfiguration.setConfigurationSettings(settings, pluginName); - updateCalibrationText(); + updateCalibrationButton(); } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8505e07181..95e3cec3b5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -109,6 +109,7 @@ #include #include #include +#include #include #include #include @@ -1997,6 +1998,7 @@ void Application::initializeUi() { surfaceContext->setContextProperty("TextureCache", DependencyManager::get().data()); surfaceContext->setContextProperty("ModelCache", DependencyManager::get().data()); surfaceContext->setContextProperty("SoundCache", DependencyManager::get().data()); + surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get().data()); surfaceContext->setContextProperty("Account", AccountScriptingInterface::getInstance()); surfaceContext->setContextProperty("Tablet", DependencyManager::get().data()); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 5b5480dbfc..8c9baa7c43 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -38,6 +38,7 @@ #include "MainWindow.h" #include "render/DrawStatus.h" #include "scripting/MenuScriptingInterface.h" +#include "scripting/HMDScriptingInterface.h" #include "ui/DialogsManager.h" #include "ui/StandAloneJSConsole.h" #include "InterfaceLogging.h" @@ -310,10 +311,15 @@ Menu::Menu() { QString("../../hifi/tablet/TabletLodPreferences.qml"), "LodPreferencesDialog"); }); - action = addActionToQMenuAndActionHash(settingsMenu, "InputConfiguration"); + action = addActionToQMenuAndActionHash(settingsMenu, "Controller Settings"); connect(action, &QAction::triggered, [] { auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); + auto hmd = DependencyManager::get(); tablet->loadQMLSource("ControllerSettings.qml"); + + if (!hmd->getShouldShowTablet()) { + hmd->toggleShouldShowTablet(); + } }); // Settings > Control with Speech [advanced] diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index d20678b972..33948ef70d 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -28,7 +28,12 @@ QStringList InputConfiguration::inputPlugins() { QStringList inputPlugins; for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { - inputPlugins << QString(plugin->getName()); + QString pluginName = plugin->getName(); + if (pluginName == QString("OpenVR")) { + inputPlugins << QString("Vive"); + } else { + inputPlugins << pluginName; + } } return inputPlugins; } @@ -45,7 +50,12 @@ QStringList InputConfiguration::activeInputPlugins() { QStringList activePlugins; for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { if (plugin->configurable()) { - activePlugins << QString(plugin->getName()); + QString pluginName = plugin->getName(); + if (pluginName == QString("OpenVR")) { + activePlugins << QString("Vive"); + } else { + activePlugins << pluginName; + } } } return activePlugins; @@ -113,3 +123,19 @@ void InputConfiguration::calibratePlugin(QString pluginName) { } } } + + +bool InputConfiguration::uncalibratePlugin(QString pluginName) { + if (QThread::currentThread() != thread()) { + bool result; + QMetaObject::invokeMethod(this, "uncalibratePlugin", Qt::BlockingQueuedConnection, + Q_ARG(bool, result)); + return result; + } + + for (auto plugin : PluginManager::getInstance()->getInputPlugins()) { + if (plugin->getName() == pluginName) { + return plugin->uncalibrate(); + } + } +} diff --git a/libraries/plugins/src/plugins/InputConfiguration.h b/libraries/plugins/src/plugins/InputConfiguration.h index abf0c89ab4..27591edc34 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.h +++ b/libraries/plugins/src/plugins/InputConfiguration.h @@ -28,6 +28,7 @@ public: Q_INVOKABLE void setConfigurationSettings(QJsonObject configurationSettings, QString pluginName); Q_INVOKABLE void calibratePlugin(QString pluginName); Q_INVOKABLE QJsonObject configurationSettings(QString pluginName); + Q_INVOKABLE bool uncalibratePlugin(QString pluginName); signals: void calibrationStatus(const QJsonObject& status); diff --git a/libraries/plugins/src/plugins/InputPlugin.h b/libraries/plugins/src/plugins/InputPlugin.h index 51bff07de9..5d02964c97 100644 --- a/libraries/plugins/src/plugins/InputPlugin.h +++ b/libraries/plugins/src/plugins/InputPlugin.h @@ -29,6 +29,7 @@ public: virtual QJsonObject configurationSettings() { return QJsonObject(); } virtual QString configurationLayout() { return QString(); } virtual void calibrate() {} + virtual bool uncalibrate() { return false; } virtual bool configurable() { return false; } virtual bool isHandController() const { return false; } virtual bool isHeadController() const { return false; } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index f683ee75de..3b62a1a927 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -127,6 +127,14 @@ void ViveControllerManager::calibrate() { } } +bool ViveControllerManager::uncalibrate() { + if (isSupported()) { + _inputDevice->uncalibrate(); + return true; + } + return false; +} + bool ViveControllerManager::isSupported() const { return openVrSupported(); } @@ -241,10 +249,6 @@ ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) : contro _configStringMap[Config::FeetAndHips] = QString("FeetAndHips"); _configStringMap[Config::FeetHipsAndChest] = QString("FeetHipsAndChest"); _configStringMap[Config::FeetHipsAndShoulders] = QString("FeetHipsAndShoulders"); - - if (openVrSupported()) { - loadSettings(); - } } void ViveControllerManager::InputDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { @@ -319,7 +323,8 @@ void ViveControllerManager::InputDevice::calibrateFromHandController(const contr void ViveControllerManager::InputDevice::calibrateFromUI(const controller::InputCalibrationData& inputCalibrationData) { if (_calibrate) { - calibrateOrUncalibrate(inputCalibrationData); + uncalibrate(); + calibrate(inputCalibrationData); _calibrate = false; } } @@ -337,6 +342,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso bool overrideHead = headObject["override"].toBool(); if (overrideHead) { _headConfig = HeadConfig::Puck; + HEAD_PUCK_Y_OFFSET = (float)headObject["Y"].toDouble(); + HEAD_PUCK_Z_OFFSET = (float)headObject["Z"].toDouble(); } else { _headConfig = HeadConfig::HMD; } @@ -345,6 +352,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso bool overrideHands = handsObject["override"].toBool(); if (overrideHands) { _handConfig = HandConfig::Pucks; + HAND_PUCK_Y_OFFSET = (float)handsObject["Y"].toDouble(); + HAND_PUCK_Z_OFFSET = (float)handsObject["Z"].toDouble(); } else { _handConfig = HandConfig::HandController; } @@ -352,10 +361,6 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso iter++; } } - - qDebug() << configToString(_preferedConfig); - - saveSettings(); } void ViveControllerManager::InputDevice::calibrateNextFrame() { @@ -444,15 +449,22 @@ void ViveControllerManager::InputDevice::calibrateOrUncalibrate(const controller void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibrationData& inputCalibration) { qDebug() << "Puck Calibration: Starting..."; + int puckCount = (int)_validTrackedObjects.size(); + qDebug() << "Puck Calibration: " << puckCount << " pucks found for calibration"; + + if (puckCount == 0) { + uncalibrate(); + emitCalibrationStatus(false); + return; + } + glm::mat4 defaultToReferenceMat = glm::mat4(); if (_headConfig == HeadConfig::HMD) { defaultToReferenceMat = calculateDefaultToReferenceForHmd(inputCalibration); } else if (_headConfig == HeadConfig::Puck) { defaultToReferenceMat = calculateDefaultToReferenceForHeadPuck(inputCalibration); } - - int puckCount = (int)_validTrackedObjects.size(); - qDebug() << "Puck Calibration: " << puckCount << " pucks found for calibration"; + _config = _preferedConfig; bool headConfigured = configureHead(defaultToReferenceMat, inputCalibration); @@ -1006,24 +1018,6 @@ void ViveControllerManager::InputDevice::calibrateHead(glm::mat4& defaultToRefer _pucksOffset[head.first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultHeadMat, newHead); } - -void ViveControllerManager::InputDevice::loadSettings() { - Settings settings; - settings.beginGroup("PUCK_CONFIG"); - { - } - settings.endGroup(); -} - -void ViveControllerManager::InputDevice::saveSettings() const { - Settings settings; - settings.beginGroup("PUCK_CONFIG"); - { - - } - settings.endGroup(); -} - QString ViveControllerManager::InputDevice::configToString(Config config) { return _configStringMap[config]; } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 1a4df550d9..4ebe466a04 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -45,6 +45,7 @@ public: void setConfigurationSettings(const QJsonObject configurationSettings) override; QJsonObject configurationSettings() override; void calibrate() override; + bool uncalibrate() override; bool isHeadController() const override { return true; } bool isHeadControllerMounted() const; @@ -91,8 +92,6 @@ private: void partitionTouchpad(int sButton, int xAxis, int yAxis, int centerPsuedoButton, int xPseudoButton, int yPseudoButton); void printDeviceTrackingResultChange(uint32_t deviceIndex); void setConfigFromString(const QString& value); - void loadSettings(); - void saveSettings() const; bool configureHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); bool configureHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); bool configureBody(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); From 2e329602f7eb7f0ef4b020e7ff19b2a6e814d42f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 21 Jun 2017 01:13:45 +0100 Subject: [PATCH 27/31] minimize diff --- interface/resources/qml/styles-uit/Separator.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/resources/qml/styles-uit/Separator.qml b/interface/resources/qml/styles-uit/Separator.qml index eb3bc33cf7..4134b928a7 100644 --- a/interface/resources/qml/styles-uit/Separator.qml +++ b/interface/resources/qml/styles-uit/Separator.qml @@ -1,3 +1,4 @@ +// // Separator.qml // // Created by Zach Fox on 2017-06-06 From 5e82b13d65ec46f7dc97295c10323748bdb90ceb Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 21 Jun 2017 01:15:17 +0100 Subject: [PATCH 28/31] removed double include --- interface/src/Application.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e32cf1232f..04c5ab6d3d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include From 17832b602244e22767a0f2075524dbc83bc5439d Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 21 Jun 2017 01:38:05 +0100 Subject: [PATCH 29/31] edited some button behavior --- interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 9c23cf8677..2a951f31ef 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -301,8 +301,10 @@ Rectangle { boxRadius: 7 onClicked: { - if (hipsChecked) { - checked = true; + if (!checked) { + shoulderBox.checked = false; + chestBox.checked = false; + hipBox.checked = false; } sendConfigurationSettings(); } From f369303bfed4abfe5e5bdef9e6f4c921f0d2cef9 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 21 Jun 2017 18:12:31 +0100 Subject: [PATCH 30/31] removed warning --- libraries/plugins/src/plugins/InputConfiguration.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/plugins/src/plugins/InputConfiguration.cpp b/libraries/plugins/src/plugins/InputConfiguration.cpp index 33948ef70d..04b1e3b370 100644 --- a/libraries/plugins/src/plugins/InputConfiguration.cpp +++ b/libraries/plugins/src/plugins/InputConfiguration.cpp @@ -138,4 +138,6 @@ bool InputConfiguration::uncalibratePlugin(QString pluginName) { return plugin->uncalibrate(); } } + + return false; } From c4699e00ca2ace25e9bc73f633948eb102aee654 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 21 Jun 2017 23:10:08 +0100 Subject: [PATCH 31/31] added hand offsets --- .../qml/hifi/tablet/CalibratingScreen.qml | 2 +- .../qml/hifi/tablet/OpenVrConfiguration.qml | 4 ++++ plugins/openvr/src/ViveControllerManager.cpp | 17 ++++++----------- plugins/openvr/src/ViveControllerManager.h | 2 -- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/CalibratingScreen.qml b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml index b8935f5463..338a76989f 100644 --- a/interface/resources/qml/hifi/tablet/CalibratingScreen.qml +++ b/interface/resources/qml/hifi/tablet/CalibratingScreen.qml @@ -113,7 +113,7 @@ Rectangle { color: hifi.colors.white size: hifi.fontSizes.rootMenuDisclosure - text: "please stand in a T-Pose during calibration" + text: "Please stand in a T-Pose during calibration" } NumberAnimation { diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 2a951f31ef..52a935ab19 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -149,6 +149,7 @@ Rectangle { colorScheme: hifi.colorSchemes.dark onEditingFinished: { + sendConfigurationSettings(); } } @@ -163,6 +164,7 @@ Rectangle { colorScheme: hifi.colorSchemes.dark onEditingFinished: { + sendConfigurationSettings(); } } } @@ -254,6 +256,7 @@ Rectangle { colorScheme: hifi.colorSchemes.dark onEditingFinished: { + sendConfigurationSettings(); } } @@ -268,6 +271,7 @@ Rectangle { colorScheme: hifi.colorSchemes.dark onEditingFinished: { + sendConfigurationSettings(); } } } diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 3b62a1a927..d914cdcfad 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -342,8 +342,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso bool overrideHead = headObject["override"].toBool(); if (overrideHead) { _headConfig = HeadConfig::Puck; - HEAD_PUCK_Y_OFFSET = (float)headObject["Y"].toDouble(); - HEAD_PUCK_Z_OFFSET = (float)headObject["Z"].toDouble(); + HEAD_PUCK_Y_OFFSET = headObject["Y"].toDouble(); + HEAD_PUCK_Z_OFFSET = headObject["Z"].toDouble(); } else { _headConfig = HeadConfig::HMD; } @@ -352,8 +352,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso bool overrideHands = handsObject["override"].toBool(); if (overrideHands) { _handConfig = HandConfig::Pucks; - HAND_PUCK_Y_OFFSET = (float)handsObject["Y"].toDouble(); - HAND_PUCK_Z_OFFSET = (float)handsObject["Z"].toDouble(); + HAND_PUCK_Y_OFFSET = handsObject["Y"].toDouble(); + HAND_PUCK_Z_OFFSET = handsObject["Z"].toDouble(); } else { _handConfig = HandConfig::HandController; } @@ -906,7 +906,7 @@ void ViveControllerManager::InputDevice::calibrateLeftHand(glm::mat4& defaultToR glm::vec4(zPrime, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); - glm::vec3 translationOffset = glm::vec3(0.0f, -HAND_PUCK_Y_OFFSET, 0.0f); + glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET); glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); glm::quat finalRotation = glmExtractRotation(newHandMat); @@ -932,13 +932,12 @@ void ViveControllerManager::InputDevice::calibrateRightHand(glm::mat4& defaultTo glm::vec3 zPrime = handPoseZAxis; glm::vec3 xPrime = glm::normalize(glm::cross(avatarHandYAxis, handPoseZAxis)); glm::vec3 yPrime = glm::normalize(glm::cross(zPrime, xPrime)); - glm::mat4 newHandMat = glm::mat4(glm::vec4(xPrime, 0.0f), glm::vec4(yPrime, 0.0f), glm::vec4(zPrime, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); - glm::vec3 translationOffset = glm::vec3(0.0f, 0.0f, 0.0f); + glm::vec3 translationOffset = glm::vec3(0.0f, HAND_PUCK_Y_OFFSET, HAND_PUCK_Z_OFFSET); glm::quat initialRotation = glmExtractRotation(handPoseAvatarMat); glm::quat finalRotation = glmExtractRotation(newHandMat); @@ -977,10 +976,6 @@ void ViveControllerManager::InputDevice::calibrateHips(glm::mat4& defaultToRefer _pucksOffset[_validTrackedObjects[HIP].first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultHips, _validTrackedObjects[HIP].second); } - -void ViveControllerManager::InputDevice::calibrateHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, int firstHandIndex, int secondHandIndex) { -} - void ViveControllerManager::InputDevice::calibrateChest(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration) { _jointToPuckMap[controller::SPINE2] = _validTrackedObjects[CHEST].first; _pucksOffset[_validTrackedObjects[CHEST].first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultSpine2, _validTrackedObjects[CHEST].second); diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index 4ebe466a04..67a9ff46fd 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -102,8 +102,6 @@ private: void calibrateChest(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); void calibrateShoulders(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, int firstShoulderIndex, int secondShoulderIndex); - void calibrateHands(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration, - int firstHandIndex, int secondHandIndex); void calibrateHead(glm::mat4& defaultToReferenceMat, const controller::InputCalibrationData& inputCalibration); void calibrateFromHandController(const controller::InputCalibrationData& inputCalibrationData); void calibrateFromUI(const controller::InputCalibrationData& inputCalibrationData);