diff options
| author | 2016-12-21 23:49:36 -0500 | |
|---|---|---|
| committer | 2017-04-03 20:43:13 -0600 | |
| commit | 1631e99eed644bb9d313bc49ef6023ac3afe1e52 (patch) | |
| tree | 523eade6ec8d6779a4a55a46f1471079b88bf4f9 /src/citra_qt/config.cpp | |
| parent | Merge pull request #2622 from jfmherokiller/socufix (diff) | |
| download | yuzu-1631e99eed644bb9d313bc49ef6023ac3afe1e52.tar.gz yuzu-1631e99eed644bb9d313bc49ef6023ac3afe1e52.tar.xz yuzu-1631e99eed644bb9d313bc49ef6023ac3afe1e52.zip | |
citra-qt: Move config dialog code to its own directory
Diffstat (limited to 'src/citra_qt/config.cpp')
| -rw-r--r-- | src/citra_qt/config.cpp | 318 |
1 files changed, 0 insertions, 318 deletions
diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp deleted file mode 100644 index bf0ac7c66..000000000 --- a/src/citra_qt/config.cpp +++ /dev/null | |||
| @@ -1,318 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <QSettings> | ||
| 6 | #include "citra_qt/config.h" | ||
| 7 | #include "citra_qt/ui_settings.h" | ||
| 8 | #include "common/file_util.h" | ||
| 9 | #include "input_common/main.h" | ||
| 10 | |||
| 11 | Config::Config() { | ||
| 12 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | ||
| 13 | qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini"; | ||
| 14 | FileUtil::CreateFullPath(qt_config_loc); | ||
| 15 | qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); | ||
| 16 | |||
| 17 | Reload(); | ||
| 18 | } | ||
| 19 | |||
| 20 | const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { | ||
| 21 | Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, | ||
| 22 | Qt::Key_Q, Qt::Key_W, Qt::Key_M, Qt::Key_N, Qt::Key_1, Qt::Key_2, Qt::Key_B, | ||
| 23 | }; | ||
| 24 | |||
| 25 | const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> Config::default_analogs{{ | ||
| 26 | { | ||
| 27 | Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_D, | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | Qt::Key_I, Qt::Key_K, Qt::Key_J, Qt::Key_L, Qt::Key_D, | ||
| 31 | }, | ||
| 32 | }}; | ||
| 33 | |||
| 34 | void Config::ReadValues() { | ||
| 35 | qt_config->beginGroup("Controls"); | ||
| 36 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | ||
| 37 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); | ||
| 38 | Settings::values.buttons[i] = | ||
| 39 | qt_config | ||
| 40 | ->value(Settings::NativeButton::mapping[i], QString::fromStdString(default_param)) | ||
| 41 | .toString() | ||
| 42 | .toStdString(); | ||
| 43 | if (Settings::values.buttons[i].empty()) | ||
| 44 | Settings::values.buttons[i] = default_param; | ||
| 45 | } | ||
| 46 | |||
| 47 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | ||
| 48 | std::string default_param = InputCommon::GenerateAnalogParamFromKeys( | ||
| 49 | default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], | ||
| 50 | default_analogs[i][3], default_analogs[i][4], 0.5f); | ||
| 51 | Settings::values.analogs[i] = | ||
| 52 | qt_config | ||
| 53 | ->value(Settings::NativeAnalog::mapping[i], QString::fromStdString(default_param)) | ||
| 54 | .toString() | ||
| 55 | .toStdString(); | ||
| 56 | if (Settings::values.analogs[i].empty()) | ||
| 57 | Settings::values.analogs[i] = default_param; | ||
| 58 | } | ||
| 59 | |||
| 60 | qt_config->endGroup(); | ||
| 61 | |||
| 62 | qt_config->beginGroup("Core"); | ||
| 63 | Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool(); | ||
| 64 | qt_config->endGroup(); | ||
| 65 | |||
| 66 | qt_config->beginGroup("Renderer"); | ||
| 67 | Settings::values.use_hw_renderer = qt_config->value("use_hw_renderer", true).toBool(); | ||
| 68 | Settings::values.use_shader_jit = qt_config->value("use_shader_jit", true).toBool(); | ||
| 69 | Settings::values.resolution_factor = qt_config->value("resolution_factor", 1.0).toFloat(); | ||
| 70 | Settings::values.use_vsync = qt_config->value("use_vsync", false).toBool(); | ||
| 71 | Settings::values.toggle_framelimit = qt_config->value("toggle_framelimit", true).toBool(); | ||
| 72 | |||
| 73 | Settings::values.bg_red = qt_config->value("bg_red", 1.0).toFloat(); | ||
| 74 | Settings::values.bg_green = qt_config->value("bg_green", 1.0).toFloat(); | ||
| 75 | Settings::values.bg_blue = qt_config->value("bg_blue", 1.0).toFloat(); | ||
| 76 | qt_config->endGroup(); | ||
| 77 | |||
| 78 | qt_config->beginGroup("Layout"); | ||
| 79 | Settings::values.layout_option = | ||
| 80 | static_cast<Settings::LayoutOption>(qt_config->value("layout_option").toInt()); | ||
| 81 | Settings::values.swap_screen = qt_config->value("swap_screen", false).toBool(); | ||
| 82 | Settings::values.custom_layout = qt_config->value("custom_layout", false).toBool(); | ||
| 83 | Settings::values.custom_top_left = qt_config->value("custom_top_left", 0).toInt(); | ||
| 84 | Settings::values.custom_top_top = qt_config->value("custom_top_top", 0).toInt(); | ||
| 85 | Settings::values.custom_top_right = qt_config->value("custom_top_right", 400).toInt(); | ||
| 86 | Settings::values.custom_top_bottom = qt_config->value("custom_top_bottom", 240).toInt(); | ||
| 87 | Settings::values.custom_bottom_left = qt_config->value("custom_bottom_left", 40).toInt(); | ||
| 88 | Settings::values.custom_bottom_top = qt_config->value("custom_bottom_top", 240).toInt(); | ||
| 89 | Settings::values.custom_bottom_right = qt_config->value("custom_bottom_right", 360).toInt(); | ||
| 90 | Settings::values.custom_bottom_bottom = qt_config->value("custom_bottom_bottom", 480).toInt(); | ||
| 91 | qt_config->endGroup(); | ||
| 92 | |||
| 93 | qt_config->beginGroup("Audio"); | ||
| 94 | Settings::values.sink_id = qt_config->value("output_engine", "auto").toString().toStdString(); | ||
| 95 | Settings::values.enable_audio_stretching = | ||
| 96 | qt_config->value("enable_audio_stretching", true).toBool(); | ||
| 97 | Settings::values.audio_device_id = | ||
| 98 | qt_config->value("output_device", "auto").toString().toStdString(); | ||
| 99 | qt_config->endGroup(); | ||
| 100 | |||
| 101 | using namespace Service::CAM; | ||
| 102 | qt_config->beginGroup("Camera"); | ||
| 103 | Settings::values.camera_name[OuterRightCamera] = | ||
| 104 | qt_config->value("camera_outer_right_name", "blank").toString().toStdString(); | ||
| 105 | Settings::values.camera_config[OuterRightCamera] = | ||
| 106 | qt_config->value("camera_outer_right_config", "").toString().toStdString(); | ||
| 107 | Settings::values.camera_name[InnerCamera] = | ||
| 108 | qt_config->value("camera_inner_name", "blank").toString().toStdString(); | ||
| 109 | Settings::values.camera_config[InnerCamera] = | ||
| 110 | qt_config->value("camera_inner_config", "").toString().toStdString(); | ||
| 111 | Settings::values.camera_name[OuterLeftCamera] = | ||
| 112 | qt_config->value("camera_outer_left_name", "blank").toString().toStdString(); | ||
| 113 | Settings::values.camera_config[OuterLeftCamera] = | ||
| 114 | qt_config->value("camera_outer_left_config", "").toString().toStdString(); | ||
| 115 | qt_config->endGroup(); | ||
| 116 | |||
| 117 | qt_config->beginGroup("Data Storage"); | ||
| 118 | Settings::values.use_virtual_sd = qt_config->value("use_virtual_sd", true).toBool(); | ||
| 119 | qt_config->endGroup(); | ||
| 120 | |||
| 121 | qt_config->beginGroup("System"); | ||
| 122 | Settings::values.is_new_3ds = qt_config->value("is_new_3ds", false).toBool(); | ||
| 123 | Settings::values.region_value = | ||
| 124 | qt_config->value("region_value", Settings::REGION_VALUE_AUTO_SELECT).toInt(); | ||
| 125 | qt_config->endGroup(); | ||
| 126 | |||
| 127 | qt_config->beginGroup("Miscellaneous"); | ||
| 128 | Settings::values.log_filter = qt_config->value("log_filter", "*:Info").toString().toStdString(); | ||
| 129 | qt_config->endGroup(); | ||
| 130 | |||
| 131 | qt_config->beginGroup("Debugging"); | ||
| 132 | Settings::values.use_gdbstub = qt_config->value("use_gdbstub", false).toBool(); | ||
| 133 | Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt(); | ||
| 134 | qt_config->endGroup(); | ||
| 135 | |||
| 136 | qt_config->beginGroup("UI"); | ||
| 137 | |||
| 138 | qt_config->beginGroup("UILayout"); | ||
| 139 | UISettings::values.geometry = qt_config->value("geometry").toByteArray(); | ||
| 140 | UISettings::values.state = qt_config->value("state").toByteArray(); | ||
| 141 | UISettings::values.renderwindow_geometry = | ||
| 142 | qt_config->value("geometryRenderWindow").toByteArray(); | ||
| 143 | UISettings::values.gamelist_header_state = | ||
| 144 | qt_config->value("gameListHeaderState").toByteArray(); | ||
| 145 | UISettings::values.microprofile_geometry = | ||
| 146 | qt_config->value("microProfileDialogGeometry").toByteArray(); | ||
| 147 | UISettings::values.microprofile_visible = | ||
| 148 | qt_config->value("microProfileDialogVisible", false).toBool(); | ||
| 149 | qt_config->endGroup(); | ||
| 150 | |||
| 151 | qt_config->beginGroup("Paths"); | ||
| 152 | UISettings::values.roms_path = qt_config->value("romsPath").toString(); | ||
| 153 | UISettings::values.symbols_path = qt_config->value("symbolsPath").toString(); | ||
| 154 | UISettings::values.gamedir = qt_config->value("gameListRootDir", ".").toString(); | ||
| 155 | UISettings::values.gamedir_deepscan = qt_config->value("gameListDeepScan", false).toBool(); | ||
| 156 | UISettings::values.recent_files = qt_config->value("recentFiles").toStringList(); | ||
| 157 | qt_config->endGroup(); | ||
| 158 | |||
| 159 | qt_config->beginGroup("Shortcuts"); | ||
| 160 | QStringList groups = qt_config->childGroups(); | ||
| 161 | for (auto group : groups) { | ||
| 162 | qt_config->beginGroup(group); | ||
| 163 | |||
| 164 | QStringList hotkeys = qt_config->childGroups(); | ||
| 165 | for (auto hotkey : hotkeys) { | ||
| 166 | qt_config->beginGroup(hotkey); | ||
| 167 | UISettings::values.shortcuts.emplace_back(UISettings::Shortcut( | ||
| 168 | group + "/" + hotkey, | ||
| 169 | UISettings::ContextualShortcut(qt_config->value("KeySeq").toString(), | ||
| 170 | qt_config->value("Context").toInt()))); | ||
| 171 | qt_config->endGroup(); | ||
| 172 | } | ||
| 173 | |||
| 174 | qt_config->endGroup(); | ||
| 175 | } | ||
| 176 | qt_config->endGroup(); | ||
| 177 | |||
| 178 | UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); | ||
| 179 | UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); | ||
| 180 | UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool(); | ||
| 181 | UISettings::values.confirm_before_closing = qt_config->value("confirmClose", true).toBool(); | ||
| 182 | UISettings::values.first_start = qt_config->value("firstStart", true).toBool(); | ||
| 183 | |||
| 184 | qt_config->endGroup(); | ||
| 185 | } | ||
| 186 | |||
| 187 | void Config::SaveValues() { | ||
| 188 | qt_config->beginGroup("Controls"); | ||
| 189 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | ||
| 190 | qt_config->setValue(QString::fromStdString(Settings::NativeButton::mapping[i]), | ||
| 191 | QString::fromStdString(Settings::values.buttons[i])); | ||
| 192 | } | ||
| 193 | for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { | ||
| 194 | qt_config->setValue(QString::fromStdString(Settings::NativeAnalog::mapping[i]), | ||
| 195 | QString::fromStdString(Settings::values.analogs[i])); | ||
| 196 | } | ||
| 197 | qt_config->endGroup(); | ||
| 198 | |||
| 199 | qt_config->beginGroup("Core"); | ||
| 200 | qt_config->setValue("use_cpu_jit", Settings::values.use_cpu_jit); | ||
| 201 | qt_config->endGroup(); | ||
| 202 | |||
| 203 | qt_config->beginGroup("Renderer"); | ||
| 204 | qt_config->setValue("use_hw_renderer", Settings::values.use_hw_renderer); | ||
| 205 | qt_config->setValue("use_shader_jit", Settings::values.use_shader_jit); | ||
| 206 | qt_config->setValue("resolution_factor", (double)Settings::values.resolution_factor); | ||
| 207 | qt_config->setValue("use_vsync", Settings::values.use_vsync); | ||
| 208 | qt_config->setValue("toggle_framelimit", Settings::values.toggle_framelimit); | ||
| 209 | |||
| 210 | // Cast to double because Qt's written float values are not human-readable | ||
| 211 | qt_config->setValue("bg_red", (double)Settings::values.bg_red); | ||
| 212 | qt_config->setValue("bg_green", (double)Settings::values.bg_green); | ||
| 213 | qt_config->setValue("bg_blue", (double)Settings::values.bg_blue); | ||
| 214 | qt_config->endGroup(); | ||
| 215 | |||
| 216 | qt_config->beginGroup("Layout"); | ||
| 217 | qt_config->setValue("layout_option", static_cast<int>(Settings::values.layout_option)); | ||
| 218 | qt_config->setValue("swap_screen", Settings::values.swap_screen); | ||
| 219 | qt_config->setValue("custom_layout", Settings::values.custom_layout); | ||
| 220 | qt_config->setValue("custom_top_left", Settings::values.custom_top_left); | ||
| 221 | qt_config->setValue("custom_top_top", Settings::values.custom_top_top); | ||
| 222 | qt_config->setValue("custom_top_right", Settings::values.custom_top_right); | ||
| 223 | qt_config->setValue("custom_top_bottom", Settings::values.custom_top_bottom); | ||
| 224 | qt_config->setValue("custom_bottom_left", Settings::values.custom_bottom_left); | ||
| 225 | qt_config->setValue("custom_bottom_top", Settings::values.custom_bottom_top); | ||
| 226 | qt_config->setValue("custom_bottom_right", Settings::values.custom_bottom_right); | ||
| 227 | qt_config->setValue("custom_bottom_bottom", Settings::values.custom_bottom_bottom); | ||
| 228 | qt_config->endGroup(); | ||
| 229 | |||
| 230 | qt_config->beginGroup("Audio"); | ||
| 231 | qt_config->setValue("output_engine", QString::fromStdString(Settings::values.sink_id)); | ||
| 232 | qt_config->setValue("enable_audio_stretching", Settings::values.enable_audio_stretching); | ||
| 233 | qt_config->setValue("output_device", QString::fromStdString(Settings::values.audio_device_id)); | ||
| 234 | qt_config->endGroup(); | ||
| 235 | |||
| 236 | using namespace Service::CAM; | ||
| 237 | qt_config->beginGroup("Camera"); | ||
| 238 | qt_config->setValue("camera_outer_right_name", | ||
| 239 | QString::fromStdString(Settings::values.camera_name[OuterRightCamera])); | ||
| 240 | qt_config->setValue("camera_outer_right_config", | ||
| 241 | QString::fromStdString(Settings::values.camera_config[OuterRightCamera])); | ||
| 242 | qt_config->setValue("camera_inner_name", | ||
| 243 | QString::fromStdString(Settings::values.camera_name[InnerCamera])); | ||
| 244 | qt_config->setValue("camera_inner_config", | ||
| 245 | QString::fromStdString(Settings::values.camera_config[InnerCamera])); | ||
| 246 | qt_config->setValue("camera_outer_left_name", | ||
| 247 | QString::fromStdString(Settings::values.camera_name[OuterLeftCamera])); | ||
| 248 | qt_config->setValue("camera_outer_left_config", | ||
| 249 | QString::fromStdString(Settings::values.camera_config[OuterLeftCamera])); | ||
| 250 | qt_config->endGroup(); | ||
| 251 | |||
| 252 | qt_config->beginGroup("Data Storage"); | ||
| 253 | qt_config->setValue("use_virtual_sd", Settings::values.use_virtual_sd); | ||
| 254 | qt_config->endGroup(); | ||
| 255 | |||
| 256 | qt_config->beginGroup("System"); | ||
| 257 | qt_config->setValue("is_new_3ds", Settings::values.is_new_3ds); | ||
| 258 | qt_config->setValue("region_value", Settings::values.region_value); | ||
| 259 | qt_config->endGroup(); | ||
| 260 | |||
| 261 | qt_config->beginGroup("Miscellaneous"); | ||
| 262 | qt_config->setValue("log_filter", QString::fromStdString(Settings::values.log_filter)); | ||
| 263 | qt_config->endGroup(); | ||
| 264 | |||
| 265 | qt_config->beginGroup("Debugging"); | ||
| 266 | qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub); | ||
| 267 | qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port); | ||
| 268 | qt_config->endGroup(); | ||
| 269 | |||
| 270 | qt_config->beginGroup("UI"); | ||
| 271 | |||
| 272 | qt_config->beginGroup("UILayout"); | ||
| 273 | qt_config->setValue("geometry", UISettings::values.geometry); | ||
| 274 | qt_config->setValue("state", UISettings::values.state); | ||
| 275 | qt_config->setValue("geometryRenderWindow", UISettings::values.renderwindow_geometry); | ||
| 276 | qt_config->setValue("gameListHeaderState", UISettings::values.gamelist_header_state); | ||
| 277 | qt_config->setValue("microProfileDialogGeometry", UISettings::values.microprofile_geometry); | ||
| 278 | qt_config->setValue("microProfileDialogVisible", UISettings::values.microprofile_visible); | ||
| 279 | qt_config->endGroup(); | ||
| 280 | |||
| 281 | qt_config->beginGroup("Paths"); | ||
| 282 | qt_config->setValue("romsPath", UISettings::values.roms_path); | ||
| 283 | qt_config->setValue("symbolsPath", UISettings::values.symbols_path); | ||
| 284 | qt_config->setValue("gameListRootDir", UISettings::values.gamedir); | ||
| 285 | qt_config->setValue("gameListDeepScan", UISettings::values.gamedir_deepscan); | ||
| 286 | qt_config->setValue("recentFiles", UISettings::values.recent_files); | ||
| 287 | qt_config->endGroup(); | ||
| 288 | |||
| 289 | qt_config->beginGroup("Shortcuts"); | ||
| 290 | for (auto shortcut : UISettings::values.shortcuts) { | ||
| 291 | qt_config->setValue(shortcut.first + "/KeySeq", shortcut.second.first); | ||
| 292 | qt_config->setValue(shortcut.first + "/Context", shortcut.second.second); | ||
| 293 | } | ||
| 294 | qt_config->endGroup(); | ||
| 295 | |||
| 296 | qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); | ||
| 297 | qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); | ||
| 298 | qt_config->setValue("showStatusBar", UISettings::values.show_status_bar); | ||
| 299 | qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing); | ||
| 300 | qt_config->setValue("firstStart", UISettings::values.first_start); | ||
| 301 | |||
| 302 | qt_config->endGroup(); | ||
| 303 | } | ||
| 304 | |||
| 305 | void Config::Reload() { | ||
| 306 | ReadValues(); | ||
| 307 | Settings::Apply(); | ||
| 308 | } | ||
| 309 | |||
| 310 | void Config::Save() { | ||
| 311 | SaveValues(); | ||
| 312 | } | ||
| 313 | |||
| 314 | Config::~Config() { | ||
| 315 | Save(); | ||
| 316 | |||
| 317 | delete qt_config; | ||
| 318 | } | ||