|
|
|
@ -1914,26 +1914,50 @@ bool CommonHostInterface::AddAxisToInputMap(const std::string& binding, const st
|
|
|
|
StringUtil::FromChars<int>(axis.substr(axis[0] == '+' || axis[0] == '-' ? 5 : 4));
|
|
|
|
StringUtil::FromChars<int>(axis.substr(axis[0] == '+' || axis[0] == '-' ? 5 : 4));
|
|
|
|
if (axis_index)
|
|
|
|
if (axis_index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
const bool inverted = StringUtil::EndsWith(axis, "-");
|
|
|
|
ControllerInterface::AxisSide axis_side = ControllerInterface::AxisSide::Full;
|
|
|
|
ControllerInterface::AxisSide axis_side = ControllerInterface::AxisSide::Full;
|
|
|
|
if (axis[0] == '+')
|
|
|
|
if (axis[0] == '+')
|
|
|
|
|
|
|
|
{
|
|
|
|
axis_side = ControllerInterface::AxisSide::Positive;
|
|
|
|
axis_side = ControllerInterface::AxisSide::Positive;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (axis[0] == '-')
|
|
|
|
else if (axis[0] == '-')
|
|
|
|
|
|
|
|
{
|
|
|
|
axis_side = ControllerInterface::AxisSide::Negative;
|
|
|
|
axis_side = ControllerInterface::AxisSide::Negative;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bool inverted = StringUtil::EndsWith(axis, "-");
|
|
|
|
if (axis_type == Controller::AxisType::Half && axis_side == ControllerInterface::Full)
|
|
|
|
if (!inverted)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_controller_interface->BindControllerAxis(*controller_index, *axis_index, axis_side, std::move(handler)))
|
|
|
|
// full axis [-1..1] -> half axis [0..1]
|
|
|
|
|
|
|
|
if (inverted)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_controller_interface->BindControllerAxis(
|
|
|
|
|
|
|
|
*controller_index, *axis_index, axis_side,
|
|
|
|
|
|
|
|
[cb = std::move(handler)](float value) { cb(((-value) + 1.0f) * 0.5f); });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
m_controller_interface->BindControllerAxis(
|
|
|
|
|
|
|
|
*controller_index, *axis_index, axis_side,
|
|
|
|
|
|
|
|
[cb = std::move(handler)](float value) { cb((value + 1.0f) * 0.5f); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_controller_interface->BindControllerAxis(*controller_index, *axis_index, axis_side,
|
|
|
|
if (!inverted)
|
|
|
|
[cb = std::move(handler)](float value) { cb(-value); }))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
if (m_controller_interface->BindControllerAxis(*controller_index, *axis_index, axis_side,
|
|
|
|
|
|
|
|
std::move(handler)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_controller_interface->BindControllerAxis(*controller_index, *axis_index, axis_side,
|
|
|
|
|
|
|
|
[cb = std::move(handler)](float value) { cb(-value); }))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|