mirror of https://github.com/PCSX2/pcsx2.git
SDLInputSource: Do not write offset joystick button/axis id into config
Also rename these bindings to avoid conflicts with binds
This commit is contained in:
parent
edd98128e7
commit
3bc658aaf6
|
@ -534,13 +534,13 @@ std::optional<InputBindingKey> SDLInputSource::ParseKeyString(const std::string_
|
||||||
// likely an axis
|
// likely an axis
|
||||||
const std::string_view axis_name(binding.substr(1));
|
const std::string_view axis_name(binding.substr(1));
|
||||||
|
|
||||||
if (axis_name.starts_with("Axis"))
|
if (axis_name.starts_with("JoyAxis"))
|
||||||
{
|
{
|
||||||
std::string_view end;
|
std::string_view end;
|
||||||
if (auto value = StringUtil::FromChars<u32>(axis_name.substr(4), 10, &end))
|
if (auto value = StringUtil::FromChars<u32>(axis_name.substr(7), 10, &end))
|
||||||
{
|
{
|
||||||
key.source_subtype = InputSubclass::ControllerAxis;
|
key.source_subtype = InputSubclass::ControllerAxis;
|
||||||
key.data = *value;
|
key.data = *value + std::size(s_sdl_axis_names);
|
||||||
key.modifier = (binding[0] == '-') ? InputModifier::Negate : InputModifier::None;
|
key.modifier = (binding[0] == '-') ? InputModifier::Negate : InputModifier::None;
|
||||||
key.invert = (end == "~");
|
key.invert = (end == "~");
|
||||||
return key;
|
return key;
|
||||||
|
@ -558,13 +558,13 @@ std::optional<InputBindingKey> SDLInputSource::ParseKeyString(const std::string_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (binding.starts_with("FullAxis"))
|
else if (binding.starts_with("FullJoyAxis"))
|
||||||
{
|
{
|
||||||
std::string_view end;
|
std::string_view end;
|
||||||
if (auto value = StringUtil::FromChars<u32>(binding.substr(8), 10, &end))
|
if (auto value = StringUtil::FromChars<u32>(binding.substr(11), 10, &end))
|
||||||
{
|
{
|
||||||
key.source_subtype = InputSubclass::ControllerAxis;
|
key.source_subtype = InputSubclass::ControllerAxis;
|
||||||
key.data = *value;
|
key.data = *value + std::size(s_sdl_axis_names);
|
||||||
key.modifier = InputModifier::FullAxis;
|
key.modifier = InputModifier::FullAxis;
|
||||||
key.invert = (end == "~");
|
key.invert = (end == "~");
|
||||||
return key;
|
return key;
|
||||||
|
@ -589,12 +589,12 @@ std::optional<InputBindingKey> SDLInputSource::ParseKeyString(const std::string_
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// must be a button
|
// must be a button
|
||||||
if (binding.starts_with("Button"))
|
if (binding.starts_with("JoyButton"))
|
||||||
{
|
{
|
||||||
if (auto value = StringUtil::FromChars<u32>(binding.substr(6)))
|
if (auto value = StringUtil::FromChars<u32>(binding.substr(9)))
|
||||||
{
|
{
|
||||||
key.source_subtype = InputSubclass::ControllerButton;
|
key.source_subtype = InputSubclass::ControllerButton;
|
||||||
key.data = *value;
|
key.data = *value + std::size(s_sdl_button_names);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -625,14 +625,14 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
|
||||||
if (key.data < std::size(s_sdl_axis_names))
|
if (key.data < std::size(s_sdl_axis_names))
|
||||||
ret.format("SDL-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_sdl_axis_names[key.data]);
|
ret.format("SDL-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_sdl_axis_names[key.data]);
|
||||||
else
|
else
|
||||||
ret.format("SDL-{}/{}Axis{}{}", static_cast<u32>(key.source_index), modifier, key.data, (key.invert && !ShouldIgnoreInversion()) ? "~" : "");
|
ret.format("SDL-{}/{}JoyAxis{}{}", static_cast<u32>(key.source_index), modifier, key.data - std::size(s_sdl_axis_names), (key.invert && !ShouldIgnoreInversion()) ? "~" : "");
|
||||||
}
|
}
|
||||||
else if (key.source_subtype == InputSubclass::ControllerButton)
|
else if (key.source_subtype == InputSubclass::ControllerButton)
|
||||||
{
|
{
|
||||||
if (key.data < std::size(s_sdl_button_names))
|
if (key.data < std::size(s_sdl_button_names))
|
||||||
ret.format("SDL-{}/{}", static_cast<u32>(key.source_index), s_sdl_button_names[key.data]);
|
ret.format("SDL-{}/{}", static_cast<u32>(key.source_index), s_sdl_button_names[key.data]);
|
||||||
else
|
else
|
||||||
ret.format("SDL-{}/Button{}", static_cast<u32>(key.source_index), key.data);
|
ret.format("SDL-{}/JoyButton{}", static_cast<u32>(key.source_index), key.data - std::size(s_sdl_button_names));
|
||||||
}
|
}
|
||||||
else if (key.source_subtype == InputSubclass::ControllerHat)
|
else if (key.source_subtype == InputSubclass::ControllerHat)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue