WICG / webhid

Web API for accessing Human Interface Devices (HID)
Other
143 stars 35 forks source link

navigator.hid missing on Android? #113

Closed davisford closed 1 year ago

davisford commented 1 year ago

I have an Android device. The app I'm testing is with Brave b/c the device lacks Google Managed Services so I cannot install Chrome.

Application Version: 1.52.130, Chromium 114.0.5735.198 Operating System: Android 11; Build/RKQ1.211001.001

The navigator.hid is not available in the browser, but navigator.usb is available. Can anyone explain why?

nondebug commented 1 year ago

The Chromium issue has some context one why this isn't implemented on Android:

In order to support communicating with these kinds of devices on Android while preserving the same security guarantees as WebUSB and WebHID have on other platforms we need to implement checks that prevent accessing the HID usages which are normally blocked by WebHID. This is complicated by Android not having an equivalent to the HID APIs which are used to implement WebHID on other platforms. The way native Android applications connect to a USB HID device is using the USB host API (the same one WebUSB uses) and detaching the USB HID driver (which WebUSB doesn't allow). One way to implement WebHID on Android would be to use this API however this wouldn't permit sharing the HID device with other applications the way WebHID does on other platforms because the browser would have to take full control over the USB HID interface.

It would be easiest to implement this if Android provided access to the hidraw subsystem since that's what we use for WebHID on Linux and ChromeOS.