summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2022-07-07 23:17:47 +0200
committerGitHub <noreply@github.com>2022-07-07 23:17:47 +0200
commiteccf527bf6f9dace6db78e4564a07a192de3edac (patch)
treee17bd4070aed74bab795574a9e9ce91533532697 /Source
parentccdb909d06eee9b5f7e1ccf808baed8619ac8717 (diff)
parent1fc86cacd7733a0f194f517ed17094abbaa7e240 (diff)
Merge pull request #9147 from jordan-woyak/imu-accel-weight-setting
WiimoteEmu: Expose IMU pointing accelerometer weight setting.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp15
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.h3
3 files changed, 20 insertions, 2 deletions
diff --git a/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp b/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp
index f4c31ec7a8..4b4109a119 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp
@@ -320,10 +320,10 @@ void EmulateIMUCursor(IMUCursorState* state, ControllerEmu::IMUCursor* imu_ir_gr
state->rotation = gyro_rotation * state->rotation;
// If we have some non-zero accel data use it to adjust gyro drift.
- constexpr auto ACCEL_WEIGHT = 0.02f;
+ const auto accel_weight = imu_ir_group->GetAccelWeight();
auto const accel = imu_accelerometer_group->GetState().value_or(Common::Vec3{});
if (accel.LengthSquared())
- state->rotation = ComplementaryFilter(state->rotation, accel, ACCEL_WEIGHT);
+ state->rotation = ComplementaryFilter(state->rotation, accel, accel_weight);
// Clamp yaw within configured bounds.
const auto yaw = GetYaw(state->rotation);
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp
index 5ddbe05073..d7ff228a19 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp
@@ -38,6 +38,16 @@ IMUCursor::IMUCursor(std::string name_, std::string ui_name_)
// i18n: Refers to emulated wii remote movements.
_trans("Clamping of rotation about the yaw axis.")},
25, 0, 360);
+
+ AddSetting(&m_accel_weight_setting,
+ {// i18n: Percentage value of accelerometer data (complementary filter coefficient).
+ _trans("Accelerometer Influence"),
+ // i18n: The symbol/abbreviation for percent.
+ _trans("%"),
+ // i18n: Refers to a setting controling the influence of accelerometer data.
+ _trans("Influence of accelerometer data on pitch and roll. Higher values will reduce "
+ "drift at the cost of noise. Consider values between 1% and 3%.")},
+ 2, 0, 100);
}
ControlState IMUCursor::GetTotalYaw() const
@@ -45,4 +55,9 @@ ControlState IMUCursor::GetTotalYaw() const
return m_yaw_setting.GetValue() * MathUtil::TAU / 360;
}
+ControlState IMUCursor::GetAccelWeight() const
+{
+ return m_accel_weight_setting.GetValue() / 100;
+}
+
} // namespace ControllerEmu
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.h
index c599d05021..dac1479bc6 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.h
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.h
@@ -19,7 +19,10 @@ public:
// Yaw movement in radians.
ControlState GetTotalYaw() const;
+ ControlState GetAccelWeight() const;
+
private:
SettingValue<double> m_yaw_setting;
+ SettingValue<double> m_accel_weight_setting;
};
} // namespace ControllerEmu