示例#1
0
bool CPeripheralBusAddon::GetAddonWithButtonMap(const CPeripheral* device, PeripheralAddonPtr &addon) const
{
  CSingleLock lock(m_critSection);

  // If device is from an add-on, try to use that add-on
  if (device && device->GetBusType() == PERIPHERAL_BUS_ADDON)
  {
    PeripheralAddonPtr addonWithButtonMap;
    unsigned int index;
    if (SplitLocation(device->Location(), addonWithButtonMap, index))
    {
      if (addonWithButtonMap->HasButtonMaps())
        addon = std::move(addonWithButtonMap);
      else
        CLog::Log(LOGDEBUG, "Add-on %s doesn't provide button maps for its controllers", addonWithButtonMap->ID().c_str());
    }
  }

  if (!addon)
  {
    auto it = std::find_if(m_addons.begin(), m_addons.end(),
      [](const PeripheralAddonPtr& addon)
      {
        return addon->HasButtonMaps();
      });

    if (it != m_addons.end())
      addon = *it;
  }

  return addon.get() != nullptr;
}
示例#2
0
bool CPeripheralBusAddon::GetAddonWithButtonMap(PeripheralAddonPtr &addon) const
{
  CSingleLock lock(m_critSection);

  auto it = std::find_if(m_addons.begin(), m_addons.end(),
    [](const PeripheralAddonPtr& addon)
    {
      return addon->HasButtonMaps();
    });

  if (it != m_addons.end())
  {
    addon = *it;
    return  true;
  }

  return false;
}