Initialize the first controller for the keyboard even if no controllers are connected

This commit is contained in:
kalaposfos13 2025-04-25 18:32:15 +02:00
parent c962e70fd8
commit f29d79ec40
3 changed files with 11 additions and 2 deletions

View File

@ -586,8 +586,8 @@ s32 PS4_SYSV_ABI sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdLis
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
}
// TODO only first user, do the others as well
auto controllers = *Common::Singleton<Input::GameControllers>::Instance();
for (int i = 0; i < 4; i++) {
auto controllers = *Common::Singleton<Input::GameControllers>::Instance();
userIdList->user_id[i] = controllers[i]->user_id;
}
return ORBIS_OK;

View File

@ -240,6 +240,8 @@ void GameController::SetTouchpadState(int touchIndex, bool touchDown, float x, f
}
}
bool is_first_check = true;
void GameControllers::TryOpenSDLControllers(GameControllers& controllers) {
using namespace Libraries::UserService;
int controller_count;
@ -313,6 +315,13 @@ void GameControllers::TryOpenSDLControllers(GameControllers& controllers) {
}
}
}
if (is_first_check) [[unlikely]] {
is_first_check = false;
if (controller_count == 0) {
controllers[0]->user_id = 1;
AddUserServiceEvent({OrbisUserServiceEventType::Login, 1});
}
}
}
u32 GameController::Poll() {

View File

@ -143,7 +143,7 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller
// input handler init-s
Input::ControllerOutput::LinkJoystickAxes();
Input::ParseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial()));
// default login
Input::GameControllers::TryOpenSDLControllers(controllers);
using namespace Libraries::UserService;
}