summaryrefslogtreecommitdiff
path: root/src/yuzu_tester/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu_tester/config.cpp')
-rw-r--r--src/yuzu_tester/config.cpp194
1 files changed, 0 insertions, 194 deletions
diff --git a/src/yuzu_tester/config.cpp b/src/yuzu_tester/config.cpp
deleted file mode 100644
index 0aa143e1f..000000000
--- a/src/yuzu_tester/config.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <memory>
6#include <sstream>
7#include <SDL.h>
8#include <inih/cpp/INIReader.h>
9#include "common/file_util.h"
10#include "common/logging/log.h"
11#include "common/param_package.h"
12#include "core/hle/service/acc/profile_manager.h"
13#include "core/settings.h"
14#include "input_common/main.h"
15#include "yuzu_tester/config.h"
16#include "yuzu_tester/default_ini.h"
17
18namespace FS = Common::FS;
19
20Config::Config() {
21 // TODO: Don't hardcode the path; let the frontend decide where to put the config files.
22 sdl2_config_loc = FS::GetUserPath(FS::UserPath::ConfigDir) + "sdl2-tester-config.ini";
23 sdl2_config = std::make_unique<INIReader>(sdl2_config_loc);
24
25 Reload();
26}
27
28Config::~Config() = default;
29
30bool Config::LoadINI(const std::string& default_contents, bool retry) {
31 const char* location = this->sdl2_config_loc.c_str();
32 if (sdl2_config->ParseError() < 0) {
33 if (retry) {
34 LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location);
35 FS::CreateFullPath(location);
36 FS::WriteStringToFile(true, default_contents, location);
37 sdl2_config = std::make_unique<INIReader>(location); // Reopen file
38
39 return LoadINI(default_contents, false);
40 }
41 LOG_ERROR(Config, "Failed.");
42 return false;
43 }
44 LOG_INFO(Config, "Successfully loaded {}", location);
45 return true;
46}
47
48void Config::ReadValues() {
49 // Controls
50 for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
51 for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
52 Settings::values.players.GetValue()[p].buttons[i] = "";
53 }
54
55 for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
56 Settings::values.players.GetValue()[p].analogs[i] = "";
57 }
58 }
59
60 Settings::values.mouse_enabled = false;
61 for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
62 Settings::values.mouse_buttons[i] = "";
63 }
64
65 Settings::values.motion_device = "";
66
67 Settings::values.keyboard_enabled = false;
68
69 Settings::values.debug_pad_enabled = false;
70 for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
71 Settings::values.debug_pad_buttons[i] = "";
72 }
73
74 for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
75 Settings::values.debug_pad_analogs[i] = "";
76 }
77
78 Settings::values.vibration_enabled.SetValue(true);
79 Settings::values.enable_accurate_vibrations.SetValue(false);
80 Settings::values.motion_enabled.SetValue(true);
81 Settings::values.touchscreen.enabled = "";
82 Settings::values.touchscreen.device = "";
83 Settings::values.touchscreen.finger = 0;
84 Settings::values.touchscreen.rotation_angle = 0;
85 Settings::values.touchscreen.diameter_x = 15;
86 Settings::values.touchscreen.diameter_y = 15;
87
88 Settings::values.use_docked_mode.SetValue(
89 sdl2_config->GetBoolean("Controls", "use_docked_mode", true));
90
91 // Data Storage
92 Settings::values.use_virtual_sd =
93 sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
94 FS::GetUserPath(Common::FS::UserPath::NANDDir,
95 sdl2_config->Get("Data Storage", "nand_directory",
96 Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)));
97 FS::GetUserPath(Common::FS::UserPath::SDMCDir,
98 sdl2_config->Get("Data Storage", "sdmc_directory",
99 Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)));
100
101 // System
102 Settings::values.current_user = std::clamp<int>(
103 sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1);
104
105 const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false);
106 if (rng_seed_enabled) {
107 Settings::values.rng_seed.SetValue(sdl2_config->GetInteger("System", "rng_seed", 0));
108 } else {
109 Settings::values.rng_seed.SetValue(std::nullopt);
110 }
111
112 const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false);
113 if (custom_rtc_enabled) {
114 Settings::values.custom_rtc.SetValue(
115 std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0)));
116 } else {
117 Settings::values.custom_rtc.SetValue(std::nullopt);
118 }
119
120 // Core
121 Settings::values.use_multi_core.SetValue(
122 sdl2_config->GetBoolean("Core", "use_multi_core", false));
123
124 // Renderer
125 Settings::values.aspect_ratio.SetValue(
126 static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)));
127 Settings::values.max_anisotropy.SetValue(
128 static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0)));
129 Settings::values.use_frame_limit.SetValue(false);
130 Settings::values.frame_limit.SetValue(100);
131 Settings::values.use_disk_shader_cache.SetValue(
132 sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false));
133 const int gpu_accuracy_level = sdl2_config->GetInteger("Renderer", "gpu_accuracy", 0);
134 Settings::values.gpu_accuracy.SetValue(static_cast<Settings::GPUAccuracy>(gpu_accuracy_level));
135 Settings::values.use_asynchronous_gpu_emulation.SetValue(
136 sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", false));
137 Settings::values.use_fast_gpu_time.SetValue(
138 sdl2_config->GetBoolean("Renderer", "use_fast_gpu_time", true));
139
140 Settings::values.bg_red.SetValue(
141 static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0)));
142 Settings::values.bg_green.SetValue(
143 static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0)));
144 Settings::values.bg_blue.SetValue(
145 static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0)));
146
147 // Audio
148 Settings::values.sink_id = "null";
149 Settings::values.enable_audio_stretching.SetValue(false);
150 Settings::values.audio_device_id = "auto";
151 Settings::values.volume.SetValue(0);
152
153 Settings::values.language_index.SetValue(
154 sdl2_config->GetInteger("System", "language_index", 1));
155
156 // Miscellaneous
157 Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace");
158 Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false);
159
160 // Debugging
161 Settings::values.program_args = "";
162 Settings::values.dump_exefs = sdl2_config->GetBoolean("Debugging", "dump_exefs", false);
163 Settings::values.dump_nso = sdl2_config->GetBoolean("Debugging", "dump_nso", false);
164
165 const auto title_list = sdl2_config->Get("AddOns", "title_ids", "");
166 std::stringstream ss(title_list);
167 std::string line;
168 while (std::getline(ss, line, '|')) {
169 const auto title_id = std::stoul(line, nullptr, 16);
170 const auto disabled_list = sdl2_config->Get("AddOns", "disabled_" + line, "");
171
172 std::stringstream inner_ss(disabled_list);
173 std::string inner_line;
174 std::vector<std::string> out;
175 while (std::getline(inner_ss, inner_line, '|')) {
176 out.push_back(inner_line);
177 }
178
179 Settings::values.disabled_addons.insert_or_assign(title_id, out);
180 }
181
182 // Web Service
183 Settings::values.enable_telemetry =
184 sdl2_config->GetBoolean("WebService", "enable_telemetry", true);
185 Settings::values.web_api_url =
186 sdl2_config->Get("WebService", "web_api_url", "https://api.yuzu-emu.org");
187 Settings::values.yuzu_username = sdl2_config->Get("WebService", "yuzu_username", "");
188 Settings::values.yuzu_token = sdl2_config->Get("WebService", "yuzu_token", "");
189}
190
191void Config::Reload() {
192 LoadINI(DefaultINI::sdl2_config_file);
193 ReadValues();
194}