Apply sensor location setting

This commit is contained in:
David Rowe 2017-06-17 13:57:43 +12:00
parent 5de585e320
commit 8d84e86d19
2 changed files with 12 additions and 1 deletions

View file

@ -68,7 +68,7 @@ void LeapMotionPlugin::init() {
auto setter = [this](QString value) {
_sensorLocation = value;
saveSettings();
// TODO: Apply setting value.
applySensorLocation();
};
auto preference = new ComboBoxPreference(LEAPMOTION_PLUGIN, "Sensor location", getter, setter);
QStringList list = { SENSOR_ON_DESKTOP, SENSOR_ON_HMD };
@ -113,6 +113,7 @@ void LeapMotionPlugin::loadSettings() {
{
_enabled = settings.value(SETTINGS_ENABLED_KEY, QVariant(DEFAULT_ENABLED)).toBool();
_sensorLocation = settings.value(SETTINGS_SENSOR_LOCATION_KEY, QVariant(DEFAULT_SENSOR_LOCATION)).toString();
applySensorLocation();
}
settings.endGroup();
}
@ -120,3 +121,11 @@ void LeapMotionPlugin::loadSettings() {
void LeapMotionPlugin::InputDevice::clearState() {
// TODO
}
void LeapMotionPlugin::applySensorLocation() {
if (_sensorLocation == SENSOR_ON_HMD) {
_controller.setPolicyFlags(Leap::Controller::POLICY_OPTIMIZE_HMD);
} else {
_controller.setPolicyFlags(Leap::Controller::POLICY_DEFAULT);
}
}

View file

@ -59,6 +59,8 @@ protected:
std::shared_ptr<InputDevice> _inputDevice{ std::make_shared<InputDevice>() };
private:
void applySensorLocation();
Leap::Controller _controller;
};