本文整理汇总了C++中PeripheralPtr::Type方法的典型用法代码示例。如果您正苦于以下问题:C++ PeripheralPtr::Type方法的具体用法?C++ PeripheralPtr::Type怎么用?C++ PeripheralPtr::Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PeripheralPtr
的用法示例。
在下文中一共展示了PeripheralPtr::Type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Register
bool CPeripheralAddon::Register(unsigned int peripheralIndex, const PeripheralPtr& peripheral)
{
if (!peripheral)
return false;
CSingleLock lock(m_critSection);
if (m_peripherals.find(peripheralIndex) == m_peripherals.end())
{
if (peripheral->Type() == PERIPHERAL_JOYSTICK)
{
m_peripherals[peripheralIndex] = std::static_pointer_cast<CPeripheralJoystick>(peripheral);
CLog::Log(LOGNOTICE, "%s - new %s device registered on %s->%s: %s",
__FUNCTION__, PeripheralTypeTranslator::TypeToString(peripheral->Type()),
PeripheralTypeTranslator::BusTypeToString(PERIPHERAL_BUS_ADDON),
peripheral->Location().c_str(), peripheral->DeviceName().c_str());
return true;
}
}
return false;
}
示例2: Register
void CPeripheralBus::Register(const PeripheralPtr& peripheral)
{
if (!peripheral)
return;
bool bPeripheralAdded = false;
{
CSingleLock lock(m_critSection);
if (!HasPeripheral(peripheral->Location()))
{
m_peripherals.push_back(peripheral);
bPeripheralAdded = true;
}
}
if (bPeripheralAdded)
{
CLog::Log(LOGNOTICE, "%s - new %s device registered on %s->%s: %s (%s:%s)", __FUNCTION__, PeripheralTypeTranslator::TypeToString(peripheral->Type()), PeripheralTypeTranslator::BusTypeToString(m_type), peripheral->Location().c_str(), peripheral->DeviceName().c_str(), peripheral->VendorIdAsString(), peripheral->ProductIdAsString());
m_manager.OnDeviceAdded(*this, *peripheral);
}
}
示例3: ProcessEvents
bool CPeripheralAddon::ProcessEvents(void)
{
if (!m_bProvidesJoysticks)
return false;
PERIPHERAL_ERROR retVal;
unsigned int eventCount = 0;
PERIPHERAL_EVENT* pEvents = NULL;
LogError(retVal = m_pStruct->GetEvents(&eventCount, &pEvents), "GetEvents()");
if (retVal == PERIPHERAL_NO_ERROR)
{
for (unsigned int i = 0; i < eventCount; i++)
{
ADDON::PeripheralEvent event(pEvents[i]);
PeripheralPtr device = GetPeripheral(event.PeripheralIndex());
if (!device)
continue;
switch (device->Type())
{
case PERIPHERAL_JOYSTICK:
{
std::shared_ptr<CPeripheralJoystick> joystickDevice = std::static_pointer_cast<CPeripheralJoystick>(device);
switch (event.Type())
{
case PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON:
{
const bool bPressed = (event.ButtonState() == JOYSTICK_STATE_BUTTON_PRESSED);
CLog::Log(LOGDEBUG, "Button [ %u ] on %s %s", event.DriverIndex(),
joystickDevice->DeviceName().c_str(), bPressed ? "pressed" : "released");
if (joystickDevice->OnButtonMotion(event.DriverIndex(), bPressed))
CLog::Log(LOGDEBUG, "Joystick button event handled");
break;
}
case PERIPHERAL_EVENT_TYPE_DRIVER_HAT:
{
const HAT_STATE state = CPeripheralAddonTranslator::TranslateHatState(event.HatState());
CLog::Log(LOGDEBUG, "Hat [ %u ] on %s %s", event.DriverIndex(),
joystickDevice->DeviceName().c_str(), CJoystickTranslator::HatStateToString(state));
if (joystickDevice->OnHatMotion(event.DriverIndex(), state))
CLog::Log(LOGDEBUG, "Joystick hat event handled");
break;
}
case PERIPHERAL_EVENT_TYPE_DRIVER_AXIS:
{
joystickDevice->OnAxisMotion(event.DriverIndex(), event.AxisState());
break;
}
default:
break;
}
break;
}
default:
break;
}
}
for (auto it : m_peripherals)
{
if (it.second->Type() == PERIPHERAL_JOYSTICK)
std::static_pointer_cast<CPeripheralJoystick>(it.second)->ProcessAxisMotions();
}
m_pStruct->FreeEvents(eventCount, pEvents);
return true;
}
return false;
}