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
|
2013-08-30 03:35:09 +00:00
|
|
|
|
2020-02-25 15:12:46 +00:00
|
|
|
#include <chrono>
|
2015-06-23 00:59:00 +00:00
|
|
|
#include <iostream>
|
2016-04-05 12:29:55 +00:00
|
|
|
#include <memory>
|
2021-12-25 19:27:52 +00:00
|
|
|
#include <regex>
|
2016-09-18 00:38:01 +00:00
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
2015-06-23 00:59:00 +00:00
|
|
|
|
2018-08-15 09:38:37 +00:00
|
|
|
#include <fmt/ostream.h>
|
|
|
|
|
2018-09-16 18:05:51 +00:00
|
|
|
#include "common/detached_tasks.h"
|
2018-05-24 01:51:49 +00:00
|
|
|
#include "common/logging/backend.h"
|
|
|
|
#include "common/logging/log.h"
|
2015-08-17 21:25:21 +00:00
|
|
|
#include "common/microprofile.h"
|
2021-01-20 23:09:57 +00:00
|
|
|
#include "common/nvidia_flags.h"
|
2018-05-24 01:51:49 +00:00
|
|
|
#include "common/scm_rev.h"
|
|
|
|
#include "common/scope_exit.h"
|
2021-04-14 23:07:40 +00:00
|
|
|
#include "common/settings.h"
|
2018-05-24 01:51:49 +00:00
|
|
|
#include "common/string_util.h"
|
2018-08-31 16:21:34 +00:00
|
|
|
#include "common/telemetry.h"
|
2018-05-24 01:51:49 +00:00
|
|
|
#include "core/core.h"
|
2023-07-02 19:05:35 +00:00
|
|
|
#include "core/core_timing.h"
|
2022-06-17 03:42:39 +00:00
|
|
|
#include "core/cpu_manager.h"
|
2018-09-19 13:09:03 +00:00
|
|
|
#include "core/crypto/key_manager.h"
|
2020-08-27 19:16:47 +00:00
|
|
|
#include "core/file_sys/registered_cache.h"
|
2018-08-31 16:21:34 +00:00
|
|
|
#include "core/file_sys/vfs_real.h"
|
2018-09-19 13:09:03 +00:00
|
|
|
#include "core/hle/service/filesystem/filesystem.h"
|
2018-05-24 01:51:49 +00:00
|
|
|
#include "core/loader/loader.h"
|
2018-08-31 16:21:34 +00:00
|
|
|
#include "core/telemetry_session.h"
|
2020-08-27 19:16:47 +00:00
|
|
|
#include "input_common/main.h"
|
2021-12-25 19:27:52 +00:00
|
|
|
#include "network/network.h"
|
2019-01-21 19:38:23 +00:00
|
|
|
#include "video_core/renderer_base.h"
|
2018-05-24 01:51:49 +00:00
|
|
|
#include "yuzu_cmd/config.h"
|
|
|
|
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
|
2019-05-25 20:47:13 +00:00
|
|
|
#include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h"
|
2022-11-28 01:37:37 +00:00
|
|
|
#include "yuzu_cmd/emu_window/emu_window_sdl2_null.h"
|
2020-01-21 19:40:53 +00:00
|
|
|
#include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h"
|
2015-08-17 21:25:21 +00:00
|
|
|
|
2016-06-08 05:53:41 +00:00
|
|
|
#ifdef _WIN32
|
2017-06-25 00:38:16 +00:00
|
|
|
// windows.h needs to be included before shellapi.h
|
2016-12-03 20:08:02 +00:00
|
|
|
#include <windows.h>
|
2017-06-25 00:38:16 +00:00
|
|
|
|
|
|
|
#include <shellapi.h>
|
2023-03-02 01:07:59 +00:00
|
|
|
|
|
|
|
#include "common/windows/timer_resolution.h"
|
2016-06-08 05:53:41 +00:00
|
|
|
#endif
|
|
|
|
|
2019-04-15 21:32:47 +00:00
|
|
|
#undef _UNICODE
|
|
|
|
#include <getopt.h>
|
|
|
|
#ifndef _MSC_VER
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2018-04-19 18:22:26 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
extern "C" {
|
|
|
|
// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable
|
|
|
|
// graphics
|
|
|
|
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
|
|
|
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
static void PrintHelp(const char* argv0) {
|
|
|
|
std::cout << "Usage: " << argv0
|
|
|
|
<< " [options] <filename>\n"
|
2023-02-04 17:32:14 +00:00
|
|
|
"-c, --config Load the specified configuration file\n"
|
2018-09-30 18:28:17 +00:00
|
|
|
"-f, --fullscreen Start in fullscreen mode\n"
|
2023-02-04 17:32:14 +00:00
|
|
|
"-g, --game File path of the game to load\n"
|
2016-04-19 01:24:21 +00:00
|
|
|
"-h, --help Display this help and exit\n"
|
2023-02-04 17:32:14 +00:00
|
|
|
"-m, --multiplayer=nick:password@address:port"
|
|
|
|
" Nickname, password, address and port for multiplayer\n"
|
2022-03-15 05:05:55 +00:00
|
|
|
"-p, --program Pass following string as arguments to executable\n"
|
2023-02-04 17:32:14 +00:00
|
|
|
"-u, --user Select a specific user profile from 0 to 7\n"
|
|
|
|
"-v, --version Output version information and exit\n";
|
2016-04-19 01:24:21 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
static void PrintVersion() {
|
2018-01-13 23:49:16 +00:00
|
|
|
std::cout << "yuzu " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl;
|
2015-06-23 00:59:00 +00:00
|
|
|
}
|
|
|
|
|
2021-12-25 19:27:52 +00:00
|
|
|
static void OnStateChanged(const Network::RoomMember::State& state) {
|
|
|
|
switch (state) {
|
|
|
|
case Network::RoomMember::State::Idle:
|
|
|
|
LOG_DEBUG(Network, "Network is idle");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::State::Joining:
|
|
|
|
LOG_DEBUG(Network, "Connection sequence to room started");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::State::Joined:
|
|
|
|
LOG_DEBUG(Network, "Successfully joined to the room");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::State::Moderator:
|
|
|
|
LOG_DEBUG(Network, "Successfully joined the room as a moderator");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OnNetworkError(const Network::RoomMember::Error& error) {
|
|
|
|
switch (error) {
|
|
|
|
case Network::RoomMember::Error::LostConnection:
|
|
|
|
LOG_DEBUG(Network, "Lost connection to the room");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::CouldNotConnect:
|
|
|
|
LOG_ERROR(Network, "Error: Could not connect");
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::NameCollision:
|
|
|
|
LOG_ERROR(
|
|
|
|
Network,
|
|
|
|
"You tried to use the same nickname as another user that is connected to the Room");
|
|
|
|
exit(1);
|
|
|
|
break;
|
2022-07-30 03:58:23 +00:00
|
|
|
case Network::RoomMember::Error::IpCollision:
|
|
|
|
LOG_ERROR(Network, "You tried to use the same fake IP-Address as another user that is "
|
2021-12-25 19:27:52 +00:00
|
|
|
"connected to the Room");
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::WrongPassword:
|
|
|
|
LOG_ERROR(Network, "Room replied with: Wrong password");
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::WrongVersion:
|
|
|
|
LOG_ERROR(Network,
|
|
|
|
"You are using a different version than the room you are trying to connect to");
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::RoomIsFull:
|
|
|
|
LOG_ERROR(Network, "The room is full");
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::HostKicked:
|
|
|
|
LOG_ERROR(Network, "You have been kicked by the host");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::HostBanned:
|
|
|
|
LOG_ERROR(Network, "You have been banned by the host");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::UnknownError:
|
|
|
|
LOG_ERROR(Network, "UnknownError");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::PermissionDenied:
|
|
|
|
LOG_ERROR(Network, "PermissionDenied");
|
|
|
|
break;
|
|
|
|
case Network::RoomMember::Error::NoSuchUser:
|
|
|
|
LOG_ERROR(Network, "NoSuchUser");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OnMessageReceived(const Network::ChatEntry& msg) {
|
|
|
|
std::cout << std::endl << msg.nickname << ": " << msg.message << std::endl << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) {
|
|
|
|
std::string message;
|
|
|
|
switch (msg.type) {
|
|
|
|
case Network::IdMemberJoin:
|
|
|
|
message = fmt::format("{} has joined", msg.nickname);
|
|
|
|
break;
|
|
|
|
case Network::IdMemberLeave:
|
|
|
|
message = fmt::format("{} has left", msg.nickname);
|
|
|
|
break;
|
|
|
|
case Network::IdMemberKicked:
|
|
|
|
message = fmt::format("{} has been kicked", msg.nickname);
|
|
|
|
break;
|
|
|
|
case Network::IdMemberBanned:
|
|
|
|
message = fmt::format("{} has been banned", msg.nickname);
|
|
|
|
break;
|
|
|
|
case Network::IdAddressUnbanned:
|
|
|
|
message = fmt::format("{} has been unbanned", msg.nickname);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!message.empty())
|
|
|
|
std::cout << std::endl << "* " << message << std::endl << std::endl;
|
|
|
|
}
|
|
|
|
|
2013-08-30 03:35:09 +00:00
|
|
|
/// Application entry point
|
2016-09-18 00:38:01 +00:00
|
|
|
int main(int argc, char** argv) {
|
2022-12-24 02:39:59 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
|
|
|
|
freopen("CONOUT$", "wb", stdout);
|
|
|
|
freopen("CONOUT$", "wb", stderr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-08-13 18:39:45 +00:00
|
|
|
Common::Log::Initialize();
|
|
|
|
Common::Log::SetColorConsoleBackendEnabled(true);
|
2022-03-29 03:14:42 +00:00
|
|
|
Common::Log::Start();
|
2018-09-16 18:05:51 +00:00
|
|
|
Common::DetachedTasks detached_tasks;
|
2018-07-28 03:55:23 +00:00
|
|
|
|
2015-06-23 00:59:00 +00:00
|
|
|
int option_index = 0;
|
2016-06-08 05:53:41 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
int argc_w;
|
|
|
|
auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
|
|
|
|
|
|
|
|
if (argv_w == nullptr) {
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_CRITICAL(Frontend, "Failed to get command line arguments");
|
2016-06-08 05:53:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
2016-11-05 03:14:38 +00:00
|
|
|
std::string filepath;
|
2022-03-15 05:05:55 +00:00
|
|
|
std::optional<std::string> config_path;
|
|
|
|
std::string program_args;
|
2023-02-04 17:32:14 +00:00
|
|
|
std::optional<int> selected_user;
|
2016-04-06 11:01:00 +00:00
|
|
|
|
2021-12-25 19:27:52 +00:00
|
|
|
bool use_multiplayer = false;
|
2018-04-21 07:52:34 +00:00
|
|
|
bool fullscreen = false;
|
2021-12-25 19:27:52 +00:00
|
|
|
std::string nickname{};
|
|
|
|
std::string password{};
|
|
|
|
std::string address{};
|
|
|
|
u16 port = Network::DefaultRoomPort;
|
2018-04-21 07:52:34 +00:00
|
|
|
|
2016-09-19 01:01:46 +00:00
|
|
|
static struct option long_options[] = {
|
2022-03-15 05:05:55 +00:00
|
|
|
// clang-format off
|
2023-02-04 17:32:14 +00:00
|
|
|
{"config", required_argument, 0, 'c'},
|
2020-12-19 18:19:42 +00:00
|
|
|
{"fullscreen", no_argument, 0, 'f'},
|
|
|
|
{"help", no_argument, 0, 'h'},
|
2023-02-04 17:32:14 +00:00
|
|
|
{"game", required_argument, 0, 'g'},
|
|
|
|
{"multiplayer", required_argument, 0, 'm'},
|
2020-12-19 18:19:42 +00:00
|
|
|
{"program", optional_argument, 0, 'p'},
|
2023-02-04 17:32:14 +00:00
|
|
|
{"user", required_argument, 0, 'u'},
|
|
|
|
{"version", no_argument, 0, 'v'},
|
2020-12-19 18:19:42 +00:00
|
|
|
{0, 0, 0, 0},
|
2022-03-15 05:05:55 +00:00
|
|
|
// clang-format on
|
2016-09-19 01:01:46 +00:00
|
|
|
};
|
2015-06-23 00:59:00 +00:00
|
|
|
|
|
|
|
while (optind < argc) {
|
2023-05-25 14:05:22 +00:00
|
|
|
int arg = getopt_long(argc, argv, "g:fhvp::c:u:", long_options, &option_index);
|
2015-06-23 00:59:00 +00:00
|
|
|
if (arg != -1) {
|
2019-03-15 23:19:24 +00:00
|
|
|
switch (static_cast<char>(arg)) {
|
2023-02-04 17:32:14 +00:00
|
|
|
case 'c':
|
|
|
|
config_path = optarg;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
fullscreen = true;
|
|
|
|
LOG_INFO(Frontend, "Starting in fullscreen mode...");
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
PrintHelp(argv[0]);
|
|
|
|
return 0;
|
|
|
|
case 'g': {
|
|
|
|
const std::string str_arg(optarg);
|
|
|
|
filepath = str_arg;
|
|
|
|
break;
|
|
|
|
}
|
2021-12-25 19:27:52 +00:00
|
|
|
case 'm': {
|
|
|
|
use_multiplayer = true;
|
|
|
|
const std::string str_arg(optarg);
|
|
|
|
// regex to check if the format is nickname:password@ip:port
|
|
|
|
// with optional :password
|
|
|
|
const std::regex re("^([^:]+)(?::(.+))?@([^:]+)(?::([0-9]+))?$");
|
|
|
|
if (!std::regex_match(str_arg, re)) {
|
|
|
|
std::cout << "Wrong format for option --multiplayer\n";
|
|
|
|
PrintHelp(argv[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::smatch match;
|
|
|
|
std::regex_search(str_arg, match, re);
|
|
|
|
ASSERT(match.size() == 5);
|
|
|
|
nickname = match[1];
|
|
|
|
password = match[2];
|
|
|
|
address = match[3];
|
2023-09-13 17:36:09 +00:00
|
|
|
if (!match[4].str().empty()) {
|
|
|
|
port = static_cast<u16>(std::strtoul(match[4].str().c_str(), nullptr, 0));
|
|
|
|
}
|
2021-12-25 19:27:52 +00:00
|
|
|
std::regex nickname_re("^[a-zA-Z0-9._\\- ]+$");
|
|
|
|
if (!std::regex_match(nickname, nickname_re)) {
|
|
|
|
std::cout
|
|
|
|
<< "Nickname is not valid. Must be 4 to 20 alphanumeric characters.\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (address.empty()) {
|
|
|
|
std::cout << "Address to room must not be empty.\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2023-02-04 17:32:14 +00:00
|
|
|
case 'p':
|
|
|
|
program_args = argv[optind];
|
|
|
|
++optind;
|
2018-04-21 07:52:34 +00:00
|
|
|
break;
|
2023-02-04 17:32:14 +00:00
|
|
|
case 'u':
|
|
|
|
selected_user = atoi(optarg);
|
2023-05-25 18:07:52 +00:00
|
|
|
break;
|
2016-04-19 01:24:21 +00:00
|
|
|
case 'v':
|
|
|
|
PrintVersion();
|
|
|
|
return 0;
|
2015-06-23 00:59:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-06-08 05:53:41 +00:00
|
|
|
#ifdef _WIN32
|
2016-11-05 03:14:38 +00:00
|
|
|
filepath = Common::UTF16ToUTF8(argv_w[optind]);
|
2016-06-08 05:53:41 +00:00
|
|
|
#else
|
2016-11-05 03:14:38 +00:00
|
|
|
filepath = argv[optind];
|
2016-06-08 05:53:41 +00:00
|
|
|
#endif
|
2015-06-23 00:59:00 +00:00
|
|
|
optind++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-15 05:05:55 +00:00
|
|
|
Config config{config_path};
|
|
|
|
|
2022-06-16 20:07:09 +00:00
|
|
|
// apply the log_filter setting
|
|
|
|
// the logger was initialized before and doesn't pick up the filter on its own
|
|
|
|
Common::Log::Filter filter;
|
|
|
|
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
|
|
|
Common::Log::SetGlobalFilter(filter);
|
|
|
|
|
2022-03-15 05:05:55 +00:00
|
|
|
if (!program_args.empty()) {
|
|
|
|
Settings::values.program_args = program_args;
|
|
|
|
}
|
|
|
|
|
2023-02-04 17:32:14 +00:00
|
|
|
if (selected_user.has_value()) {
|
|
|
|
Settings::values.current_user = std::clamp(*selected_user, 0, 7);
|
|
|
|
}
|
|
|
|
|
2016-06-08 05:53:41 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
LocalFree(argv_w);
|
|
|
|
#endif
|
|
|
|
|
2015-08-17 21:25:21 +00:00
|
|
|
MicroProfileOnThreadCreate("EmuThread");
|
2016-03-15 02:59:14 +00:00
|
|
|
SCOPE_EXIT({ MicroProfileShutdown(); });
|
2015-08-17 21:25:21 +00:00
|
|
|
|
2021-01-20 23:09:57 +00:00
|
|
|
Common::ConfigureNvidiaEnvironmentFlags();
|
|
|
|
|
2016-11-05 03:14:38 +00:00
|
|
|
if (filepath.empty()) {
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
|
2014-06-18 22:58:09 +00:00
|
|
|
return -1;
|
2014-05-04 22:47:42 +00:00
|
|
|
}
|
2014-05-17 15:59:18 +00:00
|
|
|
|
2021-10-14 18:31:28 +00:00
|
|
|
Core::System system{};
|
2022-09-10 08:48:15 +00:00
|
|
|
system.Initialize();
|
|
|
|
|
2021-10-14 18:31:28 +00:00
|
|
|
InputCommon::InputSubsystem input_subsystem{};
|
2020-11-27 15:50:48 +00:00
|
|
|
|
2016-04-11 13:20:05 +00:00
|
|
|
// Apply the command line arguments
|
2021-04-14 23:07:40 +00:00
|
|
|
system.ApplySettings();
|
2020-02-17 20:35:14 +00:00
|
|
|
|
2020-01-21 19:40:53 +00:00
|
|
|
std::unique_ptr<EmuWindow_SDL2> emu_window;
|
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 02:42:09 +00:00
|
|
|
switch (Settings::values.renderer_backend.GetValue()) {
|
2020-01-21 19:40:53 +00:00
|
|
|
case Settings::RendererBackend::OpenGL:
|
2021-07-30 14:43:58 +00:00
|
|
|
emu_window = std::make_unique<EmuWindow_SDL2_GL>(&input_subsystem, system, fullscreen);
|
2020-01-21 19:40:53 +00:00
|
|
|
break;
|
|
|
|
case Settings::RendererBackend::Vulkan:
|
2021-07-30 14:43:58 +00:00
|
|
|
emu_window = std::make_unique<EmuWindow_SDL2_VK>(&input_subsystem, system, fullscreen);
|
2020-01-21 19:40:53 +00:00
|
|
|
break;
|
2022-11-28 01:37:37 +00:00
|
|
|
case Settings::RendererBackend::Null:
|
|
|
|
emu_window = std::make_unique<EmuWindow_SDL2_Null>(&input_subsystem, system, fullscreen);
|
|
|
|
break;
|
2020-01-21 19:40:53 +00:00
|
|
|
}
|
2014-06-18 22:58:09 +00:00
|
|
|
|
2023-07-02 19:05:35 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
Common::Windows::SetCurrentTimerResolutionToMaximum();
|
|
|
|
system.CoreTiming().SetTimerResolutionNs(Common::Windows::GetCurrentTimerResolution());
|
|
|
|
#endif
|
|
|
|
|
2019-03-04 17:40:53 +00:00
|
|
|
system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
|
2018-08-03 15:51:48 +00:00
|
|
|
system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
|
2019-04-22 21:56:56 +00:00
|
|
|
system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
|
2023-09-10 00:36:26 +00:00
|
|
|
system.GetUserChannel().clear();
|
2016-11-27 04:13:40 +00:00
|
|
|
|
2021-10-14 22:14:40 +00:00
|
|
|
const Core::SystemResultStatus load_result{system.Load(*emu_window, filepath)};
|
2016-11-20 01:40:04 +00:00
|
|
|
|
2016-11-05 03:14:38 +00:00
|
|
|
switch (load_result) {
|
2021-10-14 22:14:40 +00:00
|
|
|
case Core::SystemResultStatus::ErrorGetLoader:
|
2019-05-29 02:10:51 +00:00
|
|
|
LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath);
|
2016-11-05 03:14:38 +00:00
|
|
|
return -1;
|
2021-10-14 22:14:40 +00:00
|
|
|
case Core::SystemResultStatus::ErrorLoader:
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_CRITICAL(Frontend, "Failed to load ROM!");
|
2014-06-18 22:58:09 +00:00
|
|
|
return -1;
|
2021-10-14 22:14:40 +00:00
|
|
|
case Core::SystemResultStatus::ErrorNotInitialized:
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_CRITICAL(Frontend, "CPUCore not initialized");
|
2017-01-29 17:09:33 +00:00
|
|
|
return -1;
|
2021-10-14 22:14:40 +00:00
|
|
|
case Core::SystemResultStatus::ErrorVideoCore:
|
2018-08-03 16:55:58 +00:00
|
|
|
LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!");
|
2017-01-29 17:09:33 +00:00
|
|
|
return -1;
|
2021-10-14 22:14:40 +00:00
|
|
|
case Core::SystemResultStatus::Success:
|
2017-01-29 17:09:33 +00:00
|
|
|
break; // Expected case
|
2018-08-10 01:06:44 +00:00
|
|
|
default:
|
|
|
|
if (static_cast<u32>(load_result) >
|
2021-10-14 22:14:40 +00:00
|
|
|
static_cast<u32>(Core::SystemResultStatus::ErrorLoader)) {
|
|
|
|
const u16 loader_id = static_cast<u16>(Core::SystemResultStatus::ErrorLoader);
|
2018-08-10 01:06:44 +00:00
|
|
|
const u16 error_id = static_cast<u16>(load_result) - loader_id;
|
|
|
|
LOG_CRITICAL(Frontend,
|
2021-01-02 14:00:05 +00:00
|
|
|
"While attempting to load the ROM requested, an error occurred. Please "
|
2018-08-10 01:06:44 +00:00
|
|
|
"refer to the yuzu wiki for more information or the yuzu discord for "
|
|
|
|
"additional help.\n\nError Code: {:04X}-{:04X}\nError Description: {}",
|
2018-08-15 09:38:37 +00:00
|
|
|
loader_id, error_id, static_cast<Loader::ResultStatus>(error_id));
|
2018-08-10 01:06:44 +00:00
|
|
|
}
|
2022-11-11 09:16:58 +00:00
|
|
|
break;
|
2014-04-01 02:25:55 +00:00
|
|
|
}
|
2014-04-07 04:53:47 +00:00
|
|
|
|
2020-08-18 18:21:50 +00:00
|
|
|
system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "SDL");
|
2017-08-23 02:47:56 +00:00
|
|
|
|
2021-12-25 19:27:52 +00:00
|
|
|
if (use_multiplayer) {
|
2022-07-23 17:28:19 +00:00
|
|
|
if (auto member = system.GetRoomNetwork().GetRoomMember().lock()) {
|
2021-12-25 19:27:52 +00:00
|
|
|
member->BindOnChatMessageRecieved(OnMessageReceived);
|
|
|
|
member->BindOnStatusMessageReceived(OnStatusMessageReceived);
|
|
|
|
member->BindOnStateChanged(OnStateChanged);
|
|
|
|
member->BindOnError(OnNetworkError);
|
|
|
|
LOG_DEBUG(Network, "Start connection to {}:{} with nickname {}", address, port,
|
|
|
|
nickname);
|
2022-07-30 03:58:23 +00:00
|
|
|
member->Join(nickname, address.c_str(), port, 0, Network::NoPreferredIP, password);
|
2021-12-25 19:27:52 +00:00
|
|
|
} else {
|
|
|
|
LOG_ERROR(Network, "Could not access RoomMember");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-25 02:58:49 +00:00
|
|
|
// Core is loaded, start the GPU (makes the GPU contexts current to this thread)
|
|
|
|
system.GPU().Start();
|
2022-06-17 03:42:39 +00:00
|
|
|
system.GetCpuManager().OnGpuReady();
|
2020-02-17 20:35:14 +00:00
|
|
|
|
2021-05-28 03:29:22 +00:00
|
|
|
if (Settings::values.use_disk_shader_cache.GetValue()) {
|
|
|
|
system.Renderer().ReadRasterizer()->LoadDiskResources(
|
2023-02-13 16:21:43 +00:00
|
|
|
system.GetApplicationProcessProgramID(), std::stop_token{},
|
2021-05-28 03:29:22 +00:00
|
|
|
[](VideoCore::LoadCallbackStage, size_t value, size_t total) {});
|
|
|
|
}
|
2020-03-25 04:57:36 +00:00
|
|
|
|
2022-06-10 13:11:02 +00:00
|
|
|
system.RegisterExitCallback([&] {
|
|
|
|
// Just exit right away.
|
|
|
|
exit(0);
|
|
|
|
});
|
|
|
|
|
2020-11-18 07:06:42 +00:00
|
|
|
void(system.Run());
|
2022-06-10 13:11:02 +00:00
|
|
|
if (system.DebuggerEnabled()) {
|
|
|
|
system.InitializeDebugger();
|
|
|
|
}
|
2020-02-25 15:12:46 +00:00
|
|
|
while (emu_window->IsOpen()) {
|
Overhaul EmuWindow::PollEvents to fix yuzu-cmd calling SDL_PollEvents off main thread
EmuWindow::PollEvents was called from the GPU thread (or the CPU thread
in sync-GPU mode) when swapping buffers. It had three implementations:
- In GRenderWindow, it didn't actually poll events, just set a flag and
emit a signal to indicate that a frame was displayed.
- In EmuWindow_SDL2_Hide, it did nothing.
- In EmuWindow_SDL2, it did call SDL_PollEvents, but this is wrong
because SDL_PollEvents is supposed to be called on the thread that set
up video - in this case, the main thread, which was sleeping in a
busyloop (regardless of whether sync-GPU was enabled). On macOS this
causes a crash.
To fix this:
- Rename EmuWindow::PollEvents to OnFrameDisplayed, and give it a
default implementation that does nothing.
- In EmuWindow_SDL2, do not override OnFrameDisplayed, but instead have
the main thread call SDL_WaitEvent in a loop.
2020-11-22 21:05:18 +00:00
|
|
|
emu_window->WaitEvent();
|
2020-02-25 15:12:46 +00:00
|
|
|
}
|
2022-06-10 13:17:12 +00:00
|
|
|
system.DetachDebugger();
|
2020-11-18 07:06:42 +00:00
|
|
|
void(system.Pause());
|
2022-09-10 08:48:15 +00:00
|
|
|
system.ShutdownMainProcess();
|
2019-09-22 13:40:57 +00:00
|
|
|
|
2018-09-16 18:05:51 +00:00
|
|
|
detached_tasks.WaitForAllTasks();
|
2014-05-17 15:59:18 +00:00
|
|
|
return 0;
|
2013-08-30 03:35:09 +00:00
|
|
|
}
|