summaryrefslogtreecommitdiff
path: root/src/input_common/input_poller.cpp
diff options
context:
space:
mode:
authorGravatar german772022-01-23 21:54:33 -0600
committerGravatar german772022-01-23 21:54:33 -0600
commitebf19616f4698700738656ae09b0d9705566b9a1 (patch)
treebc7d846c3eb77831678b3308a2a238b3a995f2ab /src/input_common/input_poller.cpp
parentMerge pull request #7761 from v1993/patch-8 (diff)
downloadyuzu-ebf19616f4698700738656ae09b0d9705566b9a1.tar.gz
yuzu-ebf19616f4698700738656ae09b0d9705566b9a1.tar.xz
yuzu-ebf19616f4698700738656ae09b0d9705566b9a1.zip
input_common: Add option to configure gyro threshold
Diffstat (limited to 'src/input_common/input_poller.cpp')
-rw-r--r--src/input_common/input_poller.cpp13
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
505class InputFromMotion final : public Common::Input::InputDevice { 505class InputFromMotion final : public Common::Input::InputDevice {
506public: 506public:
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:
551private: 553private:
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);