[XAM/User] Add UserIndex enum, handle special UserIndexes inside KernelState::user_profile
This commit is contained in:
parent
73342e6d62
commit
6e4ed5b333
|
@ -835,5 +835,44 @@ bool KernelState::Restore(ByteStream* stream) {
|
|||
return true;
|
||||
}
|
||||
|
||||
xam::UserProfile* KernelState::user_profile(uint32_t user_index,
|
||||
bool allow_signed_out) const {
|
||||
auto index_enum = static_cast<xam::UserProfile::UserIndex>(user_index);
|
||||
bool use_any_profile = index_enum == xam::UserProfile::UserIndex::kAny;
|
||||
|
||||
// TODO: how to handle these two cases?
|
||||
if (index_enum == xam::UserProfile::UserIndex::kFocus) {
|
||||
assert_always();
|
||||
use_any_profile = true; // temp
|
||||
}
|
||||
if (index_enum == xam::UserProfile::UserIndex::kNone) {
|
||||
assert_always();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// TODO: any callers that use kAny need to be updated so they'll apply to all
|
||||
// profiles!
|
||||
if (use_any_profile) {
|
||||
for (auto& user : user_profiles_) {
|
||||
if (allow_signed_out || user->signed_in()) {
|
||||
return user.get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (user_index >= xam::kMaxNumUsers) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto user = &user_profiles_[user_index];
|
||||
if (!allow_signed_out) {
|
||||
if (!user->get()->signed_in()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return user->get();
|
||||
}
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -108,23 +108,7 @@ class KernelState {
|
|||
// (unless allow_signed_out is true, to allow for code dealing with sign-ins
|
||||
// etc)
|
||||
xam::UserProfile* user_profile(uint32_t user_index,
|
||||
bool allow_signed_out = false) const {
|
||||
if (user_index == 0xFF) {
|
||||
user_index = 0;
|
||||
}
|
||||
|
||||
if (user_index >= xam::kMaxNumUsers) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto user = &user_profiles_[user_index];
|
||||
if (!allow_signed_out) {
|
||||
if (!user->get()->signed_in()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return user->get();
|
||||
}
|
||||
bool allow_signed_out = false) const;
|
||||
|
||||
uint32_t num_profiles() const { return xam::kMaxNumUsers; }
|
||||
|
||||
|
|
|
@ -166,6 +166,12 @@ struct X_XAMACCOUNTINFO {
|
|||
|
||||
class UserProfile {
|
||||
public:
|
||||
enum class UserIndex {
|
||||
kAny = 0xFF, // applies to any or all signed-in users
|
||||
kNone = 0xFE, // this isn't tied to any signed-in user
|
||||
kFocus = 0xFD, // whichever user last acted / was last in focus
|
||||
};
|
||||
|
||||
static void CreateUsers(KernelState* kernel_state,
|
||||
std::unique_ptr<UserProfile>* profiles);
|
||||
|
||||
|
|
Loading…
Reference in New Issue