[PATCH 2/4] setupapi: Use lowercase device paths.

Rémi Bernon rbernon at codeweavers.com
Thu Dec 23 08:33:09 CST 2021


From: Arkadiusz Hiler <ahiler at codeweavers.com>

Some games are doing case sensitive matches on the device paths obtained from
Setup API and expect them to be lowercase.

This fixes Virginia not being able to discover DualShock 4.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/joy.cpl/main.c           |  2 +-
 dlls/setupapi/devinst.c       |  3 +++
 dlls/setupapi/tests/devinst.c | 13 +++++++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c
index a1308606f98..081dcf2dc74 100644
--- a/dlls/joy.cpl/main.c
+++ b/dlls/joy.cpl/main.c
@@ -100,7 +100,7 @@ static BOOL CALLBACK enum_callback(const DIDEVICEINSTANCEW *instance, void *cont
     joystick->num_effects = 0;
 
     IDirectInputDevice8_GetProperty(joystick->device, DIPROP_GUIDANDPATH, &prop_guid_path.diph);
-    joystick->is_xinput = wcsstr(prop_guid_path.wszPath, L"&IG_") != NULL;
+    joystick->is_xinput = wcsstr(prop_guid_path.wszPath, L"&ig_") != NULL;
 
     if (joystick->forcefeedback) data->num_ff++;
 
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 29cfbbeb87f..ecc0b58ca5c 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -407,6 +407,9 @@ static LPWSTR SETUPDI_CreateSymbolicLinkPath(LPCWSTR instanceId,
             lstrcpyW(ret + printed + 1, ReferenceString);
         }
     }
+
+    CharLowerW(ret);
+
     return ret;
 }
 
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index 6f02acb9589..35823788605 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -1025,6 +1025,18 @@ static void test_register_device_info(void)
     SetupDiDestroyDeviceInfoList(set);
 }
 
+static void check_all_lower_case(int line, const char* str)
+{
+    const char *cur;
+
+    for (cur = str; *cur; cur++)
+    {
+        BOOL is_lower = (tolower(*cur) == *cur);
+        ok_(__FILE__, line)(is_lower, "Expected device path to be all lowercase but got %s.\n", str);
+        if (!is_lower) break;
+    }
+}
+
 static void check_device_iface_(int line, HDEVINFO set, SP_DEVINFO_DATA *device,
         const GUID *class, int index, DWORD flags, const char *path)
 {
@@ -1046,6 +1058,7 @@ static void check_device_iface_(int line, HDEVINFO set, SP_DEVINFO_DATA *device,
         ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, sizeof(buffer), NULL, NULL);
         ok_(__FILE__, line)(ret, "Failed to get interface detail, error %#x.\n", GetLastError());
         ok_(__FILE__, line)(!strcasecmp(detail->DevicePath, path), "Got unexpected path %s.\n", detail->DevicePath);
+        check_all_lower_case(line, detail->DevicePath);
     }
     else
     {
-- 
2.34.1




More information about the wine-devel mailing list