本文整理汇总了C++中InputConfig::getDeviceIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ InputConfig::getDeviceIndex方法的具体用法?C++ InputConfig::getDeviceIndex怎么用?C++ InputConfig::getDeviceIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputConfig
的用法示例。
在下文中一共展示了InputConfig::getDeviceIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configureEmulators
std::string InputManager::configureEmulators() {
std::stringstream command;
// 1 recuperer les configurated
std::list<InputConfig *> availableConfigured;
for (auto it = 0; it < InputManager::getInstance()->getNumJoysticks(); it++) {
InputConfig * config = InputManager::getInstance()->getInputConfigByDevice(it);
//LOG(LogInfo) << "I am checking for an input named "<< config->getDeviceName() << " this configured ? "<<config->isConfigured();
if(config->isConfigured()) {
availableConfigured.push_back(config);
LOG(LogInfo) << "Available and configurated : " << config->getDeviceName();
}
}
//2 pour chaque joueur verifier si il y a un configurated
// associer le input au joueur
// enlever des disponibles
std::map<int, InputConfig*> playerJoysticks;
// First loop, search for GUID + NAME. High Priority
for (int player = 0; player < MAX_PLAYERS; player++) {
std::stringstream sstm;
sstm << "INPUT P" << player+1;
std::string confName = sstm.str()+"NAME";
std::string confGuid = sstm.str()+"GUID";
std::string playerConfigName = Settings::getInstance()->getString(confName);
std::string playerConfigGuid = Settings::getInstance()->getString(confGuid);
for (std::list<InputConfig *>::iterator it1=availableConfigured.begin(); it1!=availableConfigured.end(); ++it1)
{
InputConfig * config = *it1;
bool nameFound = playerConfigName.compare(config->getDeviceName()) == 0;
bool guidfound = playerConfigGuid.compare(config->getDeviceGUIDString()) == 0;
if(nameFound && guidfound) {
availableConfigured.erase(it1);
playerJoysticks[player] = config;
LOG(LogInfo) << "Saved " << config->getDeviceName() << " for player " << player;
break;
}
}
}
// Second loop, search for NAME. Low Priority
for (int player = 0; player < MAX_PLAYERS; player++) {
std::stringstream sstm;
sstm << "INPUT P" << player+1;
std::string confName = sstm.str()+"NAME";
std::string playerConfigName = Settings::getInstance()->getString(confName);
for (std::list<InputConfig *>::iterator it1=availableConfigured.begin(); it1!=availableConfigured.end(); ++it1)
{
InputConfig * config = *it1;
bool nameFound = playerConfigName.compare(config->getDeviceName()) == 0;
if(nameFound) {
availableConfigured.erase(it1);
playerJoysticks[player] = config;
LOG(LogInfo) << "Found " << config->getDeviceName() << " for player " << player;
break;
}
}
}
// Last loop, search for free controllers for remaining players.
for (int player = 0; player < MAX_PLAYERS; player++) {
// si aucune config a été trouvé pour le joueur, on essaie de lui filer un libre
if(playerJoysticks[player] == NULL){
LOG(LogInfo) << "No config for player " << player;
for (std::list<InputConfig *>::iterator it1=availableConfigured.begin(); it1!=availableConfigured.end(); ++it1)
{
playerJoysticks[player] = *it1;
availableConfigured.erase(it1);
LOG(LogInfo) << "So i set "<< playerJoysticks[player]->getDeviceName() << " for player " << player;
break;
}
}
}
// in case of hole (player 1 missing, but player 4 set, fill the holes with last players joysticks)
for (int player = 0; player < MAX_PLAYERS; player++) {
if(playerJoysticks[player] == NULL){
for (int repplayer = MAX_PLAYERS; repplayer > player; repplayer--) {
if(playerJoysticks[player] == NULL && playerJoysticks[repplayer] != NULL){
playerJoysticks[player] = playerJoysticks[repplayer];
playerJoysticks[repplayer] = NULL;
}
}
}
}
for (int player = 0; player < MAX_PLAYERS; player++) {
InputConfig * playerInputConfig = playerJoysticks[player];
if(playerInputConfig != NULL){
command << "-p" << player+1 << "index " << playerInputConfig->getDeviceIndex() << " -p" << player+1 << "guid " << playerInputConfig->getDeviceGUIDString() << " -p" << player+1 << "name \"" << playerInputConfig->getDeviceName() << "\" -p" << player+1 << "nbaxes " << playerInputConfig->getDeviceNbAxes() << " ";
}/*else {
command << " " << "DEFAULT" << " -1 DEFAULTDONOTFINDMEINCOMMAND";
//.........这里部分代码省略.........