From 260cefd60b4fea09007e695819c018dd6171d0b1 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 6 Oct 2019 09:44:46 -0500 Subject: [PATCH 1/3] WiimoteEmu: Expose maximum tilt acceleration. --- Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp | 7 ++----- .../ControllerEmu/ControlGroup/Tilt.cpp | 14 ++++++++++++++ .../InputCommon/ControllerEmu/ControlGroup/Tilt.h | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp b/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp index d012832d45..bc766ce5b1 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp @@ -91,12 +91,9 @@ void EmulateTilt(RotationalState* state, ControllerEmu::Tilt* const tilt_group, const ControlState roll = target.x * MathUtil::PI; const ControlState pitch = target.y * MathUtil::PI; - // Higher values will be more responsive but will increase rate of M+ "desync". - // 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); + const auto max_accel = std::pow(tilt_group->GetMaxRotationalVelocity(), 2) / MathUtil::TAU; - 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) diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp index 91089455f8..debca37bd1 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp @@ -7,6 +7,7 @@ #include #include "Common/Common.h" +#include "Common/MathUtil.h" #include "InputCommon/ControlReference/ControlReference.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. _trans("Maximum tilt angle.")}, 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) @@ -63,4 +72,9 @@ ControlState Tilt::GetDefaultInputRadiusAtAngle(double ang) const return SquareStickGate(1.0).GetRadiusAtAngle(ang); } +ControlState Tilt::GetMaxRotationalVelocity() const +{ + return m_max_rotational_velocity.GetValue() * MathUtil::TAU; +} + } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.h index 68281083ea..929a0e2fb7 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.h @@ -28,7 +28,11 @@ public: StateData GetState(); + // Return peak rotational velocity (for a complete turn) in radians/sec + ControlState GetMaxRotationalVelocity() const; + private: SettingValue m_max_angle_setting; + SettingValue m_max_rotational_velocity; }; } // namespace ControllerEmu From 673f13b7ac5b6cc4d96f1b08b9c2dffe514fe62f Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 6 Oct 2019 09:46:51 -0500 Subject: [PATCH 2/3] WiimoteEmu: Change default tilt angle to 85 degrees. --- Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp index debca37bd1..c010c969fc 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp @@ -31,7 +31,7 @@ Tilt::Tilt(const std::string& name_) : ReshapableInput(name_, name_, GroupType:: _trans("°"), // i18n: Refers to emulated wii remote movement. _trans("Maximum tilt angle.")}, - 90, 0, 180); + 85, 0, 180); AddSetting(&m_max_rotational_velocity, {_trans("Velocity"), From b794737bcf5db7f941cb4741757607de31c3f953 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 6 Oct 2019 09:51:09 -0500 Subject: [PATCH 3/3] WiimoteEmu: Disable simulation of centripetal acceleration. --- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index b4d5eed7a6..c1f9663c7e 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -732,18 +732,6 @@ Common::Vec3 Wiimote::GetAcceleration() // Our shake effects have never been affected by orientation. Should they be? accel += m_shake_state.acceleration; - // Simulate centripetal acceleration caused by an offset of the accelerometer sensor. - // Estimate of sensor position based on an image of the wii remote board: - constexpr float ACCELEROMETER_Y_OFFSET = 0.1f; - - const auto angular_velocity = GetAngularVelocity(); - const auto centripetal_accel = - // TODO: Is this the proper way to combine the x and z angular velocities? - std::pow(std::abs(angular_velocity.x) + std::abs(angular_velocity.z), 2) * - ACCELEROMETER_Y_OFFSET; - - accel.y += centripetal_accel; - return accel; }