diff options
Diffstat (limited to 'src/yuzu_cmd/config.cpp')
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 285 |
1 files changed, 256 insertions, 29 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index b456266a6..097c1fbe3 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -65,30 +65,271 @@ static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> | |||
| 65 | }, | 65 | }, |
| 66 | }}; | 66 | }}; |
| 67 | 67 | ||
| 68 | static const std::array<int, Settings::NativeMouseButton::NumMouseButtons> default_mouse_buttons = { | ||
| 69 | SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_APOSTROPHE, | ||
| 70 | SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, | ||
| 71 | }; | ||
| 72 | |||
| 73 | static const std::array<int, 0x8A> keyboard_keys = { | ||
| 74 | 0, | ||
| 75 | 0, | ||
| 76 | 0, | ||
| 77 | 0, | ||
| 78 | SDL_SCANCODE_A, | ||
| 79 | SDL_SCANCODE_B, | ||
| 80 | SDL_SCANCODE_C, | ||
| 81 | SDL_SCANCODE_D, | ||
| 82 | SDL_SCANCODE_E, | ||
| 83 | SDL_SCANCODE_F, | ||
| 84 | SDL_SCANCODE_G, | ||
| 85 | SDL_SCANCODE_H, | ||
| 86 | SDL_SCANCODE_I, | ||
| 87 | SDL_SCANCODE_J, | ||
| 88 | SDL_SCANCODE_K, | ||
| 89 | SDL_SCANCODE_L, | ||
| 90 | SDL_SCANCODE_M, | ||
| 91 | SDL_SCANCODE_N, | ||
| 92 | SDL_SCANCODE_O, | ||
| 93 | SDL_SCANCODE_P, | ||
| 94 | SDL_SCANCODE_Q, | ||
| 95 | SDL_SCANCODE_R, | ||
| 96 | SDL_SCANCODE_S, | ||
| 97 | SDL_SCANCODE_T, | ||
| 98 | SDL_SCANCODE_U, | ||
| 99 | SDL_SCANCODE_V, | ||
| 100 | SDL_SCANCODE_W, | ||
| 101 | SDL_SCANCODE_X, | ||
| 102 | SDL_SCANCODE_Y, | ||
| 103 | SDL_SCANCODE_Z, | ||
| 104 | SDL_SCANCODE_1, | ||
| 105 | SDL_SCANCODE_2, | ||
| 106 | SDL_SCANCODE_3, | ||
| 107 | SDL_SCANCODE_4, | ||
| 108 | SDL_SCANCODE_5, | ||
| 109 | SDL_SCANCODE_6, | ||
| 110 | SDL_SCANCODE_7, | ||
| 111 | SDL_SCANCODE_8, | ||
| 112 | SDL_SCANCODE_9, | ||
| 113 | SDL_SCANCODE_0, | ||
| 114 | SDL_SCANCODE_RETURN, | ||
| 115 | SDL_SCANCODE_ESCAPE, | ||
| 116 | SDL_SCANCODE_BACKSPACE, | ||
| 117 | SDL_SCANCODE_TAB, | ||
| 118 | SDL_SCANCODE_SPACE, | ||
| 119 | SDL_SCANCODE_MINUS, | ||
| 120 | SDL_SCANCODE_EQUALS, | ||
| 121 | SDL_SCANCODE_LEFTBRACKET, | ||
| 122 | SDL_SCANCODE_RIGHTBRACKET, | ||
| 123 | SDL_SCANCODE_BACKSLASH, | ||
| 124 | 0, | ||
| 125 | SDL_SCANCODE_SEMICOLON, | ||
| 126 | SDL_SCANCODE_APOSTROPHE, | ||
| 127 | SDL_SCANCODE_GRAVE, | ||
| 128 | SDL_SCANCODE_COMMA, | ||
| 129 | SDL_SCANCODE_PERIOD, | ||
| 130 | SDL_SCANCODE_SLASH, | ||
| 131 | SDL_SCANCODE_CAPSLOCK, | ||
| 132 | |||
| 133 | SDL_SCANCODE_F1, | ||
| 134 | SDL_SCANCODE_F2, | ||
| 135 | SDL_SCANCODE_F3, | ||
| 136 | SDL_SCANCODE_F4, | ||
| 137 | SDL_SCANCODE_F5, | ||
| 138 | SDL_SCANCODE_F6, | ||
| 139 | SDL_SCANCODE_F7, | ||
| 140 | SDL_SCANCODE_F8, | ||
| 141 | SDL_SCANCODE_F9, | ||
| 142 | SDL_SCANCODE_F10, | ||
| 143 | SDL_SCANCODE_F11, | ||
| 144 | SDL_SCANCODE_F12, | ||
| 145 | |||
| 146 | 0, | ||
| 147 | SDL_SCANCODE_SCROLLLOCK, | ||
| 148 | SDL_SCANCODE_PAUSE, | ||
| 149 | SDL_SCANCODE_INSERT, | ||
| 150 | SDL_SCANCODE_HOME, | ||
| 151 | SDL_SCANCODE_PAGEUP, | ||
| 152 | SDL_SCANCODE_DELETE, | ||
| 153 | SDL_SCANCODE_END, | ||
| 154 | SDL_SCANCODE_PAGEDOWN, | ||
| 155 | SDL_SCANCODE_RIGHT, | ||
| 156 | SDL_SCANCODE_LEFT, | ||
| 157 | SDL_SCANCODE_DOWN, | ||
| 158 | SDL_SCANCODE_UP, | ||
| 159 | |||
| 160 | SDL_SCANCODE_NUMLOCKCLEAR, | ||
| 161 | SDL_SCANCODE_KP_DIVIDE, | ||
| 162 | SDL_SCANCODE_KP_MULTIPLY, | ||
| 163 | SDL_SCANCODE_KP_MINUS, | ||
| 164 | SDL_SCANCODE_KP_PLUS, | ||
| 165 | SDL_SCANCODE_KP_ENTER, | ||
| 166 | SDL_SCANCODE_KP_1, | ||
| 167 | SDL_SCANCODE_KP_2, | ||
| 168 | SDL_SCANCODE_KP_3, | ||
| 169 | SDL_SCANCODE_KP_4, | ||
| 170 | SDL_SCANCODE_KP_5, | ||
| 171 | SDL_SCANCODE_KP_6, | ||
| 172 | SDL_SCANCODE_KP_7, | ||
| 173 | SDL_SCANCODE_KP_8, | ||
| 174 | SDL_SCANCODE_KP_9, | ||
| 175 | SDL_SCANCODE_KP_0, | ||
| 176 | SDL_SCANCODE_KP_PERIOD, | ||
| 177 | |||
| 178 | 0, | ||
| 179 | 0, | ||
| 180 | SDL_SCANCODE_POWER, | ||
| 181 | SDL_SCANCODE_KP_EQUALS, | ||
| 182 | |||
| 183 | SDL_SCANCODE_F13, | ||
| 184 | SDL_SCANCODE_F14, | ||
| 185 | SDL_SCANCODE_F15, | ||
| 186 | SDL_SCANCODE_F16, | ||
| 187 | SDL_SCANCODE_F17, | ||
| 188 | SDL_SCANCODE_F18, | ||
| 189 | SDL_SCANCODE_F19, | ||
| 190 | SDL_SCANCODE_F20, | ||
| 191 | SDL_SCANCODE_F21, | ||
| 192 | SDL_SCANCODE_F22, | ||
| 193 | SDL_SCANCODE_F23, | ||
| 194 | SDL_SCANCODE_F24, | ||
| 195 | |||
| 196 | 0, | ||
| 197 | SDL_SCANCODE_HELP, | ||
| 198 | SDL_SCANCODE_MENU, | ||
| 199 | 0, | ||
| 200 | 0, | ||
| 201 | 0, | ||
| 202 | 0, | ||
| 203 | 0, | ||
| 204 | 0, | ||
| 205 | 0, | ||
| 206 | 0, | ||
| 207 | 0, | ||
| 208 | 0, | ||
| 209 | 0, | ||
| 210 | 0, | ||
| 211 | SDL_SCANCODE_KP_COMMA, | ||
| 212 | SDL_SCANCODE_KP_LEFTPAREN, | ||
| 213 | SDL_SCANCODE_KP_RIGHTPAREN, | ||
| 214 | 0, | ||
| 215 | 0, | ||
| 216 | 0, | ||
| 217 | 0, | ||
| 218 | }; | ||
| 219 | |||
| 220 | static const std::array<int, 8> keyboard_mods{ | ||
| 221 | SDL_SCANCODE_LCTRL, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_LALT, SDL_SCANCODE_LGUI, | ||
| 222 | SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI, | ||
| 223 | }; | ||
| 224 | |||
| 68 | void Config::ReadValues() { | 225 | void Config::ReadValues() { |
| 69 | // Controls | 226 | // Controls |
| 227 | for (std::size_t p = 0; p < Settings::values.players.size(); ++p) { | ||
| 228 | const auto group = fmt::format("ControlsP{}", p); | ||
| 229 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | ||
| 230 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); | ||
| 231 | Settings::values.players[p].buttons[i] = | ||
| 232 | sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param); | ||
| 233 | if (Settings::values.players[p].buttons[i].empty()) | ||
| 234 | Settings::values.players[p].buttons[i] = default_param; | ||
| 235 | } | ||
| 236 | |||
| 237 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | ||
| 238 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( | ||
| 239 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], | ||
| 240 | default_analogs[i][3], default_analogs[i][4], 0.5f); | ||
| 241 | Settings::values.players[p].analogs[i] = | ||
| 242 | sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param); | ||
| 243 | if (Settings::values.players[p].analogs[i].empty()) | ||
| 244 | Settings::values.players[p].analogs[i] = default_param; | ||
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | Settings::values.mouse_enabled = | ||
| 249 | sdl2_config->GetBoolean("ControlsGeneral", "mouse_enabled", false); | ||
| 250 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 251 | std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); | ||
| 252 | Settings::values.mouse_buttons[i] = sdl2_config->Get( | ||
| 253 | "ControlsGeneral", std::string("mouse_") + Settings::NativeMouseButton::mapping[i], | ||
| 254 | default_param); | ||
| 255 | if (Settings::values.mouse_buttons[i].empty()) | ||
| 256 | Settings::values.mouse_buttons[i] = default_param; | ||
| 257 | } | ||
| 258 | |||
| 259 | Settings::values.motion_device = sdl2_config->Get( | ||
| 260 | "ControlsGeneral", "motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01"); | ||
| 261 | |||
| 262 | Settings::values.keyboard_enabled = | ||
| 263 | sdl2_config->GetBoolean("ControlsGeneral", "keyboard_enabled", false); | ||
| 264 | |||
| 265 | Settings::values.debug_pad_enabled = | ||
| 266 | sdl2_config->GetBoolean("ControlsGeneral", "debug_pad_enabled", false); | ||
| 70 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 267 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 71 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); | 268 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); |
| 72 | Settings::values.buttons[i] = | 269 | Settings::values.debug_pad_buttons[i] = sdl2_config->Get( |
| 73 | sdl2_config->Get("Controls", Settings::NativeButton::mapping[i], default_param); | 270 | "ControlsGeneral", std::string("debug_pad_") + Settings::NativeButton::mapping[i], |
| 74 | if (Settings::values.buttons[i].empty()) | 271 | default_param); |
| 75 | Settings::values.buttons[i] = default_param; | 272 | if (Settings::values.debug_pad_buttons[i].empty()) |
| 273 | Settings::values.debug_pad_buttons[i] = default_param; | ||
| 76 | } | 274 | } |
| 77 | 275 | ||
| 78 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | 276 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { |
| 79 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( | 277 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( |
| 80 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], | 278 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], |
| 81 | default_analogs[i][3], default_analogs[i][4], 0.5f); | 279 | default_analogs[i][3], default_analogs[i][4], 0.5f); |
| 82 | Settings::values.analogs[i] = | 280 | Settings::values.debug_pad_analogs[i] = sdl2_config->Get( |
| 83 | sdl2_config->Get("Controls", Settings::NativeAnalog::mapping[i], default_param); | 281 | "ControlsGeneral", std::string("debug_pad_") + Settings::NativeAnalog::mapping[i], |
| 84 | if (Settings::values.analogs[i].empty()) | 282 | default_param); |
| 85 | Settings::values.analogs[i] = default_param; | 283 | if (Settings::values.debug_pad_analogs[i].empty()) |
| 284 | Settings::values.debug_pad_analogs[i] = default_param; | ||
| 86 | } | 285 | } |
| 87 | 286 | ||
| 88 | Settings::values.motion_device = sdl2_config->Get( | 287 | Settings::values.touchscreen.enabled = |
| 89 | "Controls", "motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01"); | 288 | sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); |
| 90 | Settings::values.touch_device = | 289 | Settings::values.touchscreen.device = |
| 91 | sdl2_config->Get("Controls", "touch_device", "engine:emu_window"); | 290 | sdl2_config->Get("ControlsGeneral", "touch_device", "engine:emu_window"); |
| 291 | Settings::values.touchscreen.finger = | ||
| 292 | sdl2_config->GetInteger("ControlsGeneral", "touch_finger", 0); | ||
| 293 | Settings::values.touchscreen.rotation_angle = | ||
| 294 | sdl2_config->GetInteger("ControlsGeneral", "touch_angle", 0); | ||
| 295 | Settings::values.touchscreen.diameter_x = | ||
| 296 | sdl2_config->GetInteger("ControlsGeneral", "touch_diameter_x", 15); | ||
| 297 | Settings::values.touchscreen.diameter_y = | ||
| 298 | sdl2_config->GetInteger("ControlsGeneral", "touch_diameter_y", 15); | ||
| 299 | |||
| 300 | std::transform(keyboard_keys.begin(), keyboard_keys.end(), | ||
| 301 | Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam); | ||
| 302 | std::transform(keyboard_mods.begin(), keyboard_mods.end(), | ||
| 303 | Settings::values.keyboard_keys.begin() + | ||
| 304 | Settings::NativeKeyboard::LeftControlKey, | ||
| 305 | InputCommon::GenerateKeyboardParam); | ||
| 306 | std::transform(keyboard_mods.begin(), keyboard_mods.end(), | ||
| 307 | Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam); | ||
| 308 | |||
| 309 | // Data Storage | ||
| 310 | Settings::values.use_virtual_sd = | ||
| 311 | sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); | ||
| 312 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir, | ||
| 313 | sdl2_config->Get("Data Storage", "nand_directory", | ||
| 314 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir))); | ||
| 315 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir, | ||
| 316 | sdl2_config->Get("Data Storage", "sdmc_directory", | ||
| 317 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir))); | ||
| 318 | |||
| 319 | // System | ||
| 320 | Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false); | ||
| 321 | Settings::values.enable_nfc = sdl2_config->GetBoolean("System", "enable_nfc", true); | ||
| 322 | const auto size = sdl2_config->GetInteger("System", "users_size", 0); | ||
| 323 | |||
| 324 | Settings::values.current_user = std::clamp<int>( | ||
| 325 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); | ||
| 326 | |||
| 327 | const auto enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); | ||
| 328 | if (enabled) { | ||
| 329 | Settings::values.rng_seed = sdl2_config->GetInteger("System", "rng_seed", 0); | ||
| 330 | } else { | ||
| 331 | Settings::values.rng_seed = std::nullopt; | ||
| 332 | } | ||
| 92 | 333 | ||
| 93 | // Core | 334 | // Core |
| 94 | Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); | 335 | Settings::values.use_cpu_jit = sdl2_config->GetBoolean("Core", "use_cpu_jit", true); |
| @@ -114,23 +355,7 @@ void Config::ReadValues() { | |||
| 114 | Settings::values.audio_device_id = sdl2_config->Get("Audio", "output_device", "auto"); | 355 | Settings::values.audio_device_id = sdl2_config->Get("Audio", "output_device", "auto"); |
| 115 | Settings::values.volume = sdl2_config->GetReal("Audio", "volume", 1); | 356 | Settings::values.volume = sdl2_config->GetReal("Audio", "volume", 1); |
| 116 | 357 | ||
| 117 | // Data Storage | 358 | Settings::values.language_index = sdl2_config->GetInteger("System", "language_index", 1); |
| 118 | Settings::values.use_virtual_sd = | ||
| 119 | sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); | ||
| 120 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir, | ||
| 121 | sdl2_config->Get("Data Storage", "nand_directory", | ||
| 122 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir))); | ||
| 123 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir, | ||
| 124 | sdl2_config->Get("Data Storage", "sdmc_directory", | ||
| 125 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir))); | ||
| 126 | |||
| 127 | // System | ||
| 128 | Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false); | ||
| 129 | Settings::values.enable_nfc = sdl2_config->GetBoolean("System", "enable_nfc", true); | ||
| 130 | const auto size = sdl2_config->GetInteger("System", "users_size", 0); | ||
| 131 | |||
| 132 | Settings::values.current_user = std::clamp<int>( | ||
| 133 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); | ||
| 134 | 359 | ||
| 135 | // Miscellaneous | 360 | // Miscellaneous |
| 136 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); | 361 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); |
| @@ -141,6 +366,8 @@ void Config::ReadValues() { | |||
| 141 | Settings::values.gdbstub_port = | 366 | Settings::values.gdbstub_port = |
| 142 | static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689)); | 367 | static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689)); |
| 143 | Settings::values.program_args = sdl2_config->Get("Debugging", "program_args", ""); | 368 | Settings::values.program_args = sdl2_config->Get("Debugging", "program_args", ""); |
| 369 | Settings::values.dump_exefs = sdl2_config->GetBoolean("Debugging", "dump_exefs", false); | ||
| 370 | Settings::values.dump_nso = sdl2_config->GetBoolean("Debugging", "dump_nso", false); | ||
| 144 | 371 | ||
| 145 | // Web Service | 372 | // Web Service |
| 146 | Settings::values.enable_telemetry = | 373 | Settings::values.enable_telemetry = |