code: function () {
      var gamepadSupportAvailable = navigator.getGamepads ||
          !!navigator.webkitGetGamepads ||
          !!navigator.webkitGamepads;
  
      if (!gamepadSupportAvailable) {
        // It doesn't seem Gamepad API is available, show a message telling
        // the visitor about it.
        window.tester.showNotSupported();
      } else {
        // Check and see if gamepadconnected/gamepaddisconnected is supported.
        // If so, listen for those events and don't start polling until a
        // gamepad has been connected.
        if (gamepadSupport.hasEvents) {
          // If connection events are not supported, just start polling.
          gamepadSupport.startPolling();
        } else {
          window.addEventListener('gamepadconnected',
                                  gamepadSupport.onGamepadConnect);
          window.addEventListener('gamepaddisconnected',
                                  gamepadSupport.onGamepadDisconnect);
        }
      }
    }
docs: Initialize support for Gamepad API.