aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/yuzu
diff options
context:
space:
mode:
authorLiam <[email protected]>2024-01-02 18:26:53 -0500
committerLiam <[email protected]>2024-01-29 20:17:09 -0500
commit3155f4e96d10904f4a207e465f20fb4b25043f5c (patch)
tree849388480f5b7bb17f07a259b3f3661eeca99f61 /src/yuzu
parentdfb9fa0144ca79e596f6f2b1bc960b1a44745aa6 (diff)
downloadyuzu-android-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.gz
yuzu-android-3155f4e96d10904f4a207e465f20fb4b25043f5c.zip
am: retrieve main applet creation info from frontend
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/game_list.cpp12
-rw-r--r--src/yuzu/game_list.h3
-rw-r--r--src/yuzu/main.cpp72
-rw-r--r--src/yuzu/main.h23
4 files changed, 66 insertions, 44 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 59b317135..b40af957c 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -596,14 +596,10 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
connect(open_save_location, &QAction::triggered, [this, program_id, path]() {
emit OpenFolderRequested(program_id, GameListOpenTarget::SaveData, path);
});
- connect(start_game, &QAction::triggered, [this, path]() {
- emit BootGame(QString::fromStdString(path), 0, 0, StartGameType::Normal,
- AmLaunchType::UserInitiated);
- });
- connect(start_game_global, &QAction::triggered, [this, path]() {
- emit BootGame(QString::fromStdString(path), 0, 0, StartGameType::Global,
- AmLaunchType::UserInitiated);
- });
+ connect(start_game, &QAction::triggered,
+ [this, path]() { emit BootGame(QString::fromStdString(path), StartGameType::Normal); });
+ connect(start_game_global, &QAction::triggered,
+ [this, path]() { emit BootGame(QString::fromStdString(path), StartGameType::Global); });
connect(open_mod_location, &QAction::triggered, [this, program_id, path]() {
emit OpenFolderRequested(program_id, GameListOpenTarget::ModData, path);
});
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index 563a3a35b..79f9c7ec0 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -106,8 +106,7 @@ public:
static const QStringList supported_file_extensions;
signals:
- void BootGame(const QString& game_path, u64 program_id, std::size_t program_index,
- StartGameType type, AmLaunchType launch_type);
+ void BootGame(const QString& game_path, StartGameType type);
void GameChosen(const QString& game_path, const u64 title_id = 0);
void OpenFolderRequested(u64 program_id, GameListOpenTarget target,
const std::string& game_path);
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 90ddecbfc..02508b20d 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -8,6 +8,7 @@
#include <iostream>
#include <memory>
#include <thread>
+#include "core/hle/service/am/applet_manager.h"
#include "core/loader/nca.h"
#include "core/tools/renderdoc.h"
@@ -569,7 +570,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk
}
if (!game_path.isEmpty()) {
- BootGame(game_path);
+ BootGame(game_path, ApplicationAppletParameters());
}
}
@@ -1474,7 +1475,7 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
}
void GMainWindow::ConnectWidgetEvents() {
- connect(game_list, &GameList::BootGame, this, &GMainWindow::BootGame);
+ connect(game_list, &GameList::BootGame, this, &GMainWindow::BootGameFromList);
connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory);
connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder);
@@ -1762,8 +1763,7 @@ void GMainWindow::AllowOSSleep() {
#endif
}
-bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t program_index,
- AmLaunchType launch_type) {
+bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletParameters params) {
// Shutdown previous session if the emu thread is still active...
if (emu_thread != nullptr) {
ShutdownGame();
@@ -1775,7 +1775,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
system->SetFilesystem(vfs);
- if (launch_type == AmLaunchType::UserInitiated) {
+ if (params.launch_type == Service::AM::LaunchType::FrontendInitiated) {
system->GetUserChannel().clear();
}
@@ -1794,7 +1794,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
});
const Core::SystemResultStatus result{
- system->Load(*render_window, filename.toStdString(), program_id, program_index)};
+ system->Load(*render_window, filename.toStdString(), params)};
const auto drd_callout = (UISettings::values.callout_flags.GetValue() &
static_cast<u32>(CalloutFlag::DRDDeprecation)) == 0;
@@ -1917,12 +1917,12 @@ void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) {
}
}
-void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t program_index,
- StartGameType type, AmLaunchType launch_type) {
+void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletParameters params,
+ StartGameType type) {
LOG_INFO(Frontend, "yuzu starting...");
- if (program_id == 0 ||
- program_id > static_cast<u64>(Service::AM::AppletProgramId::MaxProgramId)) {
+ if (params.program_id == 0 ||
+ params.program_id > static_cast<u64>(Service::AM::AppletProgramId::MaxProgramId)) {
StoreRecentFile(filename); // Put the filename on top of the list
}
@@ -1937,7 +1937,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
ConfigureFilesystemProvider(filename.toStdString());
const auto v_file = Core::GetGameFileFromPath(vfs, filename.toUtf8().constData());
- const auto loader = Loader::GetLoader(*system, v_file, program_id, program_index);
+ const auto loader = Loader::GetLoader(*system, v_file, params.program_id, params.program_index);
if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success &&
type == StartGameType::Normal) {
@@ -1971,7 +1971,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
// behavior of asking.
user_flag_cmd_line = false;
- if (!LoadROM(filename, program_id, program_index, launch_type)) {
+ if (!LoadROM(filename, params)) {
return;
}
@@ -2061,6 +2061,10 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
OnStartGame();
}
+void GMainWindow::BootGameFromList(const QString& filename, StartGameType with_config) {
+ BootGame(filename, ApplicationAppletParameters(), with_config);
+}
+
bool GMainWindow::OnShutdownBegin() {
if (!emulation_running) {
return false;
@@ -2241,7 +2245,10 @@ void GMainWindow::UpdateRecentFiles() {
}
void GMainWindow::OnGameListLoadFile(QString game_path, u64 program_id) {
- BootGame(game_path, program_id);
+ auto params = ApplicationAppletParameters();
+ params.program_id = program_id;
+
+ BootGame(game_path, params);
}
void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target,
@@ -3173,7 +3180,7 @@ void GMainWindow::OnMenuLoadFile() {
}
UISettings::values.roms_path = QFileInfo(filename).path().toStdString();
- BootGame(filename);
+ BootGame(filename, ApplicationAppletParameters());
}
void GMainWindow::OnMenuLoadFolder() {
@@ -3187,7 +3194,7 @@ void GMainWindow::OnMenuLoadFolder() {
const QDir dir{dir_path};
const QStringList matching_main = dir.entryList({QStringLiteral("main")}, QDir::Files);
if (matching_main.size() == 1) {
- BootGame(dir.path() + QDir::separator() + matching_main[0]);
+ BootGame(dir.path() + QDir::separator() + matching_main[0], ApplicationAppletParameters());
} else {
QMessageBox::warning(this, tr("Invalid Directory Selected"),
tr("The directory you have selected does not contain a 'main' file."));
@@ -3381,7 +3388,7 @@ void GMainWindow::OnMenuRecentFile() {
const QString filename = action->data().toString();
if (QFileInfo::exists(filename)) {
- BootGame(filename);
+ BootGame(filename, ApplicationAppletParameters());
} else {
// Display an error message and remove the file from the list.
QMessageBox::information(this, tr("File not found"),
@@ -3419,7 +3426,7 @@ void GMainWindow::OnRestartGame() {
// Make a copy since ShutdownGame edits game_path
const auto current_game = QString(current_game_path);
ShutdownGame();
- BootGame(current_game);
+ BootGame(current_game, ApplicationAppletParameters());
}
}
@@ -3487,8 +3494,11 @@ void GMainWindow::OnLoadComplete() {
void GMainWindow::OnExecuteProgram(std::size_t program_index) {
ShutdownGame();
- BootGame(last_filename_booted, 0, program_index, StartGameType::Normal,
- AmLaunchType::ApplicationInitiated);
+
+ auto params = ApplicationAppletParameters();
+ params.program_index = static_cast<s32>(program_index);
+ params.launch_type = Service::AM::LaunchType::ApplicationInitiated;
+ BootGame(last_filename_booted, params);
}
void GMainWindow::OnExit() {
@@ -4174,7 +4184,7 @@ void GMainWindow::OnAlbum() {
const auto filename = QString::fromStdString(album_nca->GetFullPath());
UISettings::values.roms_path = QFileInfo(filename).path().toStdString();
- BootGame(filename, AlbumId);
+ BootGame(filename, LibraryAppletParameters(AlbumId, Service::AM::AppletId::PhotoViewer));
}
void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) {
@@ -4198,7 +4208,7 @@ void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) {
const auto filename = QString::fromStdString(cabinet_nca->GetFullPath());
UISettings::values.roms_path = QFileInfo(filename).path().toStdString();
- BootGame(filename, CabinetId);
+ BootGame(filename, LibraryAppletParameters(CabinetId, Service::AM::AppletId::Cabinet));
}
void GMainWindow::OnMiiEdit() {
@@ -4221,7 +4231,7 @@ void GMainWindow::OnMiiEdit() {
const auto filename = QString::fromStdString((mii_applet_nca->GetFullPath()));
UISettings::values.roms_path = QFileInfo(filename).path().toStdString();
- BootGame(filename, MiiEditId);
+ BootGame(filename, LibraryAppletParameters(MiiEditId, Service::AM::AppletId::MiiEdit));
}
void GMainWindow::OnOpenControllerMenu() {
@@ -4245,7 +4255,8 @@ void GMainWindow::OnOpenControllerMenu() {
const auto filename = QString::fromStdString((controller_applet_nca->GetFullPath()));
UISettings::values.roms_path = QFileInfo(filename).path().toStdString();
- BootGame(filename, ControllerAppletId);
+ BootGame(filename,
+ LibraryAppletParameters(ControllerAppletId, Service::AM::AppletId::Controller));
}
void GMainWindow::OnCaptureScreenshot() {
@@ -4728,7 +4739,7 @@ bool GMainWindow::DropAction(QDropEvent* event) {
} else {
// Game
if (ConfirmChangeGame()) {
- BootGame(filename);
+ BootGame(filename, ApplicationAppletParameters());
}
}
return true;
@@ -4943,6 +4954,19 @@ void GMainWindow::changeEvent(QEvent* event) {
QWidget::changeEvent(event);
}
+Service::AM::FrontendAppletParameters GMainWindow::ApplicationAppletParameters() {
+ return Service::AM::FrontendAppletParameters{};
+}
+
+Service::AM::FrontendAppletParameters GMainWindow::LibraryAppletParameters(
+ u64 program_id, Service::AM::AppletId applet_id) {
+ return Service::AM::FrontendAppletParameters{
+ .program_id = program_id,
+ .applet_id = applet_id,
+ .applet_type = Service::AM::AppletType::LibraryApplet,
+ };
+}
+
void VolumeButton::wheelEvent(QWheelEvent* event) {
int num_degrees = event->angleDelta().y() / 8;
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index c079baffa..aba61e388 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -64,11 +64,6 @@ enum class StartGameType {
Global, // Only uses global configuration
};
-enum class AmLaunchType {
- UserInitiated,
- ApplicationInitiated,
-};
-
namespace Core {
enum class SystemResultStatus : u32;
class System;
@@ -101,6 +96,11 @@ namespace InputCommon {
class InputSubsystem;
}
+namespace Service::AM {
+struct FrontendAppletParameters;
+enum class AppletId : u32;
+} // namespace Service::AM
+
namespace Service::AM::Frontend {
enum class SwkbdResult : u32;
enum class SwkbdTextCheckResult : u32;
@@ -268,11 +268,10 @@ private:
void PreventOSSleep();
void AllowOSSleep();
- bool LoadROM(const QString& filename, u64 program_id, std::size_t program_index,
- AmLaunchType launch_type);
- void BootGame(const QString& filename, u64 program_id = 0, std::size_t program_index = 0,
- StartGameType with_config = StartGameType::Normal,
- AmLaunchType launch_type = AmLaunchType::UserInitiated);
+ bool LoadROM(const QString& filename, Service::AM::FrontendAppletParameters params);
+ void BootGame(const QString& filename, Service::AM::FrontendAppletParameters params,
+ StartGameType with_config = StartGameType::Normal);
+ void BootGameFromList(const QString& filename, StartGameType with_config);
void ShutdownGame();
void ShowTelemetryCallout();
@@ -325,6 +324,10 @@ private:
void SetGamemodeEnabled(bool state);
#endif
+ Service::AM::FrontendAppletParameters ApplicationAppletParameters();
+ Service::AM::FrontendAppletParameters LibraryAppletParameters(u64 program_id,
+ Service::AM::AppletId applet_id);
+
private slots:
void OnStartGame();
void OnRestartGame();