From MozillaWiki
Jump to: navigation, search

WebUSB provides a way for USB device drivers to be implemented in pure JavaScript.

Basic usage strategy:

Create a MozUSBManager in order to claim specific device types and begin receiving events related to them. Once a device type is claimed, you can respond to the 'attachdevice' event by sending and receiving data over the device's endpoints.


var usbm = new MozUSBManager();
var descriptor = {
  deviceClass: n,
  deviceSubClass: n,
  deviceProtocol: n,
  deviceVendor: n,
  deviceProduct: n

usbm.addEventListener("attachdevice", function () {
  // ...
usbm.addEventListener("detachdevice", function () {
  // ...