WebHID allows websites to access devices that use the human interface devices (HID) protocol via JavaScript. Here is a little Christmas present π to the community to celebrate the API approval: releasing Joy-Con WebHID, a WebHID “driver” for Nintendo Joy-Con controllers so you can use them in the browser. If you have Joy-Cons, be sure to check out the demo to get a feel for what is possible.
Installation per NPM:
npm install joy-con-webhid
Once a Joy-Con has been paired, you can listen to hidinput
events:
joyCon.addEventListener('hidinput', ({ detail }) => {
// Careful, this fires at ~60fps.
console.log(`Input report from ${joyCon.device.productName}:`, detail);
});
π‘ The code does not use on the Gamepad API but the WebHID API as the former does not have support for orientation, a feature the Joy-Con controllers use extensively.