diff options
| author | Léo Lam <leo@leolam.fr> | 2020-02-02 16:52:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-02 16:52:12 +0100 |
| commit | 049183148307ad6a5a3244c313841fc97448b647 (patch) | |
| tree | 430fd6027c08899e2dbe6aa5fdae653ed17396a8 /Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp | |
| parent | 06d0b1ad481bb94c09e373c0c92fe03c29f7ffcf (diff) | |
| parent | 02c5d292fac8de40e4a311b04153a17bbb557769 (diff) | |
Merge pull request #8592 from phcoder/devid
ButtonManager: Fix handling of empty device id.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp b/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp index 35d4552afc..22b05952f6 100644 --- a/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp @@ -10,6 +10,7 @@ #include "Common/FileUtil.h" #include "Common/IniFile.h" +#include "Common/StringUtil.h" #include "Common/Thread.h" #include "InputCommon/ControllerInterface/Touch/ButtonManager.h" @@ -630,7 +631,7 @@ void Init(const std::string& game_id) config << CONFIG_STRINGS[a] << "_" << pad_id; BindType type; int bindnum; - char dev[128]; + char dev[128]{}; bool hasbind = false; char modifier = '+'; std::string value; @@ -641,13 +642,19 @@ void Init(const std::string& game_id) { hasbind = true; type = BIND_AXIS; - sscanf(value.c_str(), "Device '%127[^\']'-Axis %d%c", dev, &bindnum, &modifier); + if (StringBeginsWith(value, "Device ''")) + sscanf(value.c_str(), "Device ''-Axis %d%c", &bindnum, &modifier); + else + 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 (StringBeginsWith(value, "Device ''")) + sscanf(value.c_str(), "Device ''-Button %d", &bindnum); + else + sscanf(value.c_str(), "Device '%127[^\']'-Button %d", dev, &bindnum); } if (hasbind) AddBind(std::string(dev), |
