mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Remove unused parameter and extract branching behaviour
This commit is contained in:
parent
4ff5ff2772
commit
a05798b50a
@ -133,24 +133,18 @@ bool IMUGyroscope::CanCalibrate() const
|
||||
return ControlReference::GetInputGate();
|
||||
}
|
||||
|
||||
std::optional<IMUGyroscope::StateData> IMUGyroscope::GetState(bool update)
|
||||
std::optional<IMUGyroscope::StateData> IMUGyroscope::GetState()
|
||||
{
|
||||
if (!AreInputsBound())
|
||||
{
|
||||
if (update)
|
||||
{
|
||||
// Set calibration to zero.
|
||||
m_calibration = {};
|
||||
RestartCalibration();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
return AreInputsBound() ? GetStateInternal() : Reset();
|
||||
}
|
||||
|
||||
std::optional<IMUGyroscope::StateData> IMUGyroscope::GetStateInternal()
|
||||
{
|
||||
auto state = GetRawState();
|
||||
|
||||
// Alternatively we could open the control gate around GetRawState() while calibrating,
|
||||
// but that would imply background input would temporarily be treated differently for our controls
|
||||
if (update && CanCalibrate())
|
||||
if (CanCalibrate())
|
||||
UpdateCalibration(state);
|
||||
|
||||
state -= m_calibration;
|
||||
@ -162,6 +156,14 @@ std::optional<IMUGyroscope::StateData> IMUGyroscope::GetState(bool update)
|
||||
return state;
|
||||
}
|
||||
|
||||
std::nullopt_t IMUGyroscope::Reset()
|
||||
{
|
||||
// Set calibration to zero.
|
||||
m_calibration = {};
|
||||
RestartCalibration();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
ControlState IMUGyroscope::GetDeadzone() const
|
||||
{
|
||||
return m_deadzone_setting.GetValue() / 360 * MathUtil::TAU;
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
StateData GetRawState() const;
|
||||
// Also updates the state by default
|
||||
std::optional<StateData> GetState(bool update = true);
|
||||
std::optional<StateData> GetState();
|
||||
|
||||
// Value is in rad/s.
|
||||
ControlState GetDeadzone() const;
|
||||
@ -35,6 +35,8 @@ private:
|
||||
|
||||
bool AreInputsBound() const;
|
||||
bool CanCalibrate() const;
|
||||
std::nullopt_t Reset();
|
||||
std::optional<StateData> GetStateInternal();
|
||||
void RestartCalibration();
|
||||
void UpdateCalibration(const StateData&);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user