| 718 | } |
| 719 | |
| 720 | bool JoyMapping::ParseMappingFromString(StringView mappingString, MappedJoystick& map, bool suppressErrors) |
| 721 | { |
| 722 | if (mappingString.empty() || mappingString[0] == '#') { |
| 723 | return false; |
| 724 | } |
| 725 | |
| 726 | auto sub = mappingString.partition(','); |
| 727 | sub[0] = sub[0].trimmed(); |
| 728 | if (sub[0].empty()) { |
| 729 | // Ignore malformed string comming from Steam Input (2024/08/13) |
| 730 | if (!mappingString.hasPrefix(",platform:"_s)) { |
| 731 | #if !defined(DEATH_DEBUG) |
| 732 | if (!suppressErrors) |
| 733 | #endif |
| 734 | { |
| 735 | LOGE("Invalid mapping string \"{}\"", mappingString); |
| 736 | } |
| 737 | } |
| 738 | return false; |
| 739 | } |
| 740 | |
| 741 | map.guid.fromString(sub[0]); |
| 742 | |
| 743 | sub = sub[2].partition(','); |
| 744 | sub[0] = sub[0].trimmed(); |
| 745 | if (sub[0].empty()) { |
| 746 | #if !defined(DEATH_DEBUG) |
| 747 | if (!suppressErrors) |
| 748 | #endif |
| 749 | { |
| 750 | LOGE("Invalid mapping string \"{}\"", mappingString); |
| 751 | } |
| 752 | return false; |
| 753 | } |
| 754 | |
| 755 | copyStringFirst(map.name, sub[0]); |
| 756 | |
| 757 | while (!sub[2].empty()) { |
| 758 | sub = sub[2].partition(','); |
| 759 | |
| 760 | auto keyValue = sub[0].partition(':'); |
| 761 | keyValue[0] = keyValue[0].trimmed(); |
| 762 | keyValue[2] = keyValue[2].trimmed(); |
| 763 | if (keyValue[0].empty()) { |
| 764 | #if !defined(DEATH_DEBUG) |
| 765 | if (!suppressErrors) |
| 766 | #endif |
| 767 | { |
| 768 | LOGE("Invalid mapping string \"{}\"", mappingString); |
| 769 | } |
| 770 | return false; |
| 771 | } |
| 772 | |
| 773 | if (keyValue[0] == "platform"_s) { |
| 774 | // Platform name |
| 775 | if (!ParsePlatformName(keyValue[2])) { |
| 776 | return false; |
| 777 | } |
nothing calls this directly
no test coverage detected