diff --git a/rpcs3/Emu/Io/PadHandler.cpp b/rpcs3/Emu/Io/PadHandler.cpp index b29d1195e5..65e54b23b4 100644 --- a/rpcs3/Emu/Io/PadHandler.cpp +++ b/rpcs3/Emu/Io/PadHandler.cpp @@ -130,14 +130,14 @@ u16 PadHandlerBase::NormalizeTriggerInput(u16 value, int threshold) // normalizes a directed input, meaning it will correspond to a single "button" and not an axis with two directions // the input values must lie in 0+ -u16 PadHandlerBase::NormalizeDirectedInput(u16 raw_value, s32 threshold, s32 maximum) +u16 PadHandlerBase::NormalizeDirectedInput(s32 raw_value, s32 threshold, s32 maximum) { if (threshold >= maximum || maximum <= 0) { return static_cast(0); } - float val = float(std::clamp(static_cast(raw_value), 0, maximum)) / float(maximum); // value based on max range converted to [0, 1] + float val = float(std::clamp(raw_value, 0, maximum)) / float(maximum); // value based on max range converted to [0, 1] if (threshold <= 0) { @@ -150,15 +150,17 @@ u16 PadHandlerBase::NormalizeDirectedInput(u16 raw_value, s32 threshold, s32 max } } -u16 PadHandlerBase::NormalizeStickInput(u16 raw_value, int threshold, bool ignore_threshold) +u16 PadHandlerBase::NormalizeStickInput(u16 raw_value, int threshold, int multiplier, bool ignore_threshold) { + const s32 scaled_value = (multiplier * raw_value) / 100; + if (ignore_threshold) { - return static_cast(ScaleStickInput(raw_value, 0, thumb_max)); + return static_cast(ScaleStickInput(scaled_value, 0, thumb_max)); } else { - return NormalizeDirectedInput(raw_value, threshold, thumb_max); + return NormalizeDirectedInput(scaled_value, threshold, thumb_max); } } diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index 01d710a4b5..4edfbd4315 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -346,6 +346,8 @@ struct pad_config final : cfg::node cfg::string l2 { this, "L2", "" }; cfg::string l3 { this, "L3", "" }; + cfg::_int<0, 200> lstickmultiplier{this, "Left Stick Multiplier", 100}; + cfg::_int<0, 200> rstickmultiplier{this, "Right Stick Multiplier", 100}; cfg::_int<0, 1000000> lstickdeadzone{ this, "Left Stick Deadzone", 0 }; cfg::_int<0, 1000000> rstickdeadzone{ this, "Right Stick Deadzone", 0 }; cfg::_int<0, 1000000> ltriggerthreshold{ this, "Left Trigger Threshold", 0 }; @@ -437,9 +439,9 @@ protected: // normalizes a directed input, meaning it will correspond to a single "button" and not an axis with two directions // the input values must lie in 0+ - u16 NormalizeDirectedInput(u16 raw_value, s32 threshold, s32 maximum); + u16 NormalizeDirectedInput(s32 raw_value, s32 threshold, s32 maximum); - u16 NormalizeStickInput(u16 raw_value, int threshold, bool ignore_threshold = false); + u16 NormalizeStickInput(u16 raw_value, int threshold, int multiplier, bool ignore_threshold = false); // This function normalizes stick deadzone based on the DS3's deadzone, which is ~13% // X and Y is expected to be in (-255) to 255 range, deadzone should be in terms of thumb stick range diff --git a/rpcs3/ds4_pad_handler.cpp b/rpcs3/ds4_pad_handler.cpp index 6c1e1f6cb4..41f01cf075 100644 --- a/rpcs3/ds4_pad_handler.cpp +++ b/rpcs3/ds4_pad_handler.cpp @@ -1,4 +1,4 @@ -#include "ds4_pad_handler.h" +#include "ds4_pad_handler.h" #include @@ -340,14 +340,14 @@ void ds4_pad_handler::TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, case DS4KeyCodes::LSYNeg: case DS4KeyCodes::LSYPos: pressed = val > (ignore_threshold ? 0 : p_profile->lstickdeadzone); - val = pressed ? NormalizeStickInput(val, p_profile->lstickdeadzone, ignore_threshold) : 0; + val = pressed ? NormalizeStickInput(val, p_profile->lstickdeadzone, p_profile->lstickmultiplier, ignore_threshold) : 0; break; case DS4KeyCodes::RSXNeg: case DS4KeyCodes::RSXPos: case DS4KeyCodes::RSYNeg: case DS4KeyCodes::RSYPos: pressed = val > (ignore_threshold ? 0 : p_profile->rstickdeadzone); - val = pressed ? NormalizeStickInput(val, p_profile->rstickdeadzone, ignore_threshold) : 0; + val = pressed ? NormalizeStickInput(val, p_profile->rstickdeadzone, p_profile->rstickmultiplier, ignore_threshold) : 0; break; default: // normal button (should in theory also support sensitive buttons) pressed = val > 0; diff --git a/rpcs3/evdev_joystick_handler.cpp b/rpcs3/evdev_joystick_handler.cpp index b4b8279ac4..a497ddf0ce 100644 --- a/rpcs3/evdev_joystick_handler.cpp +++ b/rpcs3/evdev_joystick_handler.cpp @@ -525,12 +525,12 @@ void evdev_joystick_handler::TranslateButtonPress(u64 keyCode, bool& pressed, u1 else if (checkButtons(m_dev.axis_left)) { pressed = value > (ignore_threshold ? 0 : profile->lstickdeadzone); - value = pressed ? NormalizeStickInput(value, profile->lstickdeadzone, ignore_threshold) : 0; + value = pressed ? NormalizeStickInput(value, profile->lstickdeadzone, profile->lstickmultiplier, ignore_threshold) : 0; } else if (checkButtons(m_dev.axis_right)) { pressed = value > (ignore_threshold ? 0 : profile->rstickdeadzone); - value = pressed ? NormalizeStickInput(value, profile->rstickdeadzone, ignore_threshold) : 0; + value = pressed ? NormalizeStickInput(value, profile->rstickdeadzone, profile->rstickmultiplier, ignore_threshold) : 0; } else // normal button (should in theory also support sensitive buttons) { diff --git a/rpcs3/mm_joystick_handler.cpp b/rpcs3/mm_joystick_handler.cpp index 88c1fcca09..4b4368697b 100644 --- a/rpcs3/mm_joystick_handler.cpp +++ b/rpcs3/mm_joystick_handler.cpp @@ -1,4 +1,4 @@ -#ifdef _WIN32 +#ifdef _WIN32 #include "mm_joystick_handler.h" mm_joystick_handler::mm_joystick_handler() : PadHandlerBase(pad_handler::mm) @@ -448,12 +448,12 @@ void mm_joystick_handler::TranslateButtonPress(u64 keyCode, bool& pressed, u16& else if (std::find(m_dev->axis_left.begin(), m_dev->axis_left.end(), keyCode) != m_dev->axis_left.end()) { pressed = val > (ignore_threshold ? 0 : p_profile->lstickdeadzone); - val = pressed ? NormalizeStickInput(val, p_profile->lstickdeadzone, ignore_threshold) : 0; + val = pressed ? NormalizeStickInput(val, p_profile->lstickdeadzone, p_profile->lstickmultiplier, ignore_threshold) : 0; } else if (std::find(m_dev->axis_right.begin(), m_dev->axis_right.end(), keyCode) != m_dev->axis_right.end()) { pressed = val > (ignore_threshold ? 0 : p_profile->rstickdeadzone); - val = pressed ? NormalizeStickInput(val, p_profile->rstickdeadzone, ignore_threshold) : 0; + val = pressed ? NormalizeStickInput(val, p_profile->rstickdeadzone, p_profile->rstickmultiplier, ignore_threshold) : 0; } else // normal button (should in theory also support sensitive buttons) { diff --git a/rpcs3/xinput_pad_handler.cpp b/rpcs3/xinput_pad_handler.cpp index 0436066e94..52772fde05 100644 --- a/rpcs3/xinput_pad_handler.cpp +++ b/rpcs3/xinput_pad_handler.cpp @@ -1,4 +1,4 @@ - + #ifdef _WIN32 #include "xinput_pad_handler.h" @@ -172,14 +172,14 @@ void xinput_pad_handler::TranslateButtonPress(u64 keyCode, bool& pressed, u16& v case XInputKeyCodes::LSYPos: case XInputKeyCodes::LSYNeg: pressed = val > (ignore_threshold ? 0 : p_profile->lstickdeadzone); - val = pressed ? NormalizeStickInput(val, p_profile->lstickdeadzone, ignore_threshold) : 0; + val = pressed ? NormalizeStickInput(val, p_profile->lstickdeadzone, p_profile->lstickmultiplier, ignore_threshold) : 0; break; case XInputKeyCodes::RSXNeg: case XInputKeyCodes::RSXPos: case XInputKeyCodes::RSYPos: case XInputKeyCodes::RSYNeg: pressed = val > (ignore_threshold ? 0 : p_profile->rstickdeadzone); - val = pressed ? NormalizeStickInput(val, p_profile->rstickdeadzone, ignore_threshold) : 0; + val = pressed ? NormalizeStickInput(val, p_profile->rstickdeadzone, p_profile->rstickmultiplier, ignore_threshold) : 0; break; default: // normal button (should in theory also support sensitive buttons) pressed = val > 0;