Exemple #1
0
int ConfigurationFile::AutoBind(const string& directory, const string& file)
{
  ConfigurationFile refConfigFile;

  int ret = refConfigFile.ReadConfigFile(directory, file);

  if(ret >= 0)
  {
    for(int i=0; i<MAX_CONTROLLERS; ++i)
    {
      Controller* refController = refConfigFile.GetController(i);
      Controller* modController = GetController(i);
      for(int j=0; j<MAX_PROFILES; ++j)
      {
        Profile* refConfig = refController->GetProfile(j);
        Profile* modConfig = modController->GetProfile(j);

        modConfig->SetTrigger(*refConfig->GetTrigger());
        modConfig->SetIntensityList(*refConfig->GetIntensityList());

        AutoBindMappers<ControlMapper>(refConfig->GetButtonMapperList(), modConfig->GetButtonMapperList());

        AutoBindMappers<ControlMapper>(refConfig->GetAxisMapperList(), modConfig->GetAxisMapperList());
      }
    }
  }

  return ret;
}
Exemple #2
0
void ConfigurationFile::GetLabels(const string& directory, const string& file, list<string>& button_labels, list<string>& axis_labels)
{
  ConfigurationFile configFile;
  configFile.SetCheckDevices(false);
  if(configFile.ReadConfigFile(directory, file) >= 0)
  {
    configFile.GetLabels(button_labels, axis_labels);
  }
}
Exemple #3
0
int ConfigurationFile::ConvertSensitivity(const string& directory, const string& file)
{
  ConfigurationFile refConfigFile;

  int ret = refConfigFile.ReadConfigFile(directory, file);

  if(ret >= 0)
  {
    for(int i=0; i<MAX_CONTROLLERS; ++i)
    {
      Controller* refController = refConfigFile.GetController(i);
      Controller* modController = GetController(i);

      int refdpi = refController->GetMouseDPI();
      int dpi = modController->GetMouseDPI();

      if(refdpi && dpi && refdpi != dpi)
      {
        for(int k=0; k<MAX_PROFILES; ++k)
        {
          Profile* modConfig = modController->GetProfile(k);

          list<ControlMapper>* modAxisMappers = modConfig->GetAxisMapperList();

          for(list<ControlMapper>::iterator itModControlMappers = modAxisMappers->begin(); itModControlMappers!=modAxisMappers->end(); ++itModControlMappers)
          {
            if(itModControlMappers->GetDevice()->GetType() == "mouse" && itModControlMappers->GetEvent()->GetType() == "axis")
            {
                double val = atof(itModControlMappers->GetEvent()->GetMultiplier().c_str());
                double exp = atof(itModControlMappers->GetEvent()->GetExponent().c_str());
                val = val * pow((double)dpi / refdpi, exp);
                ostringstream ios;
                ios << setprecision(2) << val;
                itModControlMappers->GetEvent()->SetMultiplier(ios.str());
            }
          }
        }

        modController->SetMouseDPI(refdpi);
      }
    }
  }

  return ret;

}