MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / AddMappingsFromStringInternal

Method AddMappingsFromStringInternal

Sources/nCine/Input/JoyMapping.cpp:188–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.45
partitionMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected