From: Evan Tang etang@codeweavers.com
When registering for WM_INPUT_DEVICE_CHANGE messages, one should be sent for every existing matching device. --- dlls/user32/tests/input.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index f8b40099091..b0c4b699141 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -2108,7 +2108,9 @@ static void test_RegisterRawInputDevices(void) DestroyWindow(hwnd); }
-static int rawinputbuffer_wndproc_count; +static int rawinputbuffer_wndproc_wm_input_count; +static int rawinputbuffer_wndproc_wm_input_device_change_count; +static int rawinputbuffer_wndproc_other_msg_count;
typedef struct { @@ -2149,7 +2151,7 @@ static int rawinput_buffer_mouse_x(void *buffer, size_t index)
static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - UINT i, size, count, rawinput_size, iteration = rawinputbuffer_wndproc_count++; + UINT i, size, count, rawinput_size; RAWINPUT ri; char buffer[16 * sizeof(RAWINPUT64)]; MSG message; @@ -2159,6 +2161,8 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara
if (msg == WM_INPUT) { + UINT iteration = rawinputbuffer_wndproc_wm_input_count++; + SetLastError(0xdeadbeef); count = GetRawInputBuffer(NULL, NULL, sizeof(RAWINPUTHEADER)); ok(count == ~0U, "GetRawInputBuffer succeeded\n"); @@ -2290,19 +2294,39 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara
return 0; } + else if (msg == WM_INPUT_DEVICE_CHANGE) + { + ok(rawinputbuffer_wndproc_wm_input_count == 0, "device change event came after input event\n"); + rawinputbuffer_wndproc_wm_input_device_change_count++; + } + else + { + rawinputbuffer_wndproc_other_msg_count++; + }
return DefWindowProcA(hwnd, msg, wparam, lparam); }
static void test_GetRawInputBuffer(void) { - unsigned int size, count, rawinput_size, header_size, scan_code; + unsigned int i, size, count, rawinput_size, header_size, scan_code, num_mice = 0; RAWINPUTDEVICE raw_devices[1]; + RAWINPUTDEVICELIST *raw_device_list; char buffer[16 * sizeof(RAWINPUT64)]; HWND hwnd; BOOL ret; POINT pt;
+ GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)); + raw_device_list = malloc(sizeof(RAWINPUTDEVICELIST) * count); + GetRawInputDeviceList(raw_device_list, &count, sizeof(RAWINPUTDEVICELIST)); + for (i = 0; i < count; i++) + { + if (raw_device_list[i].dwType == RIM_TYPEMOUSE) + num_mice++; + } + free(raw_device_list); + #define HEADER_FIELD(field) (is_wow64 ? ((RAWINPUT64 *)buffer)->header.field : ((RAWINPUT *)buffer)->header.field)
if (is_wow64) rawinput_size = sizeof(RAWINPUT64); @@ -2320,7 +2344,7 @@ static void test_GetRawInputBuffer(void)
raw_devices[0].usUsagePage = 0x01; raw_devices[0].usUsage = 0x02; - raw_devices[0].dwFlags = RIDEV_INPUTSINK; + raw_devices[0].dwFlags = RIDEV_INPUTSINK | RIDEV_DEVNOTIFY; raw_devices[0].hwndTarget = hwnd;
SetLastError(0xdeadbeef); @@ -2416,13 +2440,15 @@ static void test_GetRawInputBuffer(void) ok(count == 0U, "GetRawInputBuffer returned %u\n", count);
- rawinputbuffer_wndproc_count = 0; + rawinputbuffer_wndproc_wm_input_count = 0; + rawinputbuffer_wndproc_wm_input_device_change_count = 0; mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0); mouse_event(MOUSEEVENTF_MOVE, 2, 0, 0, 0); mouse_event(MOUSEEVENTF_MOVE, 3, 0, 0, 0); mouse_event(MOUSEEVENTF_MOVE, 4, 0, 0, 0); empty_message_queue(); - ok(rawinputbuffer_wndproc_count == 2, "Spurious WM_INPUT messages\n"); + ok(rawinputbuffer_wndproc_wm_input_count == 2, "Spurious WM_INPUT messages\n"); + todo_wine ok(rawinputbuffer_wndproc_wm_input_device_change_count == num_mice, "Got %d WM_INPUT_DEVICE_CHANGE messages (expected %d)\n", rawinputbuffer_wndproc_wm_input_device_change_count, num_mice);
raw_devices[0].dwFlags = RIDEV_REMOVE; raw_devices[0].hwndTarget = 0;