rawinput-sharp icon indicating copy to clipboard operation
rawinput-sharp copied to clipboard

Register Only Specific Devices

Open uvotguy opened this issue 2 years ago • 1 comments

I have a WPF application that has one or more HID keyboard devices connected. Is there a way to register ONLY these devices (and not the regular keyboard) with RawInput? I see there is an UnregisterDevice method, but it only works for specific "types" of device; for example, I could call it like this:

RawInputDevice.UnregisterDevice(HidUsageAndPage.Keyboard);

Unfortunately, this unregisters ALL keyboard devices.

What I would like to do is loop through registered devices and Unregister those which are NOT of a specific (VendorId, ProductId). Better yet, I would like to get a list of HID devices and register ONLY devices with a specific (VendorId, ProductId).

Any ideas how I can accomplish this?

UvotGuy

uvotguy avatar Jul 12 '23 23:07 uvotguy

RegisterDevice and UnregisterDevice are wrapper for the native RegisterRawInputDevices. This function only allows specifing device "types" by Usage and Page. Instead, you need to check the RawInputDevice.VendorId / RawInputDevice.ProductId, which can be acquired by RawInputData.Device property.

mfakane avatar Jul 26 '23 04:07 mfakane