forked from Frogging-Family/wine-tkg-git
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new dualsense patches to valvexbe
- Loading branch information
1 parent
84a2aea
commit fba3903
Showing
13 changed files
with
600 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...e-tkg-userpatches/valvexbe/ds1-pending-review-mmdevapi-support-VT_CLSID-for-contain.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
From 5357232357bf12a766be1fdc4080abfc0bd7b0bc Mon Sep 17 00:00:00 2001 | ||
From: Claire Girka <[email protected]> | ||
Date: Fri, 15 Jul 2022 22:09:57 +0200 | ||
Subject: [PATCH 1/9] [pending review] mmdevapi: support VT_CLSID for | ||
containerId property in MMDevice_SetPropValue. | ||
|
||
CLSID is special-cased to this property because we can't safely differentiate | ||
an encoded VT_CLSID from an encoded VT_BLOB. | ||
--- | ||
dlls/mmdevapi/devenum.c | 12 ++++++++++++ | ||
1 file changed, 12 insertions(+) | ||
|
||
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c | ||
index daafb4a822e..24f25628831 100644 | ||
--- a/dlls/mmdevapi/devenum.c | ||
+++ b/dlls/mmdevapi/devenum.c | ||
@@ -227,6 +227,18 @@ static HRESULT MMDevice_SetPropValue(const GUID *devguid, DWORD flow, REFPROPERT | ||
ret = RegSetValueExW(regkey, buffer, 0, REG_SZ, (const BYTE*)pv->pwszVal, sizeof(WCHAR)*(1+lstrlenW(pv->pwszVal))); | ||
break; | ||
} | ||
+ case VT_CLSID: | ||
+ { | ||
+ if (IsEqualPropertyKey(*key, DEVPKEY_Device_ContainerId)) { | ||
+ BYTE value[24] = { VT_CLSID, 0, 0, 0, 1, 0, 0, 0 }; | ||
+ memcpy(value + 8, pv->puuid, sizeof(GUID)); | ||
+ | ||
+ ret = RegSetValueExW(regkey, buffer, 0, REG_BINARY, (const BYTE*)value, 24); | ||
+ break; | ||
+ } | ||
+ /* If it's not containerId, fall through the default unsupported case as we can't | ||
+ ensure it will be decoded as CLSID. */ | ||
+ } | ||
default: | ||
ret = 0; | ||
FIXME("Unhandled type %u\n", pv->vt); | ||
-- | ||
2.47.1 | ||
|
39 changes: 39 additions & 0 deletions
39
...e-tkg-userpatches/valvexbe/ds2-pending-review-mmdevapi-decode-ContainerId-property-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
From c39a2e52706b6f3cdd23f266484cf3ea4b1ddeaa Mon Sep 17 00:00:00 2001 | ||
From: Claire Girka <[email protected]> | ||
Date: Fri, 15 Jul 2022 22:09:57 +0200 | ||
Subject: [PATCH 2/9] [pending review] mmdevapi: decode ContainerId property to | ||
CLSID in MMDevice_GetPropValue. | ||
|
||
--- | ||
dlls/mmdevapi/devenum.c | 15 +++++++++++++++ | ||
1 file changed, 15 insertions(+) | ||
|
||
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c | ||
index 24f25628831..8a427d347d9 100644 | ||
--- a/dlls/mmdevapi/devenum.c | ||
+++ b/dlls/mmdevapi/devenum.c | ||
@@ -191,6 +191,21 @@ static HRESULT MMDevice_GetPropValue(const GUID *devguid, DWORD flow, REFPROPERT | ||
break; | ||
} | ||
RegCloseKey(regkey); | ||
+ | ||
+ /* Special case ContainerID as CLSID */ | ||
+ if(pv->vt == VT_BLOB && pv->blob.pBlobData && pv->blob.cbSize == 24 && pv->blob.pBlobData[0] == VT_CLSID && IsEqualPropertyKey(*key, DEVPKEY_Device_ContainerId)) { | ||
+ GUID *guid = CoTaskMemAlloc(sizeof(GUID)); | ||
+ if (!guid) { | ||
+ PropVariantClear(pv); | ||
+ hr = E_OUTOFMEMORY; | ||
+ } else { | ||
+ memcpy(guid, pv->blob.pBlobData + 8, sizeof(GUID)); | ||
+ CoTaskMemFree(pv->blob.pBlobData); | ||
+ pv->vt = VT_CLSID; | ||
+ pv->puuid = guid; | ||
+ } | ||
+ } | ||
+ | ||
return hr; | ||
} | ||
|
||
-- | ||
2.47.1 | ||
|
30 changes: 30 additions & 0 deletions
30
...e-tkg-userpatches/valvexbe/ds3-pending-review-mmdevapi-copy-ContainerID-from-audio-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 2585851b3e426eaacfd0700296eddde10cab88cc Mon Sep 17 00:00:00 2001 | ||
From: Claire Girka <[email protected]> | ||
Date: Fri, 15 Jul 2022 22:09:57 +0200 | ||
Subject: [PATCH 3/9] [pending review] mmdevapi: copy ContainerID from audio | ||
driver if available. | ||
|
||
Some games with support for the haptic feedback and speaker features of the | ||
Sony DualSense controller select the controller's audio output by filtering on | ||
the ContainerId IMMDevice property to find one that matches the controller's | ||
HID's. | ||
--- | ||
dlls/mmdevapi/devenum.c | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c | ||
index 8a427d347d9..8a39886f918 100644 | ||
--- a/dlls/mmdevapi/devenum.c | ||
+++ b/dlls/mmdevapi/devenum.c | ||
@@ -421,6 +421,8 @@ static MMDevice *MMDevice_Create(const WCHAR *name, GUID *id, EDataFlow flow, DW | ||
MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv); | ||
MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_DeviceDesc, &pv); | ||
|
||
+ set_driver_prop_value(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_ContainerId); | ||
+ | ||
pv.pwszVal = guidstr; | ||
MMDevice_SetPropValue(id, flow, &deviceinterface_key, &pv); | ||
|
||
-- | ||
2.47.1 | ||
|
74 changes: 74 additions & 0 deletions
74
...e-tkg-userpatches/valvexbe/ds4-pending-review-mmdevapi-Invalidate-ContainerID-of-un.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
From 3b7eb04cd53690c024d74a1309bae245b23a62c6 Mon Sep 17 00:00:00 2001 | ||
From: Claire Girka <[email protected]> | ||
Date: Fri, 15 Jul 2022 22:10:06 +0200 | ||
Subject: [PATCH 4/9] [pending review] mmdevapi: Invalidate ContainerID of | ||
unavailable audio devices. | ||
|
||
Some games, like Deathloop, enumerate all unavailable audio devices, including | ||
unavailable ones, and stop at the first one matching the ContainerID. | ||
|
||
Depending on how ContainerIDs end up being attributed, an active device may end | ||
up sharing a ContainerID with an unplugged device that was previously plugged | ||
in the same physical port. Depending on the audio backend, the same audio | ||
device plugged in the same port may be seen as a different audio device by Wine | ||
depending on things like in which order devices were discovered. | ||
|
||
In those cases, a game might find an inactive matching device before the active | ||
one, and thus fail to open the audio output. | ||
|
||
By invalidating the ContainerID of unavailable devices, we this issue can be | ||
avoided. | ||
--- | ||
dlls/mmdevapi/devenum.c | 29 ++++++++++++++++++++++++++++- | ||
1 file changed, 28 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c | ||
index 8a39886f918..cbc38e46213 100644 | ||
--- a/dlls/mmdevapi/devenum.c | ||
+++ b/dlls/mmdevapi/devenum.c | ||
@@ -209,6 +209,26 @@ static HRESULT MMDevice_GetPropValue(const GUID *devguid, DWORD flow, REFPROPERT | ||
return hr; | ||
} | ||
|
||
+static HRESULT MMDevice_DeletePropValue(const GUID *devguid, DWORD flow, REFPROPERTYKEY key) | ||
+{ | ||
+ WCHAR buffer[80]; | ||
+ const GUID *id = &key->fmtid; | ||
+ HRESULT hr; | ||
+ HKEY regkey; | ||
+ LONG ret; | ||
+ | ||
+ hr = MMDevPropStore_OpenPropKey(devguid, flow, ®key); | ||
+ if (FAILED(hr)) | ||
+ return hr; | ||
+ wsprintfW( buffer, propkey_formatW, id->Data1, id->Data2, id->Data3, | ||
+ id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], | ||
+ id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7], key->pid ); | ||
+ ret = RegDeleteValueW(regkey, buffer); | ||
+ RegCloseKey(regkey); | ||
+ TRACE("Deleting %s returned %lu\n", debugstr_w(buffer), ret); | ||
+ return hr; | ||
+} | ||
+ | ||
static HRESULT MMDevice_SetPropValue(const GUID *devguid, DWORD flow, REFPROPERTYKEY key, REFPROPVARIANT pv) | ||
{ | ||
WCHAR buffer[80]; | ||
@@ -421,7 +441,14 @@ static MMDevice *MMDevice_Create(const WCHAR *name, GUID *id, EDataFlow flow, DW | ||
MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv); | ||
MMDevice_SetPropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_DeviceDesc, &pv); | ||
|
||
- set_driver_prop_value(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_ContainerId); | ||
+ /* The mechanism we use to attribute Container IDs is not very robust and could end up making | ||
+ an active device share a ContainerID with inactive devices, and some games enumerate even | ||
+ inactive devices, stopping at the first matching one. | ||
+ To avoid issues, invalidate the ContainerID of devices that are not present. */ | ||
+ if (state & DEVICE_STATE_ACTIVE) | ||
+ set_driver_prop_value(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_ContainerId); | ||
+ else if (state & DEVICE_STATE_NOTPRESENT) | ||
+ MMDevice_DeletePropValue(id, flow, (const PROPERTYKEY*)&DEVPKEY_Device_ContainerId); | ||
|
||
pv.pwszVal = guidstr; | ||
MMDevice_SetPropValue(id, flow, &deviceinterface_key, &pv); | ||
-- | ||
2.47.1 | ||
|
52 changes: 52 additions & 0 deletions
52
...-tkg-userpatches/valvexbe/ds5--draft-winepulse-Store-PulseAudio-device-s-sysfs-path.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
From 5f19f38096754765ab6acb2015ef2a18e40e5a1e Mon Sep 17 00:00:00 2001 | ||
From: Claire Girka <[email protected]> | ||
Date: Sat, 2 Jul 2022 12:15:47 +0200 | ||
Subject: [PATCH 5/9] [draft] winepulse: Store PulseAudio device's sysfs path | ||
when available. | ||
|
||
--- | ||
dlls/winepulse.drv/pulse.c | 7 +++++++ | ||
1 file changed, 7 insertions(+) | ||
|
||
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c | ||
index 944cf938bdc..db4289777da 100644 | ||
--- a/dlls/winepulse.drv/pulse.c | ||
+++ b/dlls/winepulse.drv/pulse.c | ||
@@ -104,6 +104,7 @@ typedef struct _PhysDevice { | ||
UINT index; | ||
REFERENCE_TIME min_period, def_period; | ||
WAVEFORMATEXTENSIBLE fmt; | ||
+ char *sysfs_path; | ||
char pulse_name[0]; | ||
} PhysDevice; | ||
|
||
@@ -169,6 +170,8 @@ static void free_phys_device_lists(void) | ||
do { | ||
LIST_FOR_EACH_ENTRY_SAFE(dev, dev_next, *list, PhysDevice, entry) { | ||
free(dev->name); | ||
+ if (dev->sysfs_path) | ||
+ free(dev->sysfs_path); | ||
free(dev); | ||
} | ||
} while (*(++list)); | ||
@@ -541,6 +544,7 @@ static void fill_device_info(PhysDevice *dev, pa_proplist *p) | ||
dev->bus_type = phys_device_bus_invalid; | ||
dev->vendor_id = 0; | ||
dev->product_id = 0; | ||
+ dev->sysfs_path = NULL; | ||
|
||
if (!p) | ||
return; | ||
@@ -557,6 +561,9 @@ static void fill_device_info(PhysDevice *dev, pa_proplist *p) | ||
|
||
if ((buffer = pa_proplist_gets(p, PA_PROP_DEVICE_PRODUCT_ID))) | ||
dev->product_id = strtol(buffer, NULL, 16); | ||
+ | ||
+ if ((buffer = pa_proplist_gets(p, "sysfs.path"))) | ||
+ dev->sysfs_path = strdup(buffer); | ||
} | ||
|
||
static void pulse_add_device(struct list *list, pa_proplist *proplist, int index, EndpointFormFactor form, | ||
-- | ||
2.47.1 | ||
|
112 changes: 112 additions & 0 deletions
112
...e-tkg-userpatches/valvexbe/ds6-draft-winepulse-Add-support-for-containerId-property.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
From 407c9eb19c951b6574450348f8733cb86554646c Mon Sep 17 00:00:00 2001 | ||
From: Claire Girka <[email protected]> | ||
Date: Sat, 2 Jul 2022 12:16:34 +0200 | ||
Subject: [PATCH 6/9] [draft] winepulse: Add support for containerId property | ||
from sysfs path. | ||
|
||
--- | ||
dlls/winepulse.drv/pulse.c | 74 ++++++++++++++++++++++++++++++++++++++ | ||
1 file changed, 74 insertions(+) | ||
|
||
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c | ||
index db4289777da..8212b8004a5 100644 | ||
--- a/dlls/winepulse.drv/pulse.c | ||
+++ b/dlls/winepulse.drv/pulse.c | ||
@@ -45,6 +45,7 @@ | ||
#include "../mmdevapi/unixlib.h" | ||
|
||
#include "mult.h" | ||
+#include "devpkey.h" | ||
|
||
WINE_DEFAULT_DEBUG_CHANNEL(pulse); | ||
|
||
@@ -2536,6 +2537,76 @@ static BOOL get_device_path(PhysDevice *dev, struct get_prop_value_params *param | ||
return TRUE; | ||
} | ||
|
||
+static BOOL get_device_container(PhysDevice *dev, struct get_prop_value_params *params) | ||
+{ | ||
+ char buffer[10]; | ||
+ char *path, *p; | ||
+ PROPVARIANT *out = params->value; | ||
+ | ||
+ if (*params->buffer_size < sizeof(GUID)) { | ||
+ params->result = E_NOT_SUFFICIENT_BUFFER; | ||
+ *params->buffer_size = sizeof(GUID); | ||
+ return FALSE; | ||
+ } | ||
+ | ||
+ if (dev->sysfs_path == NULL) { | ||
+ params->result = E_FAIL; | ||
+ return FALSE; | ||
+ } | ||
+ | ||
+ path = malloc(strlen(dev->sysfs_path) + strlen("/sys") + strlen("/removable") + 1); | ||
+ path[0] = 0; | ||
+ | ||
+ if (strncmp(dev->sysfs_path, "/sys", 4) != 0) | ||
+ strcpy(path, "/sys"); | ||
+ | ||
+ strcat(path, dev->sysfs_path); | ||
+ | ||
+ while ((p = strrchr(path, '/'))) { | ||
+ FILE *f; | ||
+ | ||
+ strcpy(p, "/removable"); | ||
+ f = fopen(path, "r"); | ||
+ *p = 0; | ||
+ | ||
+ if (f) { | ||
+ if (fgets(buffer, 10, f)) { | ||
+ if (strcmp(buffer, "fixed") != 0) { | ||
+ /* It's a potentially removable device, so treat it as a container */ | ||
+ fclose(f); | ||
+ break; | ||
+ } | ||
+ } | ||
+ fclose(f); | ||
+ } | ||
+ } | ||
+ | ||
+ /* Get just the USB bus-devpath part */ | ||
+ p = strrchr(path, '/'); | ||
+ if (p && (p - path) > 12) { | ||
+ char *guid = (char*) params->buffer; | ||
+ out->puuid = params->buffer; | ||
+ | ||
+ memset(out->puuid, 0, sizeof(GUID)); | ||
+ out->puuid->Data1 = (dev->vendor_id << 16) | dev->product_id; | ||
+ | ||
+ for (int i = 0; p[i]; i++) { | ||
+ guid[4 + i % 12] ^= p[i]; | ||
+ } | ||
+ | ||
+ out->vt = VT_CLSID; | ||
+ params->result = S_OK; | ||
+ | ||
+ free(path); | ||
+ return TRUE; | ||
+ } | ||
+ | ||
+ free(path); | ||
+ | ||
+ params->result = E_FAIL; | ||
+ return FALSE; | ||
+} | ||
+ | ||
static NTSTATUS pulse_get_prop_value(void *args) | ||
{ | ||
static const GUID PKEY_AudioEndpoint_GUID = { | ||
@@ -2554,6 +2625,9 @@ static NTSTATUS pulse_get_prop_value(void *args) | ||
if (IsEqualPropertyKey(*params->prop, devicepath_key)) { | ||
get_device_path(dev, params); | ||
return STATUS_SUCCESS; | ||
+ } else if (IsEqualPropertyKey(*params->prop, DEVPKEY_Device_ContainerId)) { | ||
+ get_device_container(dev, params); | ||
+ return STATUS_SUCCESS; | ||
} else if (IsEqualGUID(¶ms->prop->fmtid, &PKEY_AudioEndpoint_GUID)) { | ||
switch (params->prop->pid) { | ||
case 0: /* FormFactor */ | ||
-- | ||
2.47.1 | ||
|
Oops, something went wrong.