From c885da0a3f219a47b913d4966ab7c61f676c09ca Mon Sep 17 00:00:00 2001 From: Arthur Alves <61949512+arthuralvesdev@users.noreply.github.com> Date: Sun, 4 Oct 2026 12:44:55 -0300 Subject: [PATCH] haptics: recognize 'Wireless Controller' audio endpoint on Linux (#1046) On Linux (PipeWire / ALSA), the 4-channel USB audio playback device for the DualSense controller is named 'Wireless Controller' based on Sony's USB product descriptor string. Previously, FindDevice() only matched names containing 'DualSense', causing quad-channel endpoint discovery to fail on Linux systems. Add 'Wireless Controller' to the allowed endpoint names when 4 channels are present, and add a test case verifying discovery under this name. --- src/libs/dualSenseHaptics.cpp | 6 +++++- tests/PadHapticsTests.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libs/dualSenseHaptics.cpp b/src/libs/dualSenseHaptics.cpp index a698ed5e9..aa79f8532 100644 --- a/src/libs/dualSenseHaptics.cpp +++ b/src/libs/dualSenseHaptics.cpp @@ -178,7 +178,11 @@ SDL_AudioDeviceID FindDevice() { for (int i = 0; i < count; i++) { const char* name = SDL_GetAudioDeviceName(devices[i]); SDL_AudioSpec spec {}; - if (name != nullptr && SDL_strcasestr(name, "DualSense") != nullptr && + const bool is_dualsense_name = + name != nullptr && + (SDL_strcasestr(name, "DualSense") != nullptr || + SDL_strcasestr(name, "Wireless Controller") != nullptr); + if (is_dualsense_name && SDL_GetAudioDeviceFormat(devices[i], &spec, nullptr) && spec.channels == 4) { if (device != 0) { device = 0; // Multiple matching endpoints cannot be associated reliably either. diff --git a/tests/PadHapticsTests.cpp b/tests/PadHapticsTests.cpp index da3f1973a..28e420d5a 100644 --- a/tests/PadHapticsTests.cpp +++ b/tests/PadHapticsTests.cpp @@ -438,7 +438,15 @@ void TestDiscoveryAndHotplug() { devices[0].channels = 4; now += 2001; Queue(port, pcm.data()); - Check(streams.size() == 1 && opened_device == 10, "late USB connection was not discovered"); + devices.clear(); + now += 2001; + Queue(port, pcm.data()); + Check(streams.empty(), "disconnected endpoint retained its stream"); + devices = {{10, "Wireless Controller", 4}}; + now += 2001; + Queue(port, pcm.data()); + Check(streams.size() == 1 && opened_device == 10, + "Linux Wireless Controller endpoint was not discovered"); devices.clear(); now += 2001; Queue(port, pcm.data());