Skip to content

Commit

Permalink
update lib and fix windows: libusb/hidapi#334
Browse files Browse the repository at this point in the history
git subrepo pull custom/dependencies/hidapi

subrepo:
  subdir:   "custom/dependencies/hidapi"
  merged:   "b66d7c2c"
upstream:
  origin:   "https://github.com/libusb/hidapi.git"
  branch:   "master"
  commit:   "b66d7c2c"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"
  • Loading branch information
CEnnis91 committed Aug 3, 2022
1 parent 405a7ba commit a808afd
Show file tree
Hide file tree
Showing 26 changed files with 863 additions and 545 deletions.
18 changes: 15 additions & 3 deletions custom/dependencies/hidapi/.github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ jobs:
- name: Check artifacts
uses: andstor/file-existence-action@v1
with:
files: "install/shared/lib/libhidapi.dylib, install/shared/include/hidapi/hidapi.h, install/framework/lib/hidapi.framework/hidapi, install/framework/lib/hidapi.framework/Headers/hidapi.h"
files: "install/shared/lib/libhidapi.dylib, \
install/shared/include/hidapi/hidapi.h, \
install/framework/lib/hidapi.framework/hidapi, \
install/framework/lib/hidapi.framework/Headers/hidapi.h"
allow_failure: true

ubuntu-cmake:
Expand All @@ -59,7 +62,9 @@ jobs:
with:
path: hidapisrc
- name: Install dependencies
run: sudo apt install libudev-dev libusb-1.0-0-dev
run: |
sudo apt update
sudo apt install libudev-dev libusb-1.0-0-dev
- name: Configure CMake
run: |
rm -rf build install
Expand All @@ -74,7 +79,14 @@ jobs:
- name: Check artifacts
uses: andstor/file-existence-action@v1
with:
files: "install/shared/lib/libhidapi-libusb.so, install/shared/lib/libhidapi-hidraw.so, install/shared/include/hidapi/hidapi.h, install/static/lib/libhidapi-libusb.a, install/static/lib/libhidapi-hidraw.a, install/static/include/hidapi/hidapi.h"
files: "install/shared/lib/libhidapi-libusb.so, \
install/shared/lib/libhidapi-hidraw.so, \
install/shared/include/hidapi/hidapi.h, \
install/shared/include/hidapi/hidapi_libusb.h, \
install/static/lib/libhidapi-libusb.a, \
install/static/lib/libhidapi-hidraw.a, \
install/static/include/hidapi/hidapi.h, \
install/static/include/hidapi/hidapi_libusb.h"
allow_failure: true

windows-cmake-msvc:
Expand Down
4 changes: 4 additions & 0 deletions custom/dependencies/hidapi/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ Makefile
stamp-h1
libtool

# macOS
.DS_Store

# Qt Creator
CMakeLists.txt.user
4 changes: 2 additions & 2 deletions custom/dependencies/hidapi/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/libusb/hidapi.git
branch = master
commit = 382138ee67adf539f60fc986a3409cf1f1fc3cee
parent = b0b794fdc973191c6e3c46cc1cd0adb45f81d033
commit = b66d7c2c889d39cdce8eedc50692c318911b04a9
parent = 9ede812a19ae69de06ec4d0fb5227b67c1b0327c
method = merge
cmdver = 0.4.3
2 changes: 1 addition & 1 deletion custom/dependencies/hidapi/AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ libusb/hidapi Team:
Development/maintainance since June 4th 2019

For a comprehensive list of contributions, see the commit list at github:
https://github.com/libusb/hidapi/commits/master
https://github.com/libusb/hidapi/graphs/contributors

10 changes: 9 additions & 1 deletion custom/dependencies/hidapi/BUILD.autotools.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Building HIDAPI using Autotools
# Building HIDAPI using Autotools (deprecated)

---
**NOTE**: for all intentions and purposes the Autotools build scripts for HIDAPI are _deprecated_ and going to be obsolete in the future.
HIDAPI Team recommends using CMake build for HIDAPI.
If you are already using Autotools build scripts provided by HIDAPI,
consider switching to CMake build scripts as soon as possible.

---

To be able to use Autotools to build HIDAPI, it has to be [installed](#installing-autotools)/available in the system.

Expand Down
6 changes: 6 additions & 0 deletions custom/dependencies/hidapi/BUILD.cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ set(BUILD_SHARED_LIBS FALSE) # HIDAPI as static library on all platforms
add_subdirectory(hidapi)
```

<details>
<summary>NOTE</summary>

If you project happen to use `BUILD_SHARED_LIBS` as a `CACHE` variable globally for you project, setting it as simple variable, as showed above _will have not affect_ up until _CMake 3.13_. See [CMP0077](https://cmake.org/cmake/help/latest/policy/CMP0077.html) for details.
</details><br>

There are several important differences in the behavior of HIDAPI CMake build system when CMake is built as standalone package vs subdirectory build:

1) In _standalone build_ a number of standard and HIDAPI-specific variables are marked as _cache variables_ or _options_.
Expand Down
24 changes: 6 additions & 18 deletions custom/dependencies/hidapi/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
For various reasons you may need to build HIDAPI on your own.

It can be done in several different ways:
- using [Autotools](BUILD.autotools.md);
- using [CMake](BUILD.cmake.md);
- using [Autotools](BUILD.autotools.md) (deprecated);
- using [manual makefiles](#building-the-manual-way-on-unix-platforms).

**Autotools** build system is historically first mature build system for
HIDAPI. Most common usage of it is in its separate README: [BUILD.autotools.md](BUILD.autotools.md).
HIDAPI. Most common usage of it is in its separate README: [BUILD.autotools.md](BUILD.autotools.md).<br/>
NOTE: for all intentions and purposes the Autotools build scripts for HIDAPI are _deprecated_ and going to be obsolete in the future.
HIDAPI Team recommends using CMake build for HIDAPI.

**CMake** build system is de facto an industry standard for many open-source and proprietary projects and solutions.
HIDAPI is one of the projects which uses the power of CMake for its advantage.
Expand Down Expand Up @@ -104,19 +106,5 @@ To build HIDAPI using MinGW or Cygwin using Autotools, use a general Autotools

Any windows builds (MSVC or MinGW/Cygwin) are also supported by [CMake](BUILD.cmake.md).

HIDAPI can also be built using the Windows DDK (now also called the Windows
Driver Kit or WDK). This method was originally required for the HIDAPI build
but not anymore. However, some users still prefer this method. It is not as
well supported anymore but should still work. Patches are welcome if it does
not. To build using the DDK:

1. Install the Windows Driver Kit (WDK) from Microsoft.
2. From the Start menu, in the Windows Driver Kits folder, select Build
Environments, then your operating system, then the x86 Free Build
Environment (or one that is appropriate for your system).
3. From the console, change directory to the `windows/ddk_build/` directory,
which is part of the HIDAPI distribution.
4. Type build.
5. You can find the output files (DLL and LIB) in a subdirectory created
by the build system which is appropriate for your environment. On
Windows XP, this directory is `objfre_wxp_x86/i386`.
If you are looking for information regarding DDK build of HIDAPI
- the build has been broken for a while and now the support files are obsolete.
29 changes: 18 additions & 11 deletions custom/dependencies/hidapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ It was moved to [libusb/hidapi](https://github.com/libusb/hidapi) on June 4th, 2

* [About](#about)
* [Test GUI](#test-gui)
* [Console Test App](#console-test-app)
* [What Does the API Look Like?](#what-does-the-api-look-like)
* [License](#license)
* [Installing HIDAPI](#installing-hidapi)
Expand All @@ -28,7 +29,7 @@ It was moved to [libusb/hidapi](https://github.com/libusb/hidapi) on June 4th, 2

## About

HIDAPI has four back-ends:
### HIDAPI has four back-ends:
* Windows (using `hid.dll`)
* Linux/hidraw (using the Kernel's hidraw driver)
* libusb (using libusb-1.0 - Linux/BSD/other UNIX-like systems)
Expand All @@ -45,7 +46,7 @@ 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.

__Linux/hidraw__ (`linux/hid.c`):
#### __Linux/hidraw__ (`linux/hid.c`):

This back-end uses the hidraw interface in the Linux kernel, and supports
both USB and Bluetooth HID devices. It requires kernel version at least 2.6.39
Expand All @@ -55,7 +56,7 @@ Keyboards, mice, and some other devices which are blacklisted from having
hidraw nodes will not work. Fortunately, for nearly all the uses of hidraw,
this is not a problem.

__Linux/FreeBSD/libusb__ (`libusb/hid.c`):
#### __Linux/FreeBSD/libusb__ (`libusb/hid.c`):

This back-end uses libusb-1.0 to communicate directly to a USB device. This
back-end will of course not work with Bluetooth devices.
Expand All @@ -65,7 +66,7 @@ back-end will of course not work with Bluetooth devices.
HIDAPI also comes with a Test GUI. The Test GUI is cross-platform and uses
Fox Toolkit <http://www.fox-toolkit.org>. It will build on every platform
which HIDAPI supports. Since it relies on a 3rd party library, building it
is optional but recommended because it is so useful when debugging hardware.
is optional but it is useful when debugging hardware.

NOTE: Test GUI based on Fox Toolkit is not actively developed nor supported
by HIDAPI team. It is kept as a historical artifact. It may even work sometime
Expand All @@ -74,6 +75,14 @@ or on some platforms, but it is not going to get any new features or bugfixes.
Instructions for installing Fox-Toolkit on each platform is not provided.
Make sure to use Fox-Toolkit v1.6 if you choose to use it.

### Console Test App

If you want to play around with your HID device before starting
any development with HIDAPI and using a GUI app is not an option for you, you may try [`hidapitester`](https://github.com/todbot/hidapitester).

This app has a console interface for most of the features supported
by HIDAPI library.

## What Does the API Look Like?

The API provides the most commonly used HID functions including sending
Expand All @@ -83,15 +92,13 @@ Generic HID sample looks like this (with error checking removed for
simplicity):

**Warning: Only run the code you understand, and only when it conforms to the
device spec. Writing data at random to your HID devices can break them.**
device spec. Writing data (`hid_write`) at random to your HID devices can break them.**

```c
#ifdef WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "hidapi.h"
#include <stdio.h> // printf
#include <wchar.h> // wprintf

#include <hidapi.h>

#define MAX_STR 255

Expand Down
2 changes: 1 addition & 1 deletion custom/dependencies/hidapi/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.0-dev
0.11.0
3 changes: 3 additions & 0 deletions custom/dependencies/hidapi/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ AC_PREREQ(2.63)

AC_INIT([hidapi],[m4_normalize(m4_builtin([include], VERSION))],[https://github.com/libusb/hidapi/issues])

echo "This build script for HIDAPI is deprecated."
echo "Consider using CMake instead."

# Library soname version
# Follow the following rules (particularly the ones in the second link):
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
Expand Down
7 changes: 4 additions & 3 deletions custom/dependencies/hidapi/hidtest/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include <wchar.h>
#include <string.h>
#include <stdlib.h>
#include "hidapi.h"

#include <hidapi.h>

// Headers needed for sleeping.
#ifdef _WIN32
Expand Down Expand Up @@ -175,7 +176,7 @@ int main(int argc, char* argv[])
printf("waiting...\n");
if (res < 0)
printf("Unable to read()\n");
#ifdef WIN32
#ifdef _WIN32
Sleep(500);
#else
usleep(500*1000);
Expand All @@ -193,7 +194,7 @@ int main(int argc, char* argv[])
/* Free static HIDAPI objects. */
hid_exit();

#ifdef WIN32
#ifdef _WIN32
system("pause");
#endif

Expand Down
2 changes: 2 additions & 0 deletions custom/dependencies/hidapi/libusb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.6.3 FATAL_ERROR)

list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_libusb.h")

add_library(hidapi_libusb
${HIDAPI_PUBLIC_HEADERS}
hid.c
Expand Down
2 changes: 1 addition & 1 deletion custom/dependencies/hidapi/libusb/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ libhidapi_la_LIBADD = $(LIBS_LIBUSB)
endif

hdrdir = $(includedir)/hidapi
hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h hidapi_libusb.h

EXTRA_DIST = Makefile-manual
Loading

0 comments on commit a808afd

Please sign in to comment.