| 637 | |
| 638 | |
| 639 | void Pad::LoadMacroButtonConfig(const SettingsInterface& si, u32 pad, const ControllerInfo* ci, const std::string& section) |
| 640 | { |
| 641 | for (u32 i = 0; i < NUM_MACRO_BUTTONS_PER_CONTROLLER; i++) |
| 642 | { |
| 643 | std::string binds_string; |
| 644 | if (!si.GetStringValue(section.c_str(), TinyString::from_format("Macro{}Binds", i + 1), &binds_string)) |
| 645 | continue; |
| 646 | |
| 647 | const u32 frequency = std::min<u32>(si.GetUIntValue(section.c_str(), |
| 648 | TinyString::from_format("Macro{}Frequency", i + 1), 0u), |
| 649 | std::numeric_limits<u16>::max()); |
| 650 | const float pressure = si.GetFloatValue(section.c_str(), TinyString::from_format("Macro{}Pressure", i + 1), 1.0f); |
| 651 | const bool toggle = si.GetBoolValue(section.c_str(), TinyString::from_format("Macro{}Toggle", i + 1), false); |
| 652 | |
| 653 | // convert binds |
| 654 | std::vector<u32> bind_indices; |
| 655 | std::vector<std::string_view> buttons_split(StringUtil::SplitString(binds_string, '&', true)); |
| 656 | if (buttons_split.empty()) |
| 657 | continue; |
| 658 | for (const std::string_view& button : buttons_split) |
| 659 | { |
| 660 | std::optional<u32> bind_index = ci->GetBindIndex(button); |
| 661 | if (!bind_index.has_value()) |
| 662 | { |
| 663 | Console.Error(fmt::format("Invalid bind '{}' in macro button {} for pad {}", button, i, pad)); |
| 664 | continue; |
| 665 | } |
| 666 | |
| 667 | bind_indices.push_back(bind_index.value()); |
| 668 | } |
| 669 | if (bind_indices.empty()) |
| 670 | continue; |
| 671 | |
| 672 | MacroButton& macro = s_macro_buttons[pad][i]; |
| 673 | macro.buttons = std::move(bind_indices); |
| 674 | macro.toggle_frequency = static_cast<u16>(frequency); |
| 675 | macro.pressure = pressure; |
| 676 | macro.trigger_toggle = toggle; |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | void Pad::SetMacroButtonState(InputBindingKey& key, u32 pad, u32 index, bool state) |
| 681 | { |
nothing calls this directly
no test coverage detected