[Libusbx-devel] Linux patches for 1.0.9 release
Xiaofan Chen
xiaofanc at gmail.com
Thu Mar 29 19:36:49 EDT 2012
On Thu, Mar 29, 2012 at 10:09 PM, Ludovic Rousseau
<ludovic.rousseau at gmail.com> wrote:
> I use a HID device under OS X using HIDAPI.
> HIDAPI uses the native OS X HID API. No need to use a kernel extension
> or ask a driver to release my device.
>
> I do not need libusb to use a HID device on OS X.
> The same is/will be true on Linux using hidraw (instead of libusb) in
> HIDAPI.
hidraw backend for HIDAPI only works with quite new Linux
kernel versions.
+++++++
https://github.com/signal11/hidapi
Linux/hidraw (linux/hid.c):
This back-end uses the hidraw interface in the Linux kernel. While this
back-end will support both USB and Bluetooth, it has some limitations on
kernels prior to 2.6.39, including the inability to send or receive feature
reports.
+++++++
>
> I understand a multi OS HID API is needed. I don't see why it should
> be _IN_ libusb.
> Isn't it possible to provide the HID API _above_ libusb?
That is what HIDAPI does with Linux -- the libusb-1.0 backend
is the default for HIDAPI under Linux. With libusb's current HID
limitation under other OS (Windows, Mac OS X and OpenBSD),
providing a cross-platform HID API above libusb is not feasible.
That is why the author of HIDAPI choose to base the Windows
and Mac OS X native API as the base.
libhid basically died is the one trying to provide the cross-platform
API for USB HID device, based on libusb-0.1.
http://libhid.alioth.debian.org/
> Can't HIDAPI be the multi OS HID API?
Yes HIDAPI is the preferred multi-OS API for HID device
(USB and Bluetooth -- to support Bluetooth, hidraw backend
is needed for Linux), for new project anyway.
However, there are already many existing codes using
libusb to talk to USB HID device under Linux, it is good
to let them port the codes to other OS (say Mac OS X
and Windows) without changing the USB Codes.
On the other hand, even if HIDAPI is the preferred cross-platform
API for HID device now, it may not be able to have all
the future features like hot-plug.
> Note that I have no idea of the Windows situation regarding
> HID and libusb.
Other than what Pete's answer, if libusb0.sys is integrated,
USB HID device (including mouse/keryboard which will not
work with the Windows HID backend) can be made to work
with libusb using the filter driver.
That is the current approach we use in the libusb-win32
and libusbK project, no HID backend is planned for
libusb-win32 and libusbK now.
So in a way, native HID backend for Mac OS X and
Windows are quite desirable from my point of view,
but there are workaround if they are not integrated.
For Mac OS X, the users will have to use the code-less
kernel extension (kext). For Windows, libusb0.sys
device filter can be used.
For FreeBSD/OpenBSD, I do not know HIDAPI
will support them any time soon.
Technically FreeBSD can be supported by HIDAPI with
similar codes to the Linux libusb-1.0 backend
since generic USB HID device have both
ugen and uhid attached to them. Anyway, FreeBSD
is out of our consideration since they have their
own libusb-1.0 implementation under BSD license.
They even have user-land Mouse/Keyboard driver
based on their own libusb20 library.
http://www.unix.com/man-page/FreeBSD/3/libusb/
http://www.unix.com/man-page/FreeBSD/3/libusb20/
http://www.unix.com/man-page/freebsd/4/uhid/
http://wiki.freebsd.org/uhidd
The libusb20 API is specific to FreeBSD but may
have something interesting to learn from.
BTW, similarly to libusbK API which is Windows
specific but may have something to learn from
as well.
Eg: streaming API
http://libusbk.sourceforge.net/UsbK3/group__stmk.html
For OpenBSD, I think we just leave it alone
for USB HID device even though it may be possible
to use uhid.
http://www.openbsd.org/cgi-bin/man.cgi?query=uhid&sektion=4
--
Xiaofan
More information about the libusbx
mailing list