misc fixes

This commit is contained in:
kalaposfos13 2026-02-24 21:41:24 +01:00
parent faf9cce67e
commit dc3e0a83e0
6 changed files with 30 additions and 20 deletions

View File

@ -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<Input::GameControllers>::Instance();
auto controllers = *Common::Singleton<GameControllers>::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<Input::GameControllers>::Instance();
auto controllers = *Common::Singleton<GameControllers>::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<Input::GameControllers>::Instance();
auto controllers = *Common::Singleton<GameControllers>::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<GameController>::Instance();
auto controllers = *Common::Singleton<GameControllers>::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<Input::GameController>::Instance();
controller->SetLightBarRGB(pParam->r, pParam->g, pParam->b);
auto controllers = *Common::Singleton<GameControllers>::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<Input::GameController>::Instance();
controller->SetVibration(pParam->smallMotor, pParam->largeMotor);
auto controllers = *Common::Singleton<GameControllers>::Instance();
controllers[*controller_id]->SetVibration(pParam->smallMotor, pParam->largeMotor);
return ORBIS_OK;
}
return ORBIS_PAD_ERROR_INVALID_ARG;

View File

@ -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;

View File

@ -296,6 +296,7 @@ void GameControllers::TryOpenSDLControllers(GameControllers& controllers) {
AddUserServiceEvent({OrbisUserServiceEventType::Login, 1});
}
}
SDL_free(new_joysticks);
}
u8 GameController::GetTouchCount() {
return m_touch_count;

View File

@ -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<InputEvent, bool>& 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});

View File

@ -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();

View File

@ -271,6 +271,7 @@ void WindowSDL::WaitEvent() {
break;
}
}
break;
case SDL_EVENT_RDOC_CAPTURE:
VideoCore::TriggerCapture();
break;