code: function () {
      var buttonState;
      var controller = this.controller;
      var id;
  
      if (!controller) { return; }
  
      // Check every button.
      for (id = 0; id < controller.buttons.length; ++id) {
        // Initialize button state.
        if (!this.buttonStates[id]) {
          this.buttonStates[id] = {pressed: false, touched: false, value: 0};
        }
        if (!this.buttonEventDetails[id]) {
          this.buttonEventDetails[id] = {id: id, state: this.buttonStates[id]};
        }
  
        buttonState = controller.buttons[id];
        this.handleButton(id, buttonState);
      }
      // Check axes.
      this.handleAxes();
    }
docs: Handle button changes including axes, presses, touches, values.