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

"STANDARD GAMEPAD" should be defined in a separate attribute #129

Open
Grovkillen opened this issue Mar 24, 2020 · 5 comments
Open

"STANDARD GAMEPAD" should be defined in a separate attribute #129

Grovkillen opened this issue Mar 24, 2020 · 5 comments

Comments

@Grovkillen
Copy link

Grovkillen commented Mar 24, 2020

Currently the type of controller is added to the id attribute. This makes the developer having to do a ".includes('STANDARD GAMEPAD')" for the id. Not ideal. So I suggest that the gamepad API have a specific attribute for this:

id: "uuid"
mapping: "standard"
type: "standard gamepad"
vendor: "Microsoft"
product: "Xbox 360 Controller"

@Grovkillen
Copy link
Author

Grovkillen commented Mar 24, 2020

And, since the standard suggest a setup of inputs to comply with the "standard gamepad" the API should give the axis and button names.

I mean should the developer have to go to the w3 standard to know what axis is what. If we have a input setup the developer should be able to call the "x" axis or the "b" button instead of using index.

With that being said, the type attribute give the developer all the information needed to know what inputs that's available.

@Grovkillen
Copy link
Author

#73

@mrmcpowned
Copy link

The inclusion of a vendor and product attribute would be welcomed as it would provide more usable metadata for application developers to use.

Is what you're proposing that the mapping attribute be completely removed? I don't know how well that would work in terms of existing implementations since the standard mapping as per the spec is defined in relation to the gamepads for the two most used platforms (Xbox and Playstation).

I'm honestly not even sure if the mapping attribute has been of much help, though. The spec defined that the "standard" layout is relative to the button mapping shown on the spec page, but if that mapping were to change to accommodate for some new "standard", that would make using the attribute value useless in terms of validating such a mapping. In my personal usage of the API, I haven't really relied much on the attribute itself, and more on the actual button/axis mapping information as per the spec.

@nondebug
Copy link
Collaborator

nondebug commented Jun 8, 2020

The ID string format isn't specified by the spec (even if it maybe should have been), the "STANDARD GAMEPAD" string is inserted by Chrome only when mapping is "standard", so there's no need for a separate type attribute.

https://html5gamepad.com/controllers conveniently logs all the ID strings it has seen.

In Chrome, the ID string is one of these:

%s (Vendor: %04x Product: %04x) <-- unrecognized HID gamepad
%s (STANDARD GAMEPAD Vendor: %04x Product: %04x) <-- any recognized USB or Bluetooth gamepad
%s (STANDARD GAMEPAD) <-- Game Controller on macOS
Xbox 360 Controller (XInput STANDARD %s) <-- XInput on Windows

There are XInput IDs for different controller types, I've never actually seen any of these except STANDARD GAMEPAD:

Xbox 360 Controller (XInput STANDARD GAMEPAD)
Xbox 360 Controller (XInput STANDARD WHEEL)
Xbox 360 Controller (XInput STANDARD ARCADE_STICK)
Xbox 360 Controller (XInput STANDARD FLIGHT_STICK)
Xbox 360 Controller (XInput STANDARD DANCE_PAD)
Xbox 360 Controller (XInput STANDARD GUITAR)
Xbox 360 Controller (XInput STANDARD GUITAR_ALTERNATE)
Xbox 360 Controller (XInput STANDARD DRUM_KIT)
Xbox 360 Controller (XInput STANDARD GUITAR_BASS)
Xbox 360 Controller (XInput STANDARD ARCADE_PAD)

In Firefox:

%04x-%04x-%s
xinput

We can't modify id itself because it would break applications that rely on collections of known ID strings for device identification. We could add new productName, vendorId, and productId attributes to break out the components of the ID string. The vendor and product IDs should be optional because those IDs are specific to USB and Bluetooth devices. The product name should be a string suitable for display in a user-facing context like a chooser dialog. I think the spec should explicitly warn against using the product name as a stable identifier. That way the browser could choose to provide better strings than those reported by the device.

I don't think we should expose the vendor/manufacturer name reported by the device. This information isn't as useful for identification because different devices from the same vendor may report different strings. Sometimes Chrome pulls the vendor name into the ID string because it's included by the platform API used for device enumeration, for instance here's DS4 v1 and DS4 v2 on different platforms:

Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 05c4)
Sony Computer Entertainment Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 05c4)

Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 09cc)
Sony Interactive Entertainment Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 09cc)

It really shouldn't include the vendor name string but it's too late to change it. Also note that the vendor name is reported differently for DS4 v1 vs DS4 v2 even though the vendor ID is the same.

Modifying your example (new attributes in bold):

id: whatever is currently reported
mapping: "standard"
productName: "Xbox 360 Controller"
vendorId: "045e"
productId: "028e"

@Grovkillen
Copy link
Author

Grovkillen commented Jun 8, 2020

The suggested change is liked by me.

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

3 participants