diff --git a/src/core/analog_controller.cpp b/src/core/analog_controller.cpp index 47aa2cdbb..7ab401652 100644 --- a/src/core/analog_controller.cpp +++ b/src/core/analog_controller.cpp @@ -353,7 +353,7 @@ void AnalogController::UpdateHostVibration() { // Curve from https://github.com/KrossX/Pokopom/blob/master/Pokopom/Input_XInput.cpp#L210 const u8 state = m_motor_state[motor]; - const double x = static_cast(std::min(state + static_cast(m_rumble_bias), 255)); + const double x = static_cast(std::clamp(static_cast(state) + m_vibration_bias[motor], 0, 255)); const double strength = 0.006474549734772402 * std::pow(x, 3.0) - 1.258165252213538 * std::pow(x, 2.0) + 156.82454281087692 * x + 3.637978807091713e-11; @@ -866,10 +866,18 @@ static const SettingInfo s_settings[] = { TRANSLATE_NOOP("AnalogController", "Sets the deadzone for activating buttons/triggers, " "i.e. the fraction of the trigger which will be ignored."), "0.25", "0.01", "1.00", "0.01", "%.0f%%", nullptr, 100.0f}, - {SettingInfo::Type::Integer, "VibrationBias", TRANSLATE_NOOP("AnalogController", "Vibration Bias"), - TRANSLATE_NOOP("AnalogController", "Sets the rumble bias value. If rumble in some games is too weak or not " - "functioning, try increasing this value."), - "8", "0", "255", "1", "%d", nullptr, 1.0f}, + {SettingInfo::Type::Integer, "LargeMotorVibrationBias", + TRANSLATE_NOOP("AnalogController", "Large Motor Vibration Bias"), + TRANSLATE_NOOP("AnalogController", + "Sets the bias value for the large vibration motor. If vibration in some games is too weak or not " + "functioning, try increasing this value. Negative values will decrease the intensity of vibration."), + "8", "-255", "255", "1", "%d", nullptr, 1.0f}, + {SettingInfo::Type::Integer, "SmallMotorVibrationBias", + TRANSLATE_NOOP("AnalogController", "Small Motor Vibration Bias"), + TRANSLATE_NOOP("AnalogController", + "Sets the bias value for the small vibration motor. If vibration in some games is too weak or not " + "functioning, try increasing this value. Negative values will decrease the intensity of vibration."), + "8", "-255", "255", "1", "%d", nullptr, 1.0f}, {SettingInfo::Type::IntegerList, "InvertLeftStick", TRANSLATE_NOOP("AnalogController", "Invert Left Stick"), TRANSLATE_NOOP("AnalogController", "Inverts the direction of the left analog stick."), "0", "0", "3", nullptr, nullptr, s_invert_settings, 0.0f}, @@ -895,7 +903,10 @@ void AnalogController::LoadSettings(SettingsInterface& si, const char* section, m_analog_sensitivity = std::clamp(si.GetFloatValue(section, "AnalogSensitivity", DEFAULT_STICK_SENSITIVITY), 0.01f, 3.0f); m_button_deadzone = std::clamp(si.GetFloatValue(section, "ButtonDeadzone", DEFAULT_BUTTON_DEADZONE), 0.01f, 1.0f); - m_rumble_bias = static_cast(std::min(si.GetIntValue(section, "VibrationBias", 8), 255)); + m_vibration_bias[0] = static_cast( + std::clamp(si.GetIntValue(section, "LargeMotorVibrationBias", DEFAULT_LARGE_MOTOR_VIBRATION_BIAS), -255, 255)); + m_vibration_bias[1] = static_cast( + std::clamp(si.GetIntValue(section, "SmallMotorVibrationBias", DEFAULT_SMALL_MOTOR_VIBRATION_BIAS), -255, 255)); m_invert_left_stick = static_cast(si.GetIntValue(section, "InvertLeftStick", 0)); m_invert_right_stick = static_cast(si.GetIntValue(section, "InvertRightStick", 0)); } diff --git a/src/core/analog_controller.h b/src/core/analog_controller.h index 0e6756fc7..eb6ceaea3 100644 --- a/src/core/analog_controller.h +++ b/src/core/analog_controller.h @@ -99,6 +99,9 @@ private: GetSetRumble // 0x4D }; + static constexpr s16 DEFAULT_SMALL_MOTOR_VIBRATION_BIAS = 8; + static constexpr s16 DEFAULT_LARGE_MOTOR_VIBRATION_BIAS = 8; + Command m_command = Command::Idle; int m_command_step = 0; @@ -122,14 +125,14 @@ private: void ResetRumbleConfig(); void SetMotorStateForConfigIndex(int index, u8 value); - bool m_force_analog_on_reset = false; - bool m_analog_dpad_in_digital_mode = false; float m_analog_deadzone = 0.0f; float m_analog_sensitivity = 1.33f; float m_button_deadzone = 0.0f; - u8 m_rumble_bias = 8; + std::array m_vibration_bias{DEFAULT_LARGE_MOTOR_VIBRATION_BIAS, DEFAULT_SMALL_MOTOR_VIBRATION_BIAS}; u8 m_invert_left_stick = 0; u8 m_invert_right_stick = 0; + bool m_force_analog_on_reset = false; + bool m_analog_dpad_in_digital_mode = false; bool m_analog_mode = false; bool m_analog_locked = false; diff --git a/src/core/negcon_rumble.cpp b/src/core/negcon_rumble.cpp index 2806133c2..53020556a 100644 --- a/src/core/negcon_rumble.cpp +++ b/src/core/negcon_rumble.cpp @@ -291,7 +291,7 @@ void NeGconRumble::UpdateHostVibration() { // Curve from https://github.com/KrossX/Pokopom/blob/master/Pokopom/Input_XInput.cpp#L210 const u8 state = m_motor_state[motor]; - const double x = static_cast(std::min(state + static_cast(m_rumble_bias), 255)); + const double x = static_cast(std::clamp(static_cast(state) + m_vibration_bias[motor], 0, 255)); const double strength = 0.006474549734772402 * std::pow(x, 3.0) - 1.258165252213538 * std::pow(x, 2.0) + 156.82454281087692 * x + 3.637978807091713e-11; @@ -757,6 +757,16 @@ static const SettingInfo s_settings[] = { {SettingInfo::Type::Float, "SteeringSensitivity", TRANSLATE_NOOP("NeGconRumble", "Steering Axis Sensitivity"), TRANSLATE_NOOP("NeGconRumble", "Sets the steering axis scaling factor."), "1.00f", "0.01f", "2.00f", "0.01f", "%.0f%%", nullptr, 100.0f}, + {SettingInfo::Type::Integer, "LargeMotorVibrationBias", TRANSLATE_NOOP("NeGconRumble", "Large Motor Vibration Bias"), + TRANSLATE_NOOP("NeGconRumble", + "Sets the bias value for the large vibration motor. If vibration in some games is too weak or not " + "functioning, try increasing this value. Negative values will decrease the intensity of vibration."), + "8", "-255", "255", "1", "%d", nullptr, 1.0f}, + {SettingInfo::Type::Integer, "SmallMotorVibrationBias", TRANSLATE_NOOP("NeGconRumble", "Small Motor Vibration Bias"), + TRANSLATE_NOOP("NeGconRumble", + "Sets the bias value for the small vibration motor. If vibration in some games is too weak or not " + "functioning, try increasing this value. Negative values will decrease the intensity of vibration."), + "8", "-255", "255", "1", "%d", nullptr, 1.0f}, }; const Controller::ControllerInfo NeGconRumble::INFO = {ControllerType::NeGconRumble, @@ -772,5 +782,8 @@ void NeGconRumble::LoadSettings(SettingsInterface& si, const char* section, bool Controller::LoadSettings(si, section, initial); m_steering_deadzone = si.GetFloatValue(section, "SteeringDeadzone", 0.10f); m_steering_sensitivity = si.GetFloatValue(section, "SteeringSensitivity", 1.00f); - m_rumble_bias = static_cast(std::min(si.GetIntValue(section, "VibrationBias", 8), 255)); + m_vibration_bias[0] = static_cast( + std::clamp(si.GetIntValue(section, "LargeMotorVibrationBias", DEFAULT_LARGE_MOTOR_VIBRATION_BIAS), -255, 255)); + m_vibration_bias[1] = static_cast( + std::clamp(si.GetIntValue(section, "SmallMotorVibrationBias", DEFAULT_SMALL_MOTOR_VIBRATION_BIAS), -255, 255)); } \ No newline at end of file diff --git a/src/core/negcon_rumble.h b/src/core/negcon_rumble.h index 25706dc6e..43141fea9 100644 --- a/src/core/negcon_rumble.h +++ b/src/core/negcon_rumble.h @@ -88,14 +88,17 @@ private: GetSetRumble // 0x4D }; - bool m_force_analog_on_reset = true; - bool m_analog_dpad_in_digital_mode = false; + static constexpr s16 DEFAULT_SMALL_MOTOR_VIBRATION_BIAS = 8; + static constexpr s16 DEFAULT_LARGE_MOTOR_VIBRATION_BIAS = 8; + float m_analog_deadzone = 0.0f; float m_analog_sensitivity = 1.33f; float m_button_deadzone = 0.0f; - u8 m_rumble_bias = 8; + std::array m_vibration_bias{DEFAULT_LARGE_MOTOR_VIBRATION_BIAS, DEFAULT_SMALL_MOTOR_VIBRATION_BIAS}; u8 m_invert_left_stick = 0; u8 m_invert_right_stick = 0; + bool m_force_analog_on_reset = true; + bool m_analog_dpad_in_digital_mode = false; bool m_analog_mode = false; bool m_analog_locked = false;