| 875 | } |
| 876 | |
| 877 | void InputManager::AddPadBindings(SettingsInterface& si, u32 pad_index, bool is_profile) |
| 878 | { |
| 879 | const Pad::ControllerType type = EmuConfig.Pad.Ports[pad_index].Type; |
| 880 | |
| 881 | // Don't bother checking macros/vibration if it's not a connected type. |
| 882 | if (type == Pad::ControllerType::NotConnected) |
| 883 | return; |
| 884 | |
| 885 | // Or if it's a multitap port, and this multitap isn't enabled. |
| 886 | if (sioPadIsMultitapSlot(pad_index)) |
| 887 | { |
| 888 | const auto& [mt_port, mt_slot] = sioConvertPadToPortAndSlot(pad_index); |
| 889 | if (!EmuConfig.Pad.IsMultitapPortEnabled(mt_port)) |
| 890 | return; |
| 891 | } |
| 892 | |
| 893 | const std::string section = Pad::GetConfigSection(pad_index); |
| 894 | const Pad::ControllerInfo* cinfo = Pad::GetControllerInfo(type); |
| 895 | pxAssert(cinfo); |
| 896 | |
| 897 | for (const InputBindingInfo& bi : cinfo->bindings) |
| 898 | { |
| 899 | switch (bi.bind_type) |
| 900 | { |
| 901 | case InputBindingInfo::Type::Button: |
| 902 | case InputBindingInfo::Type::Axis: |
| 903 | case InputBindingInfo::Type::HalfAxis: |
| 904 | { |
| 905 | const std::vector<std::string> bindings(si.GetStringList(section.c_str(), bi.name)); |
| 906 | if (!bindings.empty()) |
| 907 | { |
| 908 | // we use axes for all pad bindings to simplify things, and because they are pressure sensitive |
| 909 | const float sensitivity = si.GetFloatValue(section.c_str(), fmt::format("{}Scale", bi.name).c_str(), 1.0f); |
| 910 | const float deadzone = si.GetFloatValue(section.c_str(), fmt::format("{}Deadzone", bi.name).c_str(), 0.0f); |
| 911 | AddBindings( |
| 912 | bindings, InputAxisEventHandler{[pad_index, bind_index = bi.bind_index, sensitivity, deadzone](InputBindingKey key, float value) { |
| 913 | Pad::SetControllerState(pad_index, bind_index, ApplySingleBindingScale(sensitivity, deadzone, value)); |
| 914 | }}, |
| 915 | bi.bind_type, si, section.c_str(), bi.name, is_profile); |
| 916 | |
| 917 | // Build reverse maps for controller navigation; user bindings take priority over static defaults. |
| 918 | if (bi.generic_mapping != GenericInputBinding::Unknown) |
| 919 | { |
| 920 | for (const std::string& binding_str : bindings) |
| 921 | { |
| 922 | InputBindingKey bkey; |
| 923 | InputSource* bsrc; |
| 924 | if (!ParseBindingAndGetSource(binding_str, &bkey, &bsrc)) |
| 925 | continue; |
| 926 | |
| 927 | if (bkey.source_subtype == InputSubclass::ControllerButton) |
| 928 | { |
| 929 | s_controller_button_generic_map.emplace(bkey.MaskDirection(), bi.generic_mapping); |
| 930 | } |
| 931 | else if (bkey.source_subtype == InputSubclass::ControllerAxis) |
| 932 | { |
| 933 | auto& entry = s_controller_axis_generic_map[bkey.MaskDirection()]; |
| 934 | // Negate modifier = negative half of axis (e.g. "-Axis0" → LeftStickLeft) |
nothing calls this directly
no test coverage detected