2019-06-25 01:17:13 +02:00
|
|
|
// 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 {
|
|
|
|
|
2019-06-26 04:25:10 +02:00
|
|
|
struct ARPManager::MapEntry {
|
|
|
|
ApplicationLaunchProperty launch;
|
|
|
|
std::vector<u8> control;
|
|
|
|
};
|
|
|
|
|
2019-06-25 01:17:13 +02:00
|
|
|
ARPManager::ARPManager() = default;
|
|
|
|
|
|
|
|
ARPManager::~ARPManager() = default;
|
|
|
|
|
|
|
|
ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const {
|
|
|
|
if (title_id == 0) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_INVALID_PROCESS_ID;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto iter = entries.find(title_id);
|
|
|
|
if (iter == entries.end()) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_NOT_REGISTERED;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return MakeResult<ApplicationLaunchProperty>(iter->second.launch);
|
|
|
|
}
|
|
|
|
|
|
|
|
ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
|
|
|
|
if (title_id == 0) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_INVALID_PROCESS_ID;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto iter = entries.find(title_id);
|
|
|
|
if (iter == entries.end()) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_NOT_REGISTERED;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return MakeResult<std::vector<u8>>(iter->second.control);
|
|
|
|
}
|
|
|
|
|
|
|
|
ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
|
|
|
|
std::vector<u8> control) {
|
|
|
|
if (title_id == 0) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_INVALID_PROCESS_ID;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto iter = entries.find(title_id);
|
|
|
|
if (iter != entries.end()) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_INVALID_ACCESS;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)});
|
2021-05-21 07:05:04 +02:00
|
|
|
return ResultSuccess;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ResultCode ARPManager::Unregister(u64 title_id) {
|
|
|
|
if (title_id == 0) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_INVALID_PROCESS_ID;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto iter = entries.find(title_id);
|
|
|
|
if (iter == entries.end()) {
|
2019-06-26 04:25:10 +02:00
|
|
|
return ERR_NOT_REGISTERED;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
entries.erase(iter);
|
2021-05-21 07:05:04 +02:00
|
|
|
return ResultSuccess;
|
2019-06-25 01:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ARPManager::ResetAll() {
|
|
|
|
entries.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Service::Glue
|