Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- v4: Attempt to split up the patch somewhat.
dlls/user32/rawinput.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 85ff0c5e809..54d836b22b2 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -39,7 +39,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(rawinput);
-struct hid_device +struct device { WCHAR *path; HANDLE file; @@ -47,7 +47,7 @@ struct hid_device PHIDP_PREPARSED_DATA data; };
-static struct hid_device *hid_devices; +static struct device *hid_devices; static unsigned int hid_devices_count, hid_devices_max;
static CRITICAL_SECTION hid_devices_cs; @@ -86,10 +86,10 @@ static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int return TRUE; }
-static struct hid_device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) +static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) { SP_DEVICE_INTERFACE_DETAIL_DATA_W *detail; - struct hid_device *device; + struct device *device; HANDLE file; WCHAR *path; DWORD size; @@ -147,7 +147,7 @@ static void find_hid_devices(void) static ULONGLONG last_check;
SP_DEVICE_INTERFACE_DATA iface = { sizeof(iface) }; - struct hid_device *device; + struct device *device; HIDD_ATTRIBUTES attr; HIDP_CAPS caps; GUID hid_guid; @@ -398,7 +398,7 @@ UINT WINAPI GetRawInputDeviceInfoA(HANDLE device, UINT command, void *data, UINT /*********************************************************************** * GetRawInputDeviceInfoW (USER32.@) */ -UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT *data_size) +UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT *data_size) { /* FIXME: Most of this is made up. */ static const WCHAR keyboard_name[] = {'\','\','?','\','W','I','N','E','_','K','E','Y','B','O','A','R','D',0}; @@ -407,12 +407,12 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT static const RID_DEVICE_INFO_MOUSE mouse_info = {1, 5, 0, FALSE};
RID_DEVICE_INFO info; - struct hid_device *hid_device = device; + struct device *device = handle; const void *to_copy; UINT to_copy_bytes, avail_bytes;
- TRACE("device %p, command %#x, data %p, data_size %p.\n", - device, command, data, data_size); + TRACE("handle %p, command %#x, data %p, data_size %p.\n", + handle, command, data, data_size);
if (!data_size) return ~0U;
@@ -427,20 +427,20 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT case RIDI_DEVICENAME: /* for RIDI_DEVICENAME, data_size is in characters, not bytes */ avail_bytes = *data_size * sizeof(WCHAR); - if (device == WINE_MOUSE_HANDLE) + if (handle == WINE_MOUSE_HANDLE) { *data_size = ARRAY_SIZE(mouse_name); to_copy = mouse_name; } - else if (device == WINE_KEYBOARD_HANDLE) + else if (handle == WINE_KEYBOARD_HANDLE) { *data_size = ARRAY_SIZE(keyboard_name); to_copy = keyboard_name; } else { - *data_size = strlenW(hid_device->path) + 1; - to_copy = hid_device->path; + *data_size = strlenW(device->path) + 1; + to_copy = device->path; } to_copy_bytes = *data_size * sizeof(WCHAR); break; @@ -448,12 +448,12 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT case RIDI_DEVICEINFO: avail_bytes = *data_size; info.cbSize = sizeof(info); - if (device == WINE_MOUSE_HANDLE) + if (handle == WINE_MOUSE_HANDLE) { info.dwType = RIM_TYPEMOUSE; info.u.mouse = mouse_info; } - else if (device == WINE_KEYBOARD_HANDLE) + else if (handle == WINE_KEYBOARD_HANDLE) { info.dwType = RIM_TYPEKEYBOARD; info.u.keyboard = keyboard_info; @@ -461,7 +461,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT else { info.dwType = RIM_TYPEHID; - info.u.hid = hid_device->info; + info.u.hid = device->info; } to_copy_bytes = sizeof(info); *data_size = to_copy_bytes; @@ -470,8 +470,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT
case RIDI_PREPARSEDDATA: avail_bytes = *data_size; - if (device == WINE_MOUSE_HANDLE || - device == WINE_KEYBOARD_HANDLE) + if (handle == WINE_MOUSE_HANDLE || handle == WINE_KEYBOARD_HANDLE) { to_copy_bytes = 0; *data_size = 0; @@ -479,9 +478,9 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE device, UINT command, void *data, UINT } else { - to_copy_bytes = ((WINE_HIDP_PREPARSED_DATA*)hid_device->data)->dwSize; + to_copy_bytes = ((WINE_HIDP_PREPARSED_DATA*)device->data)->dwSize; *data_size = to_copy_bytes; - to_copy = hid_device->data; + to_copy = device->data; } break;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/user32/rawinput.c | 49 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 54d836b22b2..e89bb027f39 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -47,17 +47,17 @@ struct device PHIDP_PREPARSED_DATA data; };
-static struct device *hid_devices; -static unsigned int hid_devices_count, hid_devices_max; +static struct device *rawinput_devices; +static unsigned int rawinput_devices_count, rawinput_devices_max;
-static CRITICAL_SECTION hid_devices_cs; -static CRITICAL_SECTION_DEBUG hid_devices_cs_debug = +static CRITICAL_SECTION rawinput_devices_cs; +static CRITICAL_SECTION_DEBUG rawinput_devices_cs_debug = { - 0, 0, &hid_devices_cs, - { &hid_devices_cs_debug.ProcessLocksList, &hid_devices_cs_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": hid_devices_cs") } + 0, 0, &rawinput_devices_cs, + { &rawinput_devices_cs_debug.ProcessLocksList, &rawinput_devices_cs_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": rawinput_devices_cs") } }; -static CRITICAL_SECTION hid_devices_cs = { &hid_devices_cs_debug, -1, 0, 0, 0, 0 }; +static CRITICAL_SECTION rawinput_devices_cs = { &rawinput_devices_cs_debug, -1, 0, 0, 0, 0 };
static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size) { @@ -127,7 +127,8 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) return NULL; }
- if (!array_reserve((void **)&hid_devices, &hid_devices_max, hid_devices_count + 1, sizeof(*hid_devices))) + if (!array_reserve((void **)&rawinput_devices, &rawinput_devices_max, + rawinput_devices_count + 1, sizeof(*rawinput_devices))) { ERR("Failed to allocate memory.\n"); CloseHandle(file); @@ -135,14 +136,14 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) return NULL; }
- device = &hid_devices[hid_devices_count++]; + device = &rawinput_devices[rawinput_devices_count++]; device->path = path; device->file = file;
return device; }
-static void find_hid_devices(void) +static void find_devices(void) { static ULONGLONG last_check;
@@ -162,16 +163,16 @@ static void find_hid_devices(void)
set = SetupDiGetClassDevsW(&hid_guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
- EnterCriticalSection(&hid_devices_cs); + EnterCriticalSection(&rawinput_devices_cs);
/* destroy previous list */ - for (idx = 0; idx < hid_devices_count; ++idx) + for (idx = 0; idx < rawinput_devices_count; ++idx) { - CloseHandle(hid_devices[idx].file); - heap_free(hid_devices[idx].path); + CloseHandle(rawinput_devices[idx].file); + heap_free(rawinput_devices[idx].path); }
- hid_devices_count = 0; + rawinput_devices_count = 0; for (idx = 0; SetupDiEnumDeviceInterfaces(set, NULL, &hid_guid, idx, &iface); ++idx) { if (!(device = add_device(set, &iface))) @@ -194,7 +195,7 @@ static void find_hid_devices(void) device->info.usUsage = caps.Usage; }
- LeaveCriticalSection(&hid_devices_cs); + LeaveCriticalSection(&rawinput_devices_cs); SetupDiDestroyDeviceInfoList(set); }
@@ -219,18 +220,18 @@ UINT WINAPI GetRawInputDeviceList(RAWINPUTDEVICELIST *devices, UINT *device_coun return ~0U; }
- find_hid_devices(); + find_devices();
if (!devices) { - *device_count = 2 + hid_devices_count; + *device_count = 2 + rawinput_devices_count; return 0; }
- if (*device_count < 2 + hid_devices_count) + if (*device_count < 2 + rawinput_devices_count) { SetLastError(ERROR_INSUFFICIENT_BUFFER); - *device_count = 2 + hid_devices_count; + *device_count = 2 + rawinput_devices_count; return ~0U; }
@@ -239,13 +240,13 @@ UINT WINAPI GetRawInputDeviceList(RAWINPUTDEVICELIST *devices, UINT *device_coun devices[1].hDevice = WINE_KEYBOARD_HANDLE; devices[1].dwType = RIM_TYPEKEYBOARD;
- for (i = 0; i < hid_devices_count; ++i) + for (i = 0; i < rawinput_devices_count; ++i) { - devices[2 + i].hDevice = &hid_devices[i]; + devices[2 + i].hDevice = &rawinput_devices[i]; devices[2 + i].dwType = RIM_TYPEHID; }
- return 2 + hid_devices_count; + return 2 + rawinput_devices_count; }
/***********************************************************************
Halo: Spartan Strike attempts to discover input devices using rawinput. It expects to be able to open at least one device file with a zero access mask. It does not perform any other operations on the file.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/user32/rawinput.c | 47 ++++++++++++++++++++++++++++----------- dlls/user32/tests/input.c | 5 ++--- 2 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index e89bb027f39..2465262f74e 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -37,13 +37,16 @@
#include "user_private.h"
+#include "initguid.h" +#include "ntddmou.h" + WINE_DEFAULT_DEBUG_CHANNEL(rawinput);
struct device { WCHAR *path; HANDLE file; - RID_DEVICE_INFO_HID info; + RID_DEVICE_INFO info; PHIDP_PREPARSED_DATA data; };
@@ -139,6 +142,7 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) device = &rawinput_devices[rawinput_devices_count++]; device->path = path; device->file = file; + device->info.cbSize = sizeof(RID_DEVICE_INFO);
return device; } @@ -161,8 +165,6 @@ static void find_devices(void)
HidD_GetHidGuid(&hid_guid);
- set = SetupDiGetClassDevsW(&hid_guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); - EnterCriticalSection(&rawinput_devices_cs);
/* destroy previous list */ @@ -171,8 +173,10 @@ static void find_devices(void) CloseHandle(rawinput_devices[idx].file); heap_free(rawinput_devices[idx].path); } - rawinput_devices_count = 0; + + set = SetupDiGetClassDevsW(&hid_guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); + for (idx = 0; SetupDiEnumDeviceInterfaces(set, NULL, &hid_guid, idx, &iface); ++idx) { if (!(device = add_device(set, &iface))) @@ -181,9 +185,11 @@ static void find_devices(void) attr.Size = sizeof(HIDD_ATTRIBUTES); if (!HidD_GetAttributes(device->file, &attr)) WARN("Failed to get attributes.\n"); - device->info.dwVendorId = attr.VendorID; - device->info.dwProductId = attr.ProductID; - device->info.dwVersionNumber = attr.VersionNumber; + + device->info.dwType = RIM_TYPEHID; + device->info.u.hid.dwVendorId = attr.VendorID; + device->info.u.hid.dwProductId = attr.ProductID; + device->info.u.hid.dwVersionNumber = attr.VersionNumber;
if (!HidD_GetPreparsedData(device->file, &device->data)) WARN("Failed to get preparsed data.\n"); @@ -191,12 +197,28 @@ static void find_devices(void) if (!HidP_GetCaps(device->data, &caps)) WARN("Failed to get caps.\n");
- device->info.usUsagePage = caps.UsagePage; - device->info.usUsage = caps.Usage; + device->info.u.hid.usUsagePage = caps.UsagePage; + device->info.u.hid.usUsage = caps.Usage; + } + + SetupDiDestroyDeviceInfoList(set); + + set = SetupDiGetClassDevsW(&GUID_DEVINTERFACE_MOUSE, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); + + for (idx = 0; SetupDiEnumDeviceInterfaces(set, NULL, &GUID_DEVINTERFACE_MOUSE, idx, &iface); ++idx) + { + static const RID_DEVICE_INFO_MOUSE mouse_info = {1, 5, 0, FALSE}; + + if (!(device = add_device(set, &iface))) + continue; + + device->info.dwType = RIM_TYPEMOUSE; + device->info.u.mouse = mouse_info; }
- LeaveCriticalSection(&rawinput_devices_cs); SetupDiDestroyDeviceInfoList(set); + + LeaveCriticalSection(&rawinput_devices_cs); }
/*********************************************************************** @@ -243,7 +265,7 @@ UINT WINAPI GetRawInputDeviceList(RAWINPUTDEVICELIST *devices, UINT *device_coun for (i = 0; i < rawinput_devices_count; ++i) { devices[2 + i].hDevice = &rawinput_devices[i]; - devices[2 + i].dwType = RIM_TYPEHID; + devices[2 + i].dwType = rawinput_devices[i].info.dwType; }
return 2 + rawinput_devices_count; @@ -461,8 +483,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT } else { - info.dwType = RIM_TYPEHID; - info.u.hid = device->info; + info = device->info; } to_copy_bytes = sizeof(info); *data_size = to_copy_bytes; diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 3fc84f61083..43fdd341912 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1686,7 +1686,7 @@ static void test_GetRawInputDeviceList(void) * understand that; so use the \?\ prefix instead */ name[1] = '\'; file = CreateFileW(name, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - todo_wine_if(info.dwType != RIM_TYPEHID) + todo_wine_if(i == 0 || i == 1) ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError());
sz = 0; @@ -1716,8 +1716,7 @@ static void test_GetRawInputDeviceList(void) { /* succeeds on hardware, fails in some VMs */ br = HidD_GetPreparsedData(file, &preparsed); - todo_wine - ok(br == TRUE || broken(br == FALSE), "HidD_GetPreparsedData failed\n"); + ok(br == TRUE || broken(br == FALSE), "HidD_GetPreparsedData failed\n"); }
if (br)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69270
Your paranoid android.
=== w1064v1809_ar (32 bit report) ===
user32: input.c:2271: Test failed: expected WM_LBUTTONDOWN message input.c:2272: Test failed: expected WM_LBUTTONUP message
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69267
Your paranoid android.
=== debiant (64 bit WoW report) ===
user32: win.c:10086: Test failed: GetForegroundWindow() = 000D0120