Rémi Bernon (@rbernon) commented about dlls/win32u/rawinput.c:
rawinput_update_device_list();
LIST_FOR_EACH_ENTRY(device, &devices, struct device, entry)
{
BOOL matches = FALSE;
if (device->info.dwType == RIM_TYPEMOUSE)
matches = page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_MOUSE;
else if (device->info.dwType == RIM_TYPEKEYBOARD)
matches = page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_KEYBOARD;
else if (device->info.dwType == RIM_TYPEHID)
matches = page == device->info.hid.usUsagePage && usage == device->info.hid.usUsage;
if (matches)
NtUserPostMessage(hwnd, WM_INPUT_DEVICE_CHANGE, GIDC_ARRIVAL, (LPARAM)device->handle);
}
}
I'm not completely sure we should do this here, but at the same time I don't think we can do it on the server side right now as it doesn't keep a list of devices.
In any case you should invert the loops, refreshing the device list once, and looking up the client device array for each of the device list iteration: looking up the array is fast as it's sequential (and probably small), whereas iterating the list is slow.
I think you could use `MAKELONG` to combine usage and usage page together and make the comparison easier.
Regarding the device types I don't think there's anything more to do, we don't really support mouse-like or keyboard-like HID devices at the moment.