mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
load and save shoulderConfig to settings.
This commit is contained in:
parent
bcb4cc32d2
commit
6c2b6674bb
3 changed files with 38 additions and 15 deletions
|
@ -1052,17 +1052,12 @@ Rectangle {
|
||||||
"Z": handZOffset.value
|
"Z": handZOffset.value
|
||||||
}
|
}
|
||||||
|
|
||||||
var shoulderObject = {
|
|
||||||
"override": shouldersChecked,
|
|
||||||
"armCircumference": armCircumference.value,
|
|
||||||
"shoulderWidth": shoulderWidth.value
|
|
||||||
}
|
|
||||||
|
|
||||||
var settingsObject = {
|
var settingsObject = {
|
||||||
"bodyConfiguration": trackerConfiguration,
|
"bodyConfiguration": trackerConfiguration,
|
||||||
"headConfiguration": headObject,
|
"headConfiguration": headObject,
|
||||||
"handConfiguration": handObject,
|
"handConfiguration": handObject,
|
||||||
"shoulderConfiguration": shoulderObject,
|
"armCircumference": armCircumference.value,
|
||||||
|
"shoulderWidth": shoulderWidth.value,
|
||||||
"desktopMode": viveInDesktop.checked
|
"desktopMode": viveInDesktop.checked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ void ViveControllerManager::setConfigurationSettings(const QJsonObject configura
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_inputDevice->configureCalibrationSettings(configurationSettings);
|
_inputDevice->configureCalibrationSettings(configurationSettings);
|
||||||
|
saveSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +188,8 @@ QString ViveControllerManager::configurationLayout() {
|
||||||
bool ViveControllerManager::activate() {
|
bool ViveControllerManager::activate() {
|
||||||
InputPlugin::activate();
|
InputPlugin::activate();
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
|
||||||
if (!_system) {
|
if (!_system) {
|
||||||
_system = acquireOpenVrSystem();
|
_system = acquireOpenVrSystem();
|
||||||
}
|
}
|
||||||
|
@ -229,6 +232,8 @@ void ViveControllerManager::deactivate() {
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
userInputMapper->removeDevice(_inputDevice->_deviceID);
|
userInputMapper->removeDevice(_inputDevice->_deviceID);
|
||||||
_registeredWithInputMapper = false;
|
_registeredWithInputMapper = false;
|
||||||
|
|
||||||
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViveControllerManager::isHeadControllerMounted() const {
|
bool ViveControllerManager::isHeadControllerMounted() const {
|
||||||
|
@ -281,7 +286,34 @@ void ViveControllerManager::pluginUpdate(float deltaTime, const controller::Inpu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const size_t CONTROLLER_HISTORY_SIZE = 90 * 3;
|
void ViveControllerManager::loadSettings() {
|
||||||
|
Settings settings;
|
||||||
|
QString nameString = getName();
|
||||||
|
settings.beginGroup(nameString);
|
||||||
|
{
|
||||||
|
if (_inputDevice) {
|
||||||
|
const double DEFAULT_ARM_CIRCUMFERENCE = 0.33;
|
||||||
|
const double DEFAULT_SHOULDER_WIDTH = 0.48;
|
||||||
|
_inputDevice->_armCircumference = settings.value("armCircumference", QVariant(DEFAULT_ARM_CIRCUMFERENCE)).toDouble();
|
||||||
|
_inputDevice->_shoulderWidth = settings.value("shoulderWidth", QVariant(DEFAULT_SHOULDER_WIDTH)).toDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViveControllerManager::saveSettings() const {
|
||||||
|
Settings settings;
|
||||||
|
QString nameString = getName();
|
||||||
|
settings.beginGroup(nameString);
|
||||||
|
{
|
||||||
|
if (_inputDevice) {
|
||||||
|
settings.setValue(QString("armCircumference"), _inputDevice->_armCircumference);
|
||||||
|
settings.setValue(QString("shoulderWidth"), _inputDevice->_shoulderWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) :
|
ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) :
|
||||||
controller::InputDevice("Vive"),
|
controller::InputDevice("Vive"),
|
||||||
|
@ -405,13 +437,6 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso
|
||||||
} else {
|
} else {
|
||||||
_handConfig = HandConfig::HandController;
|
_handConfig = HandConfig::HandController;
|
||||||
}
|
}
|
||||||
} else if (iter.key() == "shoulderConfiguration") {
|
|
||||||
QJsonObject shoulderObj = iter.value().toObject();
|
|
||||||
bool shouldersChecked = shoulderObj["override"].toBool();
|
|
||||||
if (shouldersChecked) {
|
|
||||||
_armCircumference = shoulderObj["armCircumference"].toDouble() * CM_TO_M;
|
|
||||||
_shoulderWidth = shoulderObj["shoulderWidth"].toDouble() * CM_TO_M;
|
|
||||||
}
|
|
||||||
} else if (iter.key() == "armCircumference") {
|
} else if (iter.key() == "armCircumference") {
|
||||||
_armCircumference = (float)iter.value().toDouble() * CM_TO_M;
|
_armCircumference = (float)iter.value().toDouble() * CM_TO_M;
|
||||||
} else if (iter.key() == "shoulderWidth") {
|
} else if (iter.key() == "shoulderWidth") {
|
||||||
|
|
|
@ -57,6 +57,9 @@ public:
|
||||||
|
|
||||||
void setRenderControllers(bool renderControllers) { _renderControllers = renderControllers; }
|
void setRenderControllers(bool renderControllers) { _renderControllers = renderControllers; }
|
||||||
|
|
||||||
|
virtual void saveSettings() const override;
|
||||||
|
virtual void loadSettings() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class InputDevice : public controller::InputDevice {
|
class InputDevice : public controller::InputDevice {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue