chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75b1e47beb08937439f3ed9339e7b254
2022-05-15 02:06:02 +02:00
|
|
|
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-09-13 02:06:13 +02:00
|
|
|
|
2016-04-05 14:29:55 +02:00
|
|
|
#include <memory>
|
2022-03-15 06:05:55 +01:00
|
|
|
#include <optional>
|
2018-11-28 20:00:01 +01:00
|
|
|
#include <sstream>
|
2021-04-18 06:40:31 +02:00
|
|
|
|
|
|
|
// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307
|
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
|
|
|
|
#endif
|
2016-03-01 18:24:18 +01:00
|
|
|
#include <SDL.h>
|
2021-04-18 06:40:31 +02:00
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
#endif
|
|
|
|
|
2016-09-20 17:21:23 +02:00
|
|
|
#include <inih/cpp/INIReader.h>
|
2021-05-26 01:32:56 +02:00
|
|
|
#include "common/fs/file.h"
|
|
|
|
#include "common/fs/fs.h"
|
|
|
|
#include "common/fs/path_util.h"
|
2015-05-06 09:06:12 +02:00
|
|
|
#include "common/logging/log.h"
|
2021-04-15 01:07:40 +02:00
|
|
|
#include "common/settings.h"
|
2018-10-13 19:02:33 +02:00
|
|
|
#include "core/hle/service/acc/profile_manager.h"
|
2017-01-21 10:53:03 +01:00
|
|
|
#include "input_common/main.h"
|
2018-01-12 04:38:17 +01:00
|
|
|
#include "yuzu_cmd/config.h"
|
|
|
|
#include "yuzu_cmd/default_ini.h"
|
|
|
|
|
2020-08-15 14:33:16 +02:00
|
|
|
namespace FS = Common::FS;
|
|
|
|
|
2022-03-15 06:05:55 +01:00
|
|
|
const std::filesystem::path default_config_path =
|
|
|
|
FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "sdl2-config.ini";
|
2014-09-13 02:06:13 +02:00
|
|
|
|
2022-03-15 06:05:55 +01:00
|
|
|
Config::Config(std::optional<std::filesystem::path> config_path)
|
|
|
|
: sdl2_config_loc{config_path.value_or(default_config_path)},
|
|
|
|
sdl2_config{std::make_unique<INIReader>(FS::PathToUTF8String(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) {
|
2021-05-26 01:32:56 +02:00
|
|
|
const auto config_loc_str = FS::PathToUTF8String(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) {
|
2021-05-26 01:32:56 +02:00
|
|
|
LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...",
|
|
|
|
config_loc_str);
|
|
|
|
|
|
|
|
void(FS::CreateParentDir(sdl2_config_loc));
|
|
|
|
void(FS::WriteStringToFile(sdl2_config_loc, FS::FileType::TextFile, default_contents));
|
|
|
|
|
|
|
|
sdl2_config = std::make_unique<INIReader>(config_loc_str);
|
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;
|
|
|
|
}
|
2021-05-26 01:32:56 +02:00
|
|
|
LOG_INFO(Config, "Successfully loaded {}", config_loc_str);
|
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
|
|
|
};
|
|
|
|
|
2022-02-05 08:31:55 +01:00
|
|
|
static const std::array<int, Settings::NativeMotion::NumMotions> default_motions = {
|
|
|
|
SDL_SCANCODE_7,
|
|
|
|
SDL_SCANCODE_8,
|
|
|
|
};
|
|
|
|
|
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
|
|
|
},
|
|
|
|
}};
|
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
template <>
|
2022-06-30 18:32:03 +02:00
|
|
|
void Config::ReadSetting(const std::string& group, Settings::Setting<std::string>& setting) {
|
2022-11-27 03:09:08 +01:00
|
|
|
std::string setting_value = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault());
|
|
|
|
if (setting_value.empty()) {
|
|
|
|
setting_value = setting.GetDefault();
|
|
|
|
}
|
|
|
|
setting = std::move(setting_value);
|
2021-06-28 21:58:16 +02:00
|
|
|
}
|
2021-07-09 04:04:24 +02:00
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
template <>
|
2022-06-30 18:32:03 +02:00
|
|
|
void Config::ReadSetting(const std::string& group, Settings::Setting<bool>& setting) {
|
2021-06-28 21:58:16 +02:00
|
|
|
setting = sdl2_config->GetBoolean(group, setting.GetLabel(), setting.GetDefault());
|
|
|
|
}
|
2021-07-09 04:04:24 +02:00
|
|
|
|
2022-07-15 19:37:48 +02:00
|
|
|
template <typename Type, bool ranged>
|
|
|
|
void Config::ReadSetting(const std::string& group, Settings::Setting<Type, ranged>& setting) {
|
2021-06-28 21:58:16 +02:00
|
|
|
setting = static_cast<Type>(sdl2_config->GetInteger(group, setting.GetLabel(),
|
|
|
|
static_cast<long>(setting.GetDefault())));
|
|
|
|
}
|
|
|
|
|
2014-11-15 20:56:18 +01:00
|
|
|
void Config::ReadValues() {
|
|
|
|
// Controls
|
2020-09-28 16:00:15 +02:00
|
|
|
for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
|
2022-02-05 08:31:55 +01:00
|
|
|
auto& player = Settings::values.players.GetValue()[p];
|
|
|
|
|
2018-11-02 02:55:35 +01:00
|
|
|
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]);
|
2022-02-05 08:31:55 +01:00
|
|
|
player.buttons[i] =
|
2018-11-02 02:55:35 +01:00
|
|
|
sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param);
|
2022-02-05 08:31:55 +01:00
|
|
|
if (player.buttons[i].empty()) {
|
|
|
|
player.buttons[i] = default_param;
|
|
|
|
}
|
2018-11-02 02:55:35 +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);
|
2022-02-05 08:31:55 +01:00
|
|
|
player.analogs[i] =
|
2018-11-02 02:55:35 +01:00
|
|
|
sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param);
|
2022-02-05 08:31:55 +01:00
|
|
|
if (player.analogs[i].empty()) {
|
|
|
|
player.analogs[i] = default_param;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) {
|
|
|
|
const std::string default_param =
|
|
|
|
InputCommon::GenerateKeyboardParam(default_motions[i]);
|
|
|
|
auto& player_motions = player.motions[i];
|
|
|
|
|
|
|
|
player_motions =
|
|
|
|
sdl2_config->Get(group, Settings::NativeMotion::mapping[i], default_param);
|
|
|
|
if (player_motions.empty()) {
|
|
|
|
player_motions = default_param;
|
|
|
|
}
|
2018-11-02 02:55:35 +01:00
|
|
|
}
|
2021-08-04 23:06:39 +02:00
|
|
|
|
2022-02-05 08:31:55 +01:00
|
|
|
player.connected = sdl2_config->GetBoolean(group, "connected", false);
|
2018-11-02 02:55:35 +01:00
|
|
|
}
|
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("ControlsGeneral", Settings::values.mouse_enabled);
|
2018-11-02 02:55:35 +01:00
|
|
|
|
2021-07-16 02:48:16 +02:00
|
|
|
ReadSetting("ControlsGeneral", Settings::values.touch_device);
|
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("ControlsGeneral", Settings::values.keyboard_enabled);
|
2018-11-02 02:55:35 +01:00
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("ControlsGeneral", Settings::values.debug_pad_enabled);
|
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
|
|
|
}
|
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("ControlsGeneral", Settings::values.vibration_enabled);
|
|
|
|
ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations);
|
|
|
|
ReadSetting("ControlsGeneral", Settings::values.motion_enabled);
|
2018-11-02 02:55:35 +01:00
|
|
|
Settings::values.touchscreen.enabled =
|
|
|
|
sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true);
|
|
|
|
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);
|
2021-06-04 00:58:35 +02:00
|
|
|
|
|
|
|
int num_touch_from_button_maps =
|
|
|
|
sdl2_config->GetInteger("ControlsGeneral", "touch_from_button_map", 0);
|
|
|
|
if (num_touch_from_button_maps > 0) {
|
|
|
|
for (int i = 0; i < num_touch_from_button_maps; ++i) {
|
|
|
|
Settings::TouchFromButtonMap map;
|
|
|
|
map.name = sdl2_config->Get("ControlsGeneral",
|
|
|
|
std::string("touch_from_button_maps_") + std::to_string(i) +
|
|
|
|
std::string("_name"),
|
|
|
|
"default");
|
|
|
|
const int num_touch_maps = sdl2_config->GetInteger(
|
|
|
|
"ControlsGeneral",
|
|
|
|
std::string("touch_from_button_maps_") + std::to_string(i) + std::string("_count"),
|
|
|
|
0);
|
|
|
|
map.buttons.reserve(num_touch_maps);
|
|
|
|
|
|
|
|
for (int j = 0; j < num_touch_maps; ++j) {
|
|
|
|
std::string touch_mapping =
|
|
|
|
sdl2_config->Get("ControlsGeneral",
|
|
|
|
std::string("touch_from_button_maps_") + std::to_string(i) +
|
|
|
|
std::string("_bind_") + std::to_string(j),
|
|
|
|
"");
|
|
|
|
map.buttons.emplace_back(std::move(touch_mapping));
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings::values.touch_from_button_maps.emplace_back(std::move(map));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Settings::values.touch_from_button_maps.emplace_back(
|
|
|
|
Settings::TouchFromButtonMap{"default", {}});
|
|
|
|
num_touch_from_button_maps = 1;
|
|
|
|
}
|
2021-06-28 21:58:16 +02:00
|
|
|
Settings::values.touch_from_button_map_index = std::clamp(
|
|
|
|
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);
|
2021-06-04 00:58:35 +02:00
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("ControlsGeneral", Settings::values.udp_input_servers);
|
2018-11-02 02:55:35 +01:00
|
|
|
|
|
|
|
// Data Storage
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Data Storage", Settings::values.use_virtual_sd);
|
2021-05-26 01:32:56 +02:00
|
|
|
FS::SetYuzuPath(FS::YuzuPath::NANDDir,
|
|
|
|
sdl2_config->Get("Data Storage", "nand_directory",
|
|
|
|
FS::GetYuzuPathString(FS::YuzuPath::NANDDir)));
|
|
|
|
FS::SetYuzuPath(FS::YuzuPath::SDMCDir,
|
|
|
|
sdl2_config->Get("Data Storage", "sdmc_directory",
|
|
|
|
FS::GetYuzuPathString(FS::YuzuPath::SDMCDir)));
|
|
|
|
FS::SetYuzuPath(FS::YuzuPath::LoadDir,
|
|
|
|
sdl2_config->Get("Data Storage", "load_directory",
|
|
|
|
FS::GetYuzuPathString(FS::YuzuPath::LoadDir)));
|
|
|
|
FS::SetYuzuPath(FS::YuzuPath::DumpDir,
|
|
|
|
sdl2_config->Get("Data Storage", "dump_directory",
|
|
|
|
FS::GetYuzuPathString(FS::YuzuPath::DumpDir)));
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Data Storage", Settings::values.gamecard_inserted);
|
|
|
|
ReadSetting("Data Storage", Settings::values.gamecard_current_game);
|
|
|
|
ReadSetting("Data Storage", Settings::values.gamecard_path);
|
2018-11-02 02:55:35 +01:00
|
|
|
|
|
|
|
// System
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("System", Settings::values.use_docked_mode);
|
2018-11-02 02:55:35 +01:00
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("System", Settings::values.current_user);
|
|
|
|
Settings::values.current_user = std::clamp<int>(Settings::values.current_user.GetValue(), 0,
|
|
|
|
Service::Account::MAX_USERS - 1);
|
2018-11-02 02:55:35 +01:00
|
|
|
|
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) {
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-10 04:42:09 +02:00
|
|
|
Settings::values.rng_seed.SetValue(sdl2_config->GetInteger("System", "rng_seed", 0));
|
2018-11-17 22:26:03 +01:00
|
|
|
} else {
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-10 04:42:09 +02:00
|
|
|
Settings::values.rng_seed.SetValue(std::nullopt);
|
2018-11-17 22:26:03 +01:00
|
|
|
}
|
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) {
|
2021-10-16 08:07:18 +02:00
|
|
|
Settings::values.custom_rtc = sdl2_config->GetInteger("System", "custom_rtc", 0);
|
2018-12-29 00:35:55 +01:00
|
|
|
} else {
|
2021-05-16 07:17:18 +02:00
|
|
|
Settings::values.custom_rtc = std::nullopt;
|
2018-12-29 00:35:55 +01:00
|
|
|
}
|
|
|
|
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("System", Settings::values.language_index);
|
2021-07-16 02:48:16 +02:00
|
|
|
ReadSetting("System", Settings::values.region_index);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("System", Settings::values.time_zone_index);
|
2021-07-16 02:48:16 +02:00
|
|
|
ReadSetting("System", Settings::values.sound_index);
|
2020-05-11 23:50:07 +02:00
|
|
|
|
2014-11-15 20:56:18 +01:00
|
|
|
// Core
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Core", Settings::values.use_multi_core);
|
2022-02-21 21:35:32 +01:00
|
|
|
ReadSetting("Core", Settings::values.use_extended_memory_layout);
|
2014-10-25 21:54:44 +02:00
|
|
|
|
2021-07-16 02:48:16 +02:00
|
|
|
// Cpu
|
|
|
|
ReadSetting("Cpu", Settings::values.cpu_accuracy);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpu_debug_mode);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_page_tables);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_block_linking);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_return_stack_buffer);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_fast_dispatcher);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_context_elimination);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_const_prop);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_misc_ir);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_reduce_misalign_checks);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_fastmem);
|
2022-02-27 20:40:05 +01:00
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_fastmem_exclusives);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_recompile_exclusives);
|
2021-07-16 02:48:16 +02:00
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_unsafe_unfuse_fma);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_unsafe_reduce_fp_error);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_unsafe_ignore_standard_fpcr);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_unsafe_inaccurate_nan);
|
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_unsafe_fastmem_check);
|
2022-02-27 20:40:05 +01:00
|
|
|
ReadSetting("Cpu", Settings::values.cpuopt_unsafe_ignore_global_monitor);
|
2021-07-16 02:48:16 +02:00
|
|
|
|
2015-04-04 00:35:51 +02:00
|
|
|
// Renderer
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.renderer_backend);
|
|
|
|
ReadSetting("Renderer", Settings::values.renderer_debug);
|
2021-07-28 00:15:32 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.renderer_shader_feedback);
|
2021-07-08 23:22:31 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.enable_nsight_aftermath);
|
|
|
|
ReadSetting("Renderer", Settings::values.disable_shader_loop_safety_checks);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.vulkan_device);
|
|
|
|
|
2021-10-09 02:48:10 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.resolution_setup);
|
|
|
|
ReadSetting("Renderer", Settings::values.scaling_filter);
|
2022-11-20 01:04:04 +01:00
|
|
|
ReadSetting("Renderer", Settings::values.fsr_sharpening_slider);
|
2021-10-21 01:33:07 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.anti_aliasing);
|
2021-07-22 01:48:03 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.fullscreen_mode);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.aspect_ratio);
|
|
|
|
ReadSetting("Renderer", Settings::values.max_anisotropy);
|
2021-07-23 01:56:21 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.use_speed_limit);
|
|
|
|
ReadSetting("Renderer", Settings::values.speed_limit);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.use_disk_shader_cache);
|
|
|
|
ReadSetting("Renderer", Settings::values.gpu_accuracy);
|
|
|
|
ReadSetting("Renderer", Settings::values.use_asynchronous_gpu_emulation);
|
|
|
|
ReadSetting("Renderer", Settings::values.use_vsync);
|
2021-07-08 23:28:48 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.shader_backend);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.use_asynchronous_shaders);
|
2021-08-08 22:56:40 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.nvdec_emulation);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.accelerate_astc);
|
|
|
|
ReadSetting("Renderer", Settings::values.use_fast_gpu_time);
|
2022-08-25 18:32:14 +02:00
|
|
|
ReadSetting("Renderer", Settings::values.use_pessimistic_flushes);
|
2021-06-28 21:58:16 +02:00
|
|
|
|
|
|
|
ReadSetting("Renderer", Settings::values.bg_red);
|
|
|
|
ReadSetting("Renderer", Settings::values.bg_green);
|
|
|
|
ReadSetting("Renderer", Settings::values.bg_blue);
|
2015-04-04 00:35:51 +02:00
|
|
|
|
2018-07-31 05:57:53 +02:00
|
|
|
// Audio
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Audio", Settings::values.sink_id);
|
2022-07-17 00:48:45 +02:00
|
|
|
ReadSetting("Audio", Settings::values.audio_output_device_id);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Audio", Settings::values.volume);
|
2018-07-31 05:57:53 +02:00
|
|
|
|
2014-11-15 20:56:18 +01:00
|
|
|
// Miscellaneous
|
2021-06-28 21:58:16 +02:00
|
|
|
// log_filter has a different default here than from common
|
|
|
|
Settings::values.log_filter =
|
|
|
|
sdl2_config->Get("Miscellaneous", Settings::values.log_filter.GetLabel(), "*:Trace");
|
|
|
|
ReadSetting("Miscellaneous", Settings::values.use_dev_keys);
|
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);
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("Debugging", Settings::values.dump_exefs);
|
|
|
|
ReadSetting("Debugging", Settings::values.dump_nso);
|
|
|
|
ReadSetting("Debugging", Settings::values.enable_fs_access_log);
|
|
|
|
ReadSetting("Debugging", Settings::values.reporting_services);
|
|
|
|
ReadSetting("Debugging", Settings::values.quest_flag);
|
|
|
|
ReadSetting("Debugging", Settings::values.use_debug_asserts);
|
|
|
|
ReadSetting("Debugging", Settings::values.use_auto_stub);
|
|
|
|
ReadSetting("Debugging", Settings::values.disable_macro_jit);
|
2022-06-10 15:11:02 +02:00
|
|
|
ReadSetting("Debugging", Settings::values.use_gdbstub);
|
|
|
|
ReadSetting("Debugging", Settings::values.gdbstub_port);
|
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
|
2021-06-28 21:58:16 +02:00
|
|
|
ReadSetting("WebService", Settings::values.enable_telemetry);
|
|
|
|
ReadSetting("WebService", Settings::values.web_api_url);
|
|
|
|
ReadSetting("WebService", Settings::values.yuzu_username);
|
|
|
|
ReadSetting("WebService", Settings::values.yuzu_token);
|
2021-10-15 18:14:09 +02:00
|
|
|
|
|
|
|
// Network
|
|
|
|
ReadSetting("Network", Settings::values.network_interface);
|
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
|
|
|
}
|