【问题标题】:WebHID API: disconnect event not triggeringWebHID API:断开连接事件未触发
【发布时间】:2020-05-12 18:19:11
【问题描述】:

我正在尝试使用 WebHID API 从 USB HID 设备获取断开连接事件。

代码:

const devices = await navigator.hid.requestDevice({

    filters: [{vendorId: 'some_vendor_id'}]
,
});

const device = devices[0];




console.log(`HID connected: ${device.productName}`);


if (!device.opened) {
    await device.open();

}



navigator.hid.addEventListener('disconnect', device => {

    console.log(`HID disconnected: ${device.productName}`);

});

设备连接成功,但在关闭或与计算机断开连接后,不会触发disconnect事件。

我做错了什么还是一个错误?

【问题讨论】:

标签: javascript google-chrome webusb webhid


【解决方案1】:

这些事件尚未实施。我已经提交了an issue 来帮助跟踪。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-29
    • 2014-04-03
    • 2011-11-03
    • 2014-01-08
    • 2015-03-25
    • 2018-01-28
    • 2016-09-20
    • 1970-01-01
    相关资源
    最近更新 更多