summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2019-04-26 05:50:18 -0400
committerGitHub <noreply@github.com>2019-04-26 05:50:18 -0400
commit664376dae15ef187df4e4c8c7c5e241b9a68fb5d (patch)
tree0bbfa4617934f632156996a90922e232be1e7651 /Source/Core/InputCommon
parent057fa6c092fb10abb90a0f038d90c97a00731a59 (diff)
parentba1b3351184864ed3d5692a461b00edd2f3a21f6 (diff)
Merge pull request #7861 from jordan-woyak/mplus-emu
WiimoteEmu: Emulated MotionPlus and improved emulated swing.
Diffstat (limited to 'Source/Core/InputCommon')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp9
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h2
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp47
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h8
4 files changed, 47 insertions, 19 deletions
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 <algorithm>
#include <cmath>
+#include <limits>
#include <memory>
#include <string>
@@ -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<ControlState>::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);
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<double> m_distance_setting;
- SettingValue<double> m_jerk_setting;
+ SettingValue<double> m_speed_setting;
+ SettingValue<double> m_return_speed_setting;
SettingValue<double> m_angle_setting;
};