In case of error mbstowcs() returns (size_t) -1
It is not a negative value since mbstowcs() returns a size_t (unsigned)
Fix compiler warning:
hid.c: In function 'utf8_to_wchar_t':
hid.c:105:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
This adds the familiar autotools build system and associated documentation
for Linux, FreeBSD, Mac, MinGW, and Cygwin. The old Makefiles have been
kept, and where appropriate have been renamed Makefile-manual.
Thanks to Peter Stuge, Ludovic Rousseau, Xiaofan Chen, Alex Dupre, and
Segher Boessenkool for providing testing, review, and suggestions, and to
Ludovic Rousseau for providing patches which contributed to this commit.
This adds a FreeBSD implementation to HIDAPI using the libusb back-end. The
libusb/ folder now contains the libusb implementation and associated
Makefiles for Linux and FreeBSD. All libusb code has been removed from the
linux/ folder, so that the code in libusb/ can be shared by both (and
future) platforms.
This commit renames linux/hid-libusb.c to libusb/hid.c. Make sure to
use git log --follow to see full history of that file.
This code was written by:
Alex Dupre <ale@FreeBSD.org>
Alan Ott <alan@signal11.us>
This happens if a device gets opened a second time. The call to
libusb_submit_transfer() will fail, indicating that the read thread should
be shut down.
get_serial_number()
get_manufacturer_string()
get_product_string()
This matches the documentation in header file to return 0 on success and -1
on error.
Use a private libusb_context to avoid conflicts between
multiple libusb instances inside a single application
process. Many 3rd party libraries use libusb as backend,
so there is a good chance of collisions if the default NULL
context is used.
Modified by Alan Ott to also remove the initialized
variable since it's no longer needed (since we can use
the context instead), to make the style consistent, and
to remove unnecessary checks for initialized before calling
hid_init().
Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: Alan Ott <alan@signal11.us>
Changed to use libusb_handle_events() instead of
libusb_handle_events_timeout() on the read thread. This increases
performance because the read thread now doesn't get woken up for no
reason.
Also, when the read thread exits, signal any waiting threads (which are
waiting in hid_read_timeout() so that they don't block forever if another
thread calls hid_close() or if the device becomes disconnected.
This was all kicked off by some suggestions by Hans Hübner
<hans.huebner@gmail.com>
0. VDR`s `Makefile` was taken as a template [1].
1. Separate variables for flags for `CC` and `CXX` were introduced. `-c` is now passed explicitly. Further flags for `CXX` could be added like in VDR’s `Makefile`.
2. Separate variable `INCLUDES` defined which is only used for the libraries(?).
[1] http://git.gekrumbel.de/vdr.git?p=vdr.git;a=blob;f=Makefile;hb=bd61fee1e9328aec470c319494cccb90e53302c2
--
Please note that this is not build tested.
Added the HIDIOCSFEATURE and HIDIOCGFEATURE ioctl macros to hid.c so that it
will compile with older kernel headers. This of course doesn't make it _run_
with older kernels. Some distros ship older kernel headers than the running
kernel.
hid_read_timeout() will execute a blocking read up until a timeout has been
reached or data has been received.
This patch implements it on all platforms and comes from Urs Fleisch.
Commit log message by Alan Ott.
Signed-off-by: Urs Fleisch <urs.fleisch@gmail.com>
Tested-by: Alan Ott <alan@signal11.us>
We first check that the HID device is managed by the kernel before
calling libusb_detach_kernel_driver(). This will avoid side effects of
libusb_detach_kernel_driver() like also doing a
libusb_release_interface()
Ludovic's original patch modified by Alan Ott <alan@signal11.us>
The interface number is added to the hid_device_info struct. Since the
Linux/libusb implementation can't put the Usage and Usage Page in the
hid_device_info struct because it requires detaching the kernel driver, the
interface number is added instead so that users with composite HID devices
can differentiate between the interfaces on the device.
had to happen:
1. Create a hid_device_info struct for each interface which
reports to be HID, rather than one for each device.
2. Parse and report the Usage Page and Usage for each.