Commit 28bf1990 authored by reillyg's avatar reillyg Committed by Commit bot

Fix small inaccuracies in the HID API documentation.

Fix typos related to which functions send or receive data. Some of these
were already resolved in 1816af67d3fb992ff49fb22b2b8fc8908d6ee6b1. Also
document where the opaque device ID and connection IDs should be used
and how errors are reported.

BUG=392036

Review URL: https://codereview.chromium.org/518133004

Cr-Commit-Position: refs/heads/master@{#292745}
parent c46e9a96
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
// Use the <code>chrome.hid</code> API to interact with connected HID devices. // Use the <code>chrome.hid</code> API to interact with connected HID devices.
// This API provides access to HID operations from within the context of an app. // This API provides access to HID operations from within the context of an app.
// Using this API, apps can function as drivers for hardware devices. // Using this API, apps can function as drivers for hardware devices.
//
// Errors generated by this API are reported by setting
// $(ref:runtime.lastError) and executing the function's regular callback. The
// callback's regular parameters will be undefined in this case.
namespace hid { namespace hid {
dictionary HidCollectionInfo { dictionary HidCollectionInfo {
// HID usage page identifier. // HID usage page identifier.
...@@ -16,7 +20,7 @@ namespace hid { ...@@ -16,7 +20,7 @@ namespace hid {
}; };
[noinline_doc] dictionary HidDeviceInfo { [noinline_doc] dictionary HidDeviceInfo {
// Device opaque ID. // Opaque device ID.
long deviceId; long deviceId;
// Vendor ID. // Vendor ID.
long vendorId; long vendorId;
...@@ -32,9 +36,8 @@ namespace hid { ...@@ -32,9 +36,8 @@ namespace hid {
long maxFeatureReportSize; long maxFeatureReportSize;
}; };
// Returned by <code>connect</code> to represent a communication session with
// an HID device. Must be closed with a call to <code>disconnect</code>.
dictionary HidConnectInfo { dictionary HidConnectInfo {
// The opaque ID used to identify this connection in all other functions.
long connectionId; long connectionId;
}; };
...@@ -63,7 +66,7 @@ namespace hid { ...@@ -63,7 +66,7 @@ namespace hid {
callback ConnectCallback = void (HidConnectInfo connection); callback ConnectCallback = void (HidConnectInfo connection);
callback DisconnectCallback = void (); callback DisconnectCallback = void ();
// |reportId|: The ID of the report. // |reportId|: The report ID or <code>0</code> if none.
// |data|: The content of the report. // |data|: The content of the report.
callback ReceiveCallback = void (long reportId, ArrayBuffer data); callback ReceiveCallback = void (long reportId, ArrayBuffer data);
...@@ -79,29 +82,23 @@ namespace hid { ...@@ -79,29 +82,23 @@ namespace hid {
GetDevicesCallback callback); GetDevicesCallback callback);
// Open a connection to an HID device for communication. // Open a connection to an HID device for communication.
// |deviceId|: The ID of the device to open. // |deviceId|: The $(ref:HidDeviceInfo.deviceId) of the device to open.
static void connect(long deviceId, static void connect(long deviceId,
ConnectCallback callback); ConnectCallback callback);
// Disconnect from a device. Invoking operations on a device after calling // Disconnect from a device. Invoking operations on a device after calling
// this is safe but has no effect. // this is safe but has no effect.
// |connectionId|: The connection to close. // |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
static void disconnect(long connectionId, static void disconnect(long connectionId,
optional DisconnectCallback callback); optional DisconnectCallback callback);
// Receive an Input report from an HID device. // Receive the next input report from the device.
// // |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
// Input reports are returned to the host through the INTERRUPT IN endpoint.
// |connectionId|: The connection from which to receive a report.
static void receive(long connectionId, static void receive(long connectionId,
ReceiveCallback callback); ReceiveCallback callback);
// Send an Output report to an HID device. // Send an output report to the device.
// <code>send</code> will send the data on the first OUT endpoint, if one // |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
// exists. If one does not exist, the report will be sent through the
// Control endpoint.
//
// |connectionId|: The connection to which to send a report.
// |reportId|: The report ID to use, or <code>0</code> if none. // |reportId|: The report ID to use, or <code>0</code> if none.
// |data|: The report data. // |data|: The report data.
static void send(long connectionId, static void send(long connectionId,
...@@ -109,19 +106,15 @@ namespace hid { ...@@ -109,19 +106,15 @@ namespace hid {
ArrayBuffer data, ArrayBuffer data,
SendCallback callback); SendCallback callback);
// Receive a Feature report from the device. // Request a feature report from the device.
// // |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
// |connectionId|: The connection to read Input report from. // |reportId|: The report ID, or <code>0</code> if none.
// |reportId|: The report ID, or zero if none.
static void receiveFeatureReport(long connectionId, static void receiveFeatureReport(long connectionId,
long reportId, long reportId,
ReceiveFeatureReportCallback callback); ReceiveFeatureReportCallback callback);
// Send a Feature report to the device. // Send a feature report to the device.
// // |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
// Feature reports are sent over the Control endpoint as a Set_Report
// transfer.
// |connectionId|: The connection to read Input report from.
// |reportId|: The report ID to use, or <code>0</code> if none. // |reportId|: The report ID to use, or <code>0</code> if none.
// |data|: The report data. // |data|: The report data.
static void sendFeatureReport(long connectionId, static void sendFeatureReport(long connectionId,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment