4
edits
Changes
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>
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>