https://github.com/dbushell/deno_usbhidapi
🦕 Deno FFI bindings for the HIDAPI library to access USB devices.
https://github.com/dbushell/deno_usbhidapi
Last synced: 19 days ago
JSON representation
🦕 Deno FFI bindings for the HIDAPI library to access USB devices.
- Host: GitHub
- URL: https://github.com/dbushell/deno_usbhidapi
- Owner: dbushell
- License: mit
- Created: 2022-09-25T06:27:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-10T12:30:56.000Z (over 1 year ago)
- Last Synced: 2025-07-05T17:08:08.599Z (9 months ago)
- Language: TypeScript
- Homepage:
- Size: 34.2 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🦕 Deno USB HID API
Deno [FFI](https://deno.land/manual/runtime/ffi_api) bindings for the [HIDAPI](https://github.com/libusb/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](https://github.com/libusb/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](https://github.com/libusb/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.
```sh
deno test --unstable --allow-all src/test.ts
```
## Resources
* [libusb/hidapi](https://github.com/libusb/hidapi/) — HIDAPI library for Windows, Linux, FreeBSD and macOS.
* [Foreign Function Interface API](https://deno.land/manual/runtime/ffi_api) — Deno documentation (unstable).
* [WebHID API](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API) — MDN documentation for the native browser spec.
* ["Add support for HID API"](https://github.com/denoland/deno/issues/13893) — Deno issue discussion.
* [littledivy/webusb](https://github.com/littledivy/webusb) — WebUSB API implementation in Rust (and Deno).
* [node-hid](https://github.com/node-hid/node-hid/) — Node.js bindings.
* [Deno Stream Deck](https://github.com/dbushell/deno_streamdeck) — built with this library.
* * *
[MIT License](/LICENSE) | Copyright © 2023 [David Bushell](https://dbushell.com)