MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / LoadMacroButtonConfig

Method LoadMacroButtonConfig

pcsx2/SIO/Pad/Pad.cpp:639–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637
638
639void 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
680void Pad::SetMacroButtonState(InputBindingKey& key, u32 pad, u32 index, bool state)
681{

Callers

nothing calls this directly

Calls 13

GetBindIndexMethod · 0.80
maxFunction · 0.50
SplitStringFunction · 0.50
formatFunction · 0.50
GetStringValueMethod · 0.45
c_strMethod · 0.45
GetUIntValueMethod · 0.45
GetFloatValueMethod · 0.45
GetBoolValueMethod · 0.45
emptyMethod · 0.45
ErrorMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected