DInputControllerInterface: Support half axis bindings

This commit is contained in:
Connor McLaughlin 2021-07-03 15:03:21 +10:00
parent 1da39bdb0b
commit b5baee7c8c
1 changed files with 15 additions and 9 deletions

View File

@ -371,17 +371,23 @@ bool DInputControllerInterface::HandleAxisEvent(u32 index, u32 axis, s32 value)
const AxisCallback& cb = m_controllers[index].axis_mapping[static_cast<u32>(axis)][AxisSide::Full];
if (cb)
{
// Extend triggers from a 0 - 1 range to a -1 - 1 range for consistency with other inputs
if (axis == 4 || axis == 5)
{
cb((f_value * 2.0f) - 1.0f);
}
else
{
cb(f_value);
}
cb(f_value);
return true;
}
else
{
const AxisCallback& positive_cb = m_controllers[index].axis_mapping[static_cast<u32>(axis)][AxisSide::Positive];
const AxisCallback& negative_cb = m_controllers[index].axis_mapping[static_cast<u32>(axis)][AxisSide::Negative];
if (positive_cb || negative_cb)
{
if (positive_cb)
positive_cb((f_value < 0.0f) ? 0.0f : f_value);
if (negative_cb)
negative_cb((f_value >= 0.0f) ? 0.0f : -f_value);
return true;
}
}
// set the other direction to false so large movements don't leave the opposite on
const bool outside_deadzone = (std::abs(f_value) >= m_controllers[index].deadzone);