mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-02 14:55:57 +01:00
Add support for all x keys
This commit is contained in:
parent
cf96eb5df8
commit
fa20d13425
2 changed files with 15 additions and 1 deletions
|
@ -18,6 +18,7 @@ uint32_t KeybindManager::getKeyCodeFromName(std::string name) {
|
||||||
if (name == "")
|
if (name == "")
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
const auto ORIGINALCASENAME = name;
|
||||||
transform(name.begin(), name.end(), name.begin(), ::tolower);
|
transform(name.begin(), name.end(), name.begin(), ::tolower);
|
||||||
|
|
||||||
if (name.length() == 1) {
|
if (name.length() == 1) {
|
||||||
|
@ -44,6 +45,19 @@ uint32_t KeybindManager::getKeyCodeFromName(std::string name) {
|
||||||
return 0xff54;
|
return 0xff54;
|
||||||
} else if (name == "space") {
|
} else if (name == "space") {
|
||||||
return 0x20;
|
return 0x20;
|
||||||
|
} else {
|
||||||
|
// unknown key, find in the xmodmap
|
||||||
|
std::string command = "xmodmap -pk | grep \"(" + ORIGINALCASENAME + ")\"";
|
||||||
|
std::string returnValue = exec(command.c_str());
|
||||||
|
|
||||||
|
try {
|
||||||
|
returnValue = returnValue.substr(returnValue.find_first_of('x') + 1);
|
||||||
|
returnValue = returnValue.substr(0, returnValue.find_first_of(' '));
|
||||||
|
|
||||||
|
return std::stoi(returnValue, nullptr, 16); // return hex to int
|
||||||
|
} catch (...) {
|
||||||
|
Debug::log(ERR, "Unknown key: " + ORIGINALCASENAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ void handleBind(const std::string& command, const std::string& value) {
|
||||||
if (HANDLER == "workspace") dispatcher = KeybindManager::changeworkspace;
|
if (HANDLER == "workspace") dispatcher = KeybindManager::changeworkspace;
|
||||||
if (HANDLER == "togglefloating") dispatcher = KeybindManager::toggleActiveWindowFloating;
|
if (HANDLER == "togglefloating") dispatcher = KeybindManager::toggleActiveWindowFloating;
|
||||||
|
|
||||||
if (dispatcher)
|
if (dispatcher && KEY != 0)
|
||||||
KeybindManager::keybinds.push_back(Keybind(KeybindManager::modToMask(MOD), KEY, COMMAND, dispatcher));
|
KeybindManager::keybinds.push_back(Keybind(KeybindManager::modToMask(MOD), KEY, COMMAND, dispatcher));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue