[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

@@ -14,6 +14,7 @@
#include "xenia/base/profiling.h"
#include "xenia/hid/hid_flags.h"
#include "xenia/hid/input_driver.h"
#include "xenia/kernel/util/shim_utils.h"
namespace xe {
namespace hid {
@@ -39,7 +40,7 @@ void InputSystem::AddDriver(std::unique_ptr<InputDriver> driver) {
void InputSystem::UpdateUsedSlot(InputDriver* driver, uint8_t slot,
bool connected) {
if (slot == 0xFF) {
if (slot == XUserIndexAny) {
slot = 0;
}
@@ -50,6 +51,10 @@ void InputSystem::UpdateUsedSlot(InputDriver* driver, uint8_t slot,
XELOGI(controller_slot_state_change_message[connected].c_str(), slot);
connected_slots.flip(slot);
if (kernel::kernel_state()) {
kernel::kernel_state()->BroadcastNotification(
kXNotificationIDSystemInputDevicesChanged, 0);
}
if (driver) {
X_INPUT_CAPABILITIES capabilities = {};
@@ -147,15 +152,14 @@ void InputSystem::ToggleVibration() {
// Send instant update to vibration state to prevent awaiting for next tick.
X_INPUT_VIBRATION vibration = X_INPUT_VIBRATION();
for (uint8_t user_index = 0; user_index < max_allowed_controllers;
user_index++) {
for (uint8_t user_index = 0; user_index < XUserMaxUserCount; user_index++) {
SetState(user_index, &vibration);
}
}
void InputSystem::AdjustDeadzoneLevels(const uint8_t slot,
X_INPUT_GAMEPAD* gamepad) {
if (slot > max_allowed_controllers) {
if (slot > XUserMaxUserCount) {
return;
}

View File

@@ -27,8 +27,6 @@ class Window;
namespace xe {
namespace hid {
static constexpr uint8_t max_allowed_controllers = 4;
class InputSystem {
public:
explicit InputSystem(xe::ui::Window* window);
@@ -51,7 +49,7 @@ class InputSystem {
void ToggleVibration();
const std::bitset<max_allowed_controllers> GetConnectedSlots() const {
const std::bitset<XUserMaxUserCount> GetConnectedSlots() const {
return connected_slots;
}
@@ -72,8 +70,8 @@ class InputSystem {
std::vector<std::unique_ptr<InputDriver>> drivers_;
std::bitset<max_allowed_controllers> connected_slots = {};
std::array<std::pair<joystick_value, joystick_value>, max_allowed_controllers>
std::bitset<XUserMaxUserCount> connected_slots = {};
std::array<std::pair<joystick_value, joystick_value>, XUserMaxUserCount>
controllers_max_joystick_value = {};
xe_unlikely_mutex lock_;

View File

@@ -282,7 +282,7 @@ X_RESULT SDLInputDriver::GetKeystroke(uint32_t users, uint32_t flags,
// TODO(JoelLinn): Figure out the flags
// https://github.com/evilC/UCR/blob/0489929e2a8e39caa3484c67f3993d3fba39e46f/Libraries/XInput.ahk#L85-L98
assert(sdl_events_initialized_ && sdl_gamecontroller_initialized_);
bool user_any = users == 0xFF;
bool user_any = users == XUserIndexAny;
if (users >= HID_SDL_USER_COUNT && !user_any) {
return X_ERROR_BAD_ARGUMENTS;
}

View File

@@ -208,7 +208,7 @@ X_RESULT XInputInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
// we are not passing back an uninitialized X_INPUT_KEYSTROKE structure.
// If any user (0xFF) is polled this bug does not occur but GetCapabilities
// would fail so we need to skip it.
if (user_index != 0xFF) {
if (user_index != XUserIndexAny) {
XINPUT_CAPABILITIES caps;
auto xigc = (decltype(&XInputGetCapabilities))XInputGetCapabilities_;
result = xigc(user_index, 0, &caps);