| 83 | } |
| 84 | |
| 85 | static void parse_renderer_settings(BootConfig *config, const char *json) |
| 86 | { |
| 87 | TempAllocator1024 ta; |
| 88 | JsonObject renderer(ta); |
| 89 | sjson::parse(renderer, json); |
| 90 | |
| 91 | auto cur = json_object::begin(renderer); |
| 92 | auto end = json_object::end(renderer); |
| 93 | for (; cur != end; ++cur) { |
| 94 | JSON_OBJECT_SKIP_HOLE(renderer, cur); |
| 95 | |
| 96 | if (cur->first == "resolution") { |
| 97 | JsonArray resolution(ta); |
| 98 | sjson::parse_array(resolution, cur->second); |
| 99 | config->window_w = sjson::parse_int(resolution[0]); |
| 100 | config->window_h = sjson::parse_int(resolution[1]); |
| 101 | } else if (cur->first == "aspect_ratio") { |
| 102 | config->aspect_ratio = sjson::parse_float(cur->second); |
| 103 | } else if (cur->first == "device_id") { |
| 104 | DynamicString hex(ta); |
| 105 | sjson::parse_string(hex, cur->second); |
| 106 | s64 id; |
| 107 | from_hex(id, hex.c_str()); |
| 108 | config->device_id = (u16)id; |
| 109 | } else if (cur->first == "type") { |
| 110 | DynamicString renderer_type(ta); |
| 111 | sjson::parse_string(renderer_type, cur->second); |
| 112 | config->renderer_type = renderer_type_from_name(renderer_type.c_str()); |
| 113 | if (config->renderer_type == RendererType::COUNT) { |
| 114 | logw(BOOT_CONFIG |
| 115 | , "Unknown renderer type '%s'" |
| 116 | , renderer_type.c_str() |
| 117 | ); |
| 118 | config->renderer_type = RendererType::AUTO; |
| 119 | } |
| 120 | } else if (cur->first == "vsync") { |
| 121 | config->vsync = sjson::parse_bool(cur->second); |
| 122 | } else if (cur->first == "fullscreen") { |
| 123 | config->fullscreen = sjson::parse_bool(cur->second); |
| 124 | } else { |
| 125 | logw(BOOT_CONFIG |
| 126 | , "Unknown renderer property '%.*s'" |
| 127 | , cur->first.length() |
| 128 | , cur->first.data() |
| 129 | ); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | static void parse_platform_settings(BootConfig *config, const char *json) |
| 135 | { |
no test coverage detected