diff options
Diffstat (limited to 'src/input_common/input_poller.cpp')
| -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: | |||
| 504 | 504 | ||
| 505 | class InputFromMotion final : public Common::Input::InputDevice { | 505 | class InputFromMotion final : public Common::Input::InputDevice { |
| 506 | public: | 506 | public: |
| 507 | explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, | 507 | explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, float gyro_threshold_, |
| 508 | InputEngine* input_engine_) | 508 | InputEngine* input_engine_) |
| 509 | : identifier(identifier_), motion_sensor(motion_sensor_), input_engine(input_engine_) { | 509 | : identifier(identifier_), motion_sensor(motion_sensor_), gyro_threshold(gyro_threshold_), |
| 510 | input_engine(input_engine_) { | ||
| 510 | UpdateCallback engine_callback{[this]() { OnChange(); }}; | 511 | UpdateCallback engine_callback{[this]() { OnChange(); }}; |
| 511 | const InputIdentifier input_identifier{ | 512 | const InputIdentifier input_identifier{ |
| 512 | .identifier = identifier, | 513 | .identifier = identifier, |
| @@ -525,8 +526,9 @@ public: | |||
| 525 | const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); | 526 | const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); |
| 526 | Common::Input::MotionStatus status{}; | 527 | Common::Input::MotionStatus status{}; |
| 527 | const Common::Input::AnalogProperties properties = { | 528 | const Common::Input::AnalogProperties properties = { |
| 528 | .deadzone = 0.001f, | 529 | .deadzone = 0.0f, |
| 529 | .range = 1.0f, | 530 | .range = 1.0f, |
| 531 | .threshold = gyro_threshold, | ||
| 530 | .offset = 0.0f, | 532 | .offset = 0.0f, |
| 531 | }; | 533 | }; |
| 532 | status.accel.x = {.raw_value = basic_motion.accel_x, .properties = properties}; | 534 | status.accel.x = {.raw_value = basic_motion.accel_x, .properties = properties}; |
| @@ -551,6 +553,7 @@ public: | |||
| 551 | private: | 553 | private: |
| 552 | const PadIdentifier identifier; | 554 | const PadIdentifier identifier; |
| 553 | const int motion_sensor; | 555 | const int motion_sensor; |
| 556 | const float gyro_threshold; | ||
| 554 | int callback_key; | 557 | int callback_key; |
| 555 | InputEngine* input_engine; | 558 | InputEngine* input_engine; |
| 556 | }; | 559 | }; |
| @@ -873,9 +876,11 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( | |||
| 873 | 876 | ||
| 874 | if (params.Has("motion")) { | 877 | if (params.Has("motion")) { |
| 875 | const auto motion_sensor = params.Get("motion", 0); | 878 | const auto motion_sensor = params.Get("motion", 0); |
| 879 | const auto gyro_threshold = params.Get("threshold", 0.007f); | ||
| 876 | input_engine->PreSetController(identifier); | 880 | input_engine->PreSetController(identifier); |
| 877 | input_engine->PreSetMotion(identifier, motion_sensor); | 881 | input_engine->PreSetMotion(identifier, motion_sensor); |
| 878 | return std::make_unique<InputFromMotion>(identifier, motion_sensor, input_engine.get()); | 882 | return std::make_unique<InputFromMotion>(identifier, motion_sensor, gyro_threshold, |
| 883 | input_engine.get()); | ||
| 879 | } | 884 | } |
| 880 | 885 | ||
| 881 | const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); | 886 | const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); |