Skip to content

Commit

Permalink
Load custom game IR values if they are not set
Browse files Browse the repository at this point in the history
This is mostly for android so that a user can use the touchscreen to
accurately emulate pointer movements
  • Loading branch information
zackhow committed Jan 23, 2019
1 parent 1db02c1 commit d0b4228
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions Source/Core/InputCommon/InputConfig.cpp
Expand Up @@ -33,6 +33,11 @@ bool InputConfig::LoadConfig(bool isGC)
std::string profile[MAX_BBMOTES]; std::string profile[MAX_BBMOTES];
std::string path; std::string path;


#if defined(ANDROID)
bool use_ir_config = false;
std::string ir_values[3];
#endif

if (SConfig::GetInstance().GetGameID() != "00000000") if (SConfig::GetInstance().GetGameID() != "00000000")
{ {
std::string type; std::string type;
Expand Down Expand Up @@ -73,13 +78,26 @@ bool InputConfig::LoadConfig(bool isGC)
} }
} }
} }
#if defined(ANDROID)
// For use on android touchscreen IR pointer
// Check for IR values
if (control_section->Exists("IRWidth") && control_section->Exists("IRHeight") &&
control_section->Exists("IRCenter"))
{
use_ir_config = true;
control_section->Get("IRWidth", &ir_values[0]);
control_section->Get("IRHeight", &ir_values[1]);
control_section->Get("IRCenter", &ir_values[2]);
}
#endif
} }


if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + m_ini_name + ".ini")) if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + m_ini_name + ".ini"))
{ {
int n = 0; int n = 0;
for (auto& controller : m_controllers) for (auto& controller : m_controllers)
{ {
IniFile::Section config;
// Load settings from ini // Load settings from ini
if (useProfile[n]) if (useProfile[n])
{ {
Expand All @@ -91,13 +109,22 @@ bool InputConfig::LoadConfig(bool isGC)


IniFile profile_ini; IniFile profile_ini;
profile_ini.Load(profile[n]); profile_ini.Load(profile[n]);
controller->LoadConfig(profile_ini.GetOrCreateSection("Profile")); config = *profile_ini.GetOrCreateSection("Profile");
} }
else else
{ {
controller->LoadConfig(inifile.GetOrCreateSection(controller->GetName())); config = *inifile.GetOrCreateSection(controller->GetName());
} }

#if defined(ANDROID)
// Only set for wii pads
if (!isGC && use_ir_config)
{
config.Set("IR/Width", ir_values[0]);
config.Set("IR/Height", ir_values[1]);
config.Set("IR/Center", ir_values[2]);
}
#endif
controller->LoadConfig(&config);
// Update refs // Update refs
controller->UpdateReferences(g_controller_interface); controller->UpdateReferences(g_controller_interface);


Expand Down

0 comments on commit d0b4228

Please sign in to comment.