5

I've got some bar code scanner devices that can handle a variety of USB interfaces (COMM Emulation, HID Keyboard, HID POS, etc.) The problem is that, while I can tell if the device is in a HID mode, I need to be able to determine if it's HID Keyboard or HID POS.

Is there a way to determine this using Win32 C++, preferably with the built in windows HID library (hidsdi.h)?

Jonas
  • 121,568
  • 97
  • 310
  • 388
Adam Haile
  • 30,705
  • 58
  • 191
  • 286

3 Answers3

3

You can use HidD_GetHidGuid to get the unique GUID for the device. Device interface guids are defined by each device/application software vendor, Microsoft or third party as they see fit. In some cases the guids are published and public knowledge and are standard interfaces, in some cases they are not.

You can also use the USBView utility from Microsoft which will let you browse the USB tree or you can look in the registry and see if you can find the GUID for your device. You may still have to query your device to determine device type if the config data is not present or it does not reveal itself other than a generic device, if your device supports this.

There are two types of GUIDs: Device Class and Device Interface. A device can only be a part of one class. Unfortunately, the Device Class and Device Interface GUIDs are sometimes the same, thus confusing developers. In the WinXP DDK, standards were created to try and make the definition of GUIDs less confusing.

See also this previous SO question: Use RegisterDeviceNotification() for ALL USB devices.

Community
  • 1
  • 1
1

Here is a list of possible HID Guids: http://msdn.microsoft.com/en-us/library/ms791134.aspx and use HidD_GetHidGuid as Roboto suggested

Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103
  • Ok, closer now, but that list includes just one entry for HID, but I need HID POS vs HID Keyboard. POS is bi-directional and keyboard is unidirectional, so they are definitely different. Maybe this can't be determined with HidD_GetHidGuid ? – Adam Haile Jan 18 '10 at 14:40
  • What GUIDs do you get in POS mode and Keyboard mode? Is the same? – Victor Hurdugaci Jan 18 '10 at 14:43
  • Yes, it's the same, and the one listed here: http://msdn.microsoft.com/en-us/library/bb663084.aspx Which is just for HID in general – Adam Haile Jan 18 '10 at 14:49
  • Remember, you have device class GUID and device interface GUID. They are different –  Jan 18 '10 at 14:58
  • @Adam: Did you try the USBView utility in my answer? –  Jan 18 '10 at 16:08
  • If you search the registry under HKEY_LM\SYSTEM\ControlSet001\Control\Class you will find the GUID by searching for the VendorName/ProviderName (or look under CurrentControlSet) –  Jan 18 '10 at 17:10
1

You'll need to use the HidP_ functions to check the hid report capabilities. Find out what capabilities (usages) are presented by the HIDPOS device, and check if those usages are present using HidD_GetPreparsedData(), HidP_GetCaps() and then HidP_GetValueCaps(and/or ..ButtonCaps, etc). A good place to look for examples is Jan Axelson's page. If the usages are present, then you've got the POS device. If not, then it must be the keyboard (assuming you've confirmed the device is attached.)

Bob
  • 11
  • 1