Ejemplo n.º 1
0
bool SupportsPeripheralControllers(const std::string &condition, const std::string &value, const CSetting *setting, void *data)
{
  using namespace PERIPHERALS;

  PeripheralBusAddonPtr bus = std::static_pointer_cast<CPeripheralBusAddon>(g_peripherals.GetBusByType(PERIPHERAL_BUS_ADDON));
  return bus != nullptr && bus->HasFeature(FEATURE_JOYSTICK);
}
Ejemplo n.º 2
0
ADDON::AddonPtr CPeripheralAddon::GetRunningInstance(void) const
{
  PeripheralBusAddonPtr addonBus = std::static_pointer_cast<CPeripheralBusAddon>(g_peripherals.GetBusByType(PERIPHERAL_BUS_ADDON));
  if (addonBus)
  {
    ADDON::AddonPtr peripheralAddon;
    if (addonBus->GetAddon(ID(), peripheralAddon))
      return peripheralAddon;
  }
  return CAddon::GetRunningInstance();
}
Ejemplo n.º 3
0
PeripheralAddonPtr CPeripherals::GetAddonWithButtonMap(const CPeripheral* device)
{
  PeripheralBusAddonPtr addonBus = std::static_pointer_cast<CPeripheralBusAddon>(GetBusByType(PERIPHERAL_BUS_ADDON));

  PeripheralAddonPtr addon;

  PeripheralAddonPtr addonWithButtonMap;
  if (addonBus && addonBus->GetAddonWithButtonMap(device, addonWithButtonMap))
    addon = std::move(addonWithButtonMap);

  return addon;
}
Ejemplo n.º 4
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();
}
Ejemplo n.º 5
0
void CPeripherals::ResetButtonMaps(const std::string& controllerId)
{
  PeripheralBusAddonPtr addonBus = std::static_pointer_cast<CPeripheralBusAddon>(GetBusByType(PERIPHERAL_BUS_ADDON));

  PeripheralVector peripherals;
  GetPeripheralsWithFeature(peripherals, FEATURE_JOYSTICK);

  for (auto& peripheral : peripherals)
  {
    PeripheralAddonPtr addon;
    if (addonBus->GetAddonWithButtonMap(peripheral.get(), addon))
    {
      CAddonButtonMap buttonMap(peripheral.get(), addon, controllerId);
      buttonMap.Reset();
    }
  }
}
Ejemplo n.º 6
0
PeripheralAddonPtr CPeripherals::GetAddon(const CPeripheral* device)
{
  PeripheralAddonPtr addon;

  PeripheralBusAddonPtr addonBus = std::static_pointer_cast<CPeripheralBusAddon>(GetBusByType(PERIPHERAL_BUS_ADDON));
  if (device && addonBus)
  {
    PeripheralBusType busType = device->GetBusType();

    if (busType == PERIPHERAL_BUS_ADDON)
    {
      // If device is from an add-on, use that add-on
      unsigned int index;
      addonBus->SplitLocation(device->Location(), addon, index);
    }
    else
    {
      // Otherwise, have the add-on bus find a suitable add-on
      addonBus->GetAddonWithButtonMap(device, addon);
    }
  }

  return addon;
}