Streaming HID events in Node.js
Streaming HID Events in Node.js
Wraps node-hid with several parsers for common HID devices, specifically, keyboard-like devices.
Data parsers are available for:
- raw: passes the data as reported by
- keyboard: for keyboard-like devices.
- newline: for keyboard-like devices where events are emitted on new-lines. (e.g. many barcode scanners, etc.)
var hid = require'hidstream';var dev = '0001:001:00' parser : hidparserkeyboard ;devon"data"console.logdat; // easily consumed data format!;
The user has pressed Ctrl + Alt + Del
modifiers :l_shift : falsel_control : truel_alt : truel_meta : falser_ctrl : falser_shift : falser_alt : falser_meta : falsekeyCodes :76keyChars :errorStatus : false
The data packet has additional convenience methods,
meta() which return true if either the left or right key are down. The function
mod() returns true if any of the modifier keys is pressed.
empty() returns true if there is no modifier or key currently down.
The user has pressed w, a, s & d (simultaneously (why? I don't know))
modifiers :l_shift : falsel_control : truel_alt : truel_meta : falser_ctrl : falser_shift : falser_alt : falser_meta : falsekeyCodes:26 4 22 7charCodes:'w' 'a' 's' 'd'errorStatus: false
Right now, hidstream is only parsing keyboard events, and has no awareness of HID feature reports.
After keyboard events are being parsed properly (and fully), I will add support for feature reports and other devices such as mice.
Significant refactor contributed by @kubat