initial Gamepad profiles support

This commit is contained in:
Mahmood - Zer0xFF 2020-02-25 18:47:50 +00:00
parent 8b21aca123
commit cce77fc4ab
10 changed files with 238 additions and 45 deletions

46
Source/InputConfig.cpp Normal file
View file

@ -0,0 +1,46 @@
#include "AppConfig.h"
#include "InputConfig.h"
#include "PathUtils.h"
#define PROFILE_PATH ("inputprofiles")
CInputConfig::CInputConfig(const Framework::CConfig::PathType& path)
: CConfig(path)
{
}
bool CInputConfig::IsValidProfileName(std::string name)
{
static const std::string valid_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-";
for(auto c : name)
{
if(valid_chars.find(c) == std::string::npos)
{
return false;
}
}
return true;
}
std::unique_ptr<CInputConfig> CInputConfig::LoadProfile(std::string name)
{
auto path = GetProfilePath() / name;
path.replace_extension(".xml");
return std::make_unique<CInputConfig>(path);
}
Framework::CConfig::PathType CInputConfig::GetProfilePath()
{
auto profile_path = CAppConfig::GetBasePath() / PROFILE_PATH;
Framework::PathUtils::EnsurePathExists(profile_path);
return profile_path;
}
Framework::CConfig::PathType CInputConfig::GetProfile(std::string name)
{
auto profile_path = CAppConfig::GetBasePath() / PROFILE_PATH;
Framework::PathUtils::EnsurePathExists(profile_path);
profile_path /= name;
profile_path.replace_extension(".xml");
return profile_path;
}