function checkControllerPresentAndSetup(component, idPrefix, queryObject) {
  var el = component.el;
  var controller;
  var isControllerPresent = isControllerPresentWebXR;
  var isPresent;
  controller = isControllerPresent(component, idPrefix, queryObject);
  isPresent = !!controller;

  // Nothing changed, no need to do anything.
  if (isPresent === component.controllerPresent) {
    return isPresent;
  }
  component.controllerPresent = isPresent;

  // Update controller presence.
  if (isPresent) {
    component.addEventListeners();
    component.injectTrackedControls(controller);
    el.emit('controllerconnected', {
      name: component.name,
      component: component
    });
  } else {
    component.removeEventListeners();
    el.emit('controllerdisconnected', {
      name: component.name,
      component: component
    });
  }
}
Called on controller component `.play` handlers.
Check if controller matches parameters and inject tracked-controls component.
Handle event listeners.
Generate controllerconnected or controllerdisconnected events.

@param {object} component - Tracked controls component.
@param {object} idPrefix - Prefix to match in gamepad id if any.
@param {object} queryObject - Map of values to match.