[libhid-discuss] cross-platform capabilities?

Xiaofan Chen xiaofanc at gmail.com
Thu Apr 5 14:24:05 UTC 2007


On 4/5/07, Charles Lepple <clepple at ghz.cc> wrote:

> Short answer: if libusb can access the device without interference from
> any kernel HID drivers (e.g. FreeBSD after unloading or de-configuring
> uhid; Linux after detaching the kernel usbhid driver, or OS X if nothing
> else is using the native HID API), then libhid should be able to access
> the device.
>
> Specifically, in OS X, there is no way to claim exclusive control over the
> device if the kernel HID module has already claimed it. (You can write a
> custom stub driver with higher precedence than the kernel driver.)

Why not use the native Mac OS X HID and use it as backend for
libhid and get rid of the libusb dependency.

Eg: pk2 (http://home.pacbell.net/theposts/picmicro/) is using libusb
to support PICkit 2. Later people have replaced the libusb based
USB code with native HID API and it is much usable now.

> FreeBSD 6.2 seems to have the ugen driver compiled into the kernel, so you
> need to remove that from GENERIC and rebuild.

I think you mean "uhid" and not or "ugen"? To me it is still not convenient.
By the way, libusb under FreeBSD (as well as the USB stack)
is not as mature as under Linux. Maybe it is better to use the native
uhid or ugen API.

Recently I spent quite some time to get pk2 to work under FreeBSD.
http://lists.freebsd.org/pipermail/freebsd-usb/2007-April/003177.html

Even though I finally get pk2 to work with libusb/FreeBSD but I think
it is very troublesome for average users.

> At the moment, there is no Win32 backend, but you might have some luck
> with libusb-win32 and libhid.

That will be a problem. By default Windows will claim the HID device.
It is possible to unbind the hid driver and use libusb-win32 device
driver instead but this is not so convenient. If we use the libusb-win32
filter driver, the system will hang since the HID driver is not detached.

It seems to me the best is to use the native Windows HID API.
Eg: http://www.obdev.at/products/avrusb/index.html

> As far as sending data, libhid originally had some code to send data on
> the control endpoint, but I think that is currently broken. Shouldn't be
> too hard to add back in, though -- that functionality is in an early
> version of libhid in Network UPS Tools -
> http://www.networkupstools.org/source.html
>
> libhid also includes a function to send data over an interrupt endpoint.
>

I understand that if we use the native HID API under each OS, it
will be quite some work for libhid. But it seems to me libhid will be
much more useful if it is using the native OS HID API as the back
end and not libusb.

Regards,
Xiaofan
http://groups.google.com/group/pickit-deve



More information about the libhid-discuss mailing list