summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/config.cpp73
-rw-r--r--src/yuzu/configuration/config.h3
2 files changed, 43 insertions, 33 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index d28826c67..db27da23e 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -11,6 +11,7 @@
11#include "core/hle/service/hid/controllers/npad.h" 11#include "core/hle/service/hid/controllers/npad.h"
12#include "input_common/main.h" 12#include "input_common/main.h"
13#include "yuzu/configuration/config.h" 13#include "yuzu/configuration/config.h"
14#include "yuzu/ui_settings.h"
14 15
15Config::Config() { 16Config::Config() {
16 // TODO: Don't hardcode the path; let the frontend decide where to put the config files. 17 // TODO: Don't hardcode the path; let the frontend decide where to put the config files.
@@ -206,25 +207,28 @@ const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default
206}; 207};
207 208
208// This shouldn't have anything except static initializers (no functions). So 209// This shouldn't have anything except static initializers (no functions). So
209// QKeySequnce(...).toString() is NOT ALLOWED HERE. 210// 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 211// 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. 212// UISetting::values.shortcuts, which is alphabetically ordered.
212const std::array<UISettings::Shortcut, 15> Config::default_hotkeys{ 213// clang-format off
213 {{"Capture Screenshot", "Main Window", {"Ctrl+P", Qt::ApplicationShortcut}}, 214const std::array<UISettings::Shortcut, 15> default_hotkeys{{
214 {"Continue/Pause Emulation", "Main Window", {"F4", Qt::WindowShortcut}}, 215 {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::ApplicationShortcut}},
215 {"Decrease Speed Limit", "Main Window", {"-", Qt::ApplicationShortcut}}, 216 {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}},
216 {"Exit yuzu", "Main Window", {"Ctrl+Q", Qt::WindowShortcut}}, 217 {QStringLiteral("Decrease Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("-"), Qt::ApplicationShortcut}},
217 {"Exit Fullscreen", "Main Window", {"Esc", Qt::WindowShortcut}}, 218 {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), Qt::WindowShortcut}},
218 {"Fullscreen", "Main Window", {"F11", Qt::WindowShortcut}}, 219 {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), Qt::WindowShortcut}},
219 {"Increase Speed Limit", "Main Window", {"+", Qt::ApplicationShortcut}}, 220 {QStringLiteral("Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("F11"), Qt::WindowShortcut}},
220 {"Load Amiibo", "Main Window", {"F2", Qt::ApplicationShortcut}}, 221 {QStringLiteral("Increase Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("+"), Qt::ApplicationShortcut}},
221 {"Load File", "Main Window", {"Ctrl+O", Qt::WindowShortcut}}, 222 {QStringLiteral("Load Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F2"), Qt::ApplicationShortcut}},
222 {"Restart Emulation", "Main Window", {"F6", Qt::WindowShortcut}}, 223 {QStringLiteral("Load File"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+O"), Qt::WindowShortcut}},
223 {"Stop Emulation", "Main Window", {"F5", Qt::WindowShortcut}}, 224 {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}},
224 {"Toggle Filter Bar", "Main Window", {"Ctrl+F", Qt::WindowShortcut}}, 225 {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}},
225 {"Toggle Speed Limit", "Main Window", {"Ctrl+Z", Qt::ApplicationShortcut}}, 226 {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}},
226 {"Toggle Status Bar", "Main Window", {"Ctrl+S", Qt::WindowShortcut}}, 227 {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}},
227 {"Change Docked Mode", "Main Window", {"F10", Qt::ApplicationShortcut}}}}; 228 {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}},
229 {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}},
230}};
231// clang-format on
228 232
229void Config::ReadPlayerValues() { 233void Config::ReadPlayerValues() {
230 for (std::size_t p = 0; p < Settings::values.players.size(); ++p) { 234 for (std::size_t p = 0; p < Settings::values.players.size(); ++p) {
@@ -370,14 +374,21 @@ void Config::ReadMouseValues() {
370} 374}
371 375
372void Config::ReadTouchscreenValues() { 376void Config::ReadTouchscreenValues() {
373 Settings::values.touchscreen.enabled = ReadSetting("touchscreen_enabled", true).toBool(); 377 Settings::values.touchscreen.enabled =
378 ReadSetting(QStringLiteral("touchscreen_enabled"), true).toBool();
374 Settings::values.touchscreen.device = 379 Settings::values.touchscreen.device =
375 ReadSetting("touchscreen_device", "engine:emu_window").toString().toStdString(); 380 ReadSetting(QStringLiteral("touchscreen_device"), QStringLiteral("engine:emu_window"))
381 .toString()
382 .toStdString();
376 383
377 Settings::values.touchscreen.finger = ReadSetting("touchscreen_finger", 0).toUInt(); 384 Settings::values.touchscreen.finger =
378 Settings::values.touchscreen.rotation_angle = ReadSetting("touchscreen_angle", 0).toUInt(); 385 ReadSetting(QStringLiteral("touchscreen_finger"), 0).toUInt();
379 Settings::values.touchscreen.diameter_x = ReadSetting("touchscreen_diameter_x", 15).toUInt(); 386 Settings::values.touchscreen.rotation_angle =
380 Settings::values.touchscreen.diameter_y = ReadSetting("touchscreen_diameter_y", 15).toUInt(); 387 ReadSetting(QStringLiteral("touchscreen_angle"), 0).toUInt();
388 Settings::values.touchscreen.diameter_x =
389 ReadSetting(QStringLiteral("touchscreen_diameter_x"), 15).toUInt();
390 Settings::values.touchscreen.diameter_y =
391 ReadSetting(QStringLiteral("touchscreen_diameter_y"), 15).toUInt();
381} 392}
382 393
383void Config::ApplyDefaultProfileIfInputInvalid() { 394void Config::ApplyDefaultProfileIfInputInvalid() {
@@ -541,8 +552,8 @@ void Config::ReadRendererValues() {
541void Config::ReadShortcutValues() { 552void Config::ReadShortcutValues() {
542 qt_config->beginGroup(QStringLiteral("Shortcuts")); 553 qt_config->beginGroup(QStringLiteral("Shortcuts"));
543 554
544 for (auto [name, group, shortcut] : default_hotkeys) { 555 for (const auto& [name, group, shortcut] : default_hotkeys) {
545 auto [keyseq, context] = shortcut; 556 const auto& [keyseq, context] = shortcut;
546 qt_config->beginGroup(group); 557 qt_config->beginGroup(group);
547 qt_config->beginGroup(name); 558 qt_config->beginGroup(name);
548 UISettings::values.shortcuts.push_back( 559 UISettings::values.shortcuts.push_back(
@@ -591,7 +602,8 @@ void Config::ReadUIValues() {
591 qt_config->beginGroup(QStringLiteral("UI")); 602 qt_config->beginGroup(QStringLiteral("UI"));
592 603
593 UISettings::values.theme = 604 UISettings::values.theme =
594 ReadSetting(QStringLiteral("theme"), UISettings::themes[0].second).toString(); 605 ReadSetting(QStringLiteral("theme"), QString::fromUtf8(UISettings::themes[0].second))
606 .toString();
595 UISettings::values.enable_discord_presence = 607 UISettings::values.enable_discord_presence =
596 ReadSetting(QStringLiteral("enable_discord_presence"), true).toBool(); 608 ReadSetting(QStringLiteral("enable_discord_presence"), true).toBool();
597 UISettings::values.screenshot_resolution_factor = 609 UISettings::values.screenshot_resolution_factor =
@@ -626,7 +638,7 @@ void Config::ReadUIValues() {
626} 638}
627 639
628void Config::ReadUIGamelistValues() { 640void Config::ReadUIGamelistValues() {
629 qt_config->beginGroup("UIGameList"); 641 qt_config->beginGroup(QStringLiteral("UIGameList"));
630 642
631 UISettings::values.show_unknown = ReadSetting(QStringLiteral("show_unknown"), true).toBool(); 643 UISettings::values.show_unknown = ReadSetting(QStringLiteral("show_unknown"), true).toBool();
632 UISettings::values.show_add_ons = ReadSetting(QStringLiteral("show_add_ons"), true).toBool(); 644 UISettings::values.show_add_ons = ReadSetting(QStringLiteral("show_add_ons"), true).toBool();
@@ -723,7 +735,7 @@ void Config::SavePlayerValues() {
723} 735}
724 736
725void Config::SaveDebugValues() { 737void Config::SaveDebugValues() {
726 WriteSetting("debug_pad_enabled", Settings::values.debug_pad_enabled, false); 738 WriteSetting(QStringLiteral("debug_pad_enabled"), Settings::values.debug_pad_enabled, false);
727 for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { 739 for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
728 const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); 740 const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
729 WriteSetting(QStringLiteral("debug_pad_") + 741 WriteSetting(QStringLiteral("debug_pad_") +
@@ -924,7 +936,7 @@ void Config::SaveShortcutValues() {
924 // Lengths of UISettings::values.shortcuts & default_hotkeys are same. 936 // Lengths of UISettings::values.shortcuts & default_hotkeys are same.
925 // However, their ordering must also be the same. 937 // However, their ordering must also be the same.
926 for (std::size_t i = 0; i < default_hotkeys.size(); i++) { 938 for (std::size_t i = 0; i < default_hotkeys.size(); i++) {
927 const auto [name, group, shortcut] = UISettings::values.shortcuts[i]; 939 const auto& [name, group, shortcut] = UISettings::values.shortcuts[i];
928 const auto& default_hotkey = default_hotkeys[i].shortcut; 940 const auto& default_hotkey = default_hotkeys[i].shortcut;
929 941
930 qt_config->beginGroup(group); 942 qt_config->beginGroup(group);
@@ -961,7 +973,8 @@ void Config::SaveSystemValues() {
961void Config::SaveUIValues() { 973void Config::SaveUIValues() {
962 qt_config->beginGroup(QStringLiteral("UI")); 974 qt_config->beginGroup(QStringLiteral("UI"));
963 975
964 WriteSetting(QStringLiteral("theme"), UISettings::values.theme, UISettings::themes[0].second); 976 WriteSetting(QStringLiteral("theme"), UISettings::values.theme,
977 QString::fromUtf8(UISettings::themes[0].second));
965 WriteSetting(QStringLiteral("enable_discord_presence"), 978 WriteSetting(QStringLiteral("enable_discord_presence"),
966 UISettings::values.enable_discord_presence, true); 979 UISettings::values.enable_discord_presence, true);
967 WriteSetting(QStringLiteral("screenshot_resolution_factor"), 980 WriteSetting(QStringLiteral("screenshot_resolution_factor"),
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h
index b62a480ee..6b523ecdd 100644
--- a/src/yuzu/configuration/config.h
+++ b/src/yuzu/configuration/config.h
@@ -9,7 +9,6 @@
9#include <string> 9#include <string>
10#include <QVariant> 10#include <QVariant>
11#include "core/settings.h" 11#include "core/settings.h"
12#include "yuzu/ui_settings.h"
13 12
14class QSettings; 13class QSettings;
15 14
@@ -82,8 +81,6 @@ private:
82 void WriteSetting(const QString& name, const QVariant& value); 81 void WriteSetting(const QString& name, const QVariant& value);
83 void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); 82 void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value);
84 83
85 static const std::array<UISettings::Shortcut, 15> default_hotkeys;
86
87 std::unique_ptr<QSettings> qt_config; 84 std::unique_ptr<QSettings> qt_config;
88 std::string qt_config_loc; 85 std::string qt_config_loc;
89}; 86};