Claire Girka : mmdevapi: Override product strings for DualSense controller audio devices.
Alexandre Julliard
julliard at winehq.org
Thu Jun 30 16:35:35 CDT 2022
Module: wine
Branch: master
Commit: 67f9c76386c8f67363f1fa90d7f7ac0ac84fdcd7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=67f9c76386c8f67363f1fa90d7f7ac0ac84fdcd7
Author: Claire Girka <claire at sitedethib.com>
Date: Wed Jun 29 12:09:01 2022 +0200
mmdevapi: Override product strings for DualSense controller audio devices.
Some games expect the DualSense audio device (used for haptic feedback and
controller speaker) to be called “Wireless Controller”.
---
dlls/mmdevapi/devenum.c | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c
index 053275cac45..bfeb3f3ecd8 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 product_name_overrides
+{
+ const WCHAR *id;
+ const WCHAR *product;
+};
+
+static const struct product_name_overrides product_name_overrides[] =
+{
+ /* Sony controllers */
+ { .id = L"VID_054C&PID_0CE6", .product = L"Wireless Controller" },
+};
+
+static const WCHAR *find_product_name_override(const WCHAR *device_id)
+{
+ const WCHAR *match_id = wcschr( device_id, '\\' ) + 1;
+ DWORD i;
+
+ for (i = 0; i < ARRAY_SIZE(product_name_overrides); ++i)
+ if (!wcsnicmp( product_name_overrides[i].id, match_id, 17 ))
+ return product_name_overrides[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
@@ -321,6 +345,21 @@ static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD st
pv.vt = VT_LPWSTR;
pv.pwszVal = name;
+
+ if (SUCCEEDED(set_driver_prop_value(id, flow, &devicepath_key))) {
+ PROPVARIANT pv2;
+
+ PropVariantInit(&pv2);
+
+ if (SUCCEEDED(MMDevice_GetPropValue(id, flow, &devicepath_key, &pv2)) && pv2.vt == VT_LPWSTR) {
+ const WCHAR *override;
+ if ((override = find_product_name_override(pv2.pwszVal)) != NULL)
+ pv.pwszVal = (WCHAR*) override;
+ }
+
+ PropVariantClear(&pv2);
+ }
+
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 +367,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;
More information about the wine-cvs
mailing list