diff --git a/BUILD.cmake.md b/BUILD.cmake.md index fc7f4fa18..efcbfeb71 100644 --- a/BUILD.cmake.md +++ b/BUILD.cmake.md @@ -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.
Linux and FreeBSD-specific variables @@ -148,6 +151,7 @@ Available CMake targets after successful `find_package(hidapi)`: - `hidapi::include` - if you need only to include `` 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; @@ -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; diff --git a/BUILD.md b/BUILD.md index d7a3546f6..175688414 100644 --- a/BUILD.md +++ b/BUILD.md @@ -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 `/hid.c` and `hidapi/hidapi.h` is enough to build HIDAPI. -The only guarantee that `/hid.c` includes all necessary sources to compile it as a single file. +The only guarantee is that `/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. diff --git a/HACKING.txt b/HACKING.txt index e06b533aa..40430e07d 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -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-` -5. Push newly created tag: `git push origin hidapi-` -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- ` +4. Push newly created tag: `git push origin hidapi-` +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. diff --git a/README.md b/README.md index cf5e6e02e..f13b94628 100644 --- a/README.md +++ b/README.md @@ -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.
+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.
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)). @@ -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. diff --git a/dist/hidapi.podspec b/dist/hidapi.podspec index f48d9b8be..89f7d7664 100644 --- a/dist/hidapi.podspec +++ b/dist/hidapi.podspec @@ -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" diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 4e01360e0..9c492aee5 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -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 diff --git a/hidapi/hidapi.h b/hidapi/hidapi.h index 952225b47..fdb45042f 100644 --- a/hidapi/hidapi.h +++ b/hidapi/hidapi.h @@ -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. diff --git a/libusb/hidapi_libusb.h b/libusb/hidapi_libusb.h index 3cbc5f365..1e1e2e78f 100644 --- a/libusb/hidapi_libusb.h +++ b/libusb/hidapi_libusb.h @@ -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); @@ -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); @@ -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); diff --git a/windows/hidapi_winapi.h b/windows/hidapi_winapi.h index 7ab5e9728..120fb8fa5 100644 --- a/windows/hidapi_winapi.h +++ b/windows/hidapi_winapi.h @@ -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. @@ -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);