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 00:06:02 +00:00
|
|
|
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-09-13 00:06:13 +00:00
|
|
|
|
2016-04-05 12:29:55 +00:00
|
|
|
#include <memory>
|
2022-03-15 05:05:55 +00:00
|
|
|
#include <optional>
|
2018-11-28 19:00:01 +00:00
|
|
|
#include <sstream>
|
2022-11-25 18:35:46 +00:00
|
|
|
#include <INIReader.h>
|
2023-05-05 07:48:28 +00:00
|
|
|
#include <SDL.h>
|
2021-05-25 23:32:56 +00:00
|
|
|
#include "common/fs/file.h"
|
|
|
|
#include "common/fs/fs.h"
|
|
|
|
#include "common/fs/path_util.h"
|
2015-05-06 07:06:12 +00:00
|
|
|
#include "common/logging/log.h"
|
2021-04-14 23:07:40 +00:00
|
|
|
#include "common/settings.h"
|
2018-10-13 17:02:33 +00:00
|
|
|
#include "core/hle/service/acc/profile_manager.h"
|
2017-01-21 09:53:03 +00:00
|
|
|
#include "input_common/main.h"
|
2018-01-12 03:38:17 +00:00
|
|
|
#include "yuzu_cmd/config.h"
|
|
|
|
#include "yuzu_cmd/default_ini.h"
|
|
|
|
|
2020-08-15 12:33:16 +00:00
|
|
|
namespace FS = Common::FS;
|
|
|
|
|
2022-03-15 05:05:55 +00:00
|
|
|
const std::filesystem::path default_config_path =
|
|
|
|
FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "sdl2-config.ini";
|
2014-09-13 00:06:13 +00:00
|
|
|
|
2022-03-15 05:05:55 +00: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 00:06:13 +00:00
|
|
|
Reload();
|
|
|
|
}
|
|
|
|
|
2017-05-28 01:14:00 +00:00
|
|
|
Config::~Config() = default;
|
|
|
|
|
2016-03-02 12:49:30 +00:00
|
|
|
bool Config::LoadINI(const std::string& default_contents, bool retry) {
|
2021-05-25 23:32:56 +00:00
|
|
|
const auto config_loc_str = FS::PathToUTF8String(sdl2_config_loc);
|
2016-03-02 12:49:30 +00:00
|
|
|
if (sdl2_config->ParseError() < 0) {
|
2014-09-13 00:06:13 +00:00
|
|
|
if (retry) {
|
2021-05-25 23:32:56 +00: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 00:06:13 +00:00
|
|
|
|
2016-03-02 12:49:30 +00:00
|
|
|
return LoadINI(default_contents, false);
|
2014-09-13 00:06:13 +00:00
|
|
|
}
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_ERROR(Config, "Failed.");
|
2014-09-13 00:06:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-05-25 23:32:56 +00:00
|
|
|
LOG_INFO(Config, "Successfully loaded {}", config_loc_str);
|
2014-09-13 00:06:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 09:53:03 +00: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 03:34:45 +00:00
|
|
|
};
|
|
|
|
|
2022-02-05 07:31:55 +00:00
|
|
|
static const std::array<int, Settings::NativeMotion::NumMotions> default_motions = {
|
|
|
|
SDL_SCANCODE_7,
|
|
|
|
SDL_SCANCODE_8,
|
|
|
|
};
|
|
|
|
|
2017-01-21 11:04:00 +00:00
|
|
|
static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs{{
|
|
|
|
{
|
2018-01-20 07:48:02 +00:00
|
|
|
SDL_SCANCODE_UP,
|
|
|
|
SDL_SCANCODE_DOWN,
|
|
|
|
SDL_SCANCODE_LEFT,
|
|
|
|
SDL_SCANCODE_RIGHT,
|
|
|
|
SDL_SCANCODE_D,
|
2017-01-21 11:04:00 +00:00
|
|
|
},
|
|
|
|
{
|
2018-01-20 07:48:02 +00:00
|
|
|
SDL_SCANCODE_I,
|
|
|
|
SDL_SCANCODE_K,
|
|
|
|
SDL_SCANCODE_J,
|
|
|
|
SDL_SCANCODE_L,
|
|
|
|
SDL_SCANCODE_D,
|
2017-01-21 11:04:00 +00:00
|
|
|
},
|
|
|
|
}};
|
|
|
|
|
2021-06-28 19:58:16 +00:00
|
|
|
template <>
|
2022-06-30 16:32:03 +00:00
|
|
|
void Config::ReadSetting(const std::string& group, Settings::Setting<std::string>& setting) {
|
2022-11-27 02:09:08 +00: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 19:58:16 +00:00
|
|
|
}
|
2021-07-09 02:04:24 +00:00
|
|
|
|
2021-06-28 19:58:16 +00:00
|
|
|
template <>
|
2022-06-30 16:32:03 +00:00
|
|
|
void Config::ReadSetting(const std::string& group, Settings::Setting<bool>& setting) {
|
2021-06-28 19:58:16 +00:00
|
|
|
setting = sdl2_config->GetBoolean(group, setting.GetLabel(), setting.GetDefault());
|
|
|
|
}
|
2021-07-09 02:04:24 +00:00
|
|
|
|
2022-07-15 17:37:48 +00:00
|
|
|
template <typename Type, bool ranged>
|
|
|
|
void Config::ReadSetting(const std::string& group, Settings::Setting<Type, ranged>& setting) {
|
2021-06-28 19:58:16 +00:00
|
|
|
setting = static_cast<Type>(sdl2_config->GetInteger(group, setting.GetLabel(),
|
|
|
|
static_cast<long>(setting.GetDefault())));
|
|
|
|
}
|
|
|
|
|
2023-06-06 01:05:22 +00:00
|
|
|
void Config::ReadCategory(Settings::Category category) {
|
|
|
|
for (const auto setting : Settings::values.linkage.by_category[category]) {
|
|
|
|
const char* category_name = [&]() {
|
|
|
|
if (category == Settings::Category::Controls) {
|
|
|
|
// For compatibility with older configs
|
|
|
|
return "ControlsGeneral";
|
|
|
|
} else {
|
|
|
|
return Settings::TranslateCategory(category);
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
std::string setting_value =
|
|
|
|
sdl2_config->Get(category_name, setting->GetLabel(), setting->DefaultToString());
|
|
|
|
setting->LoadString(setting_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-15 19:56:18 +00:00
|
|
|
void Config::ReadValues() {
|
|
|
|
// Controls
|
2023-06-06 01:05:22 +00:00
|
|
|
ReadCategory(Settings::Category::Controls);
|
|
|
|
|
2020-09-28 14:00:15 +00:00
|
|
|
for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
|
2022-02-05 07:31:55 +00:00
|
|
|
auto& player = Settings::values.players.GetValue()[p];
|
|
|
|
|
2018-11-02 01:55:35 +00: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 07:31:55 +00:00
|
|
|
player.buttons[i] =
|
2018-11-02 01:55:35 +00:00
|
|
|
sdl2_config->Get(group, Settings::NativeButton::mapping[i], default_param);
|
2022-02-05 07:31:55 +00:00
|
|
|
if (player.buttons[i].empty()) {
|
|
|
|
player.buttons[i] = default_param;
|
|
|
|
}
|
2018-11-02 01:55:35 +00: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 07:31:55 +00:00
|
|
|
player.analogs[i] =
|
2018-11-02 01:55:35 +00:00
|
|
|
sdl2_config->Get(group, Settings::NativeAnalog::mapping[i], default_param);
|
2022-02-05 07:31:55 +00: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 01:55:35 +00:00
|
|
|
}
|
2021-08-04 21:06:39 +00:00
|
|
|
|
2022-02-05 07:31:55 +00:00
|
|
|
player.connected = sdl2_config->GetBoolean(group, "connected", false);
|
2018-11-02 01:55:35 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 09:53:03 +00:00
|
|
|
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
|
|
|
|
std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
|
2018-11-02 01:55:35 +00: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 03:34:45 +00:00
|
|
|
}
|
2014-09-13 00:06:13 +00:00
|
|
|
|
2017-01-21 11:04:00 +00: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 01:55:35 +00: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 11:04:00 +00:00
|
|
|
}
|
|
|
|
|
2018-11-02 01:55:35 +00: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-03 22:58:35 +00: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 19:58:16 +00: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-03 22:58:35 +00:00
|
|
|
|
2023-06-06 01:05:22 +00:00
|
|
|
ReadCategory(Settings::Category::Audio);
|
|
|
|
ReadCategory(Settings::Category::Core);
|
|
|
|
ReadCategory(Settings::Category::Cpu);
|
2023-05-07 14:35:28 +00:00
|
|
|
ReadCategory(Settings::Category::CpuDebug);
|
|
|
|
ReadCategory(Settings::Category::CpuUnsafe);
|
2023-06-06 01:05:22 +00:00
|
|
|
ReadCategory(Settings::Category::Renderer);
|
2023-05-07 14:35:28 +00:00
|
|
|
ReadCategory(Settings::Category::RendererAdvanced);
|
|
|
|
ReadCategory(Settings::Category::RendererDebug);
|
2023-06-06 01:05:22 +00:00
|
|
|
ReadCategory(Settings::Category::System);
|
|
|
|
ReadCategory(Settings::Category::DataStorage);
|
|
|
|
ReadCategory(Settings::Category::Debugging);
|
2023-05-07 14:35:28 +00:00
|
|
|
ReadCategory(Settings::Category::DebuggingGraphics);
|
2023-06-06 01:05:22 +00:00
|
|
|
ReadCategory(Settings::Category::Miscellaneous);
|
|
|
|
ReadCategory(Settings::Category::Network);
|
|
|
|
ReadCategory(Settings::Category::WebService);
|
2018-11-02 01:55:35 +00:00
|
|
|
|
|
|
|
// Data Storage
|
2021-05-25 23:32:56 +00: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)));
|
2015-09-02 12:56:38 +00:00
|
|
|
|
2015-10-12 00:07:58 +00:00
|
|
|
// Debugging
|
2019-08-26 15:29:08 +00:00
|
|
|
Settings::values.record_frame_times =
|
|
|
|
sdl2_config->GetBoolean("Debugging", "record_frame_times", false);
|
2018-09-16 18:05:51 +00:00
|
|
|
|
2018-11-28 19:00:01 +00: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);
|
|
|
|
}
|
2014-10-27 21:18:28 +00:00
|
|
|
}
|
|
|
|
|
2014-09-13 00:06:13 +00:00
|
|
|
void Config::Reload() {
|
2016-03-02 12:49:30 +00:00
|
|
|
LoadINI(DefaultINI::sdl2_config_file);
|
2014-11-15 19:56:18 +00:00
|
|
|
ReadValues();
|
2014-09-13 00:06:13 +00:00
|
|
|
}
|