-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double checking the gamepad docs are correct #14874
Labels
Content:WebAPI
Web API docs
effort: medium
This task is a medium effort.
help wanted
If you know something about this topic, we would love your help!
Comments
github-actions
bot
added
the
needs triage
Triage needed by staff and/or partners. Automatically applied when an issue is opened.
label
Apr 11, 2022
Also, I'd be nice if the code was modern using |
sideshowbarker
added
help wanted
If you know something about this topic, we would love your help!
Content:WebAPI
Web API docs
effort: medium
This task is a medium effort.
and removed
needs triage
Triage needed by staff and/or partners. Automatically applied when an issue is opened.
labels
Apr 11, 2022
Here's the code cleaned up.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Content:WebAPI
Web API docs
effort: medium
This task is a medium effort.
help wanted
If you know something about this topic, we would love your help!
MDN URL
/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
What specific section or headline is this issue about?
Multiple sections
What information was incorrect, unhelpful, or incomplete?
I could be reading the article wrong but ... stuff like this
What did you expect to see?
AFAIK This wrong.
#1. While it's true a gamepad object will be provided on gamepadconnected, it's also true that gamepad objects will be provided by navigator.getGamepads
#2. The description above and elsewhere suggests holding on to a reference to the gamepad object and querying it for values. But this fails. In fact, the example code in the article does not do this. It updates the gamepad objects near the end
In other words, it's updating the
controllers
array with a new gamepad object for the same gamepad.If instead you did this
You'd see the example would fail. At least in Chrome I get a few readings and then gamepad object I was holding a reference too goes dead. Where as if I made sure to get new gamepad objects by calling
navigator.getGamepads
then the code keeps running.Let me add, holding on to a reference used to work. I was grabbing some old code that held references and I know worked great when I wrote it 7 yrs ago but suddenly it was not working. I tracked the issue down to this. You can't keep a reference to the gamepad object. You need to take new ones by calling getGamepads
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/api/gamepad_api/using_the_gamepad_api
The text was updated successfully, but these errors were encountered: