コード例 #1
0
unsigned int CAddonCallbacksPeripheral::FeatureCount(void* addonData, const char* controllerId, JOYSTICK_FEATURE_TYPE type)
{
  using namespace ADDON;
  using namespace GAME;

  unsigned int count = 0;

  AddonPtr addon;
  if (CAddonMgr::GetInstance().GetAddon(controllerId, addon, ADDON_GAME_CONTROLLER))
  {
    ControllerPtr controller = std::static_pointer_cast<CController>(addon);
    if (controller->LoadLayout())
      count = controller->Layout().FeatureCount(CPeripheralAddonTranslator::TranslateFeatureType(type));
  }

  return count;
}
コード例 #2
0
ファイル: ButtonMapping.cpp プロジェクト: AchimTuran/xbmc
CButtonMapping::CButtonMapping(IButtonMapper* buttonMapper, IButtonMap* buttonMap, IActionMap* actionMap) :
  m_buttonMapper(buttonMapper),
  m_buttonMap(buttonMap),
  m_actionMap(actionMap),
  m_lastAction(0),
  m_frameCount(0)
{
  assert(m_buttonMapper != nullptr);
  assert(m_buttonMap != nullptr);

  // Make sure axes mapped to Select are centered before they can be mapped.
  // This ensures that they are not immediately mapped to the first button.
  if (m_actionMap && m_actionMap->ControllerID() == m_buttonMap->ControllerID())
  {
    using namespace GAME;

    CGameServices& gameServices = CServiceBroker::GetGameServices();
    ControllerPtr controller = gameServices.GetController(m_actionMap->ControllerID());

    const auto& features = controller->Layout().Features();
    for (const auto& feature : features)
    {
      if (m_actionMap->GetActionID(feature.Name()) != ACTION_SELECT_ITEM)
        continue;

      CDriverPrimitive primitive;
      if (!m_buttonMap->GetScalar(feature.Name(), primitive))
        continue;

      if (primitive.Type() != PRIMITIVE_TYPE::SEMIAXIS)
        continue;

      // Set initial config, as detection will fail because axis is already activated
      AxisConfiguration axisConfig;
      axisConfig.bKnown = true;
      axisConfig.center = primitive.Center();
      axisConfig.range = primitive.Range();

      GetAxis(primitive.Index(), primitive.Center(), axisConfig).SetEmitted(primitive);
    }
  }
}
コード例 #3
0
ファイル: GUIFeatureList.cpp プロジェクト: 0xheart0/xbmc
void CGUIFeatureList::Load(const ControllerPtr& controller)
{
  if (m_controller && m_controller->ID() == controller->ID())
    return; // Already loaded

  CleanupButtons();

  m_controller = controller;

  const std::vector<CControllerFeature>& features = controller->Layout().Features();

  for (unsigned int buttonIndex = 0; buttonIndex < features.size(); buttonIndex++)
  {
    const CControllerFeature& feature = features[buttonIndex];

    CGUIButtonControl* pButton = nullptr;
    switch (feature.Type())
    {
      case JOYSTICK::FEATURE_TYPE::SCALAR:
      {
        pButton = new CGUIScalarFeatureButton(*m_guiButtonTemplate, m_wizard, feature, buttonIndex);
        break;
      }
      case JOYSTICK::FEATURE_TYPE::ANALOG_STICK:
      {
        pButton = new CGUIAnalogStickButton(*m_guiButtonTemplate, m_wizard, feature, buttonIndex);
        break;
      }
      default:
        break;
    }
    if (pButton)
      m_guiList->AddControl(pButton);

    // Just in case
    if (buttonIndex >= MAX_FEATURE_COUNT)
      break;
  }
}