| 999 | } |
| 1000 | |
| 1001 | void InputManager::AddUSBBindings(SettingsInterface& si, u32 port, bool is_profile) |
| 1002 | { |
| 1003 | const std::string device(USB::GetConfigDevice(si, port)); |
| 1004 | if (device.empty() || device == "None") |
| 1005 | return; |
| 1006 | |
| 1007 | const std::string section(USB::GetConfigSection(port)); |
| 1008 | const u32 subtype = USB::GetConfigSubType(si, port, device); |
| 1009 | for (const InputBindingInfo& bi : USB::GetDeviceBindings(device, subtype)) |
| 1010 | { |
| 1011 | const std::string bind_name(USB::GetConfigSubKey(device, bi.name)); |
| 1012 | |
| 1013 | switch (bi.bind_type) |
| 1014 | { |
| 1015 | case InputBindingInfo::Type::Button: |
| 1016 | case InputBindingInfo::Type::Axis: |
| 1017 | case InputBindingInfo::Type::HalfAxis: |
| 1018 | { |
| 1019 | // normal bindings |
| 1020 | const std::vector<std::string> bindings(si.GetStringList(section.c_str(), bind_name.c_str())); |
| 1021 | if (!bindings.empty()) |
| 1022 | { |
| 1023 | const float sensitivity = si.GetFloatValue(section.c_str(), fmt::format("{}Scale", bi.name).c_str(), 1.0f); |
| 1024 | const float deadzone = si.GetFloatValue(section.c_str(), fmt::format("{}Deadzone", bi.name).c_str(), 0.0f); |
| 1025 | AddBindings( |
| 1026 | bindings, InputAxisEventHandler{[port, bind_index = bi.bind_index, sensitivity, deadzone](InputBindingKey key, float value) { |
| 1027 | USB::SetDeviceBindValue(port, bind_index, ApplySingleBindingScale(sensitivity, deadzone, value)); |
| 1028 | }}, |
| 1029 | bi.bind_type, si, section.c_str(), bind_name.c_str(), is_profile); |
| 1030 | } |
| 1031 | } |
| 1032 | break; |
| 1033 | |
| 1034 | case InputBindingInfo::Type::Keyboard: |
| 1035 | { |
| 1036 | // set up to receive keyboard events |
| 1037 | s_keyboard_event_callbacks.push_back([port, base = static_cast<u32>(bi.bind_index)](InputBindingKey key, float value) { |
| 1038 | USB::SetDeviceBindValue(port, base + key.data, value); |
| 1039 | }); |
| 1040 | } |
| 1041 | break; |
| 1042 | |
| 1043 | case InputBindingInfo::Type::Pointer: |
| 1044 | { |
| 1045 | const std::vector<std::string> bindings(si.GetStringList(section.c_str(), bind_name.c_str())); |
| 1046 | for (const std::string& binding : bindings) |
| 1047 | { |
| 1048 | const std::optional<u32> key(GetIndexFromPointerBinding(binding)); |
| 1049 | if (!key.has_value()) |
| 1050 | continue; |
| 1051 | |
| 1052 | s_pointer_move_callbacks.emplace_back(key.value(), [port, base = bi.bind_index](InputBindingKey key, float value) { |
| 1053 | USB::SetDeviceBindValue(port, base + key.data, value); |
| 1054 | }); |
| 1055 | } |
| 1056 | } |
| 1057 | break; |
| 1058 |
nothing calls this directly
no test coverage detected