Skip to content

Instantly share code, notes, and snippets.

@karronoli
Created October 24, 2019 00:51
Show Gist options
  • Save karronoli/15552f76f85869c848f8ae836e90875f to your computer and use it in GitHub Desktop.
Save karronoli/15552f76f85869c848f8ae836e90875f to your computer and use it in GitHub Desktop.
[WIP] YUREX Test
// https://github.com/WICG/webhid/blob/master/EXPLAINER.md
// Enable chrome://flags/#enable-experimental-web-platform-features
// Bus 020 Device 000: ID 0c45:1010 Sonix Technology Co., Ltd. YUREX
let deviceFilter = { vendorId: 0x0c45, productId: 0x1010 };
let requestParams = { filters: [deviceFilter] };
let initReport = new Uint8Array(8).fill(0xff);
initReport[0] = 0x52;
initReport[1] = 0x0d;
function handleInputReport(e) {
// debugger;
for (var i = 0; i < e.data.byteLength; ++i) { console.log(e.data.getInt8(i)); }
}
let device = await navigator.hid.requestDevice(requestParams);
device.open().then(() => {
console.log('Opened HID device');
device.addEventListener('inputreport', handleInputReport);
device.sendReport(0x0, initReport).then(() => {
console.log('Sent initialization packet');
});
});
@karronoli
Copy link
Author

BAD?

Opened HID device
VM1442:5 Sent initialization packet
VM1432:3 82
5VM1432:3 -1
VM1432:3 13
VM1432:3 0
VM1432:3 33
VM1432:3 82
VM1432:3 13
5VM1432:3 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment