| 186 | } |
| 187 | |
| 188 | bool JoyMapping::AddMappingsFromStringInternal(StringView mappingString, StringView traceSource) |
| 189 | { |
| 190 | std::int32_t parsedMappings = 0; |
| 191 | |
| 192 | StringView rest = mappingString; |
| 193 | while (!rest.empty()) { |
| 194 | auto split = rest.partition('\n'); |
| 195 | rest = split[2]; |
| 196 | |
| 197 | MappedJoystick newMapping; |
| 198 | if (ParseMappingFromString(split[0], newMapping, false)) { |
| 199 | std::int32_t index = FindMappingByGuid(newMapping.guid); |
| 200 | // if GUID is not found then mapping has to be added, not replaced |
| 201 | if (index < 0) { |
| 202 | mappings_.push_back(std::move(newMapping)); |
| 203 | } else { |
| 204 | mappings_[index] = std::move(newMapping); |
| 205 | } |
| 206 | parsedMappings++; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if (!traceSource.empty()) { |
| 211 | LOGI("Added {} gamepad mappings from {}", parsedMappings, traceSource); |
| 212 | } else { |
| 213 | LOGI("Added {} gamepad mappings", parsedMappings); |
| 214 | } |
| 215 | |
| 216 | return (parsedMappings > 0); |
| 217 | } |
| 218 | |
| 219 | bool JoyMapping::AddMappingsFromString(StringView mappingString) |
| 220 | { |