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


C++ ControllerPtr类代码示例

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


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

示例1:

std::vector<std::string> CRumbleGenerator::GetMotors(const std::string& controllerId)
{
  using namespace GAME;

  std::vector<std::string> motors;

  CControllerManager& controllerManager = CServiceBroker::GetGameControllerManager();
  ControllerPtr controller = controllerManager.GetController(controllerId);
  if (controller)
    controller->GetFeatures(motors, FEATURE_TYPE::MOTOR);
 
  return motors;
}
开发者ID:FLyrfors,项目名称:xbmc,代码行数:13,代码来源:RumbleGenerator.cpp

示例2: RegisterController

void CGUIControllerList::RegisterController(const std::string& addonId, const ADDON::VECADDONS& addonCache)
{
  auto it = std::find_if(addonCache.begin(), addonCache.end(),
    [addonId](const AddonPtr& addon)
    {
      return addon->ID() == addonId;
    });

  if (it != addonCache.end())
  {
    ControllerPtr newController = std::dynamic_pointer_cast<CController>(*it);
    if (newController && newController->LoadLayout())
      m_controllers.push_back(newController);
  }
}
开发者ID:Almarefa,项目名称:xbmc,代码行数:15,代码来源:GUIControllerList.cpp

示例3: m_buttonMapper

CButtonMapping::CButtonMapping(IButtonMapper* buttonMapper, IButtonMap* buttonMap, IKeymap* keymap) :
  m_buttonMapper(buttonMapper),
  m_buttonMap(buttonMap),
  m_keymap(keymap),
  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_keymap)
  {
    using namespace GAME;

    CControllerManager& controllerManager = CServiceBroker::GetGameControllerManager();
    ControllerPtr controller = controllerManager.GetController(m_keymap->ControllerID());

    const auto& features = controller->Features();
    for (const auto& feature : features)
    {
      bool bIsSelectAction = false;

      const auto &actions = m_keymap->GetActions(CJoystickUtils::MakeKeyName(feature.Name())).actions;
      if (!actions.empty() && actions.begin()->actionId == ACTION_SELECT_ITEM)
        bIsSelectAction = true;

      if (!bIsSelectAction)
        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(), static_cast<float>(primitive.Center()), axisConfig).SetEmitted(primitive);
    }
  }
}
开发者ID:ssfdre38,项目名称:xbmc,代码行数:48,代码来源:ButtonMapping.cpp

示例4: OpenMouse

bool CGameClientInput::OpenMouse(const ControllerPtr &controller)
{
  using namespace JOYSTICK;

  if (!controller)
  {
    CLog::Log(LOGERROR, "Failed to open mouse, no controller given");
    return false;
  }

  //! @todo Move to player manager
  PERIPHERALS::PeripheralVector mice;
  CServiceBroker::GetPeripherals().GetPeripheralsWithFeature(mice, PERIPHERALS::FEATURE_MOUSE);
  if (mice.empty())
    return false;

  std::string controllerId = controller->ID();

  game_controller controllerStruct{};

  controllerStruct.controller_id        = controllerId.c_str();
  controllerStruct.digital_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::DIGITAL);
  controllerStruct.analog_button_count  = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::ANALOG);
  controllerStruct.analog_stick_count   = controller->FeatureCount(FEATURE_TYPE::ANALOG_STICK);
  controllerStruct.accelerometer_count  = controller->FeatureCount(FEATURE_TYPE::ACCELEROMETER);
  controllerStruct.key_count            = controller->FeatureCount(FEATURE_TYPE::KEY);
  controllerStruct.rel_pointer_count    = controller->FeatureCount(FEATURE_TYPE::RELPOINTER);
  controllerStruct.abs_pointer_count    = controller->FeatureCount(FEATURE_TYPE::ABSPOINTER);
  controllerStruct.motor_count          = controller->FeatureCount(FEATURE_TYPE::MOTOR);

  bool bSuccess = false;

  {
    CSingleLock lock(m_clientAccess);

    if (m_gameClient.Initialized())
    {
      try
      {
        bSuccess = m_struct.toAddon.EnableMouse(true, &controllerStruct);
      }
      catch (...)
      {
        m_gameClient.LogException("EnableMouse()");
      }
    }
  }

  if (bSuccess)
  {
    m_mouse.reset(new CGameClientMouse(m_gameClient, controllerId, m_struct.toAddon, mice.at(0).get()));
    return true;
  }

  return false;
}
开发者ID:intrcomp,项目名称:xbmc,代码行数:56,代码来源:GameClientInput.cpp

示例5: FeatureCount

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

示例6: run

void run(ControllerPtr &controller)
try
{
    // Prepare Analysis
    //
    FilterAnalyzerPtr analyzer(new FilterAnalyzer());

    // Process inputs
    //
    controller->use(analyzer);
    controller->start();

    cout << *analyzer << endl;
}
catch(...)
{
}
开发者ID:derekstrom,项目名称:bsm_analyze,代码行数:17,代码来源:filter.cpp

示例7: scaleTorque

/// Provides new values that the body should use to control it's actuators.
void
Else::AcrobotArticulatedBody
::setActuators( const ControllerPtr argController )
{
    // 1 actuator
    double torque = 0.85 * scaleTorque( argController->getOutput(1, 0) );
    dJointAddHingeTorque( myJoints[0], torque );
}
开发者ID:allenscape,项目名称:locomotor,代码行数:9,代码来源:AcrobotArticulatedBody.cpp

示例8: UpdatePort

void CGameClient::UpdatePort(unsigned int port, const ControllerPtr& controller)
{
  using namespace JOYSTICK;

  CSingleLock lock(m_critSection);

  if (Initialized())
  {
    if (controller != CController::EmptyPtr)
    {
      std::string strId = controller->ID();

      game_controller controllerStruct;

      controllerStruct.controller_id        = strId.c_str();
      controllerStruct.digital_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::DIGITAL);
      controllerStruct.analog_button_count  = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::ANALOG);
      controllerStruct.analog_stick_count   = controller->FeatureCount(FEATURE_TYPE::ANALOG_STICK);
      controllerStruct.accelerometer_count  = controller->FeatureCount(FEATURE_TYPE::ACCELEROMETER);
      controllerStruct.key_count            = 0; //! @todo
      controllerStruct.rel_pointer_count    = controller->FeatureCount(FEATURE_TYPE::RELPOINTER);
      controllerStruct.abs_pointer_count    = controller->FeatureCount(FEATURE_TYPE::ABSPOINTER);
      controllerStruct.motor_count          = controller->FeatureCount(FEATURE_TYPE::MOTOR);

      try { m_struct.toAddon.UpdatePort(port, true, &controllerStruct); }
      catch (...) { LogException("UpdatePort()"); }
    }
    else
    {
      try { m_struct.toAddon.UpdatePort(port, false, nullptr); }
      catch (...) { LogException("UpdatePort()"); }
    }
  }
}
开发者ID:FernetMenta,项目名称:xbmc,代码行数:34,代码来源:GameClient.cpp

示例9: assert

void
XboxdrvDaemon::on_connect(ControllerSlotPtr slot)
{
  ControllerPtr controller = slot->get_controller();
  assert(controller);

  if (!m_opts.on_connect.empty())
  {
    log_info("launching connect script: " << m_opts.on_connect);

    std::vector<std::string> args;
    args.push_back(m_opts.on_connect);
    args.push_back(controller->get_usbpath());
    args.push_back(controller->get_usbid());
    args.push_back(controller->get_name());
    spawn_exe(args);
  }
}
开发者ID:Free60Project,项目名称:xboxdrv,代码行数:18,代码来源:xboxdrv_daemon.cpp

示例10: m_buttonMapper

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

示例11:

void
XboxdrvMain::init_controller(const ControllerPtr& controller)
{
  m_jsdev_number = UInput::find_jsdev_number();
  m_evdev_number = UInput::find_evdev_number();

  if (m_opts.get_controller_slot().get_led_status() == -1)
  {
    controller->set_led(static_cast<uint8_t>(2 + m_jsdev_number % 4));
  }
  else
  {
    controller->set_led(static_cast<uint8_t>(m_opts.get_controller_slot().get_led_status()));
  }

  if (m_opts.rumble_l != -1 && m_opts.rumble_r != -1)
  { // Only set rumble when explicitly requested
    controller->set_rumble(static_cast<uint8_t>(m_opts.rumble_l),
                           static_cast<uint8_t>(m_opts.rumble_r));
  }
}
开发者ID:Ape,项目名称:xboxdrv,代码行数:21,代码来源:xboxdrv_main.cpp

示例12: catch

void
XboxdrvDaemon::connect(ControllerSlotPtr slot, ControllerPtr controller)
{
  log_info("connecting slot to thread");

  try 
  {
    // set the LED status
    if (slot->get_led_status() == -1)
    {
      controller->set_led(static_cast<uint8_t>(2 + (slot->get_id() % 4)));
    }
    else
    {
      controller->set_led(static_cast<uint8_t>(slot->get_led_status()));
    }
  }
  catch(const std::exception& err)
  {
    log_error("failed to set led: " << err.what());
  }
  
  slot->connect(controller);
  on_connect(slot);

  log_info("controller connected: " 
           << controller->get_usbpath() << " "
           << controller->get_usbid() << " "
           << "'" << controller->get_name() << "'");

  log_info("launched Controller for " << controller->get_usbpath()
           << " in slot " << slot->get_id() << ", free slots: " 
           << get_free_slot_count() << "/" << m_controller_slots.size());
}
开发者ID:Free60Project,项目名称:xboxdrv,代码行数:34,代码来源:xboxdrv_daemon.cpp

示例13: Load

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

示例14: getBestMigrant

MultiKultiControllerPtr MultiKultiInstance::getBestMigrant(int nodeId){

	vector<NewsItem*>  * island = allItems[nodeId];
	//int i = Rand::randint(0,island->size());
	double bestFitness = island->at(0)->getContent()->GetOriginalFitness();
	//cout<<"Island size"<<island->size()<<endl;
	int best = 0;
	//cout<<"0:"<<bestFitness<<endl;
	for(unsigned int i =1;i<island->size();i++){
		double actualFitness = island->at(i)->getContent()->GetOriginalFitness();
		//cout<<i<<":"<<actualFitness<<endl;
		if(actualFitness > bestFitness){
			best = i;
			bestFitness = actualFitness;
			//cout<<"yay"<<endl;
		}

	}
	//cout<<"Received "<<best<<"from node "<<nodeId<<endl;
	ControllerPtr migrant = island->at(best)->getContent();

	return boost::dynamic_pointer_cast<MultiKultiController>(migrant->Clone());
}
开发者ID:DDraper95,项目名称:roborobo.roborobo-organisms,代码行数:23,代码来源:MultiKultiInstance.cpp

示例15: selectParentByBinaryTournament

ControllerPtr PopulationControlArchitecture::selectParentByBinaryTournament(ControllerPtr exclude) {
	NewsItem *selectedSolutionA = population->randomNews(exclude);
	ControllerPtr parentA;
	if (selectedSolutionA != NULL) {
		if (debug) {
			cout << population->getId() << " - ParentA: " << selectedSolutionA->getAgentId() << " (" << selectedSolutionA->getTimestamp() << ")" << endl;
		}
		parentA = selectedSolutionA->getContent();
	}
	if (parentA == NULL) { // the population gave us a NULL parent; generate a random one
		//cout << population->getId() << " - ParentA: NULL" << endl;
		if (debug) {
			cout << "Got NULL parent A, generating random parent A." << endl;
		}
		parentA = this->createRandomGenome();
	}

	// select a second parent, excluding the first from the selection
	NewsItem *selectedSolutionB = population->randomNews(parentA, exclude);
	ControllerPtr parentB;
	if (selectedSolutionB != NULL) {
		if (debug) {
			cout << population->getId() << " - ParentB: " << selectedSolutionB->getAgentId() << " (" << selectedSolutionB->getTimestamp() << ")" << endl;
		}
		parentB = selectedSolutionB->getContent();
	}
	if (parentB == NULL) { // the population gave us a NULL parent; generate a random one
		//cout << population->getId() << " - ParentB: NULL" << endl;
		if (debug) {
			cout << "Got NULL parent B, generating random parent B." << endl;
		}
		parentB = this->createRandomGenome();
	}

	if (debug) {
		cout << "ParentA: " << parentA->GetOriginalFitness() << " vs ParentB: " << parentB->GetOriginalFitness() << endl;
	}

	if (parentA->GetOriginalFitness() > parentB->GetOriginalFitness()) {
		return parentA;
	} else {
		return parentB;
	}
}
开发者ID:ci-group,项目名称:monee,代码行数:44,代码来源:PopulationControlArchitecture.cpp


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