[libhid-discuss] HID vs. vendor specific class

Xiaofan Chen xiaofanc at gmail.com
Thu Jul 22 05:32:08 UTC 2010


On Thu, Jul 22, 2010 at 10:51 AM, John Parsons <jfparsons at fastmail.fm> wrote:

> The product is a proximity sensor, and is built around a Microchip
> PIC18F14K50, their low cost 20-pin device with USB connection.  Though
> this device is not exactly human interactive, I initially planned to
> release this as a HID because it only transfers a few bytes of data, HID
> routines are included in Microchip's example code libraries, all OS's
> come with HID drivers, and it seems very simple to implement, at least
> on Windows.

I have mixed feeling with HID, I like HID. But I also agree with Peter
Stuge that at current situation, generic HID may not be a very good
solution for cross-platform application.

With libusb-1.0 Windows backend, HID device can be used with
libusb-1.0 API. Linux is also okay since you have the capability to
detach the kernel driver. The only main issue is with Mac OS X.
You need to write a codeless kext to prevent the kernel from
claim the HID device.

So I have created an feature request for libusb-1.0 Mac OS X HID backend.
http://www.libusb.org/ticket/33

If that is done, I think generic HID device will be good for most
applications require cross-OS support. Okay, here I only mention
the three major OS in the market. But FreeBSD 8.0+ will also be
good since they have libusb-1.0 compatible API which seems to
work for generic HID device as well.

BTW, despite the name libhid, I think libhid is not really meant
for generic HID device. Its strong point is the HID report parser.
For generic HID device, you do not really need libhid, rather generic
libusb-1.0 will be easier.

> But I want Mac and Linux app writers to be able to use this product with
> the same ease as Windows app writers.  Peter Stuge makes a strong case
> for vendor-specific class devices.  I am willing to go that route, but
> could use some help getting started.  Pointers to resources would be
> appreciated... something like "USB vendor specific classes for dummies!"

It is very easy to convert an HID based generic device to a vendor specific
device on the firmware side. Basically you just need to modify the descriptor to
remove the HID class specific descriptor, and you have a vendor specific device.

On the host side, the HID IN/OUT report can normally be converted to
interrupt in/out transfer. The HID feature report can easily be converted
to generic control transfer. If you use libusb, it is not that difficult.


-- 
Xiaofan http://sourceforge.net/projects/libusb-win32/



More information about the libhid-discuss mailing list