Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to spec better support for control mapping #7

Closed
luser opened this issue Apr 24, 2015 · 3 comments
Closed

Need to spec better support for control mapping #7

luser opened this issue Apr 24, 2015 · 3 comments

Comments

@luser
Copy link
Contributor

luser commented Apr 24, 2015

Originally filed as https://www.w3.org/Bugs/Public/show_bug.cgi?id=21387:

Ted Mielczarek [:ted] 2013-03-25 12:27:23 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:
https://github.com/sgraham/gamepad.js/

I've also started sketching some thoughts in data form of what a useful presentation of controller data might look like:
https://github.com/luser/gamepad-data

[reply] [−] Comment 1 Ted Mielczarek [:ted] 2013-03-25 14:27:14 UTC

To take Scott's "standard gamepad" layout a little further, I drew a diagram:
http://people.mozilla.com/~tmielczarek/gamepad.svg

This is what the data in my gamepad-data github repo is based on.

[reply] [−] Comment 2 Ted Mielczarek [:ted] 2013-03-26 12:20:52 UTC

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.

[reply] [−] Comment 3 Ted Mielczarek [:ted] 2013-04-10 18:35:30 UTC

I added Gamepad.mapping to the spec:
https://dvcs.w3.org/hg/gamepad/rev/c5c7b4651d4e

I'd still like to figure out how to expose control names to content, since I think that's really useful.

@cvan
Copy link
Contributor

cvan commented Nov 16, 2016

Copying and pasting my comment in #24 (comment):

The handling of controller mappings (see this crowdsourced listing [by 9 contributors]) and haptics is mostly what I thought we could borrow from SDL.

There are Firefox bugs on file for Gamepad mappings and rumble haptic feedback, which have good discussions. There are also spec issues on file in this repo for both of these as well: #7 and #19.

With that being said, we can probably close this. Although it breaks compatibility and arguably complicates the API surface area, I feel it could be worth a proper investigation of SDL's Gamepad API methods and capabilities to see what the Web-based API can keep the same. I'm not completely well versed in (w)asm, but the last time I was poking around, I noticed there's a lot of logic thrown away when games are exported to JS using emscripten and using the SDL Gamepad API: https://github.com/kripken/emscripten/blob/07b87426/src/library_sdl.js

I don't know if/where there are metrics for Gamepad usage in Firefox, Chrome, Edge, and Opera. The only thing I was able to find were these two Gamepad metrics from the Chrome Platform Status > JS Usage page, both at <= 0.0001% usage:

@sgraham
Copy link
Contributor

sgraham commented Feb 14, 2018

This would definitely be nice, we should push to v2 though.

@marcoscaceres
Copy link
Member

Closing as it's not actionable in the API itself... or at least, something we would add right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants