From 7b654f301ebe936cb01100bcc1781c7d823f53de Mon Sep 17 00:00:00 2001 From: Levi Pearson Date: Sun, 5 Feb 2017 12:49:24 -0700 Subject: [PATCH] Trim whitespace around, but not inside, key names in control binding. An existing static method in the Configuration object to do this was made public. Lines like this in controls.conf now work correctly: Random = R, Left Shift , joy0Button5 --- RetroFE/Source/Control/UserInput.cpp | 1 + RetroFE/Source/Database/Configuration.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index 8f803e8..6d409af 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -130,6 +130,7 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key, bool required) while (std::getline(ss, token, ',')) { + token = Configuration::trimEnds(token); scanCode = SDL_GetScancodeFromName(token.c_str()); bool found = false; diff --git a/RetroFE/Source/Database/Configuration.h b/RetroFE/Source/Database/Configuration.h index da17d2b..1ab8c63 100644 --- a/RetroFE/Source/Database/Configuration.h +++ b/RetroFE/Source/Database/Configuration.h @@ -26,6 +26,7 @@ public: virtual ~Configuration(); static void initialize(); static std::string convertToAbsolutePath(std::string prefix, std::string path); + static std::string trimEnds(std::string str); // gets the global configuration bool import(std::string keyPrefix, std::string file); bool import(std::string collection, std::string keyPrefix, std::string file, bool mustExist = true); @@ -45,7 +46,6 @@ public: private: bool getRawProperty(std::string key, std::string &value); bool parseLine(std::string collection, std::string keyPrefix, std::string line, int lineCount); - std::string trimEnds(std::string str); typedef std::map PropertiesType; typedef std::pair PropertiesPair;