2014-09-13 02:06:13 +02:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-09-13 02:06:13 +02:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-04-05 14:29:55 +02:00
|
|
|
#include <memory>
|
2018-11-28 20:00:01 +01:00
|
|
|
#include <sstream>
|
2016-03-01 18:24:18 +01:00
|
|
|
#include <SDL.h>
|
2016-09-20 17:21:23 +02:00
|
|
|
#include <inih/cpp/INIReader.h>
|
2014-09-13 02:06:13 +02:00
|
|
|
#include "common/file_util.h"
|
2015-05-06 09:06:12 +02:00
|
|
|
#include "common/logging/log.h"
|
2017-01-21 12:04:00 +01:00
|
|
|
#include "common/param_package.h"
|
2018-10-13 19:02:33 +02:00
|
|
|
#include "core/hle/service/acc/profile_manager.h"
|
2014-09-13 02:06:13 +02:00
|
|
|
#include "core/settings.h"
|
2017-01-21 10:53:03 +01:00
|
|
|
#include "input_common/main.h"
|
2019-08-24 15:57:49 +02:00
|
|
|
#include "input_common/udp/client.h"
|
2018-01-12 04:38:17 +01:00
|
|
|
#include "yuzu_cmd/config.h"
|
|
|
|
#include "yuzu_cmd/default_ini.h"
|
|
|
|
|
2014-09-13 02:06:13 +02:00
|
|
|
Config::Config() {
|
|
|
|
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
2018-07-21 21:52:42 +02:00
|
|
|
sdl2_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "sdl2-config.ini";
|
2016-04-05 14:29:55 +02:00
|
|
|
sdl2_config = std::make_unique<INIReader>(sdl2_config_loc);
|
2014-09-13 02:06:13 +02:00
|
|
|
|
|
|
|
Reload();
|
|
|
|
}
|
|
|
|
|
2017-05-28 03:14:00 +02:00
|
|
|
Config::~Config() = default;
|
|
|
|
|
2016-03-02 13:49:30 +01:00
|
|
|
bool Config::LoadINI(const std::string& default_contents, bool retry) {
|
2019-05-23 19:52:40 +02:00
|
|
|
const std::string& location = this->sdl2_config_loc;
|
2016-03-02 13:49:30 +01:00
|
|
|
if (sdl2_config->ParseError() < 0) {
|
2014-09-13 02:06:13 +02:00
|
|
|
if (retry) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location);
|
2014-09-13 02:06:13 +02:00
|
|
|
FileUtil::CreateFullPath(location);
|
2019-05-23 19:52:40 +02:00
|
|
|
FileUtil::WriteStringToFile(true, location, default_contents);
|
2016-04-05 14:29:55 +02:00
|
|
|
sdl2_config = std::make_unique<INIReader>(location); // Reopen file
|
2014-09-13 02:06:13 +02:00
|
|
|
|
2016-03-02 13:49:30 +01:00
|
|
|
return LoadINI(default_contents, false);
|
2014-09-13 02:06:13 +02:00
|
|
|
}
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_ERROR(Config, "Failed.");
|
2014-09-13 02:06:13 +02:00
|
|
|
return false;
|
|
|
|
}
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_INFO(Config, "Successfully loaded {}", location);
|
2014-09-13 02:06:13 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:53:03 +01:00
|
|
|
static const std::array<int, Settings::NativeButton::NumButtons> default_buttons = {
|
|
|
|
SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_T,
|
|
|
|
SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, SDL_SCANCODE_Q, SDL_SCANCODE_W,
|
|
|
|
SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_B,
|
2015-06-20 05:34:45 +02:00
|
|
|
};
|
|
|
|
|
2017-01-21 12:04:00 +01:00
|
|
|
static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs{{
|
|
|
|
{
|
2018-01-20 08:48:02 +01:00
|
|
|
SDL_SCANCODE_UP,
|
|
|
|
SDL_SCANCODE_DOWN,
|
|
|
|
SDL_SCANCODE_LEFT,
|
|
|
|
SDL_SCANCODE_RIGHT,
|
|
|
|
SDL_SCANCODE_D,
|
2017-01-21 12:04:00 +01:00
|
|
|
},
|
|
|
|
{
|
2018-01-20 08:48:02 +01:00
|
|
|
SDL_SCANCODE_I,
|
|
|
|
SDL_SCANCODE_K,
|
|
|
|
SDL_SCANCODE_J,
|
|
|
|
SDL_SCANCODE_L,
|
|
|
|
SDL_SCANCODE_D,
|
2017-01-21 12:04:00 +01:00
|
|
|
},
|
|
|
|
}};
|
|
|
|
|
2018-11-02 02:55:35 +01:00
|
|
|
static const std::array<int, Settings::NativeMouseButton::NumMouseButtons> default_mouse_buttons = {
|
|
|
|
SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_APOSTROPHE,
|
|
|
|
SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const std::array<int, 0x8A> keyboard_keys = {
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
SDL_SCANCODE_A,
|
|
|
|
SDL_SCANCODE_B,
|
|
|
|
SDL_SCANCODE_C,
|
|
|
|
SDL_SCANCODE_D,
|
|
|
|
SDL_SCANCODE_E,
|
|
|
|
SDL_SCANCODE_F,
|
|
|
|
SDL_SCANCODE_G,
|
|
|
|
SDL_SCANCODE_H,
|
|
|
|
SDL_SCANCODE_I,
|
|
|
|
SDL_SCANCODE_J,
|
|
|
|
SDL_SCANCODE_K,
|
|
|
|
SDL_SCANCODE_L,
|
|
|
|
SDL_SCANCODE_M,
|
|
|
|
SDL_SCANCODE_N,
|
|
|
|
SDL_SCANCODE_O,
|
|
|
|
SDL_SCANCODE_P,
|
|
|
|
SDL_SCANCODE_Q,
|
|
|
|
SDL_SCANCODE_R,
|
|
|
|
SDL_SCANCODE_S,
|
|
|
|
SD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|
|
|
SDL_SCANCODE_F15,
|
|
|
|
SDL_SCANCODE_F16,
|
|
|
|
SDL_SCANCODE_F17,
|
|
|
|
SDL_SCANCODE_F18,
|
|
|
|
SDL_SCANCODE_F19,
|
|
|
|
SDL_SCANCODE_F20,
|
|
|
|
SDL_SCANCODE_F21,
|
|
|
|
SDL_SCANCODE_F22,
|
|
|
|
SDL_SCANCODE_F23,
|
|
|
|
SDL_SCANCODE_F24,
|
|
|
|
|
|
|
|
0,
|
|
|
|
SDL_SCANCODE_HELP,
|
|
|
|
SDL_SCANCODE_MENU,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
SDL_SCANCODE_KP_COMMA,
|
|
|
|
SDL_SCANCODE_KP_LEFTPAREN,
|
|
|
|
SDL_SCANCODE_KP_RIGHTPAREN,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const std::array<int, 8> keyboard_mods{
|
|
|
|
SDL_SCANCODE_LCTRL, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_LALT, SDL_SCANCODE_LGUI,
|
|
|
|
SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI,
|
|
|
|
};
|
|
|
|
|
2014-11-15 20:56:18 +01:00
|
|
|
void Config::ReadValues() {
|
|
|
|
// Controls
|
2018-11-02 02:55:35 +01:00
|
|
|
for (std::size_t p = 0; p < Settings::values.players.size(); ++p) {
|
|
|
|
const auto group = fmt::format("ControlsP{}", p);
|
|
|
|
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
|
|
|
|
std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
|
|
|
|
Settings::values.players[p].buttons[i] =
|
|
|
|
sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param);
|
|
|
|
if (Settings::values.players[p].buttons[i].empty())
|
|
|
|
Settings::values.players[p].buttons[i] = default_param;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
|
|
|
|
std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
|
|
|
|
default_analogs[i][0], default_analogs[i][1], default_analogs[i][2],
|
|
|
|
default_analogs[i][3], default_analogs[i][4], 0.5f);
|
|
|
|
Settings::values.players[p].analogs[i] =
|
|
|
|
sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param);
|
|
|
|
if (Settings::values.players[p].analogs[i].empty())
|
|
|
|
Settings::values.players[p].analogs[i] = default_param;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings::values.mouse_enabled =
|
|
|
|
sdl2_config->GetBoolean("ControlsGeneral", "mouse_enabled", false);
|
|
|
|
for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
|
|
|
|
std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]);
|
|
|
|
Settings::values.mouse_buttons[i] = sdl2_config->Get(
|
|
|
|
"ControlsGeneral", std::string("mouse_") + Settings::NativeMouseButton::mapping[i],
|
|
|
|
default_param);
|
|
|
|
if (Settings::values.mouse_buttons[i].empty())
|
|
|
|
Settings::values.mouse_buttons[i] = default_param;
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings::values.motion_device = sdl2_config->Get(
|
|
|
|
"ControlsGeneral", "motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01");
|
|
|
|
|
|
|
|
Settings::values.keyboard_enabled =
|
|
|
|
sdl2_config->GetBoolean("ControlsGeneral", "keyboard_enabled", false);
|
|
|
|
|
|
|
|
Settings::values.debug_pad_enabled =
|
|
|
|
sdl2_config->GetBoolean("ControlsGeneral", "debug_pad_enabled", false);
|
2017-01-21 10:53:03 +01:00
|
|
|
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
|
|
|
|
std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
|
2018-11-02 02:55:35 +01:00
|
|
|
Settings::values.debug_pad_buttons[i] = sdl2_config->Get(
|
|
|
|
"ControlsGeneral", std::string("debug_pad_") + Settings::NativeButton::mapping[i],
|
|
|
|
default_param);
|
|
|
|
if (Settings::values.debug_pad_buttons[i].empty())
|
|
|
|
Settings::values.debug_pad_buttons[i] = default_param;
|
2015-06-20 05:34:45 +02:00
|
|
|
}
|
2014-09-13 02:06:13 +02:00
|
|
|
|
2017-01-21 12:04:00 +01:00
|
|
|
for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
|
|
|
|
std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
|
|
|
|
default_analogs[i][0], default_analogs[i][1], default_analogs[i][2],
|
|
|
|
default_analogs[i][3], default_analogs[i][4], 0.5f);
|
2018-11-02 02:55:35 +01:00
|
|
|
Settings::values.debug_pad_analogs[i] = sdl2_config->Get(
|
|
|
|
"ControlsGeneral", std::string("debug_pad_") + Settings::NativeAnalog::mapping[i],
|
|
|
|
default_param);
|
|
|
|
if (Settings::values.debug_pad_analogs[i].empty())
|
|
|
|
Settings::values.debug_pad_analogs[i] = default_param;
|
2017-01-21 12:04:00 +01:00
|
|
|
}
|
|
|
|
|
2018-11-02 02:55:35 +01:00
|
|
|
Settings::values.touchscreen.enabled =
|
|
|
|
sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true);
|
|
|
|
Settings::values.touchscreen.device =
|
|
|
|
sdl2_config->Get("ControlsGeneral", "touch_device", "engine:emu_window");
|
|
|
|
Settings::values.touchscreen.finger =
|
|
|
|
sdl2_config->GetInteger("ControlsGeneral", "touch_finger", 0);
|
|
|
|
Settings::values.touchscreen.rotation_angle =
|
|
|
|
sdl2_config->GetInteger("ControlsGeneral", "touch_angle", 0);
|
|
|
|
Settings::values.touchscreen.diameter_x =
|
|
|
|
sdl2_config->GetInteger("ControlsGeneral", "touch_diameter_x", 15);
|
|
|
|
Settings::values.touchscreen.diameter_y =
|
|
|
|
sdl2_config->GetInteger("ControlsGeneral", "touch_diameter_y", 15);
|
2019-11-10 19:42:24 +01:00
|
|
|
Settings::values.udp_input_address =
|
|
|
|
sdl2_config->Get("Controls", "udp_input_address", InputCommon::CemuhookUDP::DEFAULT_ADDR);
|
2019-08-24 15:57:49 +02:00
|
|
|
Settings::values.udp_input_port = static_cast<u16>(sdl2_config->GetInteger(
|
|
|
|
"Controls", "udp_input_port", InputCommon::CemuhookUDP::DEFAULT_PORT));
|
2018-11-02 02:55:35 +01:00
|
|
|
|
|
|
|
std::transform(keyboard_keys.begin(), keyboard_keys.end(),
|
|
|
|
Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam);
|
|
|
|
std::transform(keyboard_mods.begin(), keyboard_mods.end(),
|
|
|
|
Settings::values.keyboard_keys.begin() +
|
|
|
|
Settings::NativeKeyboard::LeftControlKey,
|
|
|
|
InputCommon::GenerateKeyboardParam);
|
|
|
|
std::transform(keyboard_mods.begin(), keyboard_mods.end(),
|
|
|
|
Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam);
|
|
|
|
|
|
|
|
// Data Storage
|
|
|
|
Settings::values.use_virtual_sd =
|
|
|
|
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::NANDDir,
|
|
|
|
sdl2_config->Get("Data Storage", "nand_directory",
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)));
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir,
|
|
|
|
sdl2_config->Get("Data Storage", "sdmc_directory",
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)));
|
2019-04-23 14:35:12 +02:00
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::LoadDir,
|
|
|
|
sdl2_config->Get("Data Storage", "load_directory",
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::LoadDir)));
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::DumpDir,
|
|
|
|
sdl2_config->Get("Data Storage", "dump_directory",
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::DumpDir)));
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::CacheDir,
|
|
|
|
sdl2_config->Get("Data Storage", "cache_directory",
|
|
|
|
FileUtil::GetUserPath(FileUtil::UserPath::CacheDir)));
|
|
|
|
Settings::values.gamecard_inserted =
|
|
|
|
sdl2_config->GetBoolean("Data Storage", "gamecard_inserted", false);
|
|
|
|
Settings::values.gamecard_current_game =
|
|
|
|
sdl2_config->GetBoolean("Data Storage", "gamecard_current_game", false);
|
|
|
|
Settings::values.gamecard_path = sdl2_config->Get("Data Storage", "gamecard_path", "");
|
2019-04-23 14:34:19 +02:00
|
|
|
Settings::values.nand_total_size = static_cast<Settings::NANDTotalSize>(sdl2_config->GetInteger(
|
|
|
|
"Data Storage", "nand_total_size", static_cast<long>(Settings::NANDTotalSize::S29_1GB)));
|
|
|
|
Settings::values.nand_user_size = static_cast<Settings::NANDUserSize>(sdl2_config->GetInteger(
|
|
|
|
"Data Storage", "nand_user_size", static_cast<long>(Settings::NANDUserSize::S26GB)));
|
|
|
|
Settings::values.nand_system_size = static_cast<Settings::NANDSystemSize>(
|
|
|
|
sdl2_config->GetInteger("Data Storage", "nand_system_size",
|
|
|
|
static_cast<long>(Settings::NANDSystemSize::S2_5GB)));
|
|
|
|
Settings::values.sdmc_size = static_cast<Settings::SDMCSize>(sdl2_config->GetInteger(
|
|
|
|
"Data Storage", "sdmc_size", static_cast<long>(Settings::SDMCSize::S16GB)));
|
2018-11-02 02:55:35 +01:00
|
|
|
|
|
|
|
// System
|
|
|
|
Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false);
|
|
|
|
const auto size = sdl2_config->GetInteger("System", "users_size", 0);
|
|
|
|
|
|
|
|
Settings::values.current_user = std::clamp<int>(
|
|
|
|
sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1);
|
|
|
|
|
2018-12-29 00:35:55 +01:00
|
|
|
const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false);
|
|
|
|
if (rng_seed_enabled) {
|
2018-11-17 22:26:03 +01:00
|
|
|
Settings::values.rng_seed = sdl2_config->GetInteger("System", "rng_seed", 0);
|
|
|
|
} else {
|
|
|
|
Settings::values.rng_seed = std::nullopt;
|
|
|
|
}
|
2017-08-06 23:04:06 +02:00
|
|
|
|
2018-12-29 00:35:55 +01:00
|
|
|
const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false);
|
|
|
|
if (custom_rtc_enabled) {
|
2018-12-29 02:24:24 +01:00
|
|
|
Settings::values.custom_rtc =
|
|
|
|
std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0));
|
2018-12-29 00:35:55 +01:00
|
|
|
} else {
|
|
|
|
Settings::values.custom_rtc = std::nullopt;
|
|
|
|
}
|
|
|
|
|
2014-11-15 20:56:18 +01:00
|
|
|
// Core
|
2018-05-03 06:34:54 +02:00
|
|
|
Settings::values.use_multi_core = sdl2_config->GetBoolean("Core", "use_multi_core", false);
|
2014-10-25 21:54:44 +02:00
|
|
|
|
2015-04-04 00:35:51 +02:00
|
|
|
// Renderer
|
2020-01-21 20:37:41 +01:00
|
|
|
const int renderer_backend = sdl2_config->GetInteger(
|
|
|
|
"Renderer", "backend", static_cast<int>(Settings::RendererBackend::OpenGL));
|
|
|
|
Settings::values.renderer_backend = static_cast<Settings::RendererBackend>(renderer_backend);
|
|
|
|
Settings::values.renderer_debug = sdl2_config->GetBoolean("Renderer", "debug", false);
|
|
|
|
Settings::values.vulkan_device = sdl2_config->GetInteger("Renderer", "vulkan_device", 0);
|
|
|
|
|
2017-01-11 13:32:02 +01:00
|
|
|
Settings::values.resolution_factor =
|
2019-03-09 07:59:23 +01:00
|
|
|
static_cast<float>(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0));
|
2020-02-14 04:17:28 +01:00
|
|
|
Settings::values.aspect_ratio =
|
|
|
|
static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0));
|
2020-02-24 01:01:17 +01:00
|
|
|
Settings::values.max_anisotropy =
|
|
|
|
static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0));
|
2018-08-21 01:14:06 +02:00
|
|
|
Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true);
|
|
|
|
Settings::values.frame_limit =
|
|
|
|
static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100));
|
2019-01-14 06:14:27 +01:00
|
|
|
Settings::values.use_disk_shader_cache =
|
|
|
|
sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false);
|
2018-10-16 23:02:29 +02:00
|
|
|
Settings::values.use_accurate_gpu_emulation =
|
|
|
|
sdl2_config->GetBoolean("Renderer", "use_accurate_gpu_emulation", false);
|
2019-01-08 03:46:33 +01:00
|
|
|
Settings::values.use_asynchronous_gpu_emulation =
|
|
|
|
sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", false);
|
2020-02-14 04:06:11 +01:00
|
|
|
Settings::values.use_vsync =
|
|
|
|
static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync", 1));
|
2015-05-03 21:34:48 +02:00
|
|
|
|
2019-03-09 07:59:23 +01:00
|
|
|
Settings::values.bg_red = static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0));
|
|
|
|
Settings::values.bg_green =
|
|
|
|
static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0));
|
|
|
|
Settings::values.bg_blue = static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0));
|
2015-04-04 00:35:51 +02:00
|
|
|
|
2018-07-31 05:57:53 +02:00
|
|
|
// Audio
|
|
|
|
Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto");
|
2018-08-23 14:33:03 +02:00
|
|
|
Settings::values.enable_audio_stretching =
|
|
|
|
sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true);
|
2018-07-31 05:57:53 +02:00
|
|
|
Settings::values.audio_device_id = sdl2_config->Get("Audio", "output_device", "auto");
|
2019-03-09 07:58:20 +01:00
|
|
|
Settings::values.volume = static_cast<float>(sdl2_config->GetReal("Audio", "volume", 1));
|
2018-07-31 05:57:53 +02:00
|
|
|
|
2018-11-19 04:21:17 +01:00
|
|
|
Settings::values.language_index = sdl2_config->GetInteger("System", "language_index", 1);
|
|
|
|
|
2014-11-15 20:56:18 +01:00
|
|
|
// Miscellaneous
|
2018-01-13 22:23:12 +01:00
|
|
|
Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace");
|
2018-07-28 05:55:23 +02:00
|
|
|
Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false);
|
2015-09-02 14:56:38 +02:00
|
|
|
|
2015-10-12 02:07:58 +02:00
|
|
|
// Debugging
|
2019-08-26 17:29:08 +02:00
|
|
|
Settings::values.record_frame_times =
|
|
|
|
sdl2_config->GetBoolean("Debugging", "record_frame_times", false);
|
2016-03-01 18:24:18 +01:00
|
|
|
Settings::values.use_gdbstub = sdl2_config->GetBoolean("Debugging", "use_gdbstub", false);
|
2016-09-18 02:38:01 +02:00
|
|
|
Settings::values.gdbstub_port =
|
|
|
|
static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689));
|
2018-09-30 20:28:17 +02:00
|
|
|
Settings::values.program_args = sdl2_config->Get("Debugging", "program_args", "");
|
2018-11-20 23:49:09 +01:00
|
|
|
Settings::values.dump_exefs = sdl2_config->GetBoolean("Debugging", "dump_exefs", false);
|
2018-10-29 21:09:08 +01:00
|
|
|
Settings::values.dump_nso = sdl2_config->GetBoolean("Debugging", "dump_nso", false);
|
2019-05-18 03:44:28 +02:00
|
|
|
Settings::values.reporting_services =
|
|
|
|
sdl2_config->GetBoolean("Debugging", "reporting_services", false);
|
2019-06-29 00:37:33 +02:00
|
|
|
Settings::values.quest_flag = sdl2_config->GetBoolean("Debugging", "quest_flag", false);
|
2018-09-16 20:05:51 +02:00
|
|
|
|
2018-11-28 20:00:01 +01:00
|
|
|
const auto title_list = sdl2_config->Get("AddOns", "title_ids", "");
|
|
|
|
std::stringstream ss(title_list);
|
|
|
|
std::string line;
|
|
|
|
while (std::getline(ss, line, '|')) {
|
|
|
|
const auto title_id = std::stoul(line, nullptr, 16);
|
|
|
|
const auto disabled_list = sdl2_config->Get("AddOns", "disabled_" + line, "");
|
|
|
|
|
|
|
|
std::stringstream inner_ss(disabled_list);
|
|
|
|
std::string inner_line;
|
|
|
|
std::vector<std::string> out;
|
|
|
|
while (std::getline(inner_ss, inner_line, '|')) {
|
|
|
|
out.push_back(inner_line);
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings::values.disabled_addons.insert_or_assign(title_id, out);
|
|
|
|
}
|
|
|
|
|
2018-09-16 20:05:51 +02:00
|
|
|
// Web Service
|
|
|
|
Settings::values.enable_telemetry =
|
|
|
|
sdl2_config->GetBoolean("WebService", "enable_telemetry", true);
|
|
|
|
Settings::values.web_api_url =
|
|
|
|
sdl2_config->Get("WebService", "web_api_url", "https://api.yuzu-emu.org");
|
|
|
|
Settings::values.yuzu_username = sdl2_config->Get("WebService", "yuzu_username", "");
|
|
|
|
Settings::values.yuzu_token = sdl2_config->Get("WebService", "yuzu_token", "");
|
2019-04-29 00:44:46 +02:00
|
|
|
|
|
|
|
// Services
|
|
|
|
Settings::values.bcat_backend = sdl2_config->Get("Services", "bcat_backend", "boxcat");
|
|
|
|
Settings::values.bcat_boxcat_local =
|
|
|
|
sdl2_config->GetBoolean("Services", "bcat_boxcat_local", false);
|
2014-10-27 22:18:28 +01:00
|
|
|
}
|
|
|
|
|
2014-09-13 02:06:13 +02:00
|
|
|
void Config::Reload() {
|
2016-03-02 13:49:30 +01:00
|
|
|
LoadINI(DefaultINI::sdl2_config_file);
|
2014-11-15 20:56:18 +01:00
|
|
|
ReadValues();
|
2014-09-13 02:06:13 +02:00
|
|
|
}
|