Commit 4ae893e2 authored by Evan Tang's avatar Evan Tang Committed by Alexandre Julliard

win32u: Post device arrival messages in NtUserRegisterRawInputDevices.

parent a3134963
......@@ -1880,7 +1880,7 @@ static void test_RegisterRawInputDevices(void)
TranslateMessage( &msg );
DispatchMessageW( &msg );
}
todo_wine ok( count >= 2, "got %u messages\n", count );
ok( count >= 2, "got %u messages\n", count );
count = 0;
ok_ret( 1, RegisterRawInputDevices( raw_devices, ARRAY_SIZE( raw_devices ), sizeof(RAWINPUTDEVICE) ) );
......@@ -1890,7 +1890,7 @@ static void test_RegisterRawInputDevices(void)
TranslateMessage( &msg );
DispatchMessageW( &msg );
}
todo_wine ok( count >= 2, "got %u messages\n", count );
ok( count >= 2, "got %u messages\n", count );
/* RIDEV_REMOVE requires hwndTarget == NULL */
raw_devices[0].dwFlags = RIDEV_REMOVE;
......
......@@ -598,6 +598,30 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d
return TRUE;
}
static void post_device_notifications( const RAWINPUTDEVICE *filter )
{
ULONG usages = MAKELONG( filter->usUsagePage, filter->usUsage );
struct device *device;
LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry )
{
switch (device->info.dwType)
{
case RIM_TYPEMOUSE:
if (usages != MAKELONG( HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_MOUSE )) continue;
break;
case RIM_TYPEKEYBOARD:
if (usages != MAKELONG( HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_KEYBOARD )) continue;
break;
case RIM_TYPEHID:
if (usages != MAKELONG( device->info.hid.usUsagePage, device->info.hid.usUsage )) continue;
break;
}
NtUserPostMessage( filter->hwndTarget, WM_INPUT_DEVICE_CHANGE, GIDC_ARRIVAL, (LPARAM)device->handle );
}
}
static void register_rawinput_device( const RAWINPUTDEVICE *device )
{
RAWINPUTDEVICE *pos, *end;
......@@ -619,6 +643,7 @@ static void register_rawinput_device( const RAWINPUTDEVICE *device )
}
else
{
if ((device->dwFlags & RIDEV_DEVNOTIFY) && device->hwndTarget) post_device_notifications( device );
if (pos == end || pos->usUsagePage != device->usUsagePage || pos->usUsage != device->usUsage)
{
memmove( pos + 1, pos, (char *)end - (char *)pos );
......@@ -684,6 +709,8 @@ BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT d
return FALSE;
}
rawinput_update_device_list( TRUE );
registered_devices = new_registered_devices;
for (i = 0; i < device_count; ++i) register_rawinput_device( devices + i );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment