public bootstrap()

in src/input.service.ts [372:399]


  public bootstrap(root: HTMLElement = document.body) {
    directionNumsList.forEach(num => this.emitters.set(num, new EventEmitter<ArcEvent>()));

    // The gamepadInputEmulation is a string property that exists in
    // JavaScript UWAs and in WebViews in UWAs. It won't exist in
    // Win8.1 style apps or browsers.
    if ('gamepadInputEmulation' in navigator) {
      // We want the gamepad to provide gamepad VK keyboard events rather than moving a
      // mouse like cursor. The gamepad will provide such keyboard events and provide
      // input to the DOM
      // @ts-ignore
      navigator.gamepadInputEmulation = 'keyboard';
    } else if ('getGamepads' in navigator) {
      // Poll connected gamepads and use that for input if keyboard emulation isn't available
      this.watchForGamepad();
    }

    this.addKeyboardListeners();
    this.focus.setRoot(root, this.focus.scrollSpeed);

    this.subscriptions.push(
      fromEvent<FocusEvent>(document, 'focusin')
        .pipe(filter(ev => ev.target !== this.focus.selected))
        .subscribe(ev => {
          this.focus.onFocusChange(<HTMLElement>ev.target, this.focus.scrollSpeed);
        }),
    );
  }