Created
October 24, 2019 00:51
-
-
Save karronoli/15552f76f85869c848f8ae836e90875f to your computer and use it in GitHub Desktop.
[WIP] YUREX Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BAD?