From 43746003678df348acdbee9aa866511ad9dd9bfc Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 19 Mar 2019 19:15:17 -0500 Subject: WiimoteEmu: Implement MotionPlus parameter y0 and other cleanups. --- Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp | 9 +++++++-- Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup') diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp index 5818f35d87..dd5bc87887 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -153,8 +154,7 @@ Cursor::StateData Cursor::GetState(const bool adjusted) // If auto-hide time is up or hide button is held: if (!m_auto_hide_timer || controls[6]->control_ref->State() > BUTTON_THRESHOLD) { - // TODO: Use NaN or something: - result.x = 10000; + result.x = std::numeric_limits::quiet_NaN(); result.y = 0; } @@ -176,4 +176,9 @@ ControlState Cursor::GetVerticalOffset() const return m_vertical_offset_setting.GetValue() / 100; } +bool Cursor::StateData::IsVisible() const +{ + return !std::isnan(x); +} + } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h index 7def851cc4..4b0d13eb6c 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h @@ -20,6 +20,8 @@ public: ControlState x{}; ControlState y{}; ControlState z{}; + + bool IsVisible() const; }; explicit Cursor(const std::string& name); -- cgit v1.2.3 From ba1b3351184864ed3d5692a461b00edd2f3a21f6 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 7 Apr 2019 07:57:04 -0500 Subject: WiimoteEmu: Improve emulated swing. --- .../ControllerEmu/ControlGroup/Force.cpp | 47 +++++++++++++++------- .../InputCommon/ControllerEmu/ControlGroup/Force.h | 8 ++-- 2 files changed, 38 insertions(+), 17 deletions(-) (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup') diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp index 93a9d06cb3..7ddbeba335 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp @@ -31,16 +31,30 @@ Force::Force(const std::string& name_) : ReshapableInput(name_, name_, GroupType _trans("cm"), // i18n: Refering to emulated wii remote swing movement. _trans("Distance of travel from neutral position.")}, - 25, 0, 100); - - AddSetting(&m_jerk_setting, - // i18n: "Jerk" as it relates to physics. The time derivative of acceleration. - {_trans("Jerk"), - // i18n: The symbol/abbreviation for meters per second to the 3rd power. - _trans("m/s³"), + 50, 1, 100); + + // These speed settings are used to calculate a maximum jerk (change in acceleration). + // The calculation uses a travel distance of 1 meter. + // The maximum value of 40 m/s is the approximate speed of the head of a golf club. + // Games seem to not even properly detect motions at this speed. + // Values result in an exponentially increasing jerk. + + AddSetting(&m_speed_setting, + {_trans("Speed"), + // i18n: The symbol/abbreviation for meters per second. + _trans("m/s"), + // i18n: Refering to emulated wii remote swing movement. + _trans("Peak velocity of outward swing movements.")}, + 16, 1, 40); + + // "Return Speed" allows for a "slow return" that won't trigger additional actions. + AddSetting(&m_return_speed_setting, + {_trans("Return Speed"), + // i18n: The symbol/abbreviation for meters per second. + _trans("m/s"), // i18n: Refering to emulated wii remote swing movement. - _trans("Maximum change in acceleration.")}, - 500, 1, 1000); + _trans("Peak velocity of movements to neutral position.")}, + 2, 1, 40); AddSetting(&m_angle_setting, {_trans("Angle"), @@ -48,7 +62,7 @@ Force::Force(const std::string& name_) : ReshapableInput(name_, name_, GroupType _trans("°"), // i18n: Refering to emulated wii remote swing movement. _trans("Rotation applied at extremities of swing.")}, - 45, 0, 180); + 90, 1, 180); } Force::ReshapeData Force::GetReshapableState(bool adjusted) @@ -70,8 +84,8 @@ Force::StateData Force::GetState(bool adjusted) if (adjusted) { - // Apply deadzone to z. - z = ApplyDeadzone(z, GetDeadzonePercentage()); + // Apply deadzone to z and scale. + z = ApplyDeadzone(z, GetDeadzonePercentage()) * GetMaxDistance(); } return {float(state.x), float(state.y), float(z)}; @@ -83,9 +97,14 @@ ControlState Force::GetGateRadiusAtAngle(double) const return GetMaxDistance(); } -ControlState Force::GetMaxJerk() const +ControlState Force::GetSpeed() const +{ + return m_speed_setting.GetValue(); +} + +ControlState Force::GetReturnSpeed() const { - return m_jerk_setting.GetValue(); + return m_return_speed_setting.GetValue(); } ControlState Force::GetTwistAngle() const diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h index da66dc034e..ae9cabe340 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h @@ -26,8 +26,9 @@ public: StateData GetState(bool adjusted = true); - // Return jerk in m/s^3. - ControlState GetMaxJerk() const; + // Velocities returned in m/s. + ControlState GetSpeed() const; + ControlState GetReturnSpeed() const; // Return twist angle in radians. ControlState GetTwistAngle() const; @@ -37,7 +38,8 @@ public: private: SettingValue m_distance_setting; - SettingValue m_jerk_setting; + SettingValue m_speed_setting; + SettingValue m_return_speed_setting; SettingValue m_angle_setting; }; -- cgit v1.2.3