mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-28 21:14:43 +00:00
Good enough
This commit is contained in:
parent
05ee6f0f42
commit
e0320352f1
@ -580,15 +580,21 @@ int PS4_SYSV_ABI sceUserServiceGetLoginFlag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdList* userIdList) {
|
s32 PS4_SYSV_ABI sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdList* userIdList) {
|
||||||
LOG_DEBUG(Lib_UserService, "called");
|
// LOG_DEBUG(Lib_UserService, "called");
|
||||||
if (userIdList == nullptr) {
|
if (userIdList == nullptr) {
|
||||||
LOG_ERROR(Lib_UserService, "user_id is null");
|
LOG_ERROR(Lib_UserService, "user_id is null");
|
||||||
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
// TODO only first user, do the others as well
|
// TODO only first user, do the others as well
|
||||||
auto controllers = *Common::Singleton<Input::GameControllers>::Instance();
|
auto controllers = *Common::Singleton<Input::GameControllers>::Instance();
|
||||||
for (int i = 0; i < 4; i++) {
|
int li = 0;
|
||||||
userIdList->user_id[i] = controllers[i]->user_id;
|
for (int ci = 0; ci < 4; ci++) {
|
||||||
|
if (controllers[ci]->user_id != -1) {
|
||||||
|
userIdList->user_id[li++] = controllers[ci]->user_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; li < 4; li++) {
|
||||||
|
userIdList->user_id[li] = -1;
|
||||||
}
|
}
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,9 @@ void GameControllers::TryOpenSDLControllers(GameControllers& controllers) {
|
|||||||
SDL_CloseGamepad(pad);
|
SDL_CloseGamepad(pad);
|
||||||
controllers[i]->m_sdl_gamepad = nullptr;
|
controllers[i]->m_sdl_gamepad = nullptr;
|
||||||
controllers[i]->user_id = -1;
|
controllers[i]->user_id = -1;
|
||||||
|
slot_taken[i] = false;
|
||||||
|
} else {
|
||||||
|
controllers[i]->player_index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +288,8 @@ void GameControllers::TryOpenSDLControllers(GameControllers& controllers) {
|
|||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (!slot_taken[i]) {
|
if (!slot_taken[i]) {
|
||||||
controllers[i]->m_sdl_gamepad = pad;
|
controllers[i]->m_sdl_gamepad = pad;
|
||||||
LOG_INFO(Input, "Gamepad registered for slot {}! Handle: {}", i, (void*)pad);
|
LOG_INFO(Input, "Gamepad registered for slot {}! Handle: {}", i,
|
||||||
|
SDL_GetGamepadID(pad));
|
||||||
controllers[i]->user_id = i + 1;
|
controllers[i]->user_id = i + 1;
|
||||||
slot_taken[i] = true;
|
slot_taken[i] = true;
|
||||||
controllers[i]->player_index = i;
|
controllers[i]->player_index = i;
|
||||||
@ -346,16 +350,12 @@ u32 GameController::Poll() {
|
|||||||
|
|
||||||
u8 GameControllers::GetGamepadIndexFromJoystickId(SDL_JoystickID id) {
|
u8 GameControllers::GetGamepadIndexFromJoystickId(SDL_JoystickID id) {
|
||||||
auto& controllers = *Common::Singleton<GameControllers>::Instance();
|
auto& controllers = *Common::Singleton<GameControllers>::Instance();
|
||||||
auto gamepad = SDL_GetGamepadFromID(id);
|
|
||||||
if (!gamepad) {
|
|
||||||
UNREACHABLE_MSG("Gamepad is null!");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (SDL_GetGamepadID(controllers[i]->m_sdl_gamepad) == id) {
|
if (SDL_GetGamepadID(controllers[i]->m_sdl_gamepad) == id) {
|
||||||
return controllers[i]->player_index;
|
return controllers[i]->player_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UNREACHABLE_MSG("Gamepad not registered! Handle: {}", (void*)gamepad);
|
UNREACHABLE_MSG("Handle {} is not registered!", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Input
|
} // namespace Input
|
||||||
|
Loading…
Reference in New Issue
Block a user