Closed MattTreichelYeah closed 6 years ago
It's a weird arbitrary implementation choice (pretty clearly influenced by XInput). I'm not sure what the spec could say to make this better. Do you have a suggestion? The spec text around getGamepads
doesn't really say anything about the number of entries currently:
https://w3c.github.io/gamepad/#navigator-interface-extension
I guess something related to the following sentence? There must be some way to dissuade implied common standards. The sentence does seem to imply the browsers are doing it incorrectly since when no Gamepads are connected, it still returns an array of length 4.
"The length of the array returned must be at least one more than the maximum index value of the Gamepad objects returned in the array."
Maybe an additional, explicit clarification of "The length of the array must change to accommodate an arbitrary number of Gamepads."?
There's no particular mention of "4" that I'm aware of any more, the text has been changed to say that it should just be an array of stuff, without empty trailing entries.
I notice the way Chrome and Edge seem to be implementing
navigator.getGamepads()
returns an array of 4 undefined spots for gamepads.This seems like a frustrating precedent seen with Microsoft's legacy XInput. It's entirely arbitrary to limit this to 4. Something the standard should specify against?