WICG / webhid

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

Question on HID over Bluetooth #75

Open davisford opened 3 years ago

davisford commented 3 years ago

I know HID over Bluetooth is possible, but how would it work with the WICG APIs?

I have a BTLE device that does not advertise itself to the OS (e.g. scanning with Mac OS Bluetooth dialog it is not discoverable), but if I use WebBluetooth APIs I can find it and connect to it. Once I do that, it shows up in OS list as connected.

What I'd like to know is if I can then turn around and use the WebHID APIs using Bluetooth LE as the transport? How would that work, even? If I use the WebHID API to requestDevice with the appropriate filter and it were not attached via USB but it was connected via Bluetooth, would it even show up? If it did, this would seemingly require two pop-up dialogs to make the user affirm connecting to the device (one for WebBT, and one for WebHID), which would be an awkward experience.

Thanks in advance!

nondebug commented 3 years ago

Once a BLE HID device shows up in the macOS Bluetooth device list then it should also be enumerated by WebHID, but you'll need to request permission again since the WebHID and Web Bluetooth permissions aren't connected in any way.

I agree this is awkward and I don't think it helps users to track permissions on such a granular level. I think it would be better to unify permissions so users are only prompted once per physical device. Getting that right will take some careful thought since it's not always easy to identify the physical device that's exposing a particular HID interface and making a mistake can potentially allow access to more devices than the user intended.