diff options
-rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/core/hle/service/glue/manager.cpp | 73 | ||||
-rw-r--r-- | src/core/hle/service/glue/manager.h | 46 |
3 files changed, 121 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cdb3bf6ab..6a9a3c180 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -276,6 +276,8 @@ add_library(core STATIC hle/service/friend/friend.h hle/service/friend/interface.cpp hle/service/friend/interface.h + hle/service/glue/manager.cpp + hle/service/glue/manager.h hle/service/grc/grc.cpp hle/service/grc/grc.h hle/service/hid/hid.cpp diff --git a/src/core/hle/service/glue/manager.cpp b/src/core/hle/service/glue/manager.cpp new file mode 100644 index 000000000..0d5bb4d50 --- /dev/null +++ b/src/core/hle/service/glue/manager.cpp @@ -0,0 +1,73 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/service/glue/errors.h" +#include "core/hle/service/glue/manager.h" + +namespace Service::Glue { + +ARPManager::ARPManager() = default; + +ARPManager::~ARPManager() = default; + +ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const { + if (title_id == 0) { + return ERR_TITLE_ID_ZERO; + } + + const auto iter = entries.find(title_id); + if (iter == entries.end()) { + return ERR_NONEXISTENT; + } + + return MakeResult<ApplicationLaunchProperty>(iter->second.launch); +} + +ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { + if (title_id == 0) { + return ERR_TITLE_ID_ZERO; + } + + const auto iter = entries.find(title_id); + if (iter == entries.end()) { + return ERR_NONEXISTENT; + } + + return MakeResult<std::vector<u8>>(iter->second.control); +} + +ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, + std::vector<u8> control) { + if (title_id == 0) { + return ERR_TITLE_ID_ZERO; + } + + const auto iter = entries.find(title_id); + if (iter != entries.end()) { + return ERR_ALREADY_ISSUED; + } + + entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)}); + return RESULT_SUCCESS; +} + +ResultCode ARPManager::Unregister(u64 title_id) { + if (title_id == 0) { + return ERR_TITLE_ID_ZERO; + } + + const auto iter = entries.find(title_id); + if (iter == entries.end()) { + return ERR_NONEXISTENT; + } + + entries.erase(iter); + return RESULT_SUCCESS; +} + +void ARPManager::ResetAll() { + entries.clear(); +} + +} // namespace Service::Glue diff --git a/src/core/hle/service/glue/manager.h b/src/core/hle/service/glue/manager.h new file mode 100644 index 000000000..561ebf4e0 --- /dev/null +++ b/src/core/hle/service/glue/manager.h @@ -0,0 +1,46 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/file_sys/control_metadata.h" +#include "core/file_sys/romfs_factory.h" +#include "core/hle/result.h" + +namespace Service::Glue { + +struct ApplicationLaunchProperty { + u64 title_id; + u32 version; + FileSys::StorageId base_game_storage_id; + FileSys::StorageId update_storage_id; + INSERT_PADDING_BYTES(0x2); +}; +static_assert(sizeof(ApplicationLaunchProperty) == 0x10, + "ApplicationLaunchProperty has incorrect size."); + +class ARPManager { +public: + ARPManager(); + ~ARPManager(); + + ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const; + ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const; + + ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control); + + ResultCode Unregister(u64 title_id); + + void ResetAll(); + +private: + struct MapEntry { + ApplicationLaunchProperty launch; + std::vector<u8> control; + }; + + std::map<u64, MapEntry> entries; +}; + +} // namespace Service::Glue |