Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions BUILD.cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ Some of the [standard](https://cmake.org/cmake/help/latest/manual/cmake-variable
HIDAPI-specific CMake variables:

- `HIDAPI_BUILD_HIDTEST` - when set to TRUE, build a small test application `hidtest`;
- `HIDAPI_WITH_TESTS` - when set to TRUE, build all (unit-)tests;
currently this option is only available on Windows, since only Windows backend has tests;
- `HIDAPI_WITH_TESTS` - when set to TRUE, build the tests available for the selected backends.
Defaults to FALSE on Linux and macOS. On Windows, and on other platforms when libusb is enabled,
defaults to TRUE for Debug builds and FALSE otherwise. Virtual-device tests require
CMake 3.16 or newer and skip when their device provider is unavailable.
See [HIDAPI tests](src/tests/README.md) for coverage and setup requirements.

<details>
<summary>Linux and FreeBSD-specific variables</summary>
Expand Down Expand Up @@ -148,6 +151,7 @@ Available CMake targets after successful `find_package(hidapi)`:
- `hidapi::include` - if you need only to include `<hidapi.h>` but not link against the library;
- `hidapi::winapi` - same as `hidapi::hidapi` on Windows; available only on Windows;
- `hidapi::darwin` - same as `hidapi::hidapi` on macOS; available only on macOS;
- `hidapi::netbsd` - available when the native NetBSD uhid backend is built;
- `hidapi::libusb` - available when libusb backend is used/available;
- `hidapi::hidraw` - available when hidraw backend is used/available on Linux or FreeBSD;

Expand Down Expand Up @@ -224,6 +228,7 @@ Available CMake targets after `add_subdirectory(hidapi)` _are the same as in cas
- `hidapi_include` - the interface library; `hidapi::include` is an alias of it;
- `hidapi_winapi` - library target on Windows; `hidapi::winapi` is an alias of it;
- `hidapi_darwin` - library target on macOS; `hidapi::darwin` is an alias of it;
- `hidapi_netbsd` - library target for the NetBSD uhid backend; `hidapi::netbsd` is an alias of it;
- `hidapi_libusb` - library target for libusb backend; `hidapi::libusb` is an alias of it;
- `hidapi_hidraw` - library target for hidraw backend; `hidapi::hidraw` is an alias of it;
- `hidapi-libusb` - an alias of `hidapi_libusb` for compatibility with raw library name;
Expand Down
7 changes: 6 additions & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ to your project's build system, then you need:
depending on your platform and the backend you want to use:
- [`windows\hid.c`](windows/hid.c);
- [`linux/hid.c`](linux/hid.c);
- [`freebsd/hid.c`](freebsd/hid.c);
- [`netbsd/hid.c`](netbsd/hid.c);
- [`libusb/hid.c`](libusb/hid.c);
- [`mac/hid.c`](mac/hid.c);
- add a [`hidapi`](hidapi) folder to the include path when building `hid.c`;
- make the platform/backend specific [dependencies](#prerequisites) available during the compilation/linking, when building `hid.c`;

NOTE: the above doesn't guarantee that having a copy of `<backend>/hid.c` and `hidapi/hidapi.h` is enough to build HIDAPI.
The only guarantee that `<backend>/hid.c` includes all necessary sources to compile it as a single file.
The only guarantee is that `<backend>/hid.c` includes all necessary sources to compile it as a single translation unit.
Preserve the relative paths of included files. The macOS and libusb backends require
`src/core/hidapi_input_ring.h`; libusb also requires `libusb/hidapi_libusb_report_descriptor.h`
and its thread-model header (`libusb/hidapi_thread_pthread.h` by default).

Check the manual makefiles for a simple example/reference of what are the dependencies of each specific backend.

Expand Down
27 changes: 17 additions & 10 deletions HACKING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ Updating a Version:
2. HID_API_VERSION_MAJOR/HID_API_VERSION_MINOR/HID_API_VERSION_PATCH in hidapi.h.

Before firing a new release:
1. Run the "Checks" Githtub Action
2. Make sure no defects are found at: https://scan.coverity.com/projects/hidapi
3. Fix if any
1. Update the Version (if not yet updated) and select the release commit on master.
Verify its build and test results.
Check that the expected virtual-device tests ran rather than skipped.
2. Run the "Checks" GitHub Action for that commit.
3. Wait for its Coverity analysis at https://scan.coverity.com/projects/hidapi
and fix any outstanding defects. A successful submission is not a completed analysis.
4. Verify the "Docs" workflow built and deployed documentation from that commit.
Documentation deploys on master updates, not release tags.

Firing a new release:
1. Update the Version (if not yet updated).
2. Prepare the Release Notes.
3. Store the Release Notes into a file.
4. Create locally an annotated git tag with release notes attached, e.g.: `git tag -aF ../hidapi_release_notes hidapi-<VERSION>`
5. Push newly created tag: `git push origin hidapi-<VERSION>`
6. Grab the hidapi-win.zip from Summary page of "GitHub Builds" Action for latest master build.
7. Create a Github Release with hidapi-win.zip attached, for newly created tag.
1. Prepare the Release Notes.
2. Store the Release Notes in an ignored local file, e.g. build/release-notes.txt.
3. Create an annotated git tag for the verified commit with release notes attached,
e.g.: `git tag -aF build/release-notes.txt hidapi-<VERSION> <release-commit>`
4. Push newly created tag: `git push origin hidapi-<VERSION>`
5. Grab hidapi-win.zip from the "GitHub Builds" Action for the tagged commit.
Verify the archive contents and DLL versions before attaching it.
6. Create a GitHub Release for the new tag with hidapi-win.zip attached.
7. Verify the published release, asset download and API documentation.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
HIDAPI is a multi-platform library which allows an application to interface
with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and macOS.
HIDAPI can be either built as a shared library (`.so`, `.dll` or `.dylib`) or
can be embedded directly into a target application by adding a _single source_
file (per platform) and a single header.<br>
can be embedded directly into a target application by adding one backend source
file as a compilation unit, with its supporting headers available at compile time.<br>
See [remarks](BUILD.md#embedding-hidapi-directly-into-your-source-tree) on embedding _directly_ into your build system.

HIDAPI library was originally developed by Alan Ott ([signal11](https://github.com/signal11)).
Expand All @@ -31,19 +31,21 @@ It was moved to [libusb/hidapi](https://github.com/libusb/hidapi) on June 4th, 2

## About

### HIDAPI has four back-ends:
### HIDAPI back-ends:
* Windows (using `hid.dll`)
* Linux/hidraw (using the Kernel's hidraw driver)
* FreeBSD/hidraw (using the Kernel's hidraw driver)
* NetBSD/uhid (using the Kernel's uhid driver)
* libusb (using libusb-1.0 - Linux/BSD/other UNIX-like systems)
* macOS (using IOHidManager)

On Linux, either the hidraw or the libusb back-end can be used. There are
On Linux and FreeBSD, either the hidraw or the libusb back-end can be used. There are
tradeoffs, and the functionality supported is slightly different. Both are
built by default. It is up to the application linking to hidapi to choose
the backend at link time by linking to either `libhidapi-libusb` or
`libhidapi-hidraw`.

Note that you will need to install an udev rule file with your application
On Linux, you will need to install an udev rule file with your application
for unprivileged users to be able to access HID devices with hidapi. Refer
to the [69-hid.rules](udev/69-hid.rules) file in the `udev` directory
for an example.
Expand Down
2 changes: 1 addition & 1 deletion dist/hidapi.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pod::Spec.new do |spec|
spec.summary = "A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac and Windows."

spec.description = <<-DESC
HIDAPI is a multi-platform library which allows an application to interface with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and macOS. HIDAPI can be either built as a shared library (.so, .dll or .dylib) or can be embedded directly into a target application by adding a single source file (per platform) and a single header.
HIDAPI is a multi-platform library which allows an application to interface with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and macOS. HIDAPI can be either built as a shared library (.so, .dll or .dylib) or can be embedded directly into a target application by adding one backend source file as a compilation unit, with its supporting headers available at compile time.
DESC

spec.homepage = "https://github.com/libusb/hidapi"
Expand Down
3 changes: 3 additions & 0 deletions doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,9 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.

INPUT = ../hidapi \
../libusb/hidapi_libusb.h \
../mac/hidapi_darwin.h \
../windows/hidapi_winapi.h \
./main_page.md

# This tag can be used to specify the character encoding of the source files
Expand Down
2 changes: 1 addition & 1 deletion hidapi/hidapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ extern "C" {

This function is intended for logging/debugging purposes.

This function guarantees to never return NULL for a valid @ref dev.
This function guarantees to never return NULL for a valid @p dev.
If there was no error in the last call to hid_read/hid_read_error -
the returned string clearly indicates that.

Expand Down
6 changes: 6 additions & 0 deletions libusb/hidapi_libusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ extern "C" {
* When the timeout is set to 0, the function will not exit,
* until the write operation is performed or an error occurred.
*
* @ingroup API
* @param dev A device handle returned from hid_open().
* @param timeout New timeout value in milliseconds.
*/
HID_API_EXPORT void HID_API_CALL hid_libusb_set_write_timeout(hid_device *dev, unsigned int timeout);
Expand All @@ -98,6 +100,8 @@ extern "C" {
* When the timeout is set to 0, the function will not exit,
* until the write operation is performed or an error occurred.
*
* @ingroup API
* @param dev A device handle returned from hid_open().
* @param timeout New timeout value in milliseconds.
*/
HID_API_EXPORT void HID_API_CALL hid_libusb_set_send_output_report_timeout(hid_device *dev, unsigned int timeout);
Expand All @@ -116,6 +120,8 @@ extern "C" {
* When the timeout is set to 0, the function will not exit,
* until the write operation is performed or an error occurred.
*
* @ingroup API
* @param dev A device handle returned from hid_open().
* @param timeout New timeout value in milliseconds.
*/
HID_API_EXPORT void HID_API_CALL hid_libusb_set_send_feature_report_timeout(hid_device *dev, unsigned int timeout);
Expand Down
3 changes: 3 additions & 0 deletions windows/hidapi_winapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern "C" {
* This reconstructed report descriptor is logical identical to the real report descriptor,
* but not byte wise identical.
*
* @ingroup API
* @param[in] hidp_preparsed_data Pointer to the HIDP_PREPARSED_DATA to read, i.e.: the value of PHIDP_PREPARSED_DATA,
* as returned by HidD_GetPreparsedData WinAPI function.
* @param buf Pointer to the buffer where the report descriptor should be stored.
Expand All @@ -83,6 +84,8 @@ extern "C" {
* until the write operation is performed or an error occurred.
* See dwMilliseconds parameter documentation of WaitForSingleObject function.
*
* @ingroup API
* @param dev A device handle returned from hid_open().
* @param timeout New timeout value in milliseconds.
*/
void HID_API_EXPORT_CALL hid_winapi_set_write_timeout(hid_device *dev, unsigned long timeout);
Expand Down
Loading