WiimoteEmu: Expose maximum tilt acceleration.

This commit is contained in:
Jordan Woyak 2019-10-06 09:44:46 -05:00
parent b6545ea285
commit 260cefd60b
3 changed files with 20 additions and 5 deletions

View File

@ -91,12 +91,9 @@ void EmulateTilt(RotationalState* state, ControllerEmu::Tilt* const tilt_group,
const ControlState roll = target.x * MathUtil::PI; const ControlState roll = target.x * MathUtil::PI;
const ControlState pitch = target.y * MathUtil::PI; const ControlState pitch = target.y * MathUtil::PI;
// Higher values will be more responsive but will increase rate of M+ "desync". const auto max_accel = std::pow(tilt_group->GetMaxRotationalVelocity(), 2) / MathUtil::TAU;
// I'd rather not expose this value in the UI if not needed.
// Desync caused by tilt seems not as severe as accelerometer data can estimate pitch/yaw.
constexpr auto MAX_ACCEL = float(MathUtil::TAU * 50);
ApproachAngleWithAccel(state, Common::Vec3(pitch, -roll, 0), MAX_ACCEL, time_elapsed); ApproachAngleWithAccel(state, Common::Vec3(pitch, -roll, 0), max_accel, time_elapsed);
} }
void EmulateSwing(MotionState* state, ControllerEmu::Force* swing_group, float time_elapsed) void EmulateSwing(MotionState* state, ControllerEmu::Force* swing_group, float time_elapsed)

View File

@ -7,6 +7,7 @@
#include <string> #include <string>
#include "Common/Common.h" #include "Common/Common.h"
#include "Common/MathUtil.h"
#include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/Control/Control.h"
@ -31,6 +32,14 @@ Tilt::Tilt(const std::string& name_) : ReshapableInput(name_, name_, GroupType::
// i18n: Refers to emulated wii remote movement. // i18n: Refers to emulated wii remote movement.
_trans("Maximum tilt angle.")}, _trans("Maximum tilt angle.")},
90, 0, 180); 90, 0, 180);
AddSetting(&m_max_rotational_velocity,
{_trans("Velocity"),
// i18n: The symbol/abbreviation for hertz (cycles per second).
_trans("Hz"),
// i18n: Refers to emulated wii remote movement.
_trans("Peak complete turns per second.")},
7, 1, 50);
} }
Tilt::ReshapeData Tilt::GetReshapableState(bool adjusted) Tilt::ReshapeData Tilt::GetReshapableState(bool adjusted)
@ -63,4 +72,9 @@ ControlState Tilt::GetDefaultInputRadiusAtAngle(double ang) const
return SquareStickGate(1.0).GetRadiusAtAngle(ang); return SquareStickGate(1.0).GetRadiusAtAngle(ang);
} }
ControlState Tilt::GetMaxRotationalVelocity() const
{
return m_max_rotational_velocity.GetValue() * MathUtil::TAU;
}
} // namespace ControllerEmu } // namespace ControllerEmu

View File

@ -28,7 +28,11 @@ public:
StateData GetState(); StateData GetState();
// Return peak rotational velocity (for a complete turn) in radians/sec
ControlState GetMaxRotationalVelocity() const;
private: private:
SettingValue<double> m_max_angle_setting; SettingValue<double> m_max_angle_setting;
SettingValue<double> m_max_rotational_velocity;
}; };
} // namespace ControllerEmu } // namespace ControllerEmu