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.
This commit is contained in:
Arthur Alves
2026-10-04 12:44:55 -03:00
committed by GitHub
parent 2984c41235
commit c885da0a3f
2 changed files with 14 additions and 2 deletions
+5 -1
View File
@@ -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.
+9 -1
View File
@@ -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());