From dc3e0a83e040ea5365724c4a590c12cdd70b1886 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Tue, 24 Feb 2026 21:41:24 +0100 Subject: [PATCH] misc fixes --- src/core/libraries/pad/pad.cpp | 27 ++++++++++++++--------- src/core/libraries/system/userservice.cpp | 9 ++++++-- src/input/controller.cpp | 1 + src/input/input_handler.cpp | 6 ++--- src/input/input_handler.h | 6 ++--- src/sdl_window.cpp | 1 + 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index 59c86d55c..aa66fb943 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -13,6 +13,7 @@ namespace Libraries::Pad { using Input::GameController; +using Input::GameControllers; static bool g_initialized = false; static bool g_opened = false; @@ -163,7 +164,7 @@ int PS4_SYSV_ABI scePadGetHandle(Libraries::UserService::OrbisUserServiceUserId return ORBIS_PAD_ERROR_DEVICE_NO_HANDLE; } LOG_DEBUG(Lib_Pad, "(DUMMY) called"); - return 1; + return userId; } int PS4_SYSV_ABI scePadGetIdleCount() { @@ -406,7 +407,7 @@ int PS4_SYSV_ABI scePadRead(s32 handle, OrbisPadData* pData, s32 num) { if (!controller_id) { return ORBIS_PAD_ERROR_INVALID_HANDLE; } - auto controllers = *Common::Singleton::Instance(); + auto controllers = *Common::Singleton::Instance(); auto& controller = *controllers[*controller_id]; int ret_num = controller.ReadStates(states.data(), num, &connected, &connected_count); return ProcessStates(handle, pData, controller, states.data(), ret_num, connected, @@ -439,7 +440,7 @@ int PS4_SYSV_ABI scePadReadState(s32 handle, OrbisPadData* pData) { if (!controller_id) { return ORBIS_PAD_ERROR_INVALID_HANDLE; } - auto controllers = *Common::Singleton::Instance(); + auto controllers = *Common::Singleton::Instance(); auto& controller = *controllers[*controller_id]; int connected_count = 0; bool connected = false; @@ -460,7 +461,7 @@ int PS4_SYSV_ABI scePadResetLightBar(s32 handle) { if (!controller_id) { return ORBIS_PAD_ERROR_INVALID_HANDLE; } - auto controllers = *Common::Singleton::Instance(); + auto controllers = *Common::Singleton::Instance(); int* rgb = Config::GetControllerCustomColor(); controllers[*controller_id]->SetLightBarRGB(rgb[0], rgb[1], rgb[2]); return ORBIS_OK; @@ -484,10 +485,10 @@ int PS4_SYSV_ABI scePadResetOrientation(s32 handle) { return ORBIS_PAD_ERROR_INVALID_HANDLE; } - auto* controller = Common::Singleton::Instance(); + auto controllers = *Common::Singleton::Instance(); Libraries::Pad::OrbisFQuaternion defaultOrientation = {0.0f, 0.0f, 0.0f, 1.0f}; - controller->SetLastOrientation(defaultOrientation); - controller->SetLastUpdate(std::chrono::steady_clock::now()); + controllers[*controller_id]->SetLastOrientation(defaultOrientation); + controllers[*controller_id]->SetLastUpdate(std::chrono::steady_clock::now()); return ORBIS_OK; } @@ -549,8 +550,8 @@ int PS4_SYSV_ABI scePadSetLightBar(s32 handle, const OrbisPadLightBarParam* pPar return ORBIS_PAD_ERROR_INVALID_LIGHTBAR_SETTING; } - auto* controller = Common::Singleton::Instance(); - controller->SetLightBarRGB(pParam->r, pParam->g, pParam->b); + auto controllers = *Common::Singleton::Instance(); + controllers[*controller_id]->SetLightBarRGB(pParam->r, pParam->g, pParam->b); return ORBIS_OK; } return ORBIS_PAD_ERROR_INVALID_ARG; @@ -614,11 +615,15 @@ int PS4_SYSV_ABI scePadSetUserColor() { } int PS4_SYSV_ABI scePadSetVibration(s32 handle, const OrbisPadVibrationParam* pParam) { + auto controller_id = GamepadSelect::GetControllerIndexFromUserID(handle); + if (!controller_id) { + return ORBIS_PAD_ERROR_INVALID_HANDLE; + } if (pParam != nullptr) { LOG_DEBUG(Lib_Pad, "scePadSetVibration called handle = {} data = {} , {}", handle, pParam->smallMotor, pParam->largeMotor); - auto* controller = Common::Singleton::Instance(); - controller->SetVibration(pParam->smallMotor, pParam->largeMotor); + auto controllers = *Common::Singleton::Instance(); + controllers[*controller_id]->SetVibration(pParam->smallMotor, pParam->largeMotor); return ORBIS_OK; } return ORBIS_PAD_ERROR_INVALID_ARG; diff --git a/src/core/libraries/system/userservice.cpp b/src/core/libraries/system/userservice.cpp index f820513c7..85dcbf34b 100644 --- a/src/core/libraries/system/userservice.cpp +++ b/src/core/libraries/system/userservice.cpp @@ -1113,8 +1113,13 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserName(int user_id, char* user_name, std::si LOG_ERROR(Lib_UserService, "user_name is null"); return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT; } - std::string name = - EmulatorSettings::GetInstance()->GetUserManager().GetUserByID(user_id)->user_name; + std::string name = "shadPS4"; + auto const* u = EmulatorSettings::GetInstance()->GetUserManager().GetUserByID(user_id); + if (u != nullptr) { + name = u->user_name; + } else { + LOG_ERROR(Lib_UserService, "No user found"); + } if (size < name.length()) { LOG_ERROR(Lib_UserService, "buffer is too short"); return ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT; diff --git a/src/input/controller.cpp b/src/input/controller.cpp index 72b3d78f9..8f2e5c8fa 100644 --- a/src/input/controller.cpp +++ b/src/input/controller.cpp @@ -296,6 +296,7 @@ void GameControllers::TryOpenSDLControllers(GameControllers& controllers) { AddUserServiceEvent({OrbisUserServiceEventType::Login, 1}); } } + SDL_free(new_joysticks); } u8 GameController::GetTouchCount() { return m_touch_count; diff --git a/src/input/input_handler.cpp b/src/input/input_handler.cpp index 37b152fe2..af667c43c 100644 --- a/src/input/input_handler.cpp +++ b/src/input/input_handler.cpp @@ -395,13 +395,11 @@ void ParseInputConfig(const std::string game_id = "") { binding, &*std::ranges::find(output_arrays[std::clamp(output_gamepad_id - 1, 0, 3)].data, ControllerOutput(button_it->second))); - connections.insert(connections.end(), connection); } else if (hotkey_it != string_to_hotkey_map.end()) { connection = BindingConnection( binding, &*std::ranges::find(output_arrays[std::clamp(output_gamepad_id - 1, 0, 3)].data, ControllerOutput(hotkey_it->second))); - connections.insert(connections.end(), connection); } else if (axis_it != string_to_axis_map.end()) { // todo add new shit here int value_to_set = binding.keys[2].type == InputType::Axis ? 0 : axis_it->second.value; @@ -616,6 +614,7 @@ void ControllerOutput::FinalizeUpdate(u8 gamepad_index) { break; case HOTKEY_REMOVE_VIRTUAL_USER: PushSDLEvent(SDL_EVENT_REMOVE_VIRTUAL_USER); + break; case HOTKEY_VOLUME_UP: EmulatorSettings::GetInstance()->SetVolumeSlider( std::clamp(EmulatorSettings::GetInstance()->GetVolumeSlider() + 10, 0, 500)); @@ -694,8 +693,7 @@ bool UpdatePressedKeys(InputEvent event) { // and from there, it only changes the parameter auto it = std::lower_bound(pressed_keys.begin(), pressed_keys.end(), input, [](const std::pair& e, InputID i) { - return std::tie(e.first.input.type, e.first.input.sdl_id) < - std::tie(i.type, i.sdl_id); + return e.first.input < i; }); if (it == pressed_keys.end() || it->first.input != input) { pressed_keys.insert(it, {event, false}); diff --git a/src/input/input_handler.h b/src/input/input_handler.h index 1218d2b2a..c3c87292d 100644 --- a/src/input/input_handler.h +++ b/src/input/input_handler.h @@ -91,9 +91,9 @@ public: bool operator!=(const InputID& o) const { return type != o.type || sdl_id != o.sdl_id || gamepad_id != o.gamepad_id; } - bool operator<=(const InputID& o) const { - return type <= o.type && sdl_id <= o.sdl_id; - return std::tie(gamepad_id, type, sdl_id) <= std::tie(o.gamepad_id, o.type, o.sdl_id); + auto operator<=>(const InputID& o) const { + return std::tie(gamepad_id, type, sdl_id, gamepad_id) <=> + std::tie(o.gamepad_id, o.type, o.sdl_id, o.gamepad_id); } bool IsValid() const { return *this != InputID(); diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 6143bdcbd..61117d7ac 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -271,6 +271,7 @@ void WindowSDL::WaitEvent() { break; } } + break; case SDL_EVENT_RDOC_CAPTURE: VideoCore::TriggerCapture(); break;