From e2609a87be351c701b99e1e6f03020a16bdcdfca Mon Sep 17 00:00:00 2001 From: Dean Galvin Date: Thu, 1 Oct 2026 00:35:57 +1300 Subject: [PATCH] fix(pad): build SDL with HIDAPI so DualSense output reaches the controller The bundled SDL was configured with SDL_HIDAPI OFF, so a DualSense went through the generic joystick driver of the platform: no touchpad, no light bar and no DualSense effect reports, which left the light bar, trigger effect and (on Linux) rumble requests that PadInput already sends through SDL without effect on the controller. With HIDAPI, SDL's PS5 driver handles the pad: touchpad, light bar, rumble, trigger effects and the motion sensors. A USB pad always uses the driver's enhanced reports. SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE enables them for a Bluetooth pad as well, which otherwise stays on the simple report without effects. pad_sdl checks that the bundled SDL is built with the HIDAPI joystick driver. --- CMakeLists.txt | 2 +- core/libs/prx/libSceVideoOut/CMakeLists.txt | 6 ++++++ core/libs/prx/libSceVideoOut/src/PadInput.cpp | 1 + core/libs/prx/libSceVideoOut/tests/PadSdl.cpp | 13 +++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 core/libs/prx/libSceVideoOut/tests/PadSdl.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b17426dec..9aa3edc67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ set(SDL_OPENGLES OFF CACHE BOOL "" FORCE) set(SDL_VULKAN ON CACHE BOOL "" FORCE) set(SDL_JOYSTICK ON CACHE BOOL "" FORCE) set(SDL_HAPTIC OFF CACHE BOOL "" FORCE) -set(SDL_HIDAPI OFF CACHE BOOL "" FORCE) +set(SDL_HIDAPI ON CACHE BOOL "" FORCE) set(SDL_SENSOR OFF CACHE BOOL "" FORCE) set(SDL_STATIC_PIC ON CACHE BOOL "" FORCE) set(ANYPS5_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") diff --git a/core/libs/prx/libSceVideoOut/CMakeLists.txt b/core/libs/prx/libSceVideoOut/CMakeLists.txt index e039c0529..7614efad3 100644 --- a/core/libs/prx/libSceVideoOut/CMakeLists.txt +++ b/core/libs/prx/libSceVideoOut/CMakeLists.txt @@ -30,3 +30,9 @@ target_include_directories(video_out_flip_tests PRIVATE ${LIBS_INCLUDE_DIR} ${CM target_link_libraries(video_out_flip_tests PRIVATE libSceVideoOut libSceAgcDriver libkernel libc) set_target_properties(video_out_flip_tests PROPERTIES CXX_EXTENSIONS OFF) configure_windows_unwind(video_out_flip_tests) + +if(BUILD_TESTING) + add_executable(pad_sdl_tests tests/PadSdl.cpp) + target_link_libraries(pad_sdl_tests PRIVATE SDL2-static) + add_test(NAME pad_sdl COMMAND pad_sdl_tests) +endif() diff --git a/core/libs/prx/libSceVideoOut/src/PadInput.cpp b/core/libs/prx/libSceVideoOut/src/PadInput.cpp index 7bf045fa0..3469cb70d 100644 --- a/core/libs/prx/libSceVideoOut/src/PadInput.cpp +++ b/core/libs/prx/libSceVideoOut/src/PadInput.cpp @@ -25,6 +25,7 @@ PadInput::~PadInput() { void PadInput::openFirstAvailableController() { if (controller != nullptr) return; SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); if ((SDL_WasInit(SDL_INIT_GAMECONTROLLER) & SDL_INIT_GAMECONTROLLER) == 0) { if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) != 0) { APS5_LOG_ERR("Pad: SDL game controller init failed: %s", SDL_GetError()); diff --git a/core/libs/prx/libSceVideoOut/tests/PadSdl.cpp b/core/libs/prx/libSceVideoOut/tests/PadSdl.cpp new file mode 100644 index 000000000..cec6638fb --- /dev/null +++ b/core/libs/prx/libSceVideoOut/tests/PadSdl.cpp @@ -0,0 +1,13 @@ +#include "SDL_config.h" + +#include + +int main() { +#ifdef SDL_JOYSTICK_HIDAPI + std::puts("pad_sdl: SDL drives controllers through HIDAPI"); + return 0; +#else + std::fputs("pad_sdl: SDL is built without HIDAPI, so a DualSense gets no light bar, touchpad or trigger effects\n", stderr); + return 1; +#endif +}