Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Keyboard, Keymap.c
void encoder_update_user(int8_t index, bool clockwise) {
char hidBuf[7];
snprintf(hidBuf, 7, "e-%d-%d", index, clockwise);
uint8_t * encHidCode = (uint8_t *)encBuf;
raw_hid_send(encHidCode, 32);
return;
}
// Client App JS
import nodeHid from "node-hid";
const deviceInfo = this.devices.find( function(d) {
const isDevice = d.vendorId===0xFEED && d.productId===0x1701;
return isDevice && d.usagePage===0xFF60 && d.usage===0x61;
});
if(deviceInfo) {
const device = new nodeHid.HID(deviceInfo.path ? deviceInfo.path : '');
this.hidDevice = device;
device.on("data", function(data) {
console.log(data.toString());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment