This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25203 - [gamepad] Connected Attribute appears to serve no purpose if the Gamepad object is a snapshot
Summary: [gamepad] Connected Attribute appears to serve no purpose if the Gamepad obje...
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Gamepad (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ted Mielczarek [:ted]
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-29 01:56 UTC by Oren
Modified: 2015-04-24 10:58 UTC (History)
4 users (show)

See Also:


Attachments

Description Oren 2014-03-29 01:56:47 UTC
"Retrieve a snapshot of the data for the the currently connected and interacted-with gamepads."

getGamepads returns a snapshot of the currently connected gamepads but if it is a snapshot and the devices must be connected then what will a developer use the connected attribute for as it seems it should always return 'true'?

I figured the intention is that connected attribute of the object should always return whether or not that gamepad is connected and only axes, buttons, etc should be a snapshot?



Thanks!
Comment 1 Ted Mielczarek [:ted] 2014-03-29 04:20:11 UTC
See bug 21434. The original spec text around getGamepads was written by Scott and didn't match what I had implemented in Firefox, so there's a little confusion. In Firefox Gamepad objects are not snapshots, they are updated each pass through the event loop with the most current data. In Chrome they're currently snapshots. I think Scott said he agreed with me that making them live was a sane behavior and we should change the spec to reflect that.
Comment 2 Balazs Kelemen 2014-06-17 21:36:04 UTC
We discussed it briefly with Scott, and agreed that it's not clear that the behavior implemented in Firefox is superior. It does not seem to be very clear when and how the gamepad object's are supposed to be updated. How Firefox does that today?

I think a sane approach could be to update it with requestAnimationFrame frequency, and make sure that it happens before rAF is sent to the page. Updating it with higher frequency doesn't seem to be useful to me. But than why live objects are better than a snapshot based api that naturally calls for being used with a rAF loop? In other worlds (with more buzz), the web platform already has the primitives to appropriately sync the data, so it's probably better if we add less magic to the implementation and rely on the user to use the right primitives.

Ted, could you please point out the reasons you choose the live object model? I'm not particularly critical to that model, but it would be really useful if we could get an agreement and implement the same thing.

What's also important is that now we have another player in the club, namely IE: http://msdn.microsoft.com/en-us/library/ie/dn743630(v=vs.85).aspx. I did not try it myself but from their documentation it seems like they implemented the current version of the spec with snapshots:
 - "getGamepads: Returns an array of gamepad objects that describe the state of each active gamepad device."
 - "Gamepad object: Gamepad objects describe the state of the buttons and axes associated with a gamepad device at a given time."

Thanks!
Comment 3 Ted Mielczarek [:ted] 2014-06-18 00:02:40 UTC
Balazs: it's mostly a leftover from my implementation that predated navigator.getGamepads(), where I envisioned you could just hold GamepadEvent.gamepad in a variable and refer back to it if you didn't want to use the events. In Firefox it's updated between trips to the event loop. There are ways to describe this in spec language, but I think it might be simpler to just spec them as snapshots and change Firefox's behavior to match Chrome and IE.

I started a thread on public-webapps about this two months ago if you want to read some arguments for both sides:
http://lists.w3.org/Archives/Public/public-webapps/2014AprJun/0238.html

I didn't find that there was an overwhelming argument in either way, but I'm leaning towards spec'ing snapshots.
Comment 4 Ted Mielczarek [:ted] 2015-04-24 10:58:38 UTC
Moved to https://github.com/w3c/gamepad/issues/10