I'm trying to write some code to get a gamepad and list the axes' position:
window.addEventListener("gamepadconnected", (e) => {
console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
e.gamepad.index, e.gamepad.id,
e.gamepad.buttons.length, e.gamepad.axes.length);
});
const [gp] = navigator.getGamepads()[0]
console.log(gp.axes)
and get an Uncaught TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
.
Would really appreciate help.