mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-02 13:02:44 +01:00
fix
This commit is contained in:
parent
c922d6559f
commit
a7822c2ddb
1 changed files with 61 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -12,13 +13,15 @@
|
|||
#include "core/file_sys/registered_cache.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/nintendo_switch_library.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
/**
|
||||
* NintendoSwitchLibrary class manages the operations related to installed games
|
||||
* on the emulated Nintendo Switch, including listing games and launching them.
|
||||
* on the emulated Nintendo Switch, including listing games, launching them,
|
||||
* and providing additional functionality inspired by multi-system emulation.
|
||||
*/
|
||||
class NintendoSwitchLibrary {
|
||||
public:
|
||||
|
@ -28,6 +31,7 @@ public:
|
|||
u64 program_id;
|
||||
std::string title_name;
|
||||
std::string file_path;
|
||||
u32 version;
|
||||
};
|
||||
|
||||
[[nodiscard]] std::vector<GameInfo> GetInstalledGames() {
|
||||
|
@ -38,9 +42,10 @@ public:
|
|||
if (content_type == FileSys::ContentRecordType::Program) {
|
||||
const auto title_name = GetGameName(program_id);
|
||||
const auto file_path = cache.GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program);
|
||||
const auto version = GetGameVersion(program_id);
|
||||
|
||||
if (!title_name.empty() && !file_path.empty()) {
|
||||
games.push_back({program_id, title_name, file_path});
|
||||
games.push_back({program_id, title_name, file_path, version});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +64,11 @@ public:
|
|||
return "";
|
||||
}
|
||||
|
||||
[[nodiscard]] u32 GetGameVersion(u64 program_id) {
|
||||
const auto& patch_manager = system.GetFileSystemController().GetPatchManager(program_id);
|
||||
return patch_manager.GetGameVersion().value_or(0);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool LaunchGame(u64 program_id) {
|
||||
const auto file_path = system.GetContentProvider().GetUserNANDCache().GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program);
|
||||
|
||||
|
@ -73,6 +83,12 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check firmware compatibility
|
||||
if (!CheckFirmwareCompatibility(program_id)) {
|
||||
LOG_ERROR(Core, "Firmware version not compatible with game. program_id={:016X}", program_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto result = system.Load(*loader);
|
||||
if (result != ResultStatus::Success) {
|
||||
LOG_ERROR(Core, "Failed to load game. Error: {}, program_id={:016X}", result, program_id);
|
||||
|
@ -83,8 +99,51 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CheckForUpdates(u64 program_id) {
|
||||
// TODO: Implement update checking logic
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ApplyUpdate(u64 program_id) {
|
||||
// TODO: Implement update application logic
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SetButtonMapping(const std::string& button_config) {
|
||||
// TODO: Implement button mapping logic
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CreateSaveState(u64 program_id, const std::string& save_state_name) {
|
||||
// TODO: Implement save state creation
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LoadSaveState(u64 program_id, const std::string& save_state_name) {
|
||||
// TODO: Implement save state loading
|
||||
return false;
|
||||
}
|
||||
|
||||
void EnableFastForward(bool enable) {
|
||||
// TODO: Implement fast forward functionality
|
||||
}
|
||||
|
||||
void EnableRewind(bool enable) {
|
||||
// TODO: Implement rewind functionality
|
||||
}
|
||||
|
||||
private:
|
||||
const Core::System& system;
|
||||
|
||||
bool CheckFirmwareCompatibility(u64 program_id) {
|
||||
// TODO: Implement firmware compatibility check
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Use smart pointer for better memory management
|
||||
std::unique_ptr<NintendoSwitchLibrary> CreateNintendoSwitchLibrary(Core::System& system) {
|
||||
return std::make_unique<NintendoSwitchLibrary>(system);
|
||||
}
|
||||
|
||||
} // namespace Core
|
Loading…
Reference in a new issue