-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop support for USB, HID and Serial device access #198047
base: main
Are you sure you want to change the base?
Conversation
Anything required to progress this PR? |
Is there an associated issue with sufficient upvotes and motion to justify this change? And an explainer about the scenarios this would enable? |
Issue raised here: #236450 |
There are many conflicts in this PR btw. |
TBF, there weren't conflicts when I opened it a year ago and I got tired of keeping it up to date with no feedback. If there is interest in this feature I'll revisit the PR. |
This is a new feature to add USB, HID and Serial device access to the desktop by extending the existing WebUSB, WebHID and WebSerial functionality already offered in the web version #152310.
Since Electron version 25,
Web-*
device access has been possible using the functionality described here: https://www.electronjs.org/docs/latest/tutorial/devicesThis ability is awesome because it allows access to functionality in Chrome already shipped as part of VS Code and means extension developers no longer have to include external packages such as
node-usb
orSerialPort
. In many cases this approach should be more stable and reliable, too (e.g. chrome uses winusb for device access over libusb as used in node-usb).To implement this addition, I've wired up a QuickPick dropdown for the user to choose the requested device leveraging Electron's APIs. Unfortunately the cleanest way I've been able to find to communicate between the
electron-main
and browser process is via the globals API. Happy to hear of a better way.USB Selector:
Serial Selector:
HID Selector:
Please note: As this utilises the existing features in chrome, obtaining a concrete device after authorising it is only possible in the desktop web extension host. Therefore this feature is only available to pure web extensions (those without a
main
entrypoint inpackage.json
).