From b52e6ea0558193cbeb5978e220285a552fb4fc2c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 12 Apr 2022 15:29:44 +0200 Subject: [PATCH] added an option to use keysyms as ints --- src/KeybindManager.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/KeybindManager.cpp b/src/KeybindManager.cpp index 3b0a668..9a82924 100644 --- a/src/KeybindManager.cpp +++ b/src/KeybindManager.cpp @@ -21,6 +21,9 @@ uint32_t KeybindManager::getKeyCodeFromName(std::string name) { if (name == "") return 0; + if (name.find_first_not_of("1234567890") == std::string::npos) + return std::stoi(name); + const auto ORIGINALCASENAME = name; transform(name.begin(), name.end(), name.begin(), ::tolower); @@ -69,12 +72,8 @@ uint32_t KeybindManager::getKeyCodeFromName(std::string name) { unsigned int KeybindManager::modToMask(std::string mod) { - try { - uint32_t modmask = std::stoi(mod.c_str()); - return modmask; - } catch(...) { - ; // means its not alphanumeric, go ahead - } + if (mod.find_first_not_of("1234567890") == std::string::npos && mod != "") + return std::stoi(mod); unsigned int sum = 0;