From f29d79ec40382479ef6faab77a93043cd5dd6333 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Fri, 25 Apr 2025 18:32:15 +0200 Subject: [PATCH] Initialize the first controller for the keyboard even if no controllers are connected --- src/core/libraries/system/userservice.cpp | 2 +- src/input/controller.cpp | 9 +++++++++ src/sdl_window.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core/libraries/system/userservice.cpp b/src/core/libraries/system/userservice.cpp index 843ea583f..3f737e0a4 100644 --- a/src/core/libraries/system/userservice.cpp +++ b/src/core/libraries/system/userservice.cpp @@ -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::Instance(); for (int i = 0; i < 4; i++) { - auto controllers = *Common::Singleton::Instance(); userIdList->user_id[i] = controllers[i]->user_id; } return ORBIS_OK; diff --git a/src/input/controller.cpp b/src/input/controller.cpp index 740001bda..0d9a307ba 100644 --- a/src/input/controller.cpp +++ b/src/input/controller.cpp @@ -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() { diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index c5a0b2799..cf2d101ae 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -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; }