Re: [w3c/gamepad] Mapping of HID Events to the Gamepad API (#56)

> I'm afraid individual controls have individual mapping needs, and there's no way a w3c spec can accommodate that generally speaking.

I fell into this same pit of despair a while back. I think there are two plausible paths here:

1. Spec out an algorithm for taking a HID descriptor and producing a mapping from its elements to the buttons/axes arrays in the Gamepad spec. Even if the resulting Gamepad object doesn't look sensible for every controller, if it is at least *consistent* across implementations then it ought to be possible to maintain a database of known controller layouts (I [prototyped such a thing](https://github.com/luser/gamepad-data) a while ago) and a small JS library that could produce the "standard" mapping from the consistently-mapped Gamepad.
2. Give up and expose the HID descriptor + reports in the API somehow. With all the knowledge I have now I honestly wish we would have just built a WebHID spec instead of this one, but that ship has sailed. :) WebBluetooth doesn't currently expose HID devices, AIUI, because of the security concerns of allowing web content access to things like your keyboard/mouse, but maybe a simple way to prototype this would be to tweak Chrome's implementation to allow Bluetooth HID devices that report themselves as joysticks/gamepads, and see how that feels in JS?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/issues/56#issuecomment-667155214

Received on Friday, 31 July 2020 14:42:24 UTC