[XAM] Implementation of: Profile Manager & Profiles Support

Thanks Emoose for Account Encrypt/Decrypt code!
This commit is contained in:
Gliniak
2024-09-28 10:42:32 +02:00
committed by Radosław Gliński
parent 9ba0f18c82
commit 9bdd07590c
28 changed files with 1775 additions and 298 deletions

View File

@@ -10,10 +10,6 @@
#include "xenia/kernel/xam/xam_state.h"
#include "xenia/emulator.h"
DEFINE_uint32(max_signed_profiles, 4,
"Limits how many profiles can be assigned. Possible values: 1-4",
"Kernel");
namespace xe {
namespace kernel {
namespace xam {
@@ -29,8 +25,7 @@ XamState::XamState(Emulator* emulator, KernelState* kernel_state)
content_manager_ =
std::make_unique<ContentManager>(kernel_state, content_root);
user_profiles_.emplace(0, std::make_unique<xam::UserProfile>(0));
profile_manager_ = std::make_unique<ProfileManager>(kernel_state);
achievement_manager_ = std::make_unique<AchievementManager>();
AppManager::RegisterApps(kernel_state, app_manager_.get());
@@ -43,47 +38,20 @@ XamState::~XamState() {
}
UserProfile* XamState::GetUserProfile(uint32_t user_index) const {
if (!IsUserSignedIn(user_index)) {
if (user_index >= XUserMaxUserCount && user_index < XUserIndexLatest) {
return nullptr;
}
return user_profiles_.at(user_index).get();
return profile_manager_->GetProfile(static_cast<uint8_t>(user_index));
}
UserProfile* XamState::GetUserProfile(uint64_t xuid) const {
for (const auto& [key, value] : user_profiles_) {
if (value->xuid() == xuid) {
return user_profiles_.at(key).get();
}
}
return nullptr;
}
void XamState::UpdateUsedUserProfiles() {
const std::bitset<4> used_slots = kernel_state_->GetConnectedUsers();
const uint32_t signed_profile_count =
std::max(static_cast<uint32_t>(1),
std::min(static_cast<uint32_t>(4), cvars::max_signed_profiles));
for (uint32_t i = 1; i < signed_profile_count; i++) {
bool is_used = used_slots.test(i);
if (IsUserSignedIn(i) && !is_used) {
user_profiles_.erase(i);
kernel_state_->BroadcastNotification(
kXNotificationIDSystemInputDevicesChanged, 0);
}
if (!IsUserSignedIn(i) && is_used) {
user_profiles_.emplace(i, std::make_unique<xam::UserProfile>(i));
kernel_state_->BroadcastNotification(
kXNotificationIDSystemInputDevicesChanged, 0);
}
}
return profile_manager_->GetProfile(xuid);
}
bool XamState::IsUserSignedIn(uint32_t user_index) const {
return user_profiles_.find(user_index) != user_profiles_.cend();
return profile_manager_->GetProfile(static_cast<uint8_t>(user_index)) !=
nullptr;
}
bool XamState::IsUserSignedIn(uint64_t xuid) const {