本文整理汇总了C++中ControllerPtr::FeatureCount方法的典型用法代码示例。如果您正苦于以下问题:C++ ControllerPtr::FeatureCount方法的具体用法?C++ ControllerPtr::FeatureCount怎么用?C++ ControllerPtr::FeatureCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControllerPtr
的用法示例。
在下文中一共展示了ControllerPtr::FeatureCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenJoystick
bool CGameClientInput::OpenJoystick(const std::string &portAddress, const ControllerPtr &controller)
{
using namespace JOYSTICK;
if (!controller)
{
CLog::Log(LOGERROR, "Failed to open port \"%s\", no controller given", portAddress.c_str());
return false;
}
const CControllerPortNode &port = m_controllers.GetPort(portAddress);
if (!port.IsControllerAccepted(portAddress, controller->ID()))
{
CLog::Log(LOGERROR, "Failed to open port: Invalid controller \"%s\" on port \"%s\"",
controller->ID().c_str(), portAddress.c_str());
return false;
}
std::string strId = controller->ID();
game_controller controllerStruct{};
controllerStruct.controller_id = strId.c_str();
controllerStruct.provides_input = controller->Topology().ProvidesInput();
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.ConnectController(true, portAddress.c_str(), &controllerStruct);
}
catch (...)
{
m_gameClient.LogException("ConnectController()");
}
}
}
if (bSuccess)
{
m_joysticks[portAddress].reset(new CGameClientJoystick(m_gameClient, portAddress, controller, m_struct.toAddon));
ProcessJoysticks();
return true;
}
return false;
}
示例2: 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;
}
示例3: 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()"); }
}
}
}