added an option to use keysyms as ints

This commit is contained in:
vaxerski 2022-04-12 15:29:44 +02:00
parent 1667180ac3
commit b52e6ea055

View file

@ -21,6 +21,9 @@ uint32_t KeybindManager::getKeyCodeFromName(std::string name) {
if (name == "") if (name == "")
return 0; return 0;
if (name.find_first_not_of("1234567890") == std::string::npos)
return std::stoi(name);
const auto ORIGINALCASENAME = name; const auto ORIGINALCASENAME = name;
transform(name.begin(), name.end(), name.begin(), ::tolower); 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) { unsigned int KeybindManager::modToMask(std::string mod) {
try { if (mod.find_first_not_of("1234567890") == std::string::npos && mod != "")
uint32_t modmask = std::stoi(mod.c_str()); return std::stoi(mod);
return modmask;
} catch(...) {
; // means its not alphanumeric, go ahead
}
unsigned int sum = 0; unsigned int sum = 0;