FullscreenUI: Support binding half axes

This commit is contained in:
Connor McLaughlin 2021-07-03 15:11:45 +10:00
parent f861fa40e5
commit 0d86d85752

View file

@ -150,6 +150,7 @@ enum class InputBindingType
None, None,
Button, Button,
Axis, Axis,
HalfAxis,
Rumble Rumble
}; };
@ -886,6 +887,9 @@ static void DrawInputBindingButton(InputBindingType type, const char* section, c
case InputBindingType::Axis: case InputBindingType::Axis:
title.Format(ICON_FA_BULLSEYE " %s Axis", display_name); title.Format(ICON_FA_BULLSEYE " %s Axis", display_name);
break; break;
case InputBindingType::HalfAxis:
title.Format(ICON_FA_SLIDERS_H " %s Half-Axis", display_name);
break;
case InputBindingType::Rumble: case InputBindingType::Rumble:
title.Format(ICON_FA_BELL " %s", display_name); title.Format(ICON_FA_BELL " %s", display_name);
break; break;
@ -980,6 +984,16 @@ void BeginInputBinding(InputBindingType type, const std::string_view& section, c
} }
break; break;
case InputBindingType::HalfAxis:
{
if (hook.type == ControllerInterface::Hook::Type::Axis)
{
value.Format("Controller%d/%cAxis%d", hook.controller_index,
(std::get<float>(hook.value) < 0.0f) ? '-' : '+', hook.button_or_axis_number);
}
}
break;
case InputBindingType::Button: case InputBindingType::Button:
{ {
if (hook.type == ControllerInterface::Hook::Type::Axis) if (hook.type == ControllerInterface::Hook::Type::Axis)
@ -1887,7 +1901,9 @@ void DrawSettingsWindow()
for (const auto& it : axis_cache[port]) for (const auto& it : axis_cache[port])
{ {
key.Format("Axis%s", std::get<0>(it).c_str()); key.Format("Axis%s", std::get<0>(it).c_str());
DrawInputBindingButton(InputBindingType::Axis, section, key, std::get<0>(it).c_str()); DrawInputBindingButton(std::get<2>(it) == Controller::AxisType::Half ? InputBindingType::HalfAxis :
InputBindingType::Axis,
section, key, std::get<0>(it).c_str());
} }
if (Controller::GetVibrationMotorCount(ctype) > 0) if (Controller::GetVibrationMotorCount(ctype) > 0)