Event gamepadconnected does not fire
Reported by
glroyla...@gmail.com,
Dec 4 2017
|
|||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Steps to reproduce the problem: 1. Load page with console open 2. Plug gamepad into USB port 3. Unplug gamepad from USB port What is the expected behavior? The gameportconnected event should fire when gamepad plugged in and print a line on the console. The gameportdisconnected event should fire when gamepad removed. What went wrong? The gamepadconnected event never fires. (The gamepaddisconnected event does fire.) Another scenario does not work. Load page with gamepad connected. Pressing a button on the gamepad should fire gamepadconnected. Did this work before? N/A Does this work in other browsers? N/A Chrome version: 61.0.3163.100 Channel: n/a OS Version: 10.0 Flash Version: Problem mentioned at https://stackoverflow.com/questions/44735703/gamepad-api-gamepadconnected-not-working https://theedgeofthought.itch.io/eelemental/devlog/797/chrome-has-no-gamepadconnected-event Portions of the HTML file are copied from Mozilla site that does continual polling even if there are no gamepads. https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API Management of getGamepads() seems flawed. With no gamepads, load HTML page. Plug in gamepad. Leave HTML page. Unplug gamepad. Reload HTML page and gamepad is there. Plug in gamepad and gamepad display is dead. Sometimes get ghost gamepads.
,
Dec 6 2017
glroylance@ Thanks for the issue. Tested this issue on Windows 7 and 10 on the latest Canary 65.0.3285.0 and Stable 62.0.3202.94 and unable to reproduce this issue by following the below steps. 1. Launched Chrome and opened the given html file. 2. Opened Devtools and clicked on Console tab. 3. Plugged in the Gamepad and can see a line triggered o Console as Connected. Attached is the screen cast for reference. Request you to please check and update if anything is missed from our end. Also request you to retry the issue after updating Chrome to the latest Stable build and update the thread with the observations. Thanks...
,
Dec 6 2017
Your screen shot shows that connectgamepad fired (line just before "addgamepad"). That line does not show up when I try it with a gamepad or a joystick. I'll try doing it with a clean boot later today.
,
Dec 6 2017
Thank you for providing more feedback. Adding requester "susanjuniab@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 6 2017
In Chrome 63.0.3239.84 I am seeing addgamepad events, but I'm still seeing zombie gamepads if I navigate away from the page, disconnect the gamepad, and then reload the page. I'll have to look at it some more.
,
Dec 6 2017
Hi glroylance, We made some changes to the gamepadconnected/disconnected events in Chrome 63 which should have fixed the cases in your original report. Zombie gamepads are bad, can you share which gamepad you're seeing this with?
,
Dec 11 2017
@glroylance-- Could you please respond to the comment #6 and update the thread with your observations. Thanks!
,
Dec 17 2017
I pulled them out of my old USB box. gamepad: 047d-4006 Gravis Eliminator AfterShock circa 2003. gamepad has 10 buttons, 6 axes, and vibration feedback Firefox reports the 10 buttons and the 6 axes but does not recognize vibration feedback (haptic array empty). Firefox does not have zombies. Chrome reports the 10 buttons but 8 (EIGHT) axes. I'm guessing Chrome mistakes the vibrators as additional axes. Axis map is bizarre. Left thumb is 0 and 1, right thumb is 5 and 2, quad is 7 and 4. (Axes 2 and 6 do not respond and are probably vibrators.) Chrome has zombies. Load page with no gamepad. Plug in gamepad and it displays. Unplug gamepad and its display goes away. Plug in gamepad and its display returns. Navigate away from page. Unplug gamepad while not on page. Reload page. Zombie gamepad with connected: true displays. but there is no hardware present! Plug in gamepad. Hardware exists, but buttons do nothing. Leave page loaded but select second tab. Go back to tab that has page and buttons now work. joystick: Saitek ST90 USB Stick (Vendor: 06a3 Product: 0422) circa 2004 Has 3 buttons and 3 axes. Firefox works. No zombies. Chrome has same zombie behavior as the gamepad. Looks like Chrome does not process the disconnect for its internal state unless the page has the gamepad open.
,
Dec 17 2017
Thank you for providing more feedback. Adding requester "hdodda@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 18 2017
Tested this issue on Windows 10 with chrome #50.02661.0 & #63.0.3239.108 Steps Followed: 1. Opened the provided html page in chrome 2. open Devtools->ConsoleTab 3. Connect the Sony GamePad Observations: 1. On #50.0.2661.0, On connecting the game-pad, in the console it displayed the game-pad details and in the main page it displayed blue lines. 2. On #63.0.3239.108, On connecting the game-pad, in the console it didn't displayed anything but on pressing the any button, it displayed the game-pad details and in the main page it displayed blue lines. Attaching the screen-cast for reference. glroylance@ Could you confirm that this is the issue you are facing ???
,
Dec 18 2017
No, I'm not confronting those problems. My take is you are showing additional problems with Chrome's gamepad interface. Your observation 2 is appropriate; generally, a webpage will not notice a gamepad until there is a state change: the user presses a button or moves a joystick. That's when the gamepadconnected event should fire. Sometimes noise on the joystick will trigger the gamepadconnected event. Your video shows lots of strange behavior. You connected one gamepad, but the console log shows two gamepads: one at index 0 and another at index 1. At index 0, "Unknown Gamepad (Vendor: 0000 Product: 0000)" does not look like a reasonable gamepad. The blue lines represent axes, and this gamepad has 16 axes. Moving the joysticks should cause the blue lines to move in unison with the control (think progress bars). It has lots of axes, but no buttons. At index 1, "Wireless controller (Vendor: 054c Product: 09cc)" looks like a legit USB device, but I cannot see any of its details in the video. In particular, I don't know if it showed any axes or buttons. You can tell more details by expanding the gamepad objects in the console view. There should only have been one gamepad object if you just plugged in one gamepad. I'd guess your gamepad could have two stations, but I'll discount that view. More likely, either Windows or Chrome is confused about a USB wireless controller and the wireless gamepad. I could see that happening if the USB device reports multiple interfaces. When you updated to Chrome 63, it looks like no gamepads were recognized in the video. (You'd have to press a button for the gamepad to show.) You should try http://html5gamepad.com/ and see if you get a good result. Compare with Firefox. I suspect Firefox will show either one gamepad or none (not two gamepads). The pink background items in the HTML file I submitted are just my tests to paint a similar GUI; the pink items do nothing but display. I should have diked them out, but it was simpler to just submit the HTML I had used for testing.
,
Dec 18 2017
Thank you for providing more feedback. Adding requester "kkaluri@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 19 2017
@glroylance -- Thanks for providing feedback. Could you please provide the screencast of the actual issue and expected. That would really help in further triaging the issue. Thanks in advance!
,
Jan 3 2018
,
Jan 4 2018
> gamepad: 047d-4006 Gravis Eliminator AfterShock circa 2003. Thanks! I filed a separate bug to add a mapping for the AfterShock: https://bugs.chromium.org/p/chromium/issues/detail?id=798880 Zombie gamepads: This appears to be a bug in JSGamepad.html where addgamepad is called twice for the same gamepad. There's a line that attempts to determine whether the gamepadconnected event is available, but it's buggy: var haveEvents = 'ongamepadconnected' in window; This always fails. Instead, check for GamepadEvent: var haveEvents = 'GamepadEvent' in window; If haveEvents is false, scangamepads is scheduled to poll for new gamepads every .5 sec. In the case where haveEvents is false but a gamepadconnected listener is registered, it's possible for scangamepads to add the gamepad, and then have the listener add it again. After fixing haveEvents the script still doesn't work because scangamepads is never called. It should be called during requestAnimationFrame to update button and axis state. To fix, I removed the haveEvents check inside updateStatus so scangamepads is called once per frame. function updateStatus() { //if (!haveEvents) { scangamepads(); //} Also, scangamepads should be modified so it does not add gamepads when gamepadconnected is supported. if (gamepads[i].index in controllers) { controllers[gamepads[i].index] = gamepads[i]; } else if (!haveEvents) { addgamepad(gamepads[i]); } glroylance, can you try these changes and confirm you no longer see zombie gamepads? Missing gamepadconnected events: After these fixes I still wasn't seeing gamepadconnected after a page refresh. The spec says we should: "If a gamepad was already connected when the page was loaded, the gamepadconnected event should be dispatched when the user presses a button or moves an axis." As a convenience, Chrome allows the page to remember that it has already seen a button press so gamepads will be available immediately after a refresh. This means the gamepadconnected event is fired as soon as the gamepad API is initialized, which happens before listener registration when navigator.getGamepads is called. If the call to navigator.getGamepads is removed, or if the listener is registered before this call, then the gamepadconnected event fires when the listener is registered. To make sure you receive gamepadconnected for each gamepad, register the gamepadconnected listener before calling any other gamepad API methods. |
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by sc00335...@techmahindra.com
, Dec 5 2017Labels: Triaged-ET TE-NeedsTriageFromHYD Needs-Milestone