What the Gamepad API actually tells you about stick drift (with a working verdict algorithm)
A player files a bug: "my controller drifts." You open the browser, call navigator.getGamepads() , and see a resting value of 0.03 . Is that a defective stick β or electrical noise?
A single reading can't answer that. Here's how to build a verdict that can, and the traps the Gamepad API sets along the way.
1. The API gives you samples, not facts
function poll (): Gamepad | null { const pads = navigator . getGamepads ?.() ?? []; for ( const p of pads ) if ( p ) return p ; return null ; }
Enter fullscreen mode
Exit fullscreen mode
Three things bite everyone eventually:
No data before user interaction. Browsers only populate gamepad state after a button press or stick move (by design β same policy as audio). Your tester must prompt "press a button first" or every axis reads 0 and you'll ship a false "healthy" verdict.
It's a polling API.β¦