diff options
author | bunnei <bunneidev@gmail.com> | 2022-01-28 00:44:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 00:44:04 +0100 |
commit | 0dec42431fe0511e8277a95fb872c8af67450837 (patch) | |
tree | d2e4a7350ca7362b01e5ff6a16fd25f3fbdb279c /src/input_common | |
parent | Merge pull request #7783 from lioncash/abi-cexpr (diff) | |
parent | input_common: Add option to configure gyro threshold (diff) | |
download | yuzu-0dec42431fe0511e8277a95fb872c8af67450837.tar yuzu-0dec42431fe0511e8277a95fb872c8af67450837.tar.gz yuzu-0dec42431fe0511e8277a95fb872c8af67450837.tar.bz2 yuzu-0dec42431fe0511e8277a95fb872c8af67450837.tar.lz yuzu-0dec42431fe0511e8277a95fb872c8af67450837.tar.xz yuzu-0dec42431fe0511e8277a95fb872c8af67450837.tar.zst yuzu-0dec42431fe0511e8277a95fb872c8af67450837.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/input_poller.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 7b370335f..2f3c0735a 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp @@ -504,9 +504,10 @@ private: class InputFromMotion final : public Common::Input::InputDevice { public: - explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, + explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, float gyro_threshold_, InputEngine* input_engine_) - : identifier(identifier_), motion_sensor(motion_sensor_), input_engine(input_engine_) { + : identifier(identifier_), motion_sensor(motion_sensor_), gyro_threshold(gyro_threshold_), + input_engine(input_engine_) { UpdateCallback engine_callback{[this]() { OnChange(); }}; const InputIdentifier input_identifier{ .identifier = identifier, @@ -525,8 +526,9 @@ public: const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); Common::Input::MotionStatus status{}; const Common::Input::AnalogProperties properties = { - .deadzone = 0.001f, + .deadzone = 0.0f, .range = 1.0f, + .threshold = gyro_threshold, .offset = 0.0f, }; status.accel.x = {.raw_value = basic_motion.accel_x, .properties = properties}; @@ -551,6 +553,7 @@ public: private: const PadIdentifier identifier; const int motion_sensor; + const float gyro_threshold; int callback_key; InputEngine* input_engine; }; @@ -873,9 +876,11 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( if (params.Has("motion")) { const auto motion_sensor = params.Get("motion", 0); + const auto gyro_threshold = params.Get("threshold", 0.007f); input_engine->PreSetController(identifier); input_engine->PreSetMotion(identifier, motion_sensor); - return std::make_unique<InputFromMotion>(identifier, motion_sensor, input_engine.get()); + return std::make_unique<InputFromMotion>(identifier, motion_sensor, gyro_threshold, + input_engine.get()); } const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); |