v0.3.1
🦕 Deno FFI bindings for the HIDAPI library to access USB devices.
Repository
Current version released
2 years ago
🦕 Deno USB HID API
Deno FFI bindings for the HIDAPI library to access USB devices.
This work in progress uses unstable Deno APIs and requries the --unstable
, --allow-ffi
, and --allow-env
flags.
The module exports hidapi
library symbols and hid
wrapper functions.
Usage
Install or build the HIDAPI library (e.g. brew install hidapi
). Tested with hidapi-0.12.0
.
Set the DENO_USBHIDAPI
environment variable to the dynamic library path.
Homebrew on MacOS installs at:
/opt/homebrew/opt/hidapi/lib/libhidapi.dylib
Building from source on a Raspberry Pi installs at:
/usr/local/lib/libhidapi-hidraw.so
On Windows see HIDAPI Releases (I’ve not tested Windows).
Testing
There is a basic Deno test to check the HIDAPI library defined by the DENO_USBHIDAPI
environment variable.
deno test --unstable --allow-all src/test.ts
Resources
- libusb/hidapi — HIDAPI library for Windows, Linux, FreeBSD and macOS.
- Foreign Function Interface API — Deno documentation (unstable).
- WebHID API — MDN documentation for the native browser spec.
- “Add support for HID API” — Deno issue discussion.
- littledivy/webusb — WebUSB API implementation in Rust (and Deno).
- node-hid — Node.js bindings.
- Deno Stream Deck — built with this library.
License
MIT License
MIT License | Copyright © 2022 David Bushell | @dbushell