Can I access USB HID device via a Chrome App?

2020-07-18 05:11发布

I have a simple little dongle I want to debug by sending/receiving basic USB messages. It enumerates as an HID device (like an additional mouse), but am worried that I won't have access to it. I forgot the hardware and can't test with it for a couple days.

Is it a futile effort to continue building a chrome extension to test it?

Chrome App, USB documentation: https://developer.chrome.com/apps/app_usb Getting-started example: https://github.com/GoogleChrome/chrome-app-samples/tree/master/usb/knob

2条回答
姐就是有狂的资本
2楼-- · 2020-07-18 05:46

You can't build a Chrome Extension to use that API, only Apps are allowed access.

That said, the JS side of things will probably not be the hard part, the example you linked provides an ample starting point. But I can't quickly find a ready library to do so, so prepare for relatively low-level hardware stuff.

Edit: Seems like there will be an API for that: https://code.google.com/p/chromium/issues/detail?id=290428

查看更多
▲ chillily
3楼-- · 2020-07-18 06:00

Google Chrome now proposes a USB HID API. Have a look at the API: https://developer.chrome.com/apps/hid

The API is still defined as experimental at the time of this message. But it is functional. I have just written a tutorial to explain how to use this API.

Have a look: http://www.appnearme.com/blog/2014/7/21/chrome-usb-hid-controlling-your-usb-device-javascr/

查看更多
登录 后发表回答