本文整理汇总了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;
}
示例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;
}
示例3: PowerOff
void CPeripheralBusAddon::PowerOff(const std::string& strLocation)
{
PeripheralAddonPtr addon;
unsigned int peripheralIndex;
if (SplitLocation(strLocation, addon, peripheralIndex))
addon->PowerOffJoystick(peripheralIndex);
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}