<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26181</bug_id>
          
          <creation_ts>2014-06-23 18:39:24 +0000</creation_ts>
          <short_desc>Spec should specify the presentation of the array returned by navigator.getGamepads() w.r.t &quot;holes&quot;</short_desc>
          <delta_ts>2015-02-09 09:24:22 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Gamepad</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>27549</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ted Mielczarek [:ted]">ted</reporter>
          <assigned_to name="Ted Mielczarek [:ted]">ted</assigned_to>
          <cc>b.kelemen</cc>
    
    <cc>bajones</cc>
    
    <cc>beidson</cc>
    
    <cc>bugs</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>jrossi</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>public-webapps</cc>
    
    <cc>scott.w3bugzilla</cc>
    
    <cc>ted</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>108230</commentid>
    <comment_count>0</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-06-23 18:39:24 +0000</bug_when>
    <thetext>Currently the spec is silent about how the gamepad array should look in the face of removing Gamepads.

What Firefox implements (I need to check other browsers) is like:

&lt;no gamepads connected&gt;
navigator.getGamepads() == []

&lt;connect gamepad 1&gt;
navigator.getGamepads() == [Gamepad]

&lt;connect gamepad 2&gt;
navigator.getGamepads() == [Gamepad, Gamepad]

&lt;disconnect gamepad 1&gt;
navigator.getGamepads() == [null, Gamepad]

The intent is that the array is always at least max(Gamepad.index)+1 length, and entries where there&apos;s no longer a Gamepad present are &quot;holes&quot;. Firefox uses null for their values, but Chrome and IE use undefined, so the spec should clarify that. (undefined seems sensible)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108232</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-23 18:42:19 +0000</bug_when>
    <thetext>Undefined, or hole?  Those are actually observably different in JavaScript:

 [,1].hasOwnProperty(0) === false

vs

 [undefined,1].hasOwnProperty(0) === true

while of course both arrays will return undefined if indexed with [0].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108233</commentid>
    <comment_count>2</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2014-06-23 18:45:49 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #1)
&gt; Undefined, or hole?  Those are actually observably different in JavaScript:
&gt; 

Since Chrome and IE use undefined, and Firefox uses null, none of them being holes...  I would say undefined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108237</commentid>
    <comment_count>3</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-06-23 18:59:39 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #1)
&gt; Undefined, or hole?  Those are actually observably different in JavaScript:

I had no idea, I was going to ask you that question. Thanks for the info!

I think since existing implementations already use undefined that&apos;s what we&apos;ll spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108238</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-23 19:01:09 +0000</bug_when>
    <thetext>You checked that the existing impls actually use undefined, not holes, I assume?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108239</commentid>
    <comment_count>5</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-06-23 19:12:45 +0000</bug_when>
    <thetext>...apparently they&apos;re holes in IE/Chrome:

Chrome:

&gt; navigator.getGamepads()
GamepadList {0: Gamepad, 1: undefined, 2: Gamepad, 3: undefined, length: 4, item: function}
&gt; navigator.getGamepads().hasOwnProperty(1)
false
&gt; navigator.getGamepads().length
4

IE:

&gt; navigator.getGamepads()
[
   0: undefined,
   1: { },
   2: undefined,
   3: undefined,
   length: 4
]
&gt; navigator.getGamepads().hasOwnProperty(0)
false
&gt; navigator.getGamepads().length
4


(it turns out Developer consoles just aren&apos;t very good at making the distinction here)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108249</commentid>
    <comment_count>6</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-06-24 00:59:52 +0000</bug_when>
    <thetext>I fleshed out the text around getGamepads:
https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
https://dvcs.w3.org/hg/gamepad/rev/1719d51557f2

I&apos;m not sure if I described the behavior with holes clearly. Boris: is there a more-correct way to state that?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108250</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-24 01:43:38 +0000</bug_when>
    <thetext>It looks OK to me; I&apos;m not aware of a clearer way to define this short of an actual algorithmic description (create an array, set length to N, define property with name K to have the value X, etc).  An informative example that actually makes it clear that unset means the property is not present as opposed to set to undefined might be good.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108251</commentid>
    <comment_count>8</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2014-06-24 01:55:19 +0000</bug_when>
    <thetext>&gt; Array indices for which there is no Gamepad with the corresponding index should be unset.

I would say:

&quot;Array indices for which there is no connected Gamepad with the corresponding index should be undefined.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108252</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-24 02:05:58 +0000</bug_when>
    <thetext>That&apos;s too easy to read as &quot;set to the value undefined&quot; as opposed to &quot;not set to anything&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108253</commentid>
    <comment_count>10</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2014-06-24 02:07:29 +0000</bug_when>
    <thetext>Ah, fair enough.  Not quite sure of a more clear way to state that part then.

I stand by the s/no Gamepad/no connected Gamepad/ change, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108270</commentid>
    <comment_count>11</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-06-24 12:45:35 +0000</bug_when>
    <thetext>Added the &quot;connected&quot; clarification, and added a code sample describing expected behavior:
https://dvcs.w3.org/hg/gamepad/rev/7de7f215f35b</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108276</commentid>
    <comment_count>12</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-06-24 14:19:13 +0000</bug_when>
    <thetext>So Chrome seems to return some sort of GamepadList. What does IE return?
What is navigator.getGamepads().__proto__ ?

In Gecko that is currently Array.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108281</commentid>
    <comment_count>13</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-06-24 15:08:34 +0000</bug_when>
    <thetext>IE (dev channel, DC1C0):
navigator.getGamepads().__proto__
[
   length: 0
]

Chrome (Canary, 38.0.2065.0) :
navigator.getGamepads().__proto__
GamepadList {item: function}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108282</commentid>
    <comment_count>14</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-06-24 15:10:03 +0000</bug_when>
    <thetext>(In reply to Ted Mielczarek [:ted] from comment #13)
&gt; IE (dev channel, DC1C0):
&gt; navigator.getGamepads().__proto__
&gt; [
&gt;    length: 0
&gt; ]

This didn&apos;t copy/paste what it showed me in the console, it says [object Array].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116051</commentid>
    <comment_count>15</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-12-09 17:17:19 +0000</bug_when>
    <thetext>I wish webidl had some way to say that returned array has holes.
Something like
sequence&lt;optional Gamepad&gt; getGamepads();

That would be relatively understandable, IMO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116061</commentid>
    <comment_count>16</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-09 18:07:21 +0000</bug_when>
    <thetext>I&apos;d like to make the spec a bit more sensible here. I&apos;m not particularly tied to a certain behavior here (and I don&apos;t think web content is at this point either), but I&apos;d like to hew reasonably closely to what implementations are doing and the direction of the web platform.

Apparently ES6 is doing its best to unsupport sparse arrays as a concept, so trying to spec &quot;holes&quot; here is probably not a winning move. Ideally we&apos;d just have a way of spec&apos;ing that the empty slots get undefined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116096</commentid>
    <comment_count>17</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-10 17:29:28 +0000</bug_when>
    <thetext>I&apos;m fishing for feedback from other implementers to see if anyone has any reasoning for what they&apos;ve already implemented.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116101</commentid>
    <comment_count>18</comment_count>
    <who name="Scott Graham">scott.w3bugzilla</who>
    <bug_when>2014-12-10 18:02:42 +0000</bug_when>
    <thetext>It wasn&apos;t particularly intentional in Chrome to my knowledge, it&apos;s just whatever the bindings code did with &quot;nothing&quot;.

It looks like maybe due to https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/modules/gamepad/GamepadList.idl&amp;l=31 .

Per comment 16, undefined rather than holey is fine with me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116102</commentid>
    <comment_count>19</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-10 18:47:17 +0000</bug_when>
    <thetext>The only tricky bit here right now is that WebIDL doesn&apos;t have a way to specify &quot;Gamepad or undefined&quot; as a type. We could write &quot;sequence&lt;Gamepad?&gt; getGamepads()&quot; to spec the Firefox behavior of &quot;Gamepad or null&quot;, but if we want to use undefined we&apos;ll have to have the WebIDL spec invent some way to say that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116104</commentid>
    <comment_count>20</comment_count>
    <who name="Scott Graham">scott.w3bugzilla</who>
    <bug_when>2014-12-10 18:58:30 +0000</bug_when>
    <thetext>Uh, OK. Personally, any of {false, null, undefined, &lt;hole&gt;} seem fine to me. null is fine with me if that&apos;s easiest to spec and meets people&apos;s expectations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116105</commentid>
    <comment_count>21</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-10 19:00:13 +0000</bug_when>
    <thetext>Thanks for the feedback. I feel similarly, I just want the spec to say precisely what should happen here so we can make all our implementations agree.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116107</commentid>
    <comment_count>22</comment_count>
    <who name="Scott Graham">scott.w3bugzilla</who>
    <bug_when>2014-12-10 19:28:48 +0000</bug_when>
    <thetext>(In reply to Ted Mielczarek [:ted] from comment #21)
&gt; Thanks for the feedback. I feel similarly, I just want the spec to say
&gt; precisely what should happen here so we can make all our implementations
&gt; agree.

Yes of course. sequence&lt;Gamepad?&gt; implying null sounds good then, thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116112</commentid>
    <comment_count>23</comment_count>
    <who name="Jacob Rossi [MSFT]">jrossi</who>
    <bug_when>2014-12-10 22:22:30 +0000</bug_when>
    <thetext>Holes make sense to me for keeping track of player/gamepad association. IE uses undefined because that&apos;s what our type system happens to produce by default and it matched Chrome. \o/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116113</commentid>
    <comment_count>24</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-12-10 22:26:06 +0000</bug_when>
    <thetext>Except it doesn&apos;t match Chrome, because Chrome currently uses holes, not undefined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116116</commentid>
    <comment_count>25</comment_count>
    <who name="Jacob Rossi [MSFT]">jrossi</who>
    <bug_when>2014-12-10 23:11:26 +0000</bug_when>
    <thetext>The console (unclearly) outputs undefined but is a hole in both IE and Chrome. This code runs identical in IE and Chrome:

var g = navigator.getGamepads()
g
   {0: undefined, 1: undefined, 2: undefined, 3: undefined, length: 4, item: function}
g.hasOwnProperty(0)
   false

So, unless I&apos;m missing something, the only difference I see here between IE &amp; Chrome is that IE uses an Array and Chrome uses some GamepadList interface (which seems wrong per spec)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116120</commentid>
    <comment_count>26</comment_count>
    <who name="Brandon Jones">bajones</who>
    <bug_when>2014-12-11 00:40:31 +0000</bug_when>
    <thetext>If WebIDL doesn&apos;t have a way of specifying Gamepad or undefined/hole then I&apos;m all for using a sequence of nullable Gamepads. I&apos;m also not aware of any technical reason for using the GamepadList type, or if there was one I think it&apos;s since been negated. We should be able to switch to a proper sequence without any trouble.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116437</commentid>
    <comment_count>27</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-17 23:04:41 +0000</bug_when>
    <thetext>It would be great to resolve this so that GamepadList can be retired in Blink:
https://codereview.chromium.org/808643005/

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&apos;t skip those entries, if that was the idea.

Off-topically, I&apos;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&apos;s been discussed to death already.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116480</commentid>
    <comment_count>28</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-18 14:26:28 +0000</bug_when>
    <thetext>(In reply to Philip Jägenstedt from comment #27)
&gt; Doing what the spec currently says with hasOwnPropety(n) being false for the
&gt; holes seems tricky. Null is easier to implement, but then Array.forEach
&gt; won&apos;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&apos;re swimming upstream by going that way.


&gt; Off-topically, I&apos;d be interested to know what purpose Gamepad.index and
&gt; trying to preserve that index in the returned array serves. It seems a bit
&gt; odd, but I assume it&apos;s been discussed to death already.

I don&apos;t know that it&apos;s been discussed much in the spec context, it&apos;s pretty simple really. The index can be thought of as the &quot;player number&quot;. 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&apos;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&apos;d have to search the array to find the matching device, which seems awkward.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116481</commentid>
    <comment_count>29</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-18 14:34:29 +0000</bug_when>
    <thetext>AFAICT we have two plausible paths forward:
1) Change the spec to match Firefox&apos;s implementation: sequence&lt;Gamepad?&gt; getGamepads()

This has the benefit of being incredibly easy to spec since the concept is easily expressible in WebIDL. Still need some spec language to indicate that implementations should return null for controllers that have been removed, but I need to write that either way.

2) Spec a GamepadList object with an indexed property getter, and additionally an iterator that returns only entries that are present (the default behavior of ES6 iterators on objects with indexed property getters/length properties is to iterate over 0..length-1). This could capture the existing intended semantics, but it&apos;s awfully complicated, doesn&apos;t seem to provide a whole lot of benefit, and feels like swimming against the tide of the web platform, since ES6 is trying to deprecate sparse Arrays.

I&apos;m leaning towards #1 (and the Blink folks have said they&apos;re amenable). Does anyone have a compelling reason to argue for #2?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116484</commentid>
    <comment_count>30</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-18 14:46:52 +0000</bug_when>
    <thetext>For #2, WebIDL has recently grown a maplike declaration that we could use:
http://heycam.github.io/webidl/#dfn-maplike-declaration

Presumably the resulting spec would look something like:

partial interface Navigator {
  GamepadList getGamepads();
};

interface GamepadList {
  readonly maplike&lt;unsigned long, Gamepad&gt;;
};

This doesn&apos;t seem overly terrible, but it does add a fair bit of implementation complexity just to avoid exposing a value for disconnected controllers.

In reality, most of the usage examples I&apos;ve seen (and written) have looked like:
var gamepads = navigator.getGamepads();
for (var i = 0; i &lt; gamepads.length; i++) {
  if (gamepads[i]) { ... }
}

which works either way.

If we implemented #2 then you could eventually write:
for (var gamepad of navigator.getGamepads()) {
  ...
}

which is certainly appealing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116487</commentid>
    <comment_count>31</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-18 14:55:48 +0000</bug_when>
    <thetext>Actually, no, since Map semantics don&apos;t match Array semantics, and existing content is relying on that (indexed getter, .length property).

We could define this using an iterator but it&apos;d get a bit torturous.

Jacob: do you have any objections to approach #1? I&apos;m sorry that the spec left this undefined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116488</commentid>
    <comment_count>32</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-18 14:59:31 +0000</bug_when>
    <thetext>(In reply to Ted Mielczarek [:ted] from comment #28)
&gt; &gt; Off-topically, I&apos;d be interested to know what purpose Gamepad.index and
&gt; &gt; trying to preserve that index in the returned array serves. It seems a bit
&gt; &gt; odd, but I assume it&apos;s been discussed to death already.
&gt; 
&gt; I don&apos;t know that it&apos;s been discussed much in the spec context, it&apos;s pretty
&gt; simple really. The index can be thought of as the &quot;player number&quot;. This is
&gt; pretty common in console-land where you have a fixed number of controllers,
&gt; and Gamepad is taking a cue from them (most specifically you can look at
&gt; Microsoft&apos;s XInput:
&gt; http://msdn.microsoft.com/en-us/library/windows/desktop/ee417001%28v=vs.
&gt; 85%29.aspx#multiple_controllers ). Being able to keep track of which
&gt; controller is which, especially when you may have multiple devices of the
&gt; same type connected is pretty important. Having .index correspond to the
&gt; index in the getGamepads array just seemed sensible at the time, since it
&gt; allows you to write code like:
&gt; 
&gt; function onconnected(e) {
&gt;   player.gamepad = e.gamepad.index;
&gt; }
&gt; 
&gt; function handleInput() {
&gt;   var gamepad = navigator.getGamepads()[player.gamepad];
&gt; }
&gt; 
&gt; If we compacted the array and got rid of empty entries you&apos;d have to search
&gt; the array to find the matching device, which seems awkward.

Why not:

function onconnected(e) {
  player.gamepad = e.gamepad;
}

And then just use that until the gamepaddisconnected fires or player.gamepad.connected is false? Getting the gamepad via getGamepads() on each input event or animation frame will generate a lot of garbage since a new Array is returned each time.

The XInputGetState API seems to need an index because there&apos;s no equivalent to Gamepad objects to hold on to.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116489</commentid>
    <comment_count>33</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-18 15:00:28 +0000</bug_when>
    <thetext>Of the two options in comment #29, I think the first (Gamepad?[]) is better.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116490</commentid>
    <comment_count>34</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2014-12-18 15:06:14 +0000</bug_when>
    <thetext>(In reply to Philip Jägenstedt from comment #32)
&gt; Why not:
&gt; 
&gt; function onconnected(e) {
&gt;   player.gamepad = e.gamepad;
&gt; }
&gt; 
&gt; And then just use that until the gamepaddisconnected fires or
&gt; player.gamepad.connected is false? Getting the gamepad via getGamepads() on
&gt; each input event or animation frame will generate a lot of garbage since a
&gt; new Array is returned each time.

Congratulations, you found the other big spec bug I need to fix: bug 21434.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117427</commentid>
    <comment_count>35</comment_count>
    <who name="Ted Mielczarek [:ted]">ted</who>
    <bug_when>2015-01-22 14:17:42 +0000</bug_when>
    <thetext>I changed the spec to use sequence&lt;Gamepad?&gt;:
https://dvcs.w3.org/hg/gamepad/rev/105439653c33

So implementations should simply use null as the value for disconnected controllers. I&apos;ll write a test for this behavior for w3c-test.org.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117760</commentid>
    <comment_count>36</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-02-09 09:24:22 +0000</bug_when>
    <thetext>Thanks Ted, did you get around to that web-platform-tests thing?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>