[PATCH 1/1] mmdevapi: Override product strings for DualSense controller audio devices
Claire Girka
wine at gitlab.winehq.org
Wed Jun 29 05:12:44 CDT 2022
From: Claire Girka <claire at sitedethib.com>
Some games expect the DualSense audio device (used for haptic feedback and
controller speaker) to be called “Wireless Controller”.
---
dlls/mmdevapi/devenum.c | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c
index 053275cac45..dbbcfa7ce07 100644
--- a/dlls/mmdevapi/devenum.c
+++ b/dlls/mmdevapi/devenum.c
@@ -255,6 +255,30 @@ static HRESULT set_driver_prop_value(GUID *id, const EDataFlow flow, const PROPE
return hr;
}
+struct device_strings
+{
+ const WCHAR *id;
+ const WCHAR *product;
+};
+
+static const struct device_strings device_strings[] =
+{
+ /* Sony controllers */
+ { .id = L"VID_054C&PID_0CE6", .product = L"Wireless Controller" },
+};
+
+static const WCHAR *find_device_string(const WCHAR *device_id)
+{
+ const WCHAR *match_id = wcschr( device_id, '\\' ) + 1;
+ DWORD i;
+
+ for (i = 0; i < ARRAY_SIZE(device_strings); ++i)
+ if (!wcsnicmp( device_strings[i].id, match_id, 17 ))
+ return device_strings[i].product;
+
+ return NULL;
+}
+
/* Creates or updates the state of a device
* If GUID is null, a random guid will be assigned
* and the device will be created
@@ -318,9 +342,19 @@ static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD st
if (!RegCreateKeyExW(key, L"Properties", 0, NULL, 0, KEY_WRITE|KEY_READ|KEY_WOW64_64KEY, NULL, &keyprop, NULL))
{
PROPVARIANT pv;
+ pv.pwszVal = NULL;
+
+ if (SUCCEEDED(drvs.pGetPropValue(id, &devicepath_key, &pv))) {
+ MMDevice_SetPropValue(id, flow, &devicepath_key, &pv);
+
+ /* Some applications expect a specific name for the DualSense audio device */
+ pv.pwszVal = find_device_string(pv.pwszVal);
+ }
pv.vt = VT_LPWSTR;
- pv.pwszVal = name;
+ if (pv.pwszVal == NULL)
+ pv.pwszVal = name;
+
MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv);
MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv);
MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_DeviceDesc, &pv);
@@ -328,8 +362,6 @@ static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD st
pv.pwszVal = guidstr;
MMDevice_SetPropValue(id, flow, &deviceinterface_key, &pv);
- set_driver_prop_value(id, flow, &devicepath_key);
-
if (FAILED(set_driver_prop_value(id, flow, &PKEY_AudioEndpoint_FormFactor)))
{
pv.vt = VT_UI4;
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/338
More information about the wine-devel
mailing list