diff --git a/plugins/hifiLeapMotion/src/LeapMotionPlugin.cpp b/plugins/hifiLeapMotion/src/LeapMotionPlugin.cpp index 4d2cc474bd..34913cb415 100644 --- a/plugins/hifiLeapMotion/src/LeapMotionPlugin.cpp +++ b/plugins/hifiLeapMotion/src/LeapMotionPlugin.cpp @@ -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); + } +} diff --git a/plugins/hifiLeapMotion/src/LeapMotionPlugin.h b/plugins/hifiLeapMotion/src/LeapMotionPlugin.h index 60b476a443..7db4f4d8d7 100644 --- a/plugins/hifiLeapMotion/src/LeapMotionPlugin.h +++ b/plugins/hifiLeapMotion/src/LeapMotionPlugin.h @@ -59,6 +59,8 @@ protected: std::shared_ptr _inputDevice{ std::make_shared() }; private: + void applySensorLocation(); + Leap::Controller _controller; };