Update: 更新 Web USB

This commit is contained in:
王立帮
2024-12-20 18:51:04 +08:00
parent 03211cb1b2
commit 8727b62cb2
17 changed files with 1428 additions and 583 deletions

View File

@@ -119,9 +119,9 @@ class WebHID extends Serial {
async #addReadEventListener_() {
this.#device_.oninputreport = (event) => {
const { data, reportId } = event;
const length = Math.min(data.getUint8(0), data.byteLength);
const length = Math.min(data.getUint8(0) + 1, data.byteLength);
let buffer = [];
for (let i = 1; i <= length; i++) {
for (let i = 1; i < length; i++) {
buffer.push(data.getUint8(i));
}
this.onBuffer(buffer);