| 98 | } |
| 99 | |
| 100 | KeyChord inputDescriptorFromJson(Json const& json) { |
| 101 | Key key; |
| 102 | auto type = json.getString("type"); |
| 103 | if (type == "key") { |
| 104 | auto value = json.get("value"); |
| 105 | if (value.isType(Json::Type::String)) { |
| 106 | key = KeyNames.getLeft(value.toString()); |
| 107 | } else if (value.canConvert(Json::Type::Int)) { |
| 108 | key = (Key)value.toUInt(); |
| 109 | } else { |
| 110 | throw StarException::format("Improper key value '{}'", value); |
| 111 | } |
| 112 | } else { |
| 113 | throw StarException::format("Improper bindings type '{}'", type); |
| 114 | } |
| 115 | |
| 116 | KeyMod mods = KeyMod::NoMod; |
| 117 | for (auto mod : json.get("mods").iterateArray()) |
| 118 | mods |= KeyModNames.getLeft(mod.toString()); |
| 119 | |
| 120 | return {key, mods}; |
| 121 | } |
| 122 | |
| 123 | Json inputDescriptorToJson(KeyChord const& chord) { |
| 124 | JsonArray modNames; |
no test coverage detected