diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index d28826c67..98963bec8 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -206,25 +206,28 @@ const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default | |||
| 206 | }; | 206 | }; |
| 207 | 207 | ||
| 208 | // This shouldn't have anything except static initializers (no functions). So | 208 | // This shouldn't have anything except static initializers (no functions). So |
| 209 | // QKeySequnce(...).toString() is NOT ALLOWED HERE. | 209 | // QKeySequence(...).toString() is NOT ALLOWED HERE. |
| 210 | // This must be in alphabetical order according to action name as it must have the same order as | 210 | // This must be in alphabetical order according to action name as it must have the same order as |
| 211 | // UISetting::values.shortcuts, which is alphabetically ordered. | 211 | // UISetting::values.shortcuts, which is alphabetically ordered. |
| 212 | const std::array<UISettings::Shortcut, 15> Config::default_hotkeys{ | 212 | // clang-format off |
| 213 | {{"Capture Screenshot", "Main Window", {"Ctrl+P", Qt::ApplicationShortcut}}, | 213 | const std::array<UISettings::Shortcut, 15> Config::default_hotkeys{{ |
| 214 | {"Continue/Pause Emulation", "Main Window", {"F4", Qt::WindowShortcut}}, | 214 | {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::ApplicationShortcut}}, |
| 215 | {"Decrease Speed Limit", "Main Window", {"-", Qt::ApplicationShortcut}}, | 215 | {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}}, |
| 216 | {"Exit yuzu", "Main Window", {"Ctrl+Q", Qt::WindowShortcut}}, | 216 | {QStringLiteral("Decrease Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("-"), Qt::ApplicationShortcut}}, |
| 217 | {"Exit Fullscreen", "Main Window", {"Esc", Qt::WindowShortcut}}, | 217 | {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), Qt::WindowShortcut}}, |
| 218 | {"Fullscreen", "Main Window", {"F11", Qt::WindowShortcut}}, | 218 | {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), Qt::WindowShortcut}}, |
| 219 | {"Increase Speed Limit", "Main Window", {"+", Qt::ApplicationShortcut}}, | 219 | {QStringLiteral("Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("F11"), Qt::WindowShortcut}}, |
| 220 | {"Load Amiibo", "Main Window", {"F2", Qt::ApplicationShortcut}}, | 220 | {QStringLiteral("Increase Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("+"), Qt::ApplicationShortcut}}, |
| 221 | {"Load File", "Main Window", {"Ctrl+O", Qt::WindowShortcut}}, | 221 | {QStringLiteral("Load Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F2"), Qt::ApplicationShortcut}}, |
| 222 | {"Restart Emulation", "Main Window", {"F6", Qt::WindowShortcut}}, | 222 | {QStringLiteral("Load File"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+O"), Qt::WindowShortcut}}, |
| 223 | {"Stop Emulation", "Main Window", {"F5", Qt::WindowShortcut}}, | 223 | {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, |
| 224 | {"Toggle Filter Bar", "Main Window", {"Ctrl+F", Qt::WindowShortcut}}, | 224 | {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, |
| 225 | {"Toggle Speed Limit", "Main Window", {"Ctrl+Z", Qt::ApplicationShortcut}}, | 225 | {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, |
| 226 | {"Toggle Status Bar", "Main Window", {"Ctrl+S", Qt::WindowShortcut}}, | 226 | {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, |
| 227 | {"Change Docked Mode", "Main Window", {"F10", Qt::ApplicationShortcut}}}}; | 227 | {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, |
| 228 | {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}}, | ||
| 229 | }}; | ||
| 230 | // clang-format on | ||
| 228 | 231 | ||
| 229 | void Config::ReadPlayerValues() { | 232 | void Config::ReadPlayerValues() { |
| 230 | for (std::size_t p = 0; p < Settings::values.players.size(); ++p) { | 233 | for (std::size_t p = 0; p < Settings::values.players.size(); ++p) { |
| @@ -370,14 +373,21 @@ void Config::ReadMouseValues() { | |||
| 370 | } | 373 | } |
| 371 | 374 | ||
| 372 | void Config::ReadTouchscreenValues() { | 375 | void Config::ReadTouchscreenValues() { |
| 373 | Settings::values.touchscreen.enabled = ReadSetting("touchscreen_enabled", true).toBool(); | 376 | Settings::values.touchscreen.enabled = |
| 377 | ReadSetting(QStringLiteral("touchscreen_enabled"), true).toBool(); | ||
| 374 | Settings::values.touchscreen.device = | 378 | Settings::values.touchscreen.device = |
| 375 | ReadSetting("touchscreen_device", "engine:emu_window").toString().toStdString(); | 379 | ReadSetting(QStringLiteral("touchscreen_device"), QStringLiteral("engine:emu_window")) |
| 380 | .toString() | ||
| 381 | .toStdString(); | ||
| 376 | 382 | ||
| 377 | Settings::values.touchscreen.finger = ReadSetting("touchscreen_finger", 0).toUInt(); | 383 | Settings::values.touchscreen.finger = |
| 378 | Settings::values.touchscreen.rotation_angle = ReadSetting("touchscreen_angle", 0).toUInt(); | 384 | ReadSetting(QStringLiteral("touchscreen_finger"), 0).toUInt(); |
| 379 | Settings::values.touchscreen.diameter_x = ReadSetting("touchscreen_diameter_x", 15).toUInt(); | 385 | Settings::values.touchscreen.rotation_angle = |
| 380 | Settings::values.touchscreen.diameter_y = ReadSetting("touchscreen_diameter_y", 15).toUInt(); | 386 | ReadSetting(QStringLiteral("touchscreen_angle"), 0).toUInt(); |
| 387 | Settings::values.touchscreen.diameter_x = | ||
| 388 | ReadSetting(QStringLiteral("touchscreen_diameter_x"), 15).toUInt(); | ||
| 389 | Settings::values.touchscreen.diameter_y = | ||
| 390 | ReadSetting(QStringLiteral("touchscreen_diameter_y"), 15).toUInt(); | ||
| 381 | } | 391 | } |
| 382 | 392 | ||
| 383 | void Config::ApplyDefaultProfileIfInputInvalid() { | 393 | void Config::ApplyDefaultProfileIfInputInvalid() { |
| @@ -541,8 +551,8 @@ void Config::ReadRendererValues() { | |||
| 541 | void Config::ReadShortcutValues() { | 551 | void Config::ReadShortcutValues() { |
| 542 | qt_config->beginGroup(QStringLiteral("Shortcuts")); | 552 | qt_config->beginGroup(QStringLiteral("Shortcuts")); |
| 543 | 553 | ||
| 544 | for (auto [name, group, shortcut] : default_hotkeys) { | 554 | for (const auto& [name, group, shortcut] : default_hotkeys) { |
| 545 | auto [keyseq, context] = shortcut; | 555 | const auto& [keyseq, context] = shortcut; |
| 546 | qt_config->beginGroup(group); | 556 | qt_config->beginGroup(group); |
| 547 | qt_config->beginGroup(name); | 557 | qt_config->beginGroup(name); |
| 548 | UISettings::values.shortcuts.push_back( | 558 | UISettings::values.shortcuts.push_back( |
| @@ -591,7 +601,8 @@ void Config::ReadUIValues() { | |||
| 591 | qt_config->beginGroup(QStringLiteral("UI")); | 601 | qt_config->beginGroup(QStringLiteral("UI")); |
| 592 | 602 | ||
| 593 | UISettings::values.theme = | 603 | UISettings::values.theme = |
| 594 | ReadSetting(QStringLiteral("theme"), UISettings::themes[0].second).toString(); | 604 | ReadSetting(QStringLiteral("theme"), QString::fromUtf8(UISettings::themes[0].second)) |
| 605 | .toString(); | ||
| 595 | UISettings::values.enable_discord_presence = | 606 | UISettings::values.enable_discord_presence = |
| 596 | ReadSetting(QStringLiteral("enable_discord_presence"), true).toBool(); | 607 | ReadSetting(QStringLiteral("enable_discord_presence"), true).toBool(); |
| 597 | UISettings::values.screenshot_resolution_factor = | 608 | UISettings::values.screenshot_resolution_factor = |
| @@ -626,7 +637,7 @@ void Config::ReadUIValues() { | |||
| 626 | } | 637 | } |
| 627 | 638 | ||
| 628 | void Config::ReadUIGamelistValues() { | 639 | void Config::ReadUIGamelistValues() { |
| 629 | qt_config->beginGroup("UIGameList"); | 640 | qt_config->beginGroup(QStringLiteral("UIGameList")); |
| 630 | 641 | ||
| 631 | UISettings::values.show_unknown = ReadSetting(QStringLiteral("show_unknown"), true).toBool(); | 642 | UISettings::values.show_unknown = ReadSetting(QStringLiteral("show_unknown"), true).toBool(); |
| 632 | UISettings::values.show_add_ons = ReadSetting(QStringLiteral("show_add_ons"), true).toBool(); | 643 | UISettings::values.show_add_ons = ReadSetting(QStringLiteral("show_add_ons"), true).toBool(); |
| @@ -723,7 +734,7 @@ void Config::SavePlayerValues() { | |||
| 723 | } | 734 | } |
| 724 | 735 | ||
| 725 | void Config::SaveDebugValues() { | 736 | void Config::SaveDebugValues() { |
| 726 | WriteSetting("debug_pad_enabled", Settings::values.debug_pad_enabled, false); | 737 | WriteSetting(QStringLiteral("debug_pad_enabled"), Settings::values.debug_pad_enabled, false); |
| 727 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 738 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 728 | const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); | 739 | const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); |
| 729 | WriteSetting(QStringLiteral("debug_pad_") + | 740 | WriteSetting(QStringLiteral("debug_pad_") + |
| @@ -924,7 +935,7 @@ void Config::SaveShortcutValues() { | |||
| 924 | // Lengths of UISettings::values.shortcuts & default_hotkeys are same. | 935 | // Lengths of UISettings::values.shortcuts & default_hotkeys are same. |
| 925 | // However, their ordering must also be the same. | 936 | // However, their ordering must also be the same. |
| 926 | for (std::size_t i = 0; i < default_hotkeys.size(); i++) { | 937 | for (std::size_t i = 0; i < default_hotkeys.size(); i++) { |
| 927 | const auto [name, group, shortcut] = UISettings::values.shortcuts[i]; | 938 | const auto& [name, group, shortcut] = UISettings::values.shortcuts[i]; |
| 928 | const auto& default_hotkey = default_hotkeys[i].shortcut; | 939 | const auto& default_hotkey = default_hotkeys[i].shortcut; |
| 929 | 940 | ||
| 930 | qt_config->beginGroup(group); | 941 | qt_config->beginGroup(group); |
| @@ -961,7 +972,8 @@ void Config::SaveSystemValues() { | |||
| 961 | void Config::SaveUIValues() { | 972 | void Config::SaveUIValues() { |
| 962 | qt_config->beginGroup(QStringLiteral("UI")); | 973 | qt_config->beginGroup(QStringLiteral("UI")); |
| 963 | 974 | ||
| 964 | WriteSetting(QStringLiteral("theme"), UISettings::values.theme, UISettings::themes[0].second); | 975 | WriteSetting(QStringLiteral("theme"), UISettings::values.theme, |
| 976 | QString::fromUtf8(UISettings::themes[0].second)); | ||
| 965 | WriteSetting(QStringLiteral("enable_discord_presence"), | 977 | WriteSetting(QStringLiteral("enable_discord_presence"), |
| 966 | UISettings::values.enable_discord_presence, true); | 978 | UISettings::values.enable_discord_presence, true); |
| 967 | WriteSetting(QStringLiteral("screenshot_resolution_factor"), | 979 | WriteSetting(QStringLiteral("screenshot_resolution_factor"), |