private pollGamepad()

in src/input/gamepad-input.ts [108:132]


  private pollGamepad(now: number, gamepads: { [id: string]: IGamepadWrapper }): Button | null {
    if (this.keyboardVisible) {
      return null;
    }

    for (const pad of navigator.getGamepads()) {
      if (pad === null) {
        continue;
      }
      const gamepad = gamepads[pad.id];
      if (!gamepad) {
        continue;
      }

      gamepad.pad = pad;
      for (const button of buttons) {
        const gamepadEvt = gamepad.events.get(button);
        if (gamepadEvt && gamepadEvt(now)) {
          return button;
        }
      }
    }

    return null;
  }