mirror of https://github.com/PCSX2/pcsx2.git
USB: Add deadzone for USB wheel steering axis
This commit is contained in:
parent
c00c125191
commit
1480d9ac20
|
@ -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<u16>::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<s16>(std::lroundf(value * static_cast<float>(steering_range)));
|
||||
const s16 deadzone_offset = static_cast<s16>(std::lroundf(value * static_cast<float>(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<s16>(std::lroundf(value * static_cast<float>(steering_range)));
|
||||
data.steering_left = ApplySteeringAxisDeadzone(value);
|
||||
UpdateSteering();
|
||||
break;
|
||||
|
||||
case CID_STEERING_R:
|
||||
data.steering_right = static_cast<s16>(std::lroundf(value * static_cast<float>(steering_range)));
|
||||
data.steering_right = ApplySteeringAxisDeadzone(value);
|
||||
UpdateSteering();
|
||||
break;
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue