Skip to content

Commit

Permalink
InputManager: Workaround macro chord trigger issue
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Nov 24, 2024
1 parent e987b56 commit c970740
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/util/input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,13 +904,32 @@ void InputManager::AddPadBindings(const SettingsInterface& si, const std::string
{
const float deadzone =
si.GetFloatValue(section.c_str(), fmt::format("Macro{}Deadzone", macro_button_index + 1).c_str(), 0.0f);
AddBindings(bindings, InputAxisEventHandler{[pad_index, macro_button_index, deadzone](float value) {
if (!System::IsValid())
return;
for (const std::string& binding : bindings)
{
// We currently can't use chords with a deadzone.
if (binding.find('&') != std::string::npos || deadzone == 0.0f)
{
if (deadzone != 0.0f)
WARNING_LOG("Chord binding {} not supported with trigger deadzone {}.", binding, deadzone);

AddBinding(binding, InputButtonEventHandler{[pad_index, macro_button_index](bool state) {
if (!System::IsValid())
return;

SetMacroButtonState(pad_index, macro_button_index, state);
}});
}
else
{
AddBindings(bindings, InputAxisEventHandler{[pad_index, macro_button_index, deadzone](float value) {
if (!System::IsValid())
return;

const bool state = (value > deadzone);
SetMacroButtonState(pad_index, macro_button_index, state);
}});
const bool state = (value > deadzone);
SetMacroButtonState(pad_index, macro_button_index, state);
}});
}
}
}
}

Expand Down

0 comments on commit c970740

Please sign in to comment.