HIDDevice: sendReport() method
The sendReport()
method of the HIDDevice
interface sends an output report to the HID device.
The reportId
for each of the report formats that this device supports can be retrieved from HIDDevice.collections
.
Syntax
sendReport(reportId, data)
Parameters
-
reportId
-
An 8-bit report ID. If the HID device does not use report IDs, send 0
.
-
data
-
Bytes as an ArrayBuffer
, a TypedArray
, or a DataView
.
Return value
A Promise
that resolves with undefined
once the report has been sent.
Exceptions
NotAllowedError
DOMException
-
Thrown if sending the report fails for any reason.
Examples
The example below shows how to make a Joy-Con device rumble using output reports. You can see more examples, and live demos in the article Connecting to uncommon HID devices.
const enableVibrationData = [1, 0, 1, 64, 64, 0, 1, 64, 64, 0x48, 0x01];
await device.sendReport(0x01, new Uint8Array(enableVibrationData));
const rumbleData = [
];
await device.sendReport(0x10, new Uint8Array(rumbleData));
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
sendReport |
89 |
89 |
No |
No |
75 |
No |
No |
No |
No |
No |
No |
No |