Beispiel #1
0
void CGUIControllerWindow::OnInitWindow(void)
{
  using namespace PERIPHERALS;

  CGUIDialog::OnInitWindow();

  if (!m_featureList)
  {
    m_featureList = new CGUIFeatureList(this);
    if (!m_featureList->Initialize())
    {
      delete m_featureList;
      m_featureList = nullptr;
    }
  }

  if (!m_controllerList && m_featureList)
  {
    m_controllerList = new CGUIControllerList(this, m_featureList);
    if (!m_controllerList->Initialize())
    {
      delete m_controllerList;
      m_controllerList = nullptr;
    }
  }

  // Focus the first controller so that the feature list is loaded properly
  CGUIMessage msgFocus(GUI_MSG_SETFOCUS, GetID(), CONTROL_CONTROLLER_BUTTONS_START);
  OnMessage(msgFocus);

  // Check for button mapping support
  //! @todo remove this
  PeripheralBusAddonPtr bus = std::static_pointer_cast<CPeripheralBusAddon>(g_peripherals.GetBusByType(PERIPHERAL_BUS_ADDON));
  if (bus && !bus->HasFeature(FEATURE_JOYSTICK))
  {
    //! @todo Move the XML implementation of button map storage from add-on to
    //! Kodi while keeping support for add-on button-mapping

    CLog::Log(LOGERROR, "Joystick support not found");

    // "Joystick support not found"
    // "Controller configuration is disabled. Install the proper joystick support add-on."
    CGUIDialogOK::ShowAndGetInput(CVariant{35056}, CVariant{35057});

    // close the window as there's nothing that can be done
    Close();
  }

  // FIXME: not thread safe
//  ADDON::CRepositoryUpdater::GetInstance().Events().Subscribe(this, &CGUIControllerWindow::OnEvent);

  UpdateButtons();
}