WebHID (optional)
Import from @interfaces-technology/play-u1/hid when you need the browser WebHID API alongside normal Gamepad polling.
What this is not: it does not decode proprietary vendor reports. It helps you pair an HID device, open it, and correlate it with Gamepad objects when you need permissions, feature reports, or an explicit HID session.
Browser support
WebHID is Chromium-first (Chrome, Edge, Opera). Firefox and Safari do not expose navigator.hid today. Call supportsWebHid() before showing pairing UI.
Secure context and user gestures
requestGamepadHidDevice must run in a user gesture (for example a click). Serve over HTTPS or localhost.
Example
import { createGamepadManager } from "@interfaces-technology/play-u1";
import {
supportsWebHid,
requestGamepadHidDevice,
openHidDevice,
hidLikelyMatchesGamepad,
} from "@interfaces-technology/play-u1/hid";
const manager = createGamepadManager();
document.getElementById("pair")?.addEventListener("click", async () => {
if (!supportsWebHid()) return;
const hid = await requestGamepadHidDevice();
if (!hid) return;
await openHidDevice(hid);
for (const pad of manager.getDevices()) {
if (hidLikelyMatchesGamepad(hid, pad)) {
console.log("Likely same physical device", pad.id, hid.productName);
}
}
});Discovery filters
GAMEPAD_HID_FILTERS scopes pickers to the HID game pad usage page (0x05). Add vendorId / productId when you target a single SKU.