{"id":13522320,"url":"https://github.com/node-hid/node-hid","last_synced_at":"2025-05-14T04:00:38.757Z","repository":{"id":37951156,"uuid":"1817376","full_name":"node-hid/node-hid","owner":"node-hid","description":"Access USB \u0026 Bluetooth HID devices through Node.js","archived":false,"fork":false,"pushed_at":"2025-04-21T18:58:02.000Z","size":548,"stargazers_count":1523,"open_issues_count":78,"forks_count":285,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-04-23T18:58:32.549Z","etag":null,"topics":["electron","hid","nodejs","usb"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-hid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-bsd.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-05-29T12:35:44.000Z","updated_at":"2025-04-21T20:33:00.000Z","dependencies_parsed_at":"2023-11-23T21:31:26.435Z","dependency_job_id":"8e1b5b00-0e06-43a8-a8d5-9fbf1fd1a69f","html_url":"https://github.com/node-hid/node-hid","commit_stats":{"total_commits":487,"total_committers":44,"mean_commits":"11.068181818181818","dds":0.4496919917864476,"last_synced_commit":"dfbfdc0b3e2b6f5f9e19ffb97437540c1fafb700"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-hid%2Fnode-hid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-hid%2Fnode-hid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-hid%2Fnode-hid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-hid%2Fnode-hid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-hid","download_url":"https://codeload.github.com/node-hid/node-hid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250496976,"owners_count":21440231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","hid","nodejs","usb"],"created_at":"2024-08-01T06:00:45.649Z","updated_at":"2025-04-23T18:58:43.632Z","avatar_url":"https://github.com/node-hid.png","language":"C++","readme":"# node-hid - Access USB HID devices from Node.js #\n\n[![npm](https://img.shields.io/npm/dm/node-hid.svg?maxAge=2592000)](http://npmjs.com/package/node-hid)\n[![Prebuild](https://github.com/node-hid/node-hid/actions/workflows/build.yml/badge.svg)](https://github.com/node-hid/node-hid/actions/workflows/build.yml)\n\n\n* [node-hid - Access USB HID devices from Node.js](#node-hid---access-usb-hid-devices-from-nodejs)\n  * [Platform Support](#platform-support)\n     * [Supported Platforms](#supported-platforms)\n     * [Supported Node versions](#supported-node-versions)\n     * [Supported Electron versions](#supported-electron-versions)\n  * [Installation](#installation)\n     * [Installation Special Cases](#installation-special-cases)\n  * [Examples](#examples)\n  * [Async API Usage](#async-api-usage)\n  * [Sync API Usage](#sync-api-usage)\n  * [Complete Async API](#complete-async-api)\n  * [Complete Sync API](#complete-sync-api)\n  * [General notes:](#general-notes)\n     * [Thread safety, Worker threads, Context-aware modules](#thread-safety-worker-threads-context-aware-modules)\n     * [Devices node-hid cannot read](#devices-node-hid-cannot-read)\n  * [Mac notes](#mac-notes)\n  * [Windows notes](#windows-notes)\n     * [Xbox 360 Controller on Windows 10](#xbox-360-controller-on-windows-10)\n  * [Linux notes](#linux-notes)\n     * [udev device permissions](#udev-device-permissions)\n     * [Selecting driver type](#selecting-driver-type)\n  * [Compiling from source](#compiling-from-source)\n     * [Linux (kernel 2.6 ) : (install examples shown for Debian/Ubuntu)](#linux-kernel-26--install-examples-shown-for-debianubuntu)\n     * [FreeBSD](#freebsd)\n     * [Mac OS X 10.8 ](#mac-os-x-108)\n     * [Windows 7, 8, 10](#windows-7-8-10)\n     * [Building node-hid from source, for your projects](#building-node-hid-from-source-for-your-projects)\n     * [Build node-hid for \u003ccode\u003enode-hid\u003c/code\u003e development](#build-node-hid-for-node-hid-development)\n     * [Building node-hid for cross-compiling](#building-node-hid-for-cross-compiling)\n  * [Electron projects using node-hid](#electron-projects-using-node-hid)\n  * [NW.js projects using node-hid](#nwjs-projects-using-node-hid)\n  * [Support](#support)\n\n## Platform Support\n`node-hid` currently supports Node.js v10 and upwards. For versions before that, you will need to use an older version.\nThe platforms, architectures and node versions `node-hid` supports are the following.\nIn general we try to provide pre-built native library binaries for the most common platforms, Node and Electron versions.\n\nWe strive to make `node-hid` cross-platform so there's a good chance any\ncombination not listed here will compile and work.\n\n### Supported Platforms ###\n- Windows x86 (32-bit)\n- Windows x64 (64-bit)\n- Mac OSX 10.9+\n- Linux x64 (²)\n- Linux x86 (¹)\n- Linux ARM / Raspberry Pi / Various SBC (²)\n- Linux ARM64 / Various SBC (²)\n- Linux MIPSel (¹)\n- Linux PPC64 (¹)\n\n¹ prebuilt-binaries not provided for these platforms  \n² prebuilt binary built on Debian 10 Buster\n\n### Supported Node versions ###\n\n* Node v10 to\n* Node v20\n\n### Supported Electron versions ###\n\n* Electron v3 to\n* Electron v24\n\nFuture versions of Node or Electron should work with no extra work, since `node-hid` is now based on NAPI.\n\n## Installation\n\nFor most \"standard\" use cases (macOS, Windows, Linux x86), `node-hid` will install like a standard npm package:\n\n```\nnpm install node-hid\n```\n\nIf you install globally, the test program `src/show-devices.js` is installed as `hid-showdevices`. On Linux you can use it to try the difference between `hidraw` and `libusb` driverTypes:\n```\n$ npm install -g node-hid\n$ hid-showdevices libusb\n$ hid-showdevices hidraw\n```\n\n### Installation Special Cases\n\nWe are using [prebuild](https://github.com/mafintosh/prebuild) to compile and post binaries of the library for most common use cases (Linux, MacOS, Windows on standard processor platforms). If a prebuild is not available, `node-hid` will work, but `npm install node-hid` will compile the binary when you install.  For more details on compiler setup, see  [Compling from source](#compiling-from-source) below.\n\n## Examples\n\nIn the `src/` directory, various JavaScript programs can be found\nthat talk to specific devices in some way.  Some interesting ones:\n- [`show-devices.js`](./src/show-devices.js) - display all HID devices in the system\n- [`test-ps3-rumbleled.js`](./src/test-ps3-rumbleled.js) - Read PS3 joystick and control its LED \u0026 rumblers\n- [`test-powermate.js`](./src/test-powermate.js) - Read Griffin PowerMate knob and change its LED\n- [`test-blink1.js`](./src/test-blink1.js) - Fade colors on blink(1) RGB LED\n- [`test-bigredbutton.js`](./src/test-bigredbutton.js) - Read Dreamcheeky Big Red Button\n- [`test-teensyrawhid.js`](./src/test-teensyrawhid.js) - Read/write Teensy running RawHID \"Basic\" Arduino sketch\n\nTo try them out, run them with `node src/showdevices.js` from within the node-hid directory.\n\n----\n## Async vs sync API\n\nSince 3.0.0, `node-hid` supports both the old synchronous api, and a newer async api.\nIt is recommended to use the async api to avoid `node-hid` from blocking your code from executing. For prototyping or tiny applications, this likely will not matter, but for npm libraries or larger applications it can be problematic.\n\nAdditionally, the sync api is limited to only beind able to read up to the `UV_THREADPOOL_SIZE` (default is 4) number of devices at once. Reading from multiple could degrade performance of your application, as there will be fewer than expected uv workers available for nodejs and other libraries to use for other tasks.\n\nThe async API is identical to the sync API described below, except every method returns a `Promise` that must be handled. Any unhandled promise can crash your application.\n\nIt is safe to use the sync api for some devices in an application, and the async api for other devices. The thread safety of `hidapi` is handled for you here to avoid crashes.\n\n## Cost of `HID.devices()`, `HID.devicesAsync()`, `new HID.HID()` and `HIDAsync.open()` for detecting device plug/unplug\nAll of `HID.devices()`, `HID.devicesAsync()`, `new HID.HID()` and `HIDAsync.open()` are relatively costly, each causing a USB (and potentially Bluetooth) enumeration. This takes time and OS resources. Doing either can slow down the read/write that you do in parallel with a device, and cause other USB devices to slow down too. This is how USB works.\n\nIf you are polling `HID.devices()` or `HID.devicesAsync()` or other inefficient methods to detect device plug / unplug, consider instead using [node-usb](https://github.com/node-usb/node-usb#usbdetection). `node-usb` uses OS-specific, non-bus enumeration ways to detect device plug / unplug.\n\n\n## Async API Usage\n\n### List all HID devices connected\n\n```js\nvar HID = require('node-hid');\nvar devices = await HID.devicesAsync();\n```\n\n`devices` will contain an array of objects, one for each HID device\navailable.  Of particular interest are the `vendorId` and\n`productId`, as they uniquely identify a device, and the\n`path`, which is needed to open a particular device.\n\nSample output:\n\n```js\nawait HID.devicesAsync();\n{ vendorId: 10168,\n    productId: 493,\n    path: 'IOService:/AppleACPIPl...HIDDevice@14210000,0',\n    serialNumber: '20002E8C',\n    manufacturer: 'ThingM',\n    product: 'blink(1) mk2',\n    release: 2,\n    interface: -1,\n    usagePage: 65280,\n    usage: 1 },\n  { vendorId: 1452,\n    productId: 610,\n    path: 'IOService:/AppleACPIPl...Keyboard@14400000,0',\n    serialNumber: '',\n    manufacturer: 'Apple Inc.',\n    product: 'Apple Internal Keyboard / Trackpad',\n    release: 549,\n    interface: -1,\n    usagePage: 1,\n    usage: 6 },\n    \u003cand more\u003e\n```\n\n\n### Opening a device\n\nBefore a device can be read from or written to, it must be opened.\nUse either the `path` from the list returned by a prior call to `HID.devicesAsync()`:\n\n```js\nvar device = await HID.HIDAsync.open(path);\n```\n\nor open the first device matching a VID/PID pair:\n\n```js\nvar device = await HID.HIDAsync.open(vid,pid);\n```\n\nThe `device` variable will contain a handle to the device.\nIf an error occurs opening the device, an exception will be thrown.\n\nA `node-hid` device is an `EventEmitter`.\nWhile it shares some method names and usage patterns with\n`Readable` and `Writable` streams, it is not a stream and the semantics vary.\nFor example, `device.write` does not take encoding or callback args and\n`device.pause` does not do the same thing as `readable.pause`.\nThere is also no `pipe` method.\n\n### Reading from a device\n\nTo receive FEATURE reports, use `await device.getFeatureReport()`.\n\nTo receive INPUT reports, use `device.on(\"data\",...)`.\nA `node-hid` device is an EventEmitter.\nReading from a device is performed by registering a \"data\" event handler:\n\n```js\ndevice.on(\"data\", function(data) {});\n```\n\nYou can also listen for errors like this:\n\n```js\ndevice.on(\"error\", function(err) {});\n```\nFor FEATURE reports:\n\n```js\nvar buf = await device.getFeatureReport(reportId, reportLength)\n```\n\n\nNotes:\n- Reads via `device.on(\"data\")` are asynchronous\n- To remove an event handler, close the device with `device.close()`\n- When there is not yet a data handler or no data handler exists,\n   data is not read at all -- there is no buffer.\n\n### Writing to a device\n\nTo send FEATURE reports, use `device.sendFeatureReport()`.  \n\nTo send OUTPUT reports, use `device.write()`.\n\nThe ReportId is the first byte of the array sent to `device.sendFeatureReport()` or `device.write()`, meaning the array should be one byte bigger than your report.\nIf your device does NOT use numbered reports, set the first byte of the 0x00.\n\n\n```js\ndevice.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]);\n```\n```js\ndevice.sendFeatureReport( [0x01, 'c', 0, 0xff,0x33,0x00, 70,0, 0] );\n```\nNotes:\n- All writes and other operations performed with the HIDAsync device are done in a work-queue, so will happen in the order you issue them with the returned `Promise` resolving once the operation is completed\n- You must send the exact number of bytes for your chosen OUTPUT or FEATURE report.\n- Both `device.write()` and `device.sendFeatureReport()` return a Promise containing the number of bytes written + 1.\n- For devices using Report Ids, the first byte of the array to `write()` or `sendFeatureReport()` must be the Report Id.\n\n\n## Sync API Usage\n\n### List all HID devices connected\n\n```js\nvar HID = require('node-hid');\nvar devices = HID.devices();\n```\n\n`devices` will contain an array of objects, one for each HID device\navailable.  Of particular interest are the `vendorId` and\n`productId`, as they uniquely identify a device, and the\n`path`, which is needed to open a particular device.\n\nSample output:\n\n```js\nHID.devices();\n{ vendorId: 10168,\n    productId: 493,\n    path: 'IOService:/AppleACPIPl...HIDDevice@14210000,0',\n    serialNumber: '20002E8C',\n    manufacturer: 'ThingM',\n    product: 'blink(1) mk2',\n    release: 2,\n    interface: -1,\n    usagePage: 65280,\n    usage: 1 },\n  { vendorId: 1452,\n    productId: 610,\n    path: 'IOService:/AppleACPIPl...Keyboard@14400000,0',\n    serialNumber: '',\n    manufacturer: 'Apple Inc.',\n    product: 'Apple Internal Keyboard / Trackpad',\n    release: 549,\n    interface: -1,\n    usagePage: 1,\n    usage: 6 },\n    \u003cand more\u003e\n```\n\n\n### Opening a device\n\nBefore a device can be read from or written to, it must be opened.\nUse either the `path` from the list returned by a prior call to `HID.devices()`:\n\n```js\nvar device = new HID.HID(path);\n```\n\nor open the first device matching a VID/PID pair:\n\n```js\nvar device = new HID.HID(vid,pid);\n```\n\nThe `device` variable will contain a handle to the device.\nIf an error occurs opening the device, an exception will be thrown.\n\nA `node-hid` device is an `EventEmitter`.\nWhile it shares some method names and usage patterns with\n`Readable` and `Writable` streams, it is not a stream and the semantics vary.\nFor example, `device.write` does not take encoding or callback args and\n`device.pause` does not do the same thing as `readable.pause`.\nThere is also no `pipe` method.\n\n### Picking a device from the device list\nIf you need to filter down the `HID.devices()` list, you can use\nstandard Javascript array techniques:\n```js\nvar devices = HID.devices();\nvar deviceInfo = devices.find( function(d) {\n    var isTeensy = d.vendorId===0x16C0 \u0026\u0026 d.productId===0x0486;\n    return isTeensy \u0026\u0026 d.usagePage===0xFFAB \u0026\u0026 d.usage===0x200;\n});\nif( deviceInfo ) {\n  var device = new HID.HID( deviceInfo.path );\n  // ... use device\n}\n```\nYou can also find device of interest by passing VID and PID   \n```js\n//return all the devices that match specified VID and PID\nvar devices = HID.devices(0x16C0,0x0486);\n```\n\n### Reading from a device\n\nTo receive FEATURE reports, use `device.getFeatureReport()`.\n\nTo receive INPUT reports, use `device.on(\"data\",...)`.\nA `node-hid` device is an EventEmitter.\nReading from a device is performed by registering a \"data\" event handler:\n\n```js\ndevice.on(\"data\", function(data) {});\n```\n\nYou can also listen for errors like this:\n\n```js\ndevice.on(\"error\", function(err) {});\n```\nFor FEATURE reports:\n\n```js\nvar buf = device.getFeatureReport(reportId, reportLength)\n```\n\n\nNotes:\n- Reads via `device.on(\"data\")` are asynchronous\n- Reads via `device.getFeatureReport()` are synchronous\n- To remove an event handler, close the device with `device.close()`\n- When there is not yet a data handler or no data handler exists,\n   data is not read at all -- there is no buffer.\n\n### Writing to a device\n\nTo send FEATURE reports, use `device.sendFeatureReport()`.  \n\nTo send OUTPUT reports, use `device.write()`.\n\nAll writing is synchronous.\n\nThe ReportId is the first byte of the array sent to `device.sendFeatureReport()` or `device.write()`, meaning the array should be one byte bigger than your report.\nIf your device does NOT use numbered reports, set the first byte of the 0x00.\n\n\n```js\ndevice.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]);\n```\n```js\ndevice.sendFeatureReport( [0x01, 'c', 0, 0xff,0x33,0x00, 70,0, 0] );\n```\nNotes:\n- You must send the exact number of bytes for your chosen OUTPUT or FEATURE report.\n- Both `device.write()` and `device.sendFeatureReport()` return\nnumber of bytes written + 1.\n- For devices using Report Ids, the first byte of the array to `write()` or\n`sendFeatureReport()` must be the Report Id.\n\n\n## Complete Async API\n\n### `devices = await HID.devicesAsync()`\n\n- Return array listing all connected HID devices\n\n### `devices = await HID.devicesAsync(vid,pid)`\n\n- Return array listing all connected HID devices with specific VendorId and ProductId\n\n### `device = await HID.HIDAsync.open(path)`\n\n- Open a HID device at the specified platform-specific path\n\n### `device = await HID.HIDAsync.open(vid,pid)`\n\n- Open first HID device with specific VendorId and ProductId\n\n### `device.on('data', function(data) {} )`\n\n- `data` - Buffer - the data read from the device\n\n### `device.on('error, function(error) {} )`\n\n- `error` - The error Object emitted\n\n### `device.write(data)`\n\n- `data` - the data to be synchronously written to the device,\nfirst byte is Report Id or 0x00 if not using numbered reports.\n- Returns number of bytes actually written\n\n### `device.close()`\n\n- Closes the device. Subsequent reads will raise an error.\n\n### `device.pause()`\n\n- Pauses reading and the emission of `data` events.  \nThis means the underlying device is _silenced_ until resumption --\nit is not like pausing a stream, where data continues to accumulate.\n\n### `device.resume()`\n\n- This method will cause the HID device to resume emmitting `data` events.\nIf no listeners are registered for the `data` event, data will be lost.\n\n- When a `data` event is registered for this HID device, this method will\nbe automatically called.\n\n### `device.read(time_out)`\n\n- (optional) `time_out` - timeout in milliseconds\n- Low-level function call to initiate an asynchronous read from the device.\n- Returns a Promise containing a Buffer or the Promise will reject upon error.\n- This can only be used when `device.on('data', () =\u003e {})` is not being used. It will fail if a data handler is registered\n\n### `device.sendFeatureReport(data)`\n\n- `data` - data of HID feature report, with 0th byte being report_id (`[report_id,...]`)\n- Returns number of bytes actually written\n\n### `device.getFeatureReport(report_id, report_length)`\n\n- `report_id` - HID feature report id to get\n- `report_length` - length of report\n\n### `device.setNonBlocking(no_block)`\n\n- `no_block` - boolean. Set to `true` to enable non-blocking reads\n- exactly mirrors `hid_set_nonblocking()` in [`hidapi`](https://github.com/libusb/hidapi)\n\n\n## Complete Sync API\n\n### `devices = HID.devices()`\n\n- Return array listing all connected HID devices\n\n### `devices = HID.devices(vid,pid)`\n\n- Return array listing all connected HID devices with specific VendorId and ProductId\n\n### `HID.setDriverType(type)`\n  - Linux only\n  - Sets underlying HID driver type\n  - `type` can be `\"hidraw\"` or `\"libusb\"`, defaults to `\"hidraw\"`\n\n### `device = new HID.HID(path)`\n\n- Open a HID device at the specified platform-specific path\n\n### `device = new HID.HID(vid,pid)`\n\n- Open first HID device with specific VendorId and ProductId\n\n### `device.on('data', function(data) {} )`\n\n- `data` - Buffer - the data read from the device\n\n### `device.on('error', function(error) {} )`\n\n- `error` - The error Object emitted\n\n### `device.write(data)`\n\n- `data` - the data to be synchronously written to the device,\nfirst byte is Report Id or 0x00 if not using numbered reports.\n- Returns number of bytes actually written\n\n### `device.close()`\n\n- Closes the device. Subsequent reads will raise an error.\n\n### `device.pause()`\n\n- Pauses reading and the emission of `data` events.  \nThis means the underlying device is _silenced_ until resumption --\nit is not like pausing a stream, where data continues to accumulate.\n\n### `device.resume()`\n\n- This method will cause the HID device to resume emmitting `data` events.\nIf no listeners are registered for the `data` event, data will be lost.\n\n- When a `data` event is registered for this HID device, this method will\nbe automatically called.\n\n### `device.read(callback)`\n\n- Low-level function call to initiate an asynchronous read from the device.\n- `callback` is of the form `callback(err, data)`\n\n### `device.readSync()`\n\n- Return an array of numbers data. If an error occurs, an exception will be thrown.\n\n### `device.readTimeout(time_out)`\n\n- `time_out` - timeout in milliseconds\n- Return an array of numbers data. If an error occurs, an exception will be thrown.\n\n### `device.sendFeatureReport(data)`\n\n- `data` - data of HID feature report, with 0th byte being report_id (`[report_id,...]`)\n- Returns number of bytes actually written\n\n### `device.getFeatureReport(report_id, report_length)`\n\n- `report_id` - HID feature report id to get\n- `report_length` - length of report\n\n### `device.setNonBlocking(no_block)`\n\n- `no_block` - boolean. Set to `true` to enable non-blocking reads\n- exactly mirrors `hid_set_nonblocking()` in [`hidapi`](https://github.com/libusb/hidapi)\n\n-----\n\n## General notes:\n\n### Thread safety, Worker threads, Context-aware modules\nIn general `node-hid` is not thread-safe because the underlying C-library it wraps (`hidapi`) is not thread-safe.\nTo mitigate this we are doing locking to ensure operations are performed safely. If you are using the sync api from multiple worker_threads, this will result in them waiting on each other at times.\n\n### Devices `node-hid` cannot read\nThe following devices are unavailable to `node-hid` because the OS owns them:\n\n- Keyboards\n- Mice\n- Barcode readers (in USB HID keyboard mode)\n- RFID scanners (in USB HID keyboard mode)\n- Postage Scales (in USB HID keyboard mode)\n\nMost OSes will prevent USB HID keyboards or mice, or devices that appear as a keyboard to the OS.\nThis includes many RFID scanners, barcode readers, USB HID scales, and many other devices.\nThis is a security precaution. Otherwise, it would be trivial to build keyloggers.\n\nSome keyboard-pretending devices like barcode or RFID readers can be configured to be in\n\"HID data\" mode or \"Serial / UART\" mode.  If in \"HID Data\" mode then `node-hid` can access them,\nif in \"Serial / UART\" mode, you should use `node-serialport` instead.\n\n## Mac notes\nSee General notes above Keyboards\n\n## Windows notes\nSee General notes above about Keyboards\n\n### Xbox 360 Controller on Windows 10\nFor reasons similar to mice \u0026 keyboards it appears you can't access this controller on Windows 10.\n\n\n\n## Linux notes\nSee General notes above about Keyboards\n\n### udev device permissions\nMost Linux distros use `udev` to manage access to physical devices,\nand USB HID devices are normally owned by the `root` user.\nTo allow non-root access, you must create a udev rule for the device,\nbased on the devices vendorId and productId.\n\nThis rule is a text file placed in `/etc/udev/rules.d`.  \n\nFor an example HID device (say a blink(1) light with vendorId = 0x27b8 and productId = 0x01ed,\nthe rules file to support both `hidraw` and `libusb` would look like:\n```\nSUBSYSTEM==\"input\", GROUP=\"input\", MODE=\"0666\"\nSUBSYSTEM==\"usb\", ATTRS{idVendor}==\"27b8\", ATTRS{idProduct}==\"01ed\", MODE:=\"666\", GROUP=\"plugdev\"\nKERNEL==\"hidraw*\", ATTRS{idVendor}==\"27b8\", ATTRS{idProduct}==\"01ed\", MODE=\"0666\", GROUP=\"plugdev\"\n```\nNote that the values for idVendor and idProduct must be in hex and lower-case.\n\nSave this file as `/etc/udev/rules.d/51-blink1.rules`, unplug the HID device,\nand reload the rules with:\n```\nsudo udevadm control --reload-rules\n```\n\nFor a complete example, see the\n[blink1 udev rules](https://github.com/todbot/blink1/blob/master/linux/51-blink1.rules).\n\n\n### Selecting driver type\n\nBy default as of `node-hid@0.7.0`, the [hidraw](https://www.kernel.org/doc/Documentation/hid/hidraw.txt) driver is used to talk to HID devices. Before `node-hid@0.7.0`, the more older but less capable [libusb](http://libusb.info/) driver was used.  With `hidraw` Linux apps can now see `usage` and `usagePage` attributes of devices.\n\nIf you would still like to use the `libusb` driver, then you can do either:\n\nDuring runtime, you can use `HID.setDriverType('libusb')` immediately after require()-ing `node-hid`:\n```js\nvar HID = require('node-hid');\nHID.setDriverType('libusb');\n```\n\nIf you must have the libusb version and cannot use `setDriverType()`,\nyou can install older node-hid or build from source:\n```\nnpm install node-hid@0.5.7\n```\nor:\n```\nnpm install node-hid --build-from-source --driver=libusb\n```\n\n\n## Compiling from source\n\nTo compile \u0026 develop locally or if `prebuild` cannot download a pre-built\nbinary for you, you will need the following compiler tools and libraries:\n\n### Linux (kernel 2.6+) : (install examples shown for Debian/Ubuntu)\n  * Compilation tools: `apt install build-essential git pkg-config`\n  * libudev-dev: `apt install libudev-dev` (Debian/Ubuntu) /\n    `yum install libusbx-devel` (Fedora)\n  * libusb-1.0-0 w/headers:`apt install libusb-1.0-0 libusb-1.0-0-dev`\n\n### FreeBSD\n  * Compilation tools: `pkg install git gcc gmake libiconv node npm`\n\n### Mac OS X 10.8+\n  * [Xcode](https://itunes.apple.com/us/app/xcode/id497799835?mt=12)\n\n### Windows 7, 8, 10\n  The below is slightly stale. The 2021 solution is to use the official NodeJs Windows installer\n  and pick \"install native module tools\"\n  * Visual C++ compiler and Python 2.7\n      * either:\n        * `npm install --global windows-build-tools`\n        * add `%USERPROFILE%\\.windows-build-tools\\python27` to `PATH`,\n         like PowerShell: `$env:Path += \";$env:USERPROFILE\\.windows-build-tools\\python27\"`\n      * or:\n        * [Python 2.7](https://www.python.org/downloads/windows/)\n        * [Visual Studio Express 2013 for Desktop](https://www.visualstudio.com/downloads/download-visual-studio-vs#d-2013-express)\n\n\n### Building `node-hid` from source, for your projects\n\n```\nnpm install node-hid --build-from-source\n```\n\n### Build `node-hid` for `node-hid` development\n\n* check out a copy of this repo\n* change into its directory\n* update the submodules\n* build the node package\n\nFor example:\n\n```\ngit clone https://github.com/node-hid/node-hid.git\ncd node-hid                                        # must change into node-hid directory\nnpm install -g rimraf                              # just so it doesn't get 'clean'ed\nnpm run prepublishOnly                             # get the needed hidapi submodule\nnpm install --build-from-source                    # rebuilds the module with C code\nnpm run showdevices                                # list connected HID devices\nnode ./src/show-devices.js                         # same as above\n```\n\nYou may see some warnings from the C compiler as it compiles\n[hidapi](https://github.com/libusb/hidapi) (the underlying C library `node-hid` uses).  \nThis is expected.\n\nFor ease of development, there are also the scripts:\n```\nnpm run gypclean      # \"node-gyp clean\" clean gyp build directory\nnpm run gypconfigure  # \"node-gyp configure\" configure makefiles\nnpm run gypbuild      # \"node-gyp build\" build native code\n```\n\n### Building `node-hid` for cross-compiling\nWhen cross-compiling you need to override `node-hid`'s normal behavior\nof using Linux `pkg-config` to determine CLFAGS and LDFLAGS for `libusb`.\nTo do this, you can use the `node-gyp` variable `node_hid_no_pkg_config`\nand then invoke a `node-hid` rebuild with either:\n```\n  node-gyp rebuild --node_hid_no_pkg_config=1\n```\nor\n```\n  npm gyprebuild --node_hid_no_pkg_config=1\n```\n\n\n## Electron projects using `node-hid`\n\nIf using `node-hid` with `webpack` or similar bundler, you may need to exclude\n`node-hid` and other libraries with native code.  In webpack, you say which\n`externals` you have in your `webpack-config.js`:\n```\n  externals: {\n    \"node-hid\": 'commonjs node-hid'\n  }\n```\n\nExamples of `node-hid` in Electron:\n* [electron-hid-test](https://github.com/todbot/electron-hid-test) - Simple example of using `node-hid`, should track latest Electron release\n* [electron-hid-test-erb](https://github.com/todbot/electron-hid-test-erb) - Simple example of using `node-hid` using [electron-react-boilerplate](https://github.com/electron-react-boilerplate/electron-react-boilerplate/)\n* [electron-hid-toy](https://github.com/todbot/electron-hid-toy) - Simple example of using `node-hid`, showing packaging and signing\n* [Blink1Control2](https://github.com/todbot/Blink1Control2/) - a complete application, using webpack (e.g. see its [webpack-config.js](https://github.com/todbot/Blink1Control2/blob/master/webpack.config.js))\n\n\n## NW.js projects using `node-hid`\n\nWithout knowing much about NW.js, a quick hacky solution that works is:\n\n```\ncd my-nwjs-app\nnpm install node-hid --save\nnpm install -g nw-gyp\ncd node_modules/node-hid\nnw-gyp rebuild --target=0.42.3 --arch=x64  // or whatever NW.js version you have\ncd ../..\nnwjs .\n```\n\n\n## Support\n\nPlease use the [node-hid github issues page](https://github.com/node-hid/node-hid/issues)\nfor support questions and issues.","funding_links":[],"categories":["Inspiration from elsewhere","C++","IoT"],"sub_categories":["Candidates","React Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-hid%2Fnode-hid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-hid%2Fnode-hid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-hid%2Fnode-hid/lists"}