hid_read_error is a separate error function, that returns error status of hid_read/hid_read_timeout.
hid_read/hid_read_timeout is no longer changes internal buffer used by hid_error and it makes it safe to use hid_read/hid_read_timeout from a separa thread, concurently with other device functions.
`hid_send_output_report` sends report over control pipe, unlike existing `hid_write` which would send the data on the first interrupt OUT endpoint, if one exists and only falls back to control pipe.
- updated the doxyfile using doxygen -u
- include hidtest/test.c as a doc'd example
- use a brief doxygen/main_page.md file as the generated site's main page
- strip absolute paths from doxygen output (which now displays as relative paths to repo root)
- add CI to build the docs and save as a CI artifact and rewrite the contents of the gh-pages branch for deployment (for master builds)
- add some missing docstrings and excluded undocumented "helper macros" to satisfy warnings output in doxygen's build log
This is efficient for Xbox Common Controller class (XUSB) devices like Xbox 360 or Xbox One controllers that are missing serial number via usual HID API.
On some compilers an empty definition (e.g. -DHID_API_EXPORT)
means the same as `=1` (i.e. -DHID_API_EXPORT=1), but the HID_API_EXPORT macro should be
empty in static library build case.
Having a separate compiler definition flag solves that issue.
- native implementations for hidraw/libusb/macOS;
- HID Report Descriptor reconstruction from HIDP_PREPARSED_DATA on Windows;
- unit-tests for some known devices for `hid_winapi_descriptor_reconstruct_pp_data`;
- support for ASAN builds (mainly to check the `hid_winapi_descriptor_reconstruct_pp_data`/its unit-tests;
Don't mark API functions with __declspec(dllexport) when building a static library on Windows.
Enforced by CMake builds.
For other builds a compile definition is available.
Related: #480
- new API function: `struct hid_device_info * hid_get_device_info(hid_device *dev);` to get `hid_device_info` after the device already opened;
- reused existing implementation on Windows and macOS from enumeration routines to have the implementation;
- refactored libusb implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`;
- refactored hidraw implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`;
Resolves: #431Closes: #164Closes: #163
- make the behaviour of methods which set hid_error more consistent;
- make the documentation and the implementation of hid_error consistent and safe;
- windows: add global error implementation;
Co-authored-by: Julian Waller <git@julusian.co.uk>
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.
Previously the interface would never be set on Mac.
This presents a big pain because retrieving interface numbers can be the
only way to distinguish between the interfaces returned by HIDAPI.
This change makes it possible to retrieve interface number from an
hid_device_info on Mac for USB HID devices only.
It is unclear if the macOS IOKit library returns valid interface numbers
for non-HID USB devices. Because of this, I have opted to simply skip
that case - leave it initialised to `-1`.
In the future, we can easily relax this restriction if it turns out
IOKit correctly returns interface number with non-HID USB devices. For
now, this commit brings 90% of the value at 5% of the risk.
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.
Although the Windows API doesn't provide direct access to interface number,
on child devices representing the interfaces of a composite device, it is
parsable from the device path. An excerpt of a path for interface 1 of a
Razer Hydra device is as follows:
\?\hid#vid_1532&pid_0300&mi_01
See table 4 and related text here:
http://msdn.microsoft.com/en-us/windows/hardware/gg487473
This patch, if a path is available, and further, if &mi_ is found, parses
what it can for a hex value into the interface_number field. If there is
any problem, the invalid value (-1) is used instead.
Patch from Ryan Pavlik <abiryan@ryand.net> with modifications by Alan Ott.
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>
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.