-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NetBSD: Initial UHID native backend implementation (#612)
- Loading branch information
braewoods
authored
Sep 4, 2023
1 parent
4009466
commit c19ae12
Showing
6 changed files
with
1,263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 3.6.3 FATAL_ERROR) | ||
|
||
add_library(hidapi_netbsd | ||
${HIDAPI_PUBLIC_HEADERS} | ||
hid.c | ||
) | ||
target_link_libraries(hidapi_netbsd PUBLIC hidapi_include) | ||
|
||
find_package(Threads REQUIRED) | ||
|
||
target_link_libraries(hidapi_netbsd PRIVATE Threads::Threads) | ||
|
||
set_target_properties(hidapi_netbsd | ||
PROPERTIES | ||
EXPORT_NAME "netbsd" | ||
OUTPUT_NAME "hidapi-netbsd" | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR} | ||
PUBLIC_HEADER "${HIDAPI_PUBLIC_HEADERS}" | ||
) | ||
|
||
# compatibility with find_package() | ||
add_library(hidapi::netbsd ALIAS hidapi_netbsd) | ||
# compatibility with raw library link | ||
add_library(hidapi-netbsd ALIAS hidapi_netbsd) | ||
|
||
if(HIDAPI_INSTALL_TARGETS) | ||
install(TARGETS hidapi_netbsd 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-netbsd.pc.in") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Implementation Notes | ||
-------------------- | ||
NetBSD maps every `uhidev` device to one or more `uhid` | ||
devices. Each `uhid` device only supports one report ID. | ||
The parent device `uhidev` creates one `uhid` device per | ||
report ID found in the hardware's report descriptor. | ||
|
||
In the event there are no report ID(s) found within the | ||
report descriptor, only one `uhid` device with a report ID | ||
of `0` is created. | ||
|
||
In order to remain compatible with existing `hidapi` APIs, | ||
all the `uhid` devices created by the parent `uhidev` device | ||
must be opened under the same `hid_device` instance to ensure | ||
that we can route reports to their appropriate `uhid` device. | ||
|
||
Internally the `uhid` driver will insert the report ID as | ||
needed so we must also omit the report ID in any situation | ||
where the `hidapi` API expects it to be included in the | ||
report data stream. | ||
|
||
Given the design of `uhid`, it must be augmented with extra | ||
platform specific APIs to ensure that the exact relationship | ||
between `uhidev` devices and `uhid` devices can be determined. | ||
|
||
The NetBSD implementation does this via the `drvctl` kernel | ||
driver. At present there is no known way to do this on OpenBSD | ||
for a `uhid` implementation to be at the same level as the | ||
NetBSD one. |
Oops, something went wrong.