Updated hidapi to 0.14.0 release

Upstream: https://github.com/libusb/hidapi/releases/tag/hidapi-0.14.0
This commit is contained in:
Sam Lantinga
2023-05-24 07:28:55 -07:00
parent 6b8b9af88a
commit 3b7b8f3c09
178 changed files with 31717 additions and 7757 deletions

18
src/hidapi/linux/.gitignore vendored Normal file
View File

@@ -0,0 +1,18 @@
Debug
Release
*.exp
*.ilk
*.lib
*.suo
*.vcproj.*
*.ncb
*.suo
*.dll
*.pdb
*.o
*.so
hidtest-hidraw
.deps
.libs
*.lo
*.la

View File

@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.6.3 FATAL_ERROR)
add_library(hidapi_hidraw
${HIDAPI_PUBLIC_HEADERS}
hid.c
)
target_link_libraries(hidapi_hidraw PUBLIC hidapi_include)
find_package(Threads REQUIRED)
include(FindPkgConfig)
pkg_check_modules(libudev REQUIRED IMPORTED_TARGET libudev)
target_link_libraries(hidapi_hidraw PRIVATE PkgConfig::libudev Threads::Threads)
set_target_properties(hidapi_hidraw
PROPERTIES
EXPORT_NAME "hidraw"
OUTPUT_NAME "hidapi-hidraw"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
PUBLIC_HEADER "${HIDAPI_PUBLIC_HEADERS}"
)
# compatibility with find_package()
add_library(hidapi::hidraw ALIAS hidapi_hidraw)
# compatibility with raw library link
add_library(hidapi-hidraw ALIAS hidapi_hidraw)
if(HIDAPI_INSTALL_TARGETS)
install(TARGETS hidapi_hidraw EXPORT hidapi
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hidapi"
)
endif()
hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi-hidraw.pc.in")

View File

@@ -13,23 +13,19 @@ libs: libhidapi-hidraw.so
CC ?= gcc
CFLAGS ?= -Wall -g -fpic
CXX ?= g++
CXXFLAGS ?= -Wall -g -fpic
LDFLAGS ?= -Wall -g
COBJS = hid.o
CPPOBJS = ../hidtest/hidtest.o
OBJS = $(COBJS) $(CPPOBJS)
COBJS = hid.o ../hidtest/test.o
OBJS = $(COBJS)
LIBS_UDEV = `pkg-config libudev --libs` -lrt
LIBS = $(LIBS_UDEV)
INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
# Console Test Program
hidtest-hidraw: $(COBJS) $(CPPOBJS)
$(CXX) $(LDFLAGS) $^ $(LIBS_UDEV) -o $@
hidtest-hidraw: $(COBJS)
$(CC) $(LDFLAGS) $^ $(LIBS_UDEV) -o $@
# Shared Libs
libhidapi-hidraw.so: $(COBJS)
@@ -39,11 +35,8 @@ libhidapi-hidraw.so: $(COBJS)
$(COBJS): %.o: %.c
$(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
$(CPPOBJS): %.o: %.cpp
$(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
clean:
rm -f $(OBJS) hidtest-hidraw libhidapi-hidraw.so ../hidtest/hidtest.o
rm -f $(OBJS) hidtest-hidraw libhidapi-hidraw.so $(COBJS)
.PHONY: clean libs

View File

@@ -1,59 +0,0 @@
There are two implementations of HIDAPI for Linux. One (linux/hid.c) uses the
Linux hidraw driver, and the other (libusb/hid.c) uses libusb. Which one you
use depends on your application. Complete functionality of the hidraw
version depends on patches to the Linux kernel which are not currently in
the mainline. These patches have to do with sending and receiving feature
reports. The libusb implementation uses libusb to talk directly to the
device, bypassing any Linux HID driver. The disadvantage of the libusb
version is that it will only work with USB devices, while the hidraw
implementation will work with Bluetooth devices as well.
To use HIDAPI, simply drop either linux/hid.c or libusb/hid.c into your
application and build using the build parameters in the Makefile.
Libusb Implementation notes
----------------------------
For the libusb implementation, libusb-1.0 must be installed. Libusb 1.0 is
different than the legacy libusb 0.1 which is installed on many systems. To
install libusb-1.0 on Ubuntu and other Debian-based systems, run:
sudo apt-get install libusb-1.0-0-dev
Hidraw Implementation notes
----------------------------
For the hidraw implementation, libudev headers and libraries are required to
build hidapi programs. To install libudev libraries on Ubuntu,
and other Debian-based systems, run:
sudo apt-get install libudev-dev
On Redhat-based systems, run the following as root:
yum install libudev-devel
Unfortunately, the hidraw driver, which the linux version of hidapi is based
on, contains bugs in kernel versions < 2.6.36, which the client application
should be aware of.
Bugs (hidraw implementation only):
-----------------------------------
On Kernel versions < 2.6.34, if your device uses numbered reports, an extra
byte will be returned at the beginning of all reports returned from read()
for hidraw devices. This is worked around in the library. No action should be
necessary in the client library.
On Kernel versions < 2.6.35, reports will only be sent using a Set_Report
transfer on the CONTROL endpoint. No data will ever be sent on an Interrupt
Out endpoint if one exists. This is fixed in 2.6.35. In 2.6.35, OUTPUT
reports will be sent to the device on the first INTERRUPT OUT endpoint if it
exists; If it does not exist, OUTPUT reports will be sent on the CONTROL
endpoint.
On Kernel versions < 2.6.36, add an extra byte containing the report number
to sent reports if numbered reports are used, and the device does not
contain an INTERRPUT OUT endpoint for OUTPUT transfers. For example, if
your device uses numbered reports and wants to send {0x2 0xff 0xff 0xff} to
the device (0x2 is the report number), you must send {0x2 0x2 0xff 0xff
0xff}. If your device has the optional Interrupt OUT endpoint, this does not
apply (but really on 2.6.35 only, because 2.6.34 won't use the interrupt
out endpoint).

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
#define NAMESPACE HIDRAW
#include "hid.c"