diff options
author | bunnei <bunneidev@gmail.com> | 2019-06-26 16:26:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-26 16:26:44 +0200 |
commit | 4ed2774c26602d6ee1af316da5faf391d377d701 (patch) | |
tree | a1ef0e65dfd79f8badde8dcd24014432428c51f8 /src/core/hle/service/glue/manager.cpp | |
parent | Merge pull request #2603 from WamWooWam/master (diff) | |
parent | glue: Correct missing bytes in ApplicationLaunchParameter (diff) | |
download | yuzu-4ed2774c26602d6ee1af316da5faf391d377d701.tar yuzu-4ed2774c26602d6ee1af316da5faf391d377d701.tar.gz yuzu-4ed2774c26602d6ee1af316da5faf391d377d701.tar.bz2 yuzu-4ed2774c26602d6ee1af316da5faf391d377d701.tar.lz yuzu-4ed2774c26602d6ee1af316da5faf391d377d701.tar.xz yuzu-4ed2774c26602d6ee1af316da5faf391d377d701.tar.zst yuzu-4ed2774c26602d6ee1af316da5faf391d377d701.zip |
Diffstat (limited to 'src/core/hle/service/glue/manager.cpp')
-rw-r--r-- | src/core/hle/service/glue/manager.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/core/hle/service/glue/manager.cpp b/src/core/hle/service/glue/manager.cpp new file mode 100644 index 000000000..6da52d2d6 --- /dev/null +++ b/src/core/hle/service/glue/manager.cpp @@ -0,0 +1,78 @@ +// 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 { + +struct ARPManager::MapEntry { + ApplicationLaunchProperty launch; + std::vector<u8> control; +}; + +ARPManager::ARPManager() = default; + +ARPManager::~ARPManager() = default; + +ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const { + if (title_id == 0) { + return ERR_INVALID_PROCESS_ID; + } + + const auto iter = entries.find(title_id); + if (iter == entries.end()) { + return ERR_NOT_REGISTERED; + } + + return MakeResult<ApplicationLaunchProperty>(iter->second.launch); +} + +ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { + if (title_id == 0) { + return ERR_INVALID_PROCESS_ID; + } + + const auto iter = entries.find(title_id); + if (iter == entries.end()) { + return ERR_NOT_REGISTERED; + } + + 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_INVALID_PROCESS_ID; + } + + const auto iter = entries.find(title_id); + if (iter != entries.end()) { + return ERR_INVALID_ACCESS; + } + + 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_INVALID_PROCESS_ID; + } + + const auto iter = entries.find(title_id); + if (iter == entries.end()) { + return ERR_NOT_REGISTERED; + } + + entries.erase(iter); + return RESULT_SUCCESS; +} + +void ARPManager::ResetAll() { + entries.clear(); +} + +} // namespace Service::Glue |