diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2018-10-29 01:50:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-29 01:50:29 +0100 |
| commit | dd0122944a7faa2a665acd9f4c1c3981a38a32a7 (patch) | |
| tree | c837e8cd9cb0d5bc998457fca9f63c13b4c0aee1 /Source/Android/jni/ButtonManager.cpp | |
| parent | 9095233d21a8b165bf57c88ce4287f4b9f78c406 (diff) | |
| parent | f46157793faa9c1352b9df08c3667bbafdf2f71e (diff) | |
Merge pull request #7434 from zackhow/game-controller
Android: Game settings enhancements
Diffstat (limited to 'Source/Android/jni/ButtonManager.cpp')
| -rw-r--r-- | Source/Android/jni/ButtonManager.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Source/Android/jni/ButtonManager.cpp b/Source/Android/jni/ButtonManager.cpp index 637b23b3da..251c754968 100644 --- a/Source/Android/jni/ButtonManager.cpp +++ b/Source/Android/jni/ButtonManager.cpp @@ -335,7 +335,7 @@ static void AddBind(const std::string& dev, sBind* bind) m_controllers[dev]->AddBind(bind); } -void Init() +void Init(const std::string& gameId) { // Initialize our touchScreenKey buttons for (int a = 0; a < 8; ++a) @@ -592,6 +592,40 @@ void Init() new sBind(padID, configTypes[a], type, bindnum, modifier == '-' ? -1.0f : 1.0f)); } } + + ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + std::string(gameId + ".ini")); + for (u32 a = 0; a < configStrings.size(); ++a) + { + for (int padID = 0; padID < 8; ++padID) + { + std::ostringstream config; + config << configStrings[a] << "_" << padID; + BindType type; + int bindnum; + char dev[128]; + bool hasbind = false; + char modifier = '+'; + std::string value; + ini.GetOrCreateSection("Android")->Get(config.str(), &value, "None"); + if (value == "None") + continue; + if (std::string::npos != value.find("Axis")) + { + hasbind = true; + type = BIND_AXIS; + sscanf(value.c_str(), "Device '%127[^\']'-Axis %d%c", dev, &bindnum, &modifier); + } + else if (std::string::npos != value.find("Button")) + { + hasbind = true; + type = BIND_BUTTON; + sscanf(value.c_str(), "Device '%127[^\']'-Button %d", dev, &bindnum); + } + if (hasbind) + AddBind(std::string(dev), + new sBind(padID, configTypes[a], type, bindnum, modifier == '-' ? -1.0f : 1.0f)); + } + } } bool GetButtonPressed(int padID, ButtonType button) |
