- From: <bugzilla@jessica.w3.org>
- Date: Thu, 18 Dec 2014 14:26:28 +0000
- To: public-webapps-bugzilla@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=26181 --- Comment #28 from Ted Mielczarek [:ted] <ted@mielczarek.org> --- (In reply to Philip Jägenstedt from comment #27) > Doing what the spec currently says with hasOwnPropety(n) being false for the > holes seems tricky. Null is easier to implement, but then Array.forEach > won't skip those entries, if that was the idea. I liked the appeal of being able to skip missing entries, but it looks like ES6 is ridding itself of sparse Arrays, so we're swimming upstream by going that way. > Off-topically, I'd be interested to know what purpose Gamepad.index and > trying to preserve that index in the returned array serves. It seems a bit > odd, but I assume it's been discussed to death already. I don't know that it's been discussed much in the spec context, it's pretty simple really. The index can be thought of as the "player number". This is pretty common in console-land where you have a fixed number of controllers, and Gamepad is taking a cue from them (most specifically you can look at Microsoft's XInput: http://msdn.microsoft.com/en-us/library/windows/desktop/ee417001%28v=vs.85%29.aspx#multiple_controllers ). Being able to keep track of which controller is which, especially when you may have multiple devices of the same type connected is pretty important. Having .index correspond to the index in the getGamepads array just seemed sensible at the time, since it allows you to write code like: function onconnected(e) { player.gamepad = e.gamepad.index; } function handleInput() { var gamepad = navigator.getGamepads()[player.gamepad]; } If we compacted the array and got rid of empty entries you'd have to search the array to find the matching device, which seems awkward. -- You are receiving this mail because: You are the QA Contact for the bug.
Received on Thursday, 18 December 2014 14:26:31 UTC