Changes

Jump to: navigation, search

WebAPI/WebUSB

685 bytes added, 17:21, 30 August 2011
Created page with "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 begi..."
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.

Example:

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

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

usbm.claimDevice(descriptor);
</pre>
4
edits

Navigation menu