8000 bump hidapi to 0.12.0 · arduino/crossbuild@9ddca1b · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ddca1b

Browse files
committed
bump hidapi to 0.12.0
1 parent 47fd24e commit 9ddca1b

34 files changed

+1196
-799
lines changed

deps/hidapi/.appveyor.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ environment:
88
arch: Win32
99
- BUILD_ENV: cygwin
1010

11-
install:
12-
- cmd: if %BUILD_ENV%==cygwin (
13-
C:\cygwin64\setup-x86_64.exe --quiet-mode --no-shortcuts --upgrade-also --packages autoconf,automake )
11+
for:
12+
-
13+
matrix:
14+
only:
15+
- BUILD_ENV: msbuild
1416

15-
build_script:
16-
- cmd: if %BUILD_ENV%==msbuild (
17-
msbuild .\windows\hidapi.sln /p:Configuration=Release /p:Platform=%arch% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" )
18-
- cmd: if %BUILD_ENV%==cygwin (
19-
C:\cygwin64\bin\bash -exlc "cd $APPVEYOR_BUILD_FOLDER; ./bootstrap; ./configure; make" )
17+
build_script:
18+
- cmd: msbuild .\windows\hidapi.sln /p:Configuration=Release /p:Platform=%arch% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
2019

21-
artifacts:
22-
# Win32 artifacts
23-
- path: .\windows\Release\hidapi.dll
24-
- path: .\windows\Release\hidapi.lib
25-
- path: .\windows\Release\hidapi.pdb
26-
- path: .\windows\Release\hidtest.exe
27-
- path: .\windows\Release\hidtest.pdb
28-
# x64 artifacts
29-
- path: .\windows\x64\Release\hidapi.dll
30-
- path: .\windows\x64\Release\hidapi.lib
31-
- path: .\windows\x64\Release\hidapi.pdb
32-
- path: .\windows\x64\Release\hidtest.exe
33-
- path: .\windows\x64\Release\hidtest.pdb
20+
-
21+
matrix:
22+
only:
23+
- BUILD_ENV: cygwin
24+
25+
install:
26+
- cmd: C:\cygwin64\setup-x86_64.exe --quiet-mode --no-shortcuts --upgrade-also --packages autoconf,automake
27+
28+
build_script:
29+
- cmd: C:\cygwin64\bin\bash -exlc "cd $APPVEYOR_BUILD_FOLDER; ./bootstrap; ./configure; make"

deps/hidapi/.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
# Autotools-added generated files
3+
Makefile.in
4+
aclocal.m4
5+
ar-lib
6+
autom4te.cache/
7+
config.*
8+
configure
9+
compile
10+
depcomp
11+
install-sh
12+
libusb/Makefile.in
13+
linux/Makefile.in
14+
ltmain.sh
15+
mac/Makefile.in
16+
missing
17+
testgui/Makefile.in
18+
windows/Makefile.in
19+
20+
Makefile
21+
stamp-h1
22+
libtool
23+
24+
# macOS
25+
.DS_Store
26+
27+
# Qt Creator
28+
CMakeLists.txt.user

deps/hidapi/BUILD.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* [FreeBSD](#freebsd)
99
* [Mac](#mac)
1010
* [Windows](#windows)
11-
* [Integrating hidapi directly into your source tree](#integrating-hidapi-directly-into-your-source-tree)
11+
* [Embedding HIDAPI directly into your source tree](#embedding-hidapi-directly-into-your-source-tree)
1212
* [Building the manual way on Unix platforms](#building-the-manual-way-on-unix-platforms)
1313
* [Building on Windows](#building-on-windows)
1414

@@ -68,19 +68,30 @@ On Mac make sure you have XCode installed and its Command Line Tools.
6868
On Windows you just need a compiler. You may use Visual Studio or Cygwin/MinGW,
6969
depending on which environment is best for your needs.
7070

71-
## Integrating HIDAPI directly into your source tree
71+
## Embedding HIDAPI directly into your source tree
7272

73-
Instead of using one of the provided build systems, you may want to integrate
74-
HIDAPI directly into your source tree.
75-
Generally it is not encouraged to do so, but if you must, all you need to do:
76-
- add a single source file `hid.c` (for a specific backend);
77-
- setup include directory to `<HIDAPI repo root>/hidapi`;
78-
- add link libraries, that are specific for each backend.
73+
Instead of using one of the provided standalone build systems,
74+
you may want to integrate HIDAPI directly into your source tree.
7975

80-
Check the manual makefiles for a simple example/reference of what are the dependencies of each specific backend.
76+
---
77+
If your project uses CMake as a build system, it is safe to add HIDAPI as a [subdirectory](BUILD.cmake.md#hidapi-as-a-subdirectory).
78+
79+
---
80+
If _the only option_ that works for you is adding HIDAPI sources directly
81+
to your project's build system, then you need:
82+
- include a _single source file_ into your project's build system,
83+
depending on your platform and the backend you want to use:
84+
- [`windows\hid.c`](windows/hid.c);
85+
- [`linux/hid.c`](linux/hid.c);
86+
- [`libusb/hid.c`](libusb/hid.c);
87+
- [`mac/hid.c`](mac/hid.c);
88+
- add a [`hidapi`](hidapi) folder to the include path when building `hid.c`;
89+
- make the platform/backend specific [dependencies](#prerequisites) available during the compilation/linking, when building `hid.c`;
8190

82-
NOTE: if your have a CMake-based project, you're likely be able to use
83-
HIDAPI directly as a subdirectory. Check [BUILD.cmake.md](BUILD.cmake.md) for details.
91+
NOTE: the above doesn't guarantee that having a copy of `<backend>/hid.c` and `hidapi/hidapi.h` is enough to build HIDAPI.
92+
The only guarantee that `<backend>/hid.c` includes all nesessary sources to compile it as a single file.
93+
94+
Check the manual makefiles for a simple example/reference of what are the dependencies of each specific backend.
8495

8596
## Building the manual way on Unix platforms
8697

@@ -106,5 +117,5 @@ To build HIDAPI using MinGW or Cygwin using Autotools, use a general Autotools
106117

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

109-
If you are looking for information regarding DDK build of HIDAPI
120+
If you are looking for information regarding DDK build of HIDAPI:
110121
- the build has been broken for a while and now the support files are obsolete.

deps/hidapi/HACKING.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Firing a new release:
88
1. Update the Version (if not yet updated).
99
2. Build hidapi.dll/.lib for x86/x64.
1010
3. Upload Windows binaries to Github release page.
11+
4. Make sure to tag the release as: `hidapi-<VERSION>`, where <VERSION> as in VERSION file.

deps/hidapi/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
HIDAPI is a multi-platform library which allows an application to interface
1010
with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and macOS.
1111
HIDAPI can be either built as a shared library (`.so`, `.dll` or `.dylib`) or
12-
can be embedded directly into a target application by adding a single source
13-
file (per platform) and a single header.
12+
can be embedded directly into a target application by adding a _single source_
13+
file (per platform) and a single header.<br>
14+
See [remarks](BUILD.md#embedding-hidapi-directly-into-your-source-tree) on embedding _directly_ into your build system.
1415

1516
HIDAPI library was originally developed by Alan Ott ([signal11](https://github.com/signal11)).
1617

deps/hidapi/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.11.2
1+
0.12.0

deps/hidapi/hidapi/hidapi.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,40 @@
4848
4949
@ingroup API
5050
*/
51-
#define HID_API_VERSION_MINOR 11
51+
#define HID_API_VERSION_MINOR 12
5252
/** @brief Static/compile-time patch version of the library.
5353
5454
@ingroup API
5555
*/
56-
#define HID_API_VERSION_PATCH 2
56+
#define HID_API_VERSION_PATCH 0
5757

5858
/* Helper macros */
5959
#define HID_API_AS_STR_IMPL(x) #x
6060
#define HID_API_AS_STR(x) HID_API_AS_STR_IMPL(x)
6161
#define HID_API_TO_VERSION_STR(v1, v2, v3) HID_API_AS_STR(v1.v2.v3)
6262

63+
/** @brief Coverts a version as Major/Minor/Patch into a number:
64+
<8 bit major><16 bit minor><8 bit patch>.
65+
66+
This macro was added in version 0.12.0.
67+
68+
Convenient function to be used for compile-time checks, like:
69+
#if HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
70+
71+
@ingroup API
72+
*/
73+
#define HID_API_MAKE_VERSION(mj, mn, p) (((mj) << 24) | ((mn) << 8) | (p))
74+
75+
/** @brief Static/compile-time version of the library.
76+
77+
This macro was added in version 0.12.0.
78+
79+
@see @ref HID_API_MAKE_VERSION.
80+
81+
@ingroup API
82+
*/
83+
#define HID_API_VERSION HID_API_MAKE_VERSION(HID_API_VERSION_MAJOR, HID_API_VERSION_MINOR, HID_API_VERSION_PATCH)
84+
6385
/** @brief Static/compile-time string version of the library.
6486
6587
@ingroup API
@@ -369,6 +391,8 @@ extern "C" {
369391

370392
/** @brief Get a input report from a HID device.
371393
394+
Since version 0.10.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 10, 0)
395+
372396
Set the first byte of @p data[] to the Report ID of the
373397
report to be read. Make sure to allow space for this
374398
extra byte in @p data[]. Upon return, the first byte will

deps/hidapi/hidtest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if(NOT WIN32 AND NOT APPLE AND CMAKE_SYSTEM_NAME MATCHES "Linux")
99
endif()
1010
if(TARGET hidapi::libusb)
1111
add_executable(hidtest_libusb test.c)
12+
target_compile_definitions(hidtest_libusb PRIVATE USING_HIDAPI_LIBUSB)
1213
target_link_libraries(hidtest_libusb hidapi::libusb)
1314
list(APPEND HIDAPI_HIDTEST_TARGETS hidtest_libusb)
1415
endif()

deps/hidapi/hidtest/Makefile.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ hidtest_SOURCES = test.c
1818
hidtest_LDADD = $(top_builddir)/$(backend)/libhidapi.la
1919

2020
endif
21+
22+
if OS_DARWIN
23+
AM_CPPFLAGS += -I$(top_srcdir)/mac/
24+
endif
25+
26+
if OS_WINDOWS
27+
AM_CPPFLAGS += -I$(top_srcdir)/windows/
28+
endif

deps/hidapi/hidtest/test.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@
2828
#include <unistd.h>
2929
#endif
3030

31+
// Fallback/example
32+
#ifndef HID_API_MAKE_VERSION
33+
#define HID_API_MAKE_VERSION(mj, mn, p) (((mj) << 24) | ((mn) << 8) | (p))
34+
#endif
35+
#ifndef HID_API_VERSION
36+
#define HID_API_VERSION HID_API_MAKE_VERSION(HID_API_VERSION_MAJOR, HID_API_VERSION_MINOR, HID_API_VERSION_PATCH)
37+
#endif
38+
39+
//
40+
// Sample using platform-specific headers
41+
#if defined(__APPLE__) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
42+
#include <hidapi_darwin.h>
43+
#endif
44+
45+
#if defined(_WIN32) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
46+
#include <hidapi_winapi.h>
47+
#endif
48+
49+
#if defined(USING_HIDAPI_LIBUSB) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
50+
#include <hidapi_libusb.h>
51+
#endif
52+
//
53+
3154
int main(int argc, char* argv[])
3255
{
3356
(void)argc;
@@ -43,7 +66,7 @@ int main(int argc, char* argv[])
4366
struct hid_device_info *devs, *cur_dev;
4467

4568
printf("hidapi test/example tool. Compiled with hidapi version %s, runtime version %s.\n", HID_API_VERSION_STR, hid_version_str());
46-
if (hid_version()->major == HID_API_VERSION_MAJOR && hid_version()->minor == HID_API_VERSION_MINOR && hid_version()->patch == HID_API_VERSION_PATCH) {
69+
if (HID_API_VERSION == HID_API_MAKE_VERSION(hid_version()->major, hid_version()->minor, hid_version()->patch)) {
4770
printf("Compile-time version matches runtime version of hidapi.\n\n");
4871
}
4972
else {
@@ -53,6 +76,12 @@ int main(int argc, char* argv[])
5376
if (hid_init())
5477
return -1;
5578

79+
#if defined(__APPLE__) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
80+
// To work properly needs to be called before hid_open/hid_open_path after hid_init.
81+
// Best/recommended option - call it right after hid_init.
82+
hid_darwin_set_open_exclusive(0);
83+
#endif
84+
5685
devs = hid_enumerate(0x0, 0x0);
5786
cur_dev = devs;
5887
while (cur_dev) {
@@ -143,7 +172,7 @@ int main(int argc, char* argv[])
143172
// Print out the returned buffer.
144173
printf("Feature Report\n ");
145174
for (i = 0; i < res; i++)
146-
printf("%02hhx ", buf[i]);
175+
printf("%02x ", (unsigned int) buf[i]);
147176
printf("\n");
148177
}
149178

@@ -186,7 +215,7 @@ int main(int argc, char* argv[])
186215
printf("Data read:\n ");
187216
// Print out the returned buffer.
188217
for (i = 0; i < res; i++)
189-
printf("%02hhx ", buf[i]);
218+
printf("%02x ", (unsigned int) buf[i]);
190219
printf("\n");
191220

192221
hid_close(handle);

deps/hidapi/libusb/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,29 @@ endif()
1919
find_package(Threads REQUIRED)
2020
target_link_libraries(hidapi_libusb PRIVATE Threads::Threads)
2121

22+
if(HIDAPI_NO_ICONV)
23+
target_compile_definitions(hidapi_libusb PRIVATE NO_ICONV)
24+
else()
25+
if(NOT ANDROID AND NOT CMAKE_VERSION VERSION_LESS 3.11)
26+
find_package(Iconv REQUIRED)
27+
include(CheckCSourceCompiles)
28+
target_link_libraries(hidapi_libusb PRIVATE Iconv::Iconv)
29+
set(CMAKE_REQUIRED_LIBRARIES "Iconv::Iconv")
30+
# check for error: "conflicting types for 'iconv'"
31+
check_c_source_compiles("#include<iconv.h>
32+
extern size_t iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
33+
int main() {}"
34+
HIDAPI_ICONV_CONST)
35+
if(HIDAPI_ICONV_CONST)
36+
target_compile_definitions(hidapi_libusb PRIVATE "ICONV_CONST=const")
37+
endif()
38+
endif()
39+
# otherwise there is 3 options:
40+
# 1) On Android Iconv is disabled on the code level anyway, so no issue;
41+
# 2) iconv is provided by Standard C library and the build will be just fine;
42+
# 4) The _user_ has to provide additiona compilation options for this project/target.
43+
endif()
44+
2245
set_target_properties(hidapi_libusb
2346
PROPERTIES
2447
EXPORT_NAME "libusb"

deps/hidapi/libusb/Makefile.freebsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CFLAGS ?= -Wall -g -fPIC
1515

1616
COBJS = hid.o ../hidtest/test.o
1717
OBJS = $(COBJS)
18-
INCLUDES = -I../hidapi -I/usr/local/include
18+
INCLUDES = -I../hidapi -I. -I/usr/local/include
1919
LDFLAGS = -L/usr/local/lib
2020
LIBS = -lusb -liconv -pthread
2121

deps/hidapi/libusb/Makefile.haiku

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CFLAGS ?= -Wall -g -fPIC
1515

1616
COBJS = hid.o ../hidtest/test.o
1717
OBJS = $(COBJS)
18-
INCLUDES = -I../hidapi -I/usr/local/include
18+
INCLUDES = -I../hidapi -I. -I/usr/local/include
1919
LDFLAGS = -L/usr/local/lib
2020
LIBS = -lusb -liconv -pthread
2121

deps/hidapi/libusb/Makefile.linux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ COBJS = $(COBJS_LIBUSB) ../hidtest/test.o
2020
OBJS = $(COBJS)
2121
LIBS_USB = `pkg-config libusb-1.0 --libs` -lrt -l F438 pthread
2222
LIBS = $(LIBS_USB)
23-
INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
23+
INCLUDES ?= -I../hidapi -I. `pkg-config libusb-1.0 --cflags`
2424

2525

2626
# Console Test Program

deps/hidapi/libusb/hid.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#include <libusb.h>
4545
#if !defined(__ANDROID__) && !defined(NO_ICONV)
4646
#include <iconv.h>
47+
#ifndef ICONV_CONST
48+
#define ICONV_CONST
49+
#endif
4750
#endif
4851

4952
#include "hidapi_libusb.h"
@@ -405,7 +408,7 @@ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx)
405408
size_t inbytes;
406409
size_t outbytes;
407410
size_t res;
408-
char *inptr;
411+
ICONV_CONST char *inptr;
409412
char *outptr;
410413
#endif
411414

@@ -421,7 +424,7 @@ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx)
421424
lang,
422425
(unsigned char*)buf,
423426
sizeof(buf));
424-
if (len < 0)
427+
if (len < 2) /* we always skip first 2 bytes */
425428
return NULL;
426429

427430
#if defined(__ANDROID__) || defined(NO_ICONV)
@@ -1408,6 +1411,7 @@ void HID_API_EXPORT hid_close(hid_device *dev)
14081411

14091412
/* Clean up the Transfer objects allocated in read_thread(). */
14101413
free(dev->transfer->buffer);
1414+
dev->transfer->buffer = NULL;
14111415
libusb_free_transfer(dev->transfer);
14121416

14131417
/* release the interface */

deps/hidapi/libusb/hidapi_libusb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
/** @file
2121
* @defgroup API hidapi API
22+
23+
* Since version 0.11.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 11, 0).
2224
*/
2325

2426
#ifndef HIDAPI_LIBUSB_H__

0 commit comments

Comments
 (0)
0