| Index: tools/dom/src/chrome/usb.dart
|
| diff --git a/tools/dom/src/chrome/usb.dart b/tools/dom/src/chrome/usb.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bb0764665e642756aeee7072d63378f069b85a68
|
| --- /dev/null
|
| +++ b/tools/dom/src/chrome/usb.dart
|
| @@ -0,0 +1,401 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +// Generated from namespace: usb
|
| +
|
| +part of chrome;
|
| +
|
| +/**
|
| + * Types
|
| + */
|
| +
|
| +class UsbDevice extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + UsbDevice({int handle, int vendorId, int productId}) {
|
| + if (?handle)
|
| + this.handle = handle;
|
| + if (?vendorId)
|
| + this.vendorId = vendorId;
|
| + if (?productId)
|
| + this.productId = productId;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + UsbDevice._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + int get handle => JS('int', '#.handle', this._jsObject);
|
| +
|
| + void set handle(int handle) {
|
| + JS('void', '#.handle = #', this._jsObject, handle);
|
| + }
|
| +
|
| + int get vendorId => JS('int', '#.vendorId', this._jsObject);
|
| +
|
| + void set vendorId(int vendorId) {
|
| + JS('void', '#.vendorId = #', this._jsObject, vendorId);
|
| + }
|
| +
|
| + int get productId => JS('int', '#.productId', this._jsObject);
|
| +
|
| + void set productId(int productId) {
|
| + JS('void', '#.productId = #', this._jsObject, productId);
|
| + }
|
| +
|
| +}
|
| +
|
| +class UsbControlTransferInfo extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + UsbControlTransferInfo({String direction, String recipient, String requestType, int request, int value, int index, int length, String data}) {
|
| + if (?direction)
|
| + this.direction = direction;
|
| + if (?recipient)
|
| + this.recipient = recipient;
|
| + if (?requestType)
|
| + this.requestType = requestType;
|
| + if (?request)
|
| + this.request = request;
|
| + if (?value)
|
| + this.value = value;
|
| + if (?index)
|
| + this.index = index;
|
| + if (?length)
|
| + this.length = length;
|
| + if (?data)
|
| + this.data = data;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + UsbControlTransferInfo._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// The direction of this transfer.
|
| + String get direction => JS('String', '#.direction', this._jsObject);
|
| +
|
| + void set direction(String direction) {
|
| + JS('void', '#.direction = #', this._jsObject, direction);
|
| + }
|
| +
|
| + /// The intended recipient for this transfer.
|
| + String get recipient => JS('String', '#.recipient', this._jsObject);
|
| +
|
| + void set recipient(String recipient) {
|
| + JS('void', '#.recipient = #', this._jsObject, recipient);
|
| + }
|
| +
|
| + /// The type of this request.
|
| + String get requestType => JS('String', '#.requestType', this._jsObject);
|
| +
|
| + void set requestType(String requestType) {
|
| + JS('void', '#.requestType = #', this._jsObject, requestType);
|
| + }
|
| +
|
| + int get request => JS('int', '#.request', this._jsObject);
|
| +
|
| + void set request(int request) {
|
| + JS('void', '#.request = #', this._jsObject, request);
|
| + }
|
| +
|
| + int get value => JS('int', '#.value', this._jsObject);
|
| +
|
| + void set value(int value) {
|
| + JS('void', '#.value = #', this._jsObject, value);
|
| + }
|
| +
|
| + int get index => JS('int', '#.index', this._jsObject);
|
| +
|
| + void set index(int index) {
|
| + JS('void', '#.index = #', this._jsObject, index);
|
| + }
|
| +
|
| + /// If this transfer is an input transfer, then this field must be set to
|
| + /// indicate the expected data length. If this is an output transfer, then this
|
| + /// field is ignored.
|
| + int get length => JS('int', '#.length', this._jsObject);
|
| +
|
| + void set length(int length) {
|
| + JS('void', '#.length = #', this._jsObject, length);
|
| + }
|
| +
|
| + /// The data payload carried by this transfer. If this is an output tranfer
|
| + /// then this field must be set.
|
| + String get data => JS('String', '#.data', this._jsObject);
|
| +
|
| + void set data(String data) {
|
| + JS('void', '#.data = #', this._jsObject, data);
|
| + }
|
| +
|
| +}
|
| +
|
| +class UsbGenericTransferInfo extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + UsbGenericTransferInfo({String direction, int endpoint, int length, String data}) {
|
| + if (?direction)
|
| + this.direction = direction;
|
| + if (?endpoint)
|
| + this.endpoint = endpoint;
|
| + if (?length)
|
| + this.length = length;
|
| + if (?data)
|
| + this.data = data;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + UsbGenericTransferInfo._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// The direction of this transfer.
|
| + String get direction => JS('String', '#.direction', this._jsObject);
|
| +
|
| + void set direction(String direction) {
|
| + JS('void', '#.direction = #', this._jsObject, direction);
|
| + }
|
| +
|
| + int get endpoint => JS('int', '#.endpoint', this._jsObject);
|
| +
|
| + void set endpoint(int endpoint) {
|
| + JS('void', '#.endpoint = #', this._jsObject, endpoint);
|
| + }
|
| +
|
| + /// If this is an input transfer then this field indicates the size of the
|
| + /// input buffer. If this is an output transfer then this field is ignored.
|
| + int get length => JS('int', '#.length', this._jsObject);
|
| +
|
| + void set length(int length) {
|
| + JS('void', '#.length = #', this._jsObject, length);
|
| + }
|
| +
|
| + /// If this is an output transfer then this field must be populated. Otherwise,
|
| + /// it will be ignored.
|
| + String get data => JS('String', '#.data', this._jsObject);
|
| +
|
| + void set data(String data) {
|
| + JS('void', '#.data = #', this._jsObject, data);
|
| + }
|
| +
|
| +}
|
| +
|
| +class UsbIsochronousTransferInfo extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + UsbIsochronousTransferInfo({UsbGenericTransferInfo transferInfo, int packets, int packetLength}) {
|
| + if (?transferInfo)
|
| + this.transferInfo = transferInfo;
|
| + if (?packets)
|
| + this.packets = packets;
|
| + if (?packetLength)
|
| + this.packetLength = packetLength;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + UsbIsochronousTransferInfo._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// All of the normal transfer parameters are encapsulated in the transferInfo
|
| + /// parameters. Note that the data specified in this parameter block is split
|
| + /// along packetLength boundaries to form the individual packets of the
|
| + /// transfer.
|
| + UsbGenericTransferInfo get transferInfo => new UsbGenericTransferInfo._proxy(JS('', '#.transferInfo', this._jsObject));
|
| +
|
| + void set transferInfo(UsbGenericTransferInfo transferInfo) {
|
| + JS('void', '#.transferInfo = #', this._jsObject, convertArgument(transferInfo));
|
| + }
|
| +
|
| + /// The total number of packets in this transfer.
|
| + int get packets => JS('int', '#.packets', this._jsObject);
|
| +
|
| + void set packets(int packets) {
|
| + JS('void', '#.packets = #', this._jsObject, packets);
|
| + }
|
| +
|
| + /// The length of each of the packets in this transfer.
|
| + int get packetLength => JS('int', '#.packetLength', this._jsObject);
|
| +
|
| + void set packetLength(int packetLength) {
|
| + JS('void', '#.packetLength = #', this._jsObject, packetLength);
|
| + }
|
| +
|
| +}
|
| +
|
| +class UsbTransferResultInfo extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + UsbTransferResultInfo({int resultCode, String data}) {
|
| + if (?resultCode)
|
| + this.resultCode = resultCode;
|
| + if (?data)
|
| + this.data = data;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + UsbTransferResultInfo._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + /// A value of 0 indicates that the transfer was a success. Other values
|
| + /// indicate failure.
|
| + int get resultCode => JS('int', '#.resultCode', this._jsObject);
|
| +
|
| + void set resultCode(int resultCode) {
|
| + JS('void', '#.resultCode = #', this._jsObject, resultCode);
|
| + }
|
| +
|
| + /// If the transfer was an input transfer then this field will contain all of
|
| + /// the input data requested.
|
| + String get data => JS('String', '#.data', this._jsObject);
|
| +
|
| + void set data(String data) {
|
| + JS('void', '#.data = #', this._jsObject, data);
|
| + }
|
| +
|
| +}
|
| +
|
| +class UsbFindDevicesOptions extends ChromeObject {
|
| + /*
|
| + * Public constructor
|
| + */
|
| + UsbFindDevicesOptions({int vendorId, int productId}) {
|
| + if (?vendorId)
|
| + this.vendorId = vendorId;
|
| + if (?productId)
|
| + this.productId = productId;
|
| + }
|
| +
|
| + /*
|
| + * Private constructor
|
| + */
|
| + UsbFindDevicesOptions._proxy(_jsObject) : super._proxy(_jsObject);
|
| +
|
| + /*
|
| + * Public accessors
|
| + */
|
| + int get vendorId => JS('int', '#.vendorId', this._jsObject);
|
| +
|
| + void set vendorId(int vendorId) {
|
| + JS('void', '#.vendorId = #', this._jsObject, vendorId);
|
| + }
|
| +
|
| + int get productId => JS('int', '#.productId', this._jsObject);
|
| +
|
| + void set productId(int productId) {
|
| + JS('void', '#.productId = #', this._jsObject, productId);
|
| + }
|
| +
|
| +}
|
| +
|
| +/**
|
| + * Functions
|
| + */
|
| +
|
| +class API_usb {
|
| + /*
|
| + * API connection
|
| + */
|
| + Object _jsObject;
|
| +
|
| + /*
|
| + * Functions
|
| + */
|
| + /// Finds the first instance of the USB device specified by the vendorId/
|
| + /// productId pair and, if permissions allow, opens it for use. Upon
|
| + /// successfully opening a device the callback is invoked with a populated
|
| + /// Device object. On failure, the callback is invoked with null.
|
| + void findDevices(UsbFindDevicesOptions options, void callback(List<UsbDevice> device)) {
|
| + void __proxy_callback(device) {
|
| + if (?callback) {
|
| + List<UsbDevice> __proxy_device = new List<UsbDevice>();
|
| + for (var o in device) {
|
| + __proxy_device.add(new UsbDevice._proxy(o));
|
| + }
|
| + callback(__proxy_device);
|
| + }
|
| + }
|
| + JS('void', '#.findDevices(#, #)', this._jsObject, convertArgument(options), convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + /// Closes an open device instance. Invoking operations on a device after it
|
| + /// has been closed is a safe operation, but causes no action to be taken.
|
| + void closeDevice(UsbDevice device, [void callback()]) => JS('void', '#.closeDevice(#, #)', this._jsObject, convertArgument(device), convertDartClosureToJS(callback, 0));
|
| +
|
| + /// Claims an interface on the specified USB device.
|
| + void claimInterface(UsbDevice device, int interfaceNumber, void callback()) => JS('void', '#.claimInterface(#, #, #)', this._jsObject, convertArgument(device), interfaceNumber, convertDartClosureToJS(callback, 0));
|
| +
|
| + /// Releases a claim to an interface on the provided device.
|
| + void releaseInterface(UsbDevice device, int interfaceNumber, void callback()) => JS('void', '#.releaseInterface(#, #, #)', this._jsObject, convertArgument(device), interfaceNumber, convertDartClosureToJS(callback, 0));
|
| +
|
| + /// Selects an alternate setting on a previously claimed interface on a device.
|
| + void setInterfaceAlternateSetting(UsbDevice device, int interfaceNumber, int alternateSetting, void callback()) => JS('void', '#.setInterfaceAlternateSetting(#, #, #, #)', this._jsObject, convertArgument(device), interfaceNumber, alternateSetting, convertDartClosureToJS(callback, 0));
|
| +
|
| + /// Performs a control transfer on the specified device. See the
|
| + /// ControlTransferInfo structure for the parameters required to make a
|
| + /// transfer.
|
| + void controlTransfer(UsbDevice device, UsbControlTransferInfo transferInfo, void callback(UsbTransferResultInfo info)) {
|
| + void __proxy_callback(info) {
|
| + if (?callback) {
|
| + callback(new UsbTransferResultInfo._proxy(info));
|
| + }
|
| + }
|
| + JS('void', '#.controlTransfer(#, #, #)', this._jsObject, convertArgument(device), convertArgument(transferInfo), convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + /// Performs a bulk transfer on the specified device.
|
| + void bulkTransfer(UsbDevice device, UsbGenericTransferInfo transferInfo, void callback(UsbTransferResultInfo info)) {
|
| + void __proxy_callback(info) {
|
| + if (?callback) {
|
| + callback(new UsbTransferResultInfo._proxy(info));
|
| + }
|
| + }
|
| + JS('void', '#.bulkTransfer(#, #, #)', this._jsObject, convertArgument(device), convertArgument(transferInfo), convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + /// Performs an interrupt transfer on the specified device.
|
| + void interruptTransfer(UsbDevice device, UsbGenericTransferInfo transferInfo, void callback(UsbTransferResultInfo info)) {
|
| + void __proxy_callback(info) {
|
| + if (?callback) {
|
| + callback(new UsbTransferResultInfo._proxy(info));
|
| + }
|
| + }
|
| + JS('void', '#.interruptTransfer(#, #, #)', this._jsObject, convertArgument(device), convertArgument(transferInfo), convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + /// Performs an isochronous transfer on the specific device.
|
| + void isochronousTransfer(UsbDevice device, UsbIsochronousTransferInfo transferInfo, void callback(UsbTransferResultInfo info)) {
|
| + void __proxy_callback(info) {
|
| + if (?callback) {
|
| + callback(new UsbTransferResultInfo._proxy(info));
|
| + }
|
| + }
|
| + JS('void', '#.isochronousTransfer(#, #, #)', this._jsObject, convertArgument(device), convertArgument(transferInfo), convertDartClosureToJS(__proxy_callback, 1));
|
| + }
|
| +
|
| + API_usb(this._jsObject) {
|
| + }
|
| +}
|
|
|