Bugzilla – Bug 21387
Need to spec better support for control mapping
Last modified: 2015-04-24 10:49:53 UTC
The spec text that talks about a "standard gamepad" layout is a good start, but I think we need to go a little farther. We should spec a way for implementations to provide mapping data for known controllers as well as for content to fill in mappings for devices that the implementation doesn't know about.
There are two things content will want to know:
1) The mapping of controls to the physical layout of the controller. For example, most modern gamepads have a left analog stick that's the natural control for movement, and a set of buttons that are naturally under the right thumb when holding the controller. Content should be able to locate those to map them to actions.
2) The naming of controls on the actual gamepad. This is important for providing feedback to a user, content will want to be able to say "Press A".
Scott has a JS library he wrote that provides this:
I've also started sketching some thoughts in data form of what a useful presentation of controller data might look like:
To take Scott's "standard gamepad" layout a little further, I drew a diagram:
This is what the data in my gamepad-data github repo is based on.
After thinking about this quite a bit, I think this might be too much to bite off for an initial rev of the spec. I think what I'd like to do is take the "standard gamepad" approach and just polish it a little bit:
1) Add a Gamepad.mapping field, which can be set to "standard" or something if the implementation is using the standard gamepad mapping.
2) Add a way for the implementation to provide control names.
This should be enough to be useful, and we can do something more ambitious in a later version of the spec.
I added Gamepad.mapping to the spec:
I'd still like to figure out how to expose control names to content, since I think that's really useful.
Moved to https://github.com/w3c/gamepad/issues/7