diff --git a/pcsx2/USB/usb-pad/usb-pad.cpp b/pcsx2/USB/usb-pad/usb-pad.cpp index 385468b82c..920fd088b9 100644 --- a/pcsx2/USB/usb-pad/usb-pad.cpp +++ b/pcsx2/USB/usb-pad/usb-pad.cpp @@ -157,6 +157,9 @@ namespace usb_pad {SettingInfo::Type::Integer, "SteeringSmoothing", "Steering Smoothing", "Smooths out changes in steering to the specified percentage per poll. Needed for using keyboards.", "0", "0", "100", "1", "%d%%", nullptr, nullptr, 1.0f}, + {SettingInfo::Type::Integer, "SteeringDeadzone", "Steering Deadzone", + "Steering axis deadzone for pads or non self centering wheels.", + "0", "0", "100", "1", "%d%%", nullptr, nullptr, 1.0f}, }; return info; @@ -207,6 +210,8 @@ namespace usb_pad 1, std::numeric_limits::max())); } + steering_deadzone = (steering_range * USB::GetConfigInt(si, port, devname, "SteeringDeadzone", 0)) / 100; + if (HasFF()) { const std::string ffdevname(USB::GetConfigString(si, port, devname, "FFDevice")); @@ -439,17 +444,25 @@ namespace usb_pad } } + s16 PadState::ApplySteeringAxisDeadzone(float value) + { + const s16 raw_steering = static_cast(std::lroundf(value * static_cast(steering_range))); + const s16 deadzone_offset = static_cast(std::lroundf(value * static_cast(steering_deadzone))); + + return std::max((raw_steering - steering_deadzone + deadzone_offset ), 0); + } + void PadState::SetBindValue(u32 bind_index, float value) { switch (bind_index) { case CID_STEERING_L: - data.steering_left = static_cast(std::lroundf(value * static_cast(steering_range))); + data.steering_left = ApplySteeringAxisDeadzone(value); UpdateSteering(); break; case CID_STEERING_R: - data.steering_right = static_cast(std::lroundf(value * static_cast(steering_range))); + data.steering_right = ApplySteeringAxisDeadzone(value); UpdateSteering(); break; diff --git a/pcsx2/USB/usb-pad/usb-pad.h b/pcsx2/USB/usb-pad/usb-pad.h index befefef65b..8be446df2e 100644 --- a/pcsx2/USB/usb-pad/usb-pad.h +++ b/pcsx2/USB/usb-pad/usb-pad.h @@ -327,6 +327,8 @@ namespace usb_pad void OpenFFDevice(); void ParseFFData(const ff_data* ffdata, bool isDFP); + s16 ApplySteeringAxisDeadzone(float value); + USBDevice dev{}; USBDesc desc{}; USBDescDevice desc_dev{}; @@ -336,6 +338,7 @@ namespace usb_pad s16 steering_range = 0; u16 steering_step = 0; + s32 steering_deadzone = 0; struct {