- uhid USB, Bluetooth (standard) and I2C now enumerating
* USB uhid support was added by removing the udev USB endpoint check;
- HID over I2C was excluded before (likely because it didn't exist when
hidraw was developed);
NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly.
The implementation idea is similar, as in #125 for macOS.
The open systcall is allowed to return 0 as a valid file descriptor,
and considering it an error breaks environments where unnecessary
fds are closed before executing untrusted processes.
Fixes: #199
Signed-off-by: Marc Zyngier <maz@kernel.org>
Problem reported by the Coverity tool
CID 1042532 (#1 of 1): Unchecked return value from library
(CHECKED_RETURN)2. check_return: Calling function
"fstat(dev->device_handle, &s)" without checking return value. This
library function may fail and return an error code.
Refactor version detection into a function.
Handle versions of form X.Y.Z as well as X.Y.
Don't do workarounds for old kernels if version cannot be detected.
It appears that calls to read() when in non-blocking mode will not set errno
to other than EAGAIN when the a device has been disconnected. Note that
this is the same errno code set when there is simply no data to return.
Make it so that poll() is used, in non-blocking mode, to check the
status of the device. In blocking mode though, poll() is not needed.
Passing product_id=0 will match any product of a given vendor. This patch
makes it also possible to use vendor_id=0 to match any vendor for a given
product id.
Windows code added to Ludovic's patch by Alan Ott.
hid.c: In function 'uses_numbered_reports':
hid.c:126:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
hid.c:143:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
linux/hid.c:83:13: warning: function declaration isn't a prototype [-Wstrict-prototypes]
linux/hid.c: In function 'new_hid_device':
linux/hid.c:83:13: warning: old-style function definition [-Wold-style-definition]
mbstowcs() returns a size_t not an int.
hid.c: In function 'get_device_string':
hid.c:285:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
hid.c:289:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
hid.c:318:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
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.