From c970740d1260e40e8c41965a99c59d602df2e63f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 24 Nov 2024 21:54:43 +1000 Subject: [PATCH] InputManager: Workaround macro chord trigger issue --- src/util/input_manager.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/util/input_manager.cpp b/src/util/input_manager.cpp index 4231cdade..e088a899a 100644 --- a/src/util/input_manager.cpp +++ b/src/util/input_manager.cpp @@ -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); - const bool state = (value > deadzone); - SetMacroButtonState(pad_index, macro_button_index, state); - }}); + 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); + }}); + } + } } }