当前位置: 首页>>代码示例>>C++>>正文


C++ PeripheralAddonPtr类代码示例

本文整理汇总了C++中PeripheralAddonPtr的典型用法代码示例。如果您正苦于以下问题:C++ PeripheralAddonPtr类的具体用法?C++ PeripheralAddonPtr怎么用?C++ PeripheralAddonPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PeripheralAddonPtr类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitializeProperties

bool CPeripheralBusAddon::InitializeProperties(CPeripheral& peripheral)
{
  if (!CPeripheralBus::InitializeProperties(peripheral))
    return false;

  bool bSuccess = false;

  PeripheralAddonPtr addon;
  unsigned int index;

  if (SplitLocation(peripheral.Location(), addon, index))
  {
    switch (peripheral.Type())
    {
      case PERIPHERAL_JOYSTICK:
        bSuccess = addon->GetJoystickProperties(index, static_cast<CPeripheralJoystick&>(peripheral));
        break;

      default:
        break;
    }
  }

  return bSuccess;
}
开发者ID:Arcko,项目名称:xbmc,代码行数:25,代码来源:PeripheralBusAddon.cpp

示例2: lock

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;
}
开发者ID:Arcko,项目名称:xbmc,代码行数:32,代码来源:PeripheralBusAddon.cpp

示例3: PowerOff

void CPeripheralBusAddon::PowerOff(const std::string& strLocation)
{
  PeripheralAddonPtr addon;
  unsigned int peripheralIndex;
  if (SplitLocation(strLocation, addon, peripheralIndex))
    addon->PowerOffJoystick(peripheralIndex);
}
开发者ID:Arcko,项目名称:xbmc,代码行数:7,代码来源:PeripheralBusAddon.cpp

示例4: UnRegisterAddon

void CPeripheralBusAddon::UnRegisterAddon(const std::string& addonId)
{
  CLog::Log(LOGDEBUG, "Add-on bus: Unregistering add-on %s", addonId.c_str());

  PeripheralAddonPtr erased;
  auto ErasePeripheralAddon = [&addonId, &erased](const PeripheralAddonPtr& addon)
    {
      if (addon->ID() == addonId)
      {
        erased = addon;
        return true;
      }
      return false;
    };

  m_addons.erase(std::remove_if(m_addons.begin(), m_addons.end(), ErasePeripheralAddon), m_addons.end());
  if (!erased)
    m_failedAddons.erase(std::remove_if(m_failedAddons.begin(), m_failedAddons.end(), ErasePeripheralAddon), m_failedAddons.end());

  if (erased)
  {
    CSingleExit exit(m_critSection);
    erased->DestroyAddon();
  }
}
开发者ID:ssfdre38,项目名称:xbmc,代码行数:25,代码来源:PeripheralBusAddon.cpp

示例5: SendRumbleEvent

bool CPeripheralBusAddon::SendRumbleEvent(const std::string& strLocation, unsigned int motorIndex, float magnitude)
{
  bool bHandled = false;

  PeripheralAddonPtr addon;
  unsigned int peripheralIndex;
  if (SplitLocation(strLocation, addon, peripheralIndex))
    bHandled = addon->SendRumbleEvent(peripheralIndex, motorIndex, magnitude);

  return bHandled;
}
开发者ID:Arcko,项目名称:xbmc,代码行数:11,代码来源:PeripheralBusAddon.cpp

示例6: GetPeripheral

PeripheralPtr CPeripheralBusAddon::GetPeripheral(const std::string &strLocation) const
{
  PeripheralPtr      peripheral;
  PeripheralAddonPtr addon;
  unsigned int       peripheralIndex;

  CSingleLock lock(m_critSection);

  if (SplitLocation(strLocation, addon, peripheralIndex))
    peripheral = addon->GetPeripheral(peripheralIndex);

  return peripheral;
}
开发者ID:Arcko,项目名称:xbmc,代码行数:13,代码来源:PeripheralBusAddon.cpp

示例7: SplitLocation

bool CPeripheralBusAddon::SplitLocation(const std::string& strLocation, PeripheralAddonPtr& addon, unsigned int& peripheralIndex) const
{
  std::vector<std::string> parts = StringUtils::Split(strLocation, "/");
  if (parts.size() == 2)
  {
    addon.reset();

    CSingleLock lock(m_critSection);

    const std::string& strAddonId = parts[0];
    for (const auto& addonIt : m_addons)
    {
      if (addonIt->ID() == strAddonId)
      {
        addon = addonIt;
        break;
      }
    }

    if (addon)
    {
      const char* strJoystickIndex = parts[1].c_str();
      char* p = NULL;
      peripheralIndex = strtol(strJoystickIndex, &p, 10);
      if (strJoystickIndex != p)
        return true;
    }
  }
  return false;
}
开发者ID:Arcko,项目名称:xbmc,代码行数:30,代码来源:PeripheralBusAddon.cpp

示例8: Register

void CPeripheralBusAddon::Register(const PeripheralPtr& peripheral)
{
  if (!peripheral)
    return;

  PeripheralAddonPtr addon;
  unsigned int       peripheralIndex;

  CSingleLock lock(m_critSection);

  if (SplitLocation(peripheral->Location(), addon, peripheralIndex))
  {
    if (addon->Register(peripheralIndex, peripheral))
      m_manager.OnDeviceAdded(*this, *peripheral);
  }
}
开发者ID:Arcko,项目名称:xbmc,代码行数:16,代码来源:PeripheralBusAddon.cpp

示例9: RequestRemoval

bool CPeripheralBusAddon::RequestRemoval(ADDON::AddonPtr addon)
{
  // make sure this is a peripheral addon
  PeripheralAddonPtr peripheralAddon = std::dynamic_pointer_cast<CPeripheralAddon>(addon);
  if (peripheralAddon == nullptr)
    return false;

  CSingleLock lock(m_critSection);
  // destroy the peripheral addon
  peripheralAddon->Destroy();

  // remove the peripheral addon from the list of addons
  m_addons.erase(std::remove(m_addons.begin(), m_addons.end(), peripheralAddon), m_addons.end());

  return true;
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:16,代码来源:PeripheralBusAddon.cpp

示例10: RequestRestart

bool CPeripheralBusAddon::RequestRestart(ADDON::AddonPtr addon, bool datachanged)
{
  // make sure this is a peripheral addon
  PeripheralAddonPtr peripheralAddon = std::dynamic_pointer_cast<CPeripheralAddon>(addon);
  if (peripheralAddon == nullptr)
    return false;

  if (peripheralAddon->CreateAddon() != ADDON_STATUS_OK)
  {
    CSingleLock lock(m_critSection);
    m_addons.erase(std::remove(m_addons.begin(), m_addons.end(), peripheralAddon), m_addons.end());
    m_failedAddons.push_back(peripheralAddon);
  }

  return true;
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:16,代码来源:PeripheralBusAddon.cpp

示例11: GetIcon

std::string CPeripheral::GetIcon() const
{
  std::string icon = "DefaultAddon.png";

  if (m_busType == PERIPHERAL_BUS_ADDON)
  {
    CPeripheralBusAddon* bus = static_cast<CPeripheralBusAddon*>(m_bus);

    PeripheralAddonPtr addon;
    unsigned int index;
    if (bus->SplitLocation(m_strLocation, addon, index))
    {
      std::string addonIcon = addon->Icon();
      if (!addonIcon.empty())
        icon = std::move(addonIcon);
    }
  }

  return icon;
}
开发者ID:FLyrfors,项目名称:xbmc,代码行数:20,代码来源:Peripheral.cpp


注:本文中的PeripheralAddonPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。