async function blink() {
const devices = await navigator.hid.requestDevice({
filters: [
{
vendorId: 0x057e, // Nintendo Co., Ltd
productId: 0x2007, // Joy-Con Right
},
],
});
const device = devices[0];
await device.open();
// Turn off
await device.sendFeatureReport(reportId, Uint32Array.from([0, 0]));
await new Promise((resolve) => setTimeout(resolve, 100));
// Turn on
await device.sendFeatureReport(reportId, Uint32Array.from([512, 0]));
await new Promise((resolve) => setTimeout(resolve, 100));
// Finally, disconnect from it
await device.forget();
}
blink();HIDDevice: forget() method / notebook
HIDDevice: forget() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.