mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-19 18:36:53 +02:00
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:
@@ -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.
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user