OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.hid</code> API to interact with connected HID devices. | 5 // Use the <code>chrome.hid</code> API to interact with connected HID devices. |
6 // This API provides access to HID operations from within the context of an app. | 6 // This API provides access to HID operations from within the context of an app. |
7 // Using this API, apps can function as drivers for hardware devices. | 7 // Using this API, apps can function as drivers for hardware devices. |
8 // | 8 // |
9 // Errors generated by this API are reported by setting | 9 // Errors generated by this API are reported by setting |
10 // $(ref:runtime.lastError) and executing the function's regular callback. The | 10 // $(ref:runtime.lastError) and executing the function's regular callback. The |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 dictionary GetDevicesOptions { | 57 dictionary GetDevicesOptions { |
58 [deprecated="Equivalent to setting $(ref:DeviceFilter.vendorId)."] | 58 [deprecated="Equivalent to setting $(ref:DeviceFilter.vendorId)."] |
59 long? vendorId; | 59 long? vendorId; |
60 [deprecated="Equivalent to setting $(ref:DeviceFilter.productId)."] | 60 [deprecated="Equivalent to setting $(ref:DeviceFilter.productId)."] |
61 long? productId; | 61 long? productId; |
62 // A device matching any given filter will be returned. An empty filter list | 62 // A device matching any given filter will be returned. An empty filter list |
63 // will return all devices the app has permission for. | 63 // will return all devices the app has permission for. |
64 DeviceFilter[]? filters; | 64 DeviceFilter[]? filters; |
65 }; | 65 }; |
66 | 66 |
67 dictionary DevicePromptOptions { | |
68 // Allow the user to select multiple devices. | |
69 boolean? multiple; | |
70 // Filter the list of devices presented to the user. If multiple filters | |
71 // are provided devices matching any filter will be displayed. | |
72 DeviceFilter[]? filters; | |
73 }; | |
74 | |
67 callback GetDevicesCallback = void (HidDeviceInfo[] devices); | 75 callback GetDevicesCallback = void (HidDeviceInfo[] devices); |
68 callback ConnectCallback = void (HidConnectInfo connection); | 76 callback ConnectCallback = void (HidConnectInfo connection); |
69 callback DisconnectCallback = void (); | 77 callback DisconnectCallback = void (); |
70 | 78 |
71 // |reportId|: The report ID or <code>0</code> if none. | 79 // |reportId|: The report ID or <code>0</code> if none. |
72 // |data|: The report data, the report ID prefix (if present) is removed. | 80 // |data|: The report data, the report ID prefix (if present) is removed. |
73 callback ReceiveCallback = void (long reportId, ArrayBuffer data); | 81 callback ReceiveCallback = void (long reportId, ArrayBuffer data); |
74 | 82 |
75 // |data|: The report data, including a report ID prefix if one is sent by the | 83 // |data|: The report data, including a report ID prefix if one is sent by the |
76 // device. | 84 // device. |
77 callback ReceiveFeatureReportCallback = void (ArrayBuffer data); | 85 callback ReceiveFeatureReportCallback = void (ArrayBuffer data); |
78 | 86 |
79 callback SendCallback = void(); | 87 callback SendCallback = void(); |
80 | 88 |
81 interface Functions { | 89 interface Functions { |
82 // Enumerate connected HID devices. | 90 // Enumerate connected HID devices. |
83 // |options|: The properties to search for on target devices. | 91 // |options|: The properties to search for on target devices. |
84 static void getDevices(GetDevicesOptions options, | 92 static void getDevices(GetDevicesOptions options, |
85 GetDevicesCallback callback); | 93 GetDevicesCallback callback); |
86 | 94 |
95 // Presents a device picker to the user and returns $(ref:HidDeviceInfo) | |
96 // objects for the devices selected. | |
97 // If the user cancels the picker devices will be empty. A user gesture | |
98 // is required for the dialog to display. Without a user gesture, the | |
99 // callback will run as though the user cancelled. If multiple filters are | |
100 // provided devices matching any filter will be displayed. | |
101 // |options|: Configuration of the device picker dialog box. | |
102 // |callback|: Invoked with a list of chosen $(ref:Device)s. | |
103 static void getUserSelectedDevices(DevicePromptOptions options, | |
Devlin
2015/05/05 22:19:51
Why is |options| required?
Reilly Grant (use Gerrit)
2015/05/06 00:52:53
No reason.
| |
104 GetDevicesCallback callback); | |
105 | |
87 // Open a connection to an HID device for communication. | 106 // Open a connection to an HID device for communication. |
88 // |deviceId|: The $(ref:HidDeviceInfo.deviceId) of the device to open. | 107 // |deviceId|: The $(ref:HidDeviceInfo.deviceId) of the device to open. |
89 static void connect(long deviceId, | 108 static void connect(long deviceId, |
90 ConnectCallback callback); | 109 ConnectCallback callback); |
91 | 110 |
92 // Disconnect from a device. Invoking operations on a device after calling | 111 // Disconnect from a device. Invoking operations on a device after calling |
93 // this is safe but has no effect. | 112 // this is safe but has no effect. |
94 // |connectionId|: The <code>connectionId</code> returned by $(ref:connect). | 113 // |connectionId|: The <code>connectionId</code> returned by $(ref:connect). |
95 static void disconnect(long connectionId, | 114 static void disconnect(long connectionId, |
96 optional DisconnectCallback callback); | 115 optional DisconnectCallback callback); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 // accepted an optional permission (see $(ref:permissions.request)). | 158 // accepted an optional permission (see $(ref:permissions.request)). |
140 static void onDeviceAdded(HidDeviceInfo device); | 159 static void onDeviceAdded(HidDeviceInfo device); |
141 | 160 |
142 // Event generated when a device is removed from the system. See | 161 // Event generated when a device is removed from the system. See |
143 // $(ref:onDeviceAdded) for which events are delivered. | 162 // $(ref:onDeviceAdded) for which events are delivered. |
144 // |deviceId|: The <code>deviceId</code> property of the device passed to | 163 // |deviceId|: The <code>deviceId</code> property of the device passed to |
145 // $(ref:onDeviceAdded). | 164 // $(ref:onDeviceAdded). |
146 static void onDeviceRemoved(long deviceId); | 165 static void onDeviceRemoved(long deviceId); |
147 }; | 166 }; |
148 }; | 167 }; |
OLD | NEW |