From: Arkadiusz Hiler Subject: [PATCH v2 1/3] user32: Uppercase RawInput device names. Message-Id: <20210225174004.354355-1-ahiler@codeweavers.com> Date: Thu, 25 Feb 2021 19:40:02 +0200 This is a preparation for a patch that changes setupapi to return lowercased device paths, which is the source of RawInput device names. On Windows RawInput returns mostly uppercase names. This patch tries to keep Wine's old behavior in this regards as SDL 2.0.14+ looks for uppercase IG_ to match xinput devices to their RawInput counterparts. Signed-off-by: Arkadiusz Hiler --- dlls/user32/rawinput.c | 2 ++ dlls/user32/tests/input.c | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index ba11a121bc5..823ddf6f61d 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -121,6 +121,8 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) } heap_free(detail); + wcsupr(path); /* SDL does case-sensitive search for IG_ */ + file = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); if (file == INVALID_HANDLE_VALUE) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 9d75daa0bd5..63ea80a4625 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1802,7 +1802,7 @@ static void test_GetRawInputDeviceList(void) RAWINPUTDEVICELIST devices[32]; UINT ret, oret, devcount, odevcount, i; DWORD err; - BOOLEAN br; + BOOLEAN br, xinput_tested = FALSE; SetLastError(0xdeadbeef); ret = pGetRawInputDeviceList(NULL, NULL, 0); @@ -1835,7 +1835,7 @@ static void test_GetRawInputDeviceList(void) for(i = 0; i < devcount; ++i) { - WCHAR name[128]; + WCHAR name[128], name_cpy[128]; char nameA[128]; UINT sz, len; RID_DEVICE_INFO info; @@ -1855,6 +1855,15 @@ static void test_GetRawInputDeviceList(void) len = lstrlenW(name); ok(len + 1 == ret, "GetRawInputDeviceInfo returned wrong length (name: %u, ret: %u)\n", len + 1, ret); + /* requires xinput device to be connected, SDL 2.0.14+ looks for uppercase IG_ */ + lstrcpyW(name_cpy, name); + wcsupr(name_cpy); + if (wcsstr(name_cpy, L"IG_")) + { + xinput_tested = TRUE; + ok(wcsstr(name, L"IG_") != NULL, "Expected xinput device path to contain uppercase &IG_.\n", debugstr_w(name)); + } + /* test A variant with same size */ ret = pGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICENAME, nameA, &sz); ok(ret == sz, "GetRawInputDeviceInfoA gave wrong return: %d\n", err); @@ -1927,6 +1936,10 @@ static void test_GetRawInputDeviceList(void) CloseHandle(file); } + if (!xinput_tested) + skip("No xinput device. Ignoring xinput / RawInput device path tests.\n"); + + /* check if variable changes from larger to smaller value */ devcount = odevcount = ARRAY_SIZE(devices); oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0])); -- 2.30.1