Playing with the Gamepad API: Using Game Controllers with JS
summary
Explains concrete behavior and gotchas: only two events fire so code polls with navigator.getGamepads on requestAnimationFrame; Chrome often returns an array of four with null slots; Firefox exposes six axes on some sticks; axes are -1..1 and need a deadzone (recommend ~0.2); buttons deliver continuous pressed state so track previous value; vibration APIs vary by browser; demos include Super Pepper Bros, an arenoid, and a Wacamo-style music game built in vanilla JavaScript and running locally.
AI-written summary · about
chapters (15)
- 0:00Gamepad API intro
- 1:04What is Gamepad API
- 2:08Gamepad API events
- 3:32Proactive gamepad state
- 4:13Getting gamepads
- 5:18Gamepad properties
- 8:35Standard vs non-standard
- 9:37Multiple gamepads
- 10:41requestAnimationFrame vs setInterval
- 12:51Button press states
- 14:15Joystick axis values
- 16:46Vibration actuator
- 18:12Library recommendations
- 18:33Live demos
- 22:59Q&A
related talks
38mMaking Music With JavaScript and Gamepads
29mControlling the web with a PS5 controller
25mJavascript as Play A Primer on Getting Started with Video Games
18mExploring alternative interactions in JavaScript
29mOnce Upon A Time, Somewhere Between Your Console And Browser
42mExploring Alternative Interactions in JavaScript
29mMIDI A New Dimension in Controlling Your Browser
46mMonsters, lightbulbs and robots: having fun with WebBluetooth
