Closed Bug 936104 Opened 11 years ago Closed 11 years ago

[Gamepad] Pages using only navigator.getGamepads without event listeners don't get gamepad data

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla28

People

(Reporter: ted, Assigned: ted)

References

Details

Attachments

(2 files)

This is silly, but apparently the machinery to scan for gamepads and update the DOM only triggers if you add event listeners for gamepadconnected or gamepaddisconnected. Calling navigator.getGamepads isn't sufficient, which means that pages doing strictly polling won't actually get any gamepad data. The simple workaround is just to add addEventListener("gamepadconnected", function() {}); which will make things spin up.
This fixes this issue for me on a simple local test page. Unfortunately I can't write a test for this because all of the Mochitests use a fake gamepad service, which means they don't need to spin up a platform gamepad service anyway. Conveniently the patch is trivial.
Attachment #8342342 - Flags: review?(bugs)
Assignee: nobody → ted
Status: NEW → ASSIGNED
Comment on attachment 8342342 [details] [diff] [review] pages using only navigator.getGamepads should trigger gamepad backend startup A bit hackish, but mostly because SetHasGamepadEventListener name is odd. We should change that to WantsGamepadUpdates() or some such, and then have another method for the 'false' case, perhaps DisconnectedFromGamepadService() But you can do that in a followup.
Attachment #8342342 - Flags: review?(bugs) → review+
Filed bug 947172 on renaming that method.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Keywords: verifyme
Attached file testcase (deleted) —
Here's a testcase you can use for verification. Connecting a gamepad and pressing a button on this page should display a message in the page body.
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0 With Nightly from 2013-11-06 no message is displayed. On latest Aurora (Build ID:20140203004003) a message is displayed in the page body of the attached testcase when a button is pressed on the gamepad. Tested with Xbox 360 and Logitech F310 controllers.
Status: RESOLVED → VERIFIED
Keywords: verifyme
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: