-
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
Attempt to bring the Gamepad API examples up to date #33724
Conversation
- Gamepad.buttons has been specced as an object since February 2014. - All of this stuff about Chrome seems to be to explain why you can't simply hold onto the same Gamepad object and keep checking it in Chrome? But there's no need to poll to fix that; just read `navigator.getGamepads()`, which works in every browser.
Preview URLs External URLs (2)URL:
(comment last updated: 2024-07-24 12:31:43) |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Heya @eevee thanks for opening this one. I have one prose suggestion for you above, do you plan to come back to this? Thank you :) |
Co-authored-by: Brian Thomas Smith <brian@smith.berlin>
hey! yeah that seems reasonable. (i did think about trying to get the two versions of the demo back in sync, but the upstream one seems to have sprouted some extra features in the meantime that would distract from the MDN article, so.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super, thank you. I'll merge shortly 👍🏻
This had some alarmingly ancient and misleading stuff in it. I touched this up very quickly in a jsbin textarea, but it wfm in current Firefox and current Chrome, and based on some bug tracker diving I think it should be fine going back some eight or more years.
It's unfortunate that the examples both link to github projects I have no control over, but one had already drifted out of sync, and I think making the page itself be more correct is more important.
Could probably stand further improvement; this is more a "stop the bleeding" patch after I realized I'd gotten a completely wrong impression about Chrome's behavior from this page.
Description
This code was based around very old engine differences that aren't even explained well in the prose. I am baffled by issue templates.
Motivation
I initially thought the paragraph about Chrome was suggesting that
Gamepad
's state only updated every so often unless explicitly nudged, or something, then later realized that didn't make any sense since there's no way to "nudge" it. In retrospect it looks like it was referring to howGamepadEvent.gamepad
is (to this day) a snapshot in Chrome but a live object in Firefox, but this difference can be avoided entirely by just usingnavigator.getGamepads()
when updating, instead of keeping the event's property around. Also the given code doesn't work in current Chrome anyway!Then I fixed some other stuff like how connecting two gamepads would start two rAF loops in the final demo?? And got rid of checking whether
Gamepad.button
is a float or an object because it's been specced as an object for an entire decade and nothing else in the article even explains this. And also just some style nits like.forEach
being the most 2013 thing I have ever seen.Additional details
Please. Please there are so many fields. I have now spent longer writing this issue than I spent on the patch