mirror of
https://github.com/overte-org/overte.git
synced 2025-06-18 17:00:27 +02:00
connect the ui with the input plugins
This commit is contained in:
parent
4ba1fdc323
commit
11409aae9b
7 changed files with 223 additions and 10 deletions
|
@ -162,7 +162,7 @@ Rectangle {
|
||||||
|
|
||||||
|
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
if (loader.item.hasOwnProeprty("pluginName")) {
|
if (loader.item.hasOwnProperty("pluginName")) {
|
||||||
loader.item.pluginName = box.currentText
|
loader.item.pluginName = box.currentText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,15 @@ Rectangle {
|
||||||
property int leftMargin: 75
|
property int leftMargin: 75
|
||||||
property string pluginName: ""
|
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 }
|
HifiConstants { id: hifi }
|
||||||
|
|
||||||
color: hifi.colors.baseGray
|
color: hifi.colors.baseGray
|
||||||
|
@ -53,6 +62,15 @@ Rectangle {
|
||||||
width: 15
|
width: 15
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (checked) {
|
||||||
|
headPuckBox.checked = false;
|
||||||
|
} else {
|
||||||
|
checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -66,6 +84,15 @@ Rectangle {
|
||||||
width: 15
|
width: 15
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (checked) {
|
||||||
|
headBox.checked = false;
|
||||||
|
} else {
|
||||||
|
checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -102,6 +129,15 @@ Rectangle {
|
||||||
width: 15
|
width: 15
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (checked) {
|
||||||
|
handPuckBox.checked = false;
|
||||||
|
} else {
|
||||||
|
checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -115,6 +151,15 @@ Rectangle {
|
||||||
width: 12
|
width: 12
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (checked) {
|
||||||
|
handBox.checked = false;
|
||||||
|
} else {
|
||||||
|
checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -151,6 +196,13 @@ Rectangle {
|
||||||
width: 15
|
width: 15
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (hipsChecked) {
|
||||||
|
checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -173,6 +225,17 @@ Rectangle {
|
||||||
width: 15
|
width: 15
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (checked) {
|
||||||
|
feetBox.checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chestChecked) {
|
||||||
|
checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -202,6 +265,14 @@ Rectangle {
|
||||||
width: 15
|
width: 15
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (checked) {
|
||||||
|
hipBox.checked = true;
|
||||||
|
feetBox.checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
RalewayBold {
|
||||||
|
@ -231,6 +302,14 @@ Rectangle {
|
||||||
width: 15
|
width: 15
|
||||||
height: 15
|
height: 15
|
||||||
boxRadius: 7
|
boxRadius: 7
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (checked) {
|
||||||
|
hipBox.checked = true;
|
||||||
|
feetBox.checked = true;
|
||||||
|
}
|
||||||
|
composeConfigurationSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewayBold {
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -45,14 +45,25 @@ QString InputConfiguration::configurationLayout(QString pluginName) {
|
||||||
return sourcePath;
|
return sourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputConfiguration::configurationSettings(QJsonObject configurationSettings, QString pluginName) {
|
void InputConfiguration::setConfigurationSettings(QJsonObject configurationSettings, QString pluginName) {
|
||||||
qDebug() << configurationSettings["Test"];
|
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) {
|
void InputConfiguration::calibratePlugin(QString pluginName) {
|
||||||
for (auto plugin : PluginManager::getInstance()->getInputPlugins()) {
|
for (auto plugin : PluginManager::getInstance()->getInputPlugins()) {
|
||||||
if (plugin->getName() == pluginName) {
|
if (plugin->getName() == pluginName) {
|
||||||
//calibrtate plugin
|
plugin->calibrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputConfiguration::calibrated() {
|
||||||
|
}
|
||||||
|
|
|
@ -25,8 +25,10 @@ public:
|
||||||
Q_INVOKABLE QStringList inputPlugins();
|
Q_INVOKABLE QStringList inputPlugins();
|
||||||
Q_INVOKABLE QStringList activeInputPlugins();
|
Q_INVOKABLE QStringList activeInputPlugins();
|
||||||
Q_INVOKABLE QString configurationLayout(QString pluginName);
|
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 void calibratePlugin(QString pluginName);
|
||||||
|
Q_INVOKABLE QJsonObject configurationSettings(QString pluginName);
|
||||||
|
void calibrated();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,8 +26,9 @@ public:
|
||||||
// If an input plugin is only a single device, it will only return it's primary name.
|
// If an input plugin is only a single device, it will only return it's primary name.
|
||||||
virtual QStringList getSubdeviceNames() { return { getName() }; };
|
virtual QStringList getSubdeviceNames() { return { getName() }; };
|
||||||
virtual bool isHandController() const = 0;
|
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 QString configurationLayout() { return QString(); }
|
||||||
virtual void calibrate() {}
|
virtual bool calibrate() { return false; }
|
||||||
virtual bool configurable() { return false; }
|
virtual bool configurable() { return false; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,7 +120,18 @@ bool ViveControllerManager::isSupported() const {
|
||||||
return openVrSupported();
|
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() {
|
QString ViveControllerManager::configurationLayout() {
|
||||||
|
@ -281,6 +292,44 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle
|
||||||
_lastSimPoseData = _nextSimPoseData;
|
_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) {
|
void ViveControllerManager::InputDevice::handleTrackedObject(uint32_t deviceIndex, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
uint32_t poseIndex = controller::TRACKED_OBJECT_00 + deviceIndex;
|
uint32_t poseIndex = controller::TRACKED_OBJECT_00 + deviceIndex;
|
||||||
printDeviceTrackingResultChange(deviceIndex);
|
printDeviceTrackingResultChange(deviceIndex);
|
||||||
|
|
|
@ -44,7 +44,8 @@ public:
|
||||||
bool configurable() override { return true; }
|
bool configurable() override { return true; }
|
||||||
|
|
||||||
QString configurationLayout() override;
|
QString configurationLayout() override;
|
||||||
void configurationSettings(const QJsonObject configurationSettings) override;
|
void setConfigurationSettings(const QJsonObject configurationSettings) override;
|
||||||
|
QJsonObject configurationSettings() override;
|
||||||
|
|
||||||
bool activate() override;
|
bool activate() override;
|
||||||
void deactivate() override;
|
void deactivate() override;
|
||||||
|
@ -70,6 +71,8 @@ private:
|
||||||
void calibrateOrUncalibrate(const controller::InputCalibrationData& inputCalibration);
|
void calibrateOrUncalibrate(const controller::InputCalibrationData& inputCalibration);
|
||||||
void calibrate(const controller::InputCalibrationData& inputCalibration);
|
void calibrate(const controller::InputCalibrationData& inputCalibration);
|
||||||
void uncalibrate();
|
void uncalibrate();
|
||||||
|
void configureCalibrationSettings(const QJsonObject configurationSettings);
|
||||||
|
QJsonObject configurationSettings();
|
||||||
controller::Pose addOffsetToPuckPose(int joint) const;
|
controller::Pose addOffsetToPuckPose(int joint) const;
|
||||||
glm::mat4 recalculateDefaultToReferenceForHeadPuck(const controller::InputCalibrationData& inputCalibration);
|
glm::mat4 recalculateDefaultToReferenceForHeadPuck(const controller::InputCalibrationData& inputCalibration);
|
||||||
void updateCalibratedLimbs();
|
void updateCalibratedLimbs();
|
||||||
|
@ -128,10 +131,23 @@ private:
|
||||||
FeetHipsAndChest,
|
FeetHipsAndChest,
|
||||||
FeetHipsAndShoulders,
|
FeetHipsAndShoulders,
|
||||||
FeetHipsChestAndHead,
|
FeetHipsChestAndHead,
|
||||||
FeetHipsAndHead
|
FeetHipsAndHead,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class HeadConfig {
|
||||||
|
HMD,
|
||||||
|
Puck
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class HandConfig {
|
||||||
|
HandController,
|
||||||
|
Pucks
|
||||||
|
};
|
||||||
|
|
||||||
Config _config { Config::Auto };
|
Config _config { Config::Auto };
|
||||||
Config _preferedConfig { Config::Auto };
|
Config _preferedConfig { Config::Auto };
|
||||||
|
HeadConfig _headConfig { HeadConfig::HMD };
|
||||||
|
HandConfig _handConfig { HandConfig::HandController };
|
||||||
FilteredStick _filteredLeftStick;
|
FilteredStick _filteredLeftStick;
|
||||||
FilteredStick _filteredRightStick;
|
FilteredStick _filteredRightStick;
|
||||||
|
|
||||||
|
@ -157,6 +173,7 @@ private:
|
||||||
bool _timeTilCalibrationSet { false };
|
bool _timeTilCalibrationSet { false };
|
||||||
bool _calibrate { false };
|
bool _calibrate { false };
|
||||||
bool _overrideHead { false };
|
bool _overrideHead { false };
|
||||||
|
bool _overrideHands { false };
|
||||||
mutable std::recursive_mutex _lock;
|
mutable std::recursive_mutex _lock;
|
||||||
|
|
||||||
QString configToString(Config config);
|
QString configToString(Config config);
|
||||||
|
|
Loading…
Reference in a new issue