diff options
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp index 715ae89b5a..93a9d06cb3 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp @@ -71,8 +71,7 @@ Force::StateData Force::GetState(bool adjusted) if (adjusted) { // Apply deadzone to z. - const ControlState deadzone = GetDeadzonePercentage(); - z = std::copysign(std::max(0.0, std::abs(z) - deadzone) / (1.0 - deadzone), z); + z = ApplyDeadzone(z, GetDeadzonePercentage()); } return {float(state.x), float(state.y), float(z)}; @@ -105,4 +104,69 @@ ControlState Force::GetDefaultInputRadiusAtAngle(double) const return 1.0; } +Shake::Shake(const std::string& name_, ControlState default_intensity_scale) + : ControlGroup(name_, name_, GroupType::Shake) +{ + // i18n: Refers to a 3D axis (used when mapping motion controls) + controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("X"))); + // i18n: Refers to a 3D axis (used when mapping motion controls) + controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Y"))); + // i18n: Refers to a 3D axis (used when mapping motion controls) + controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Z"))); + + AddDeadzoneSetting(&m_deadzone_setting, 50); + + // Total travel distance in centimeters. + // Negative values can be used to reverse the initial direction of movement. + AddSetting(&m_intensity_setting, + // i18n: Refers to the intensity of shaking an emulated wiimote. + {_trans("Intensity"), + // i18n: The symbol/abbreviation for centimeters. + _trans("cm"), + // i18n: Refering to emulated wii remote movement. + _trans("Total travel distance.")}, + 10 * default_intensity_scale, -50, 50); + + // Approximate number of up/down movements in one second. + AddSetting(&m_frequency_setting, + // i18n: Refers to a number of actions per second in Hz. + {_trans("Frequency"), + // i18n: The symbol/abbreviation for hertz (cycles per second). + _trans("Hz"), + // i18n: Refering to emulated wii remote movement. + _trans("Number of shakes per second.")}, + 6, 1, 20); +} + +Shake::StateData Shake::GetState(bool adjusted) const +{ + const float x = controls[0]->control_ref->State(); + const float y = controls[1]->control_ref->State(); + const float z = controls[2]->control_ref->State(); + + StateData result = {x, y, z}; + + // FYI: Unadjusted values are used in UI. + if (adjusted) + for (auto& c : result.data) + c = ApplyDeadzone(c, GetDeadzone()); + + return result; +} + +ControlState Shake::GetDeadzone() const +{ + return m_deadzone_setting.GetValue() / 100; +} + +ControlState Shake::GetIntensity() const +{ + return m_intensity_setting.GetValue() / 100; +} + +ControlState Shake::GetFrequency() const +{ + return m_frequency_setting.GetValue(); +} + } // namespace ControllerEmu |
