mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 01:46:00 +01:00
Added binding by keycodes
This commit is contained in:
parent
75c2a378e3
commit
cd0a01f4de
4 changed files with 31 additions and 14 deletions
|
@ -512,8 +512,13 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KEY != "")
|
if (KEY != "") {
|
||||||
g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap});
|
if (isNumber(KEY) && std::stoi(KEY) > 9)
|
||||||
|
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap});
|
||||||
|
else
|
||||||
|
g_pKeybindManager->addKeybind(SKeybind{KEY, -1, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::handleUnbind(const std::string& command, const std::string& value) {
|
void CConfigManager::handleUnbind(const std::string& command, const std::string& value) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) {
|
||||||
return modMask;
|
return modMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key) {
|
bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (handleInternalKeybinds(key))
|
if (handleInternalKeybinds(key))
|
||||||
|
@ -82,6 +82,15 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap)
|
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
if (k.keycode != -1) {
|
||||||
|
if (keycode != k.keycode)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (key == 0)
|
||||||
|
continue; // this is a keycode check run
|
||||||
|
|
||||||
// oMg such performance hit!!11!
|
// oMg such performance hit!!11!
|
||||||
// this little maneouver is gonna cost us 4µs
|
// this little maneouver is gonna cost us 4µs
|
||||||
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
||||||
|
@ -90,7 +99,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
|
|
||||||
if (key != KBKEY && key != KBKEYUPPER)
|
if (key != KBKEY && key != KBKEYUPPER)
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const auto DISPATCHER = m_mDispatchers.find(k.handler);
|
const auto DISPATCHER = m_mDispatchers.find(k.handler);
|
||||||
|
|
||||||
|
@ -99,7 +108,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
|
Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
|
||||||
} else {
|
} else {
|
||||||
// call the dispatcher
|
// call the dispatcher
|
||||||
Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, KBKEYUPPER);
|
Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, key);
|
||||||
DISPATCHER->second(k.arg);
|
DISPATCHER->second(k.arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
struct SKeybind {
|
struct SKeybind {
|
||||||
std::string key = "";
|
std::string key = "";
|
||||||
|
int keycode = -1;
|
||||||
uint32_t modmask = 0;
|
uint32_t modmask = 0;
|
||||||
std::string handler = "";
|
std::string handler = "";
|
||||||
std::string arg = "";
|
std::string arg = "";
|
||||||
|
@ -19,7 +20,7 @@ class CKeybindManager {
|
||||||
public:
|
public:
|
||||||
CKeybindManager();
|
CKeybindManager();
|
||||||
|
|
||||||
bool handleKeybinds(const uint32_t&, const xkb_keysym_t&);
|
bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&);
|
||||||
void addKeybind(SKeybind);
|
void addKeybind(SKeybind);
|
||||||
void removeKeybind(uint32_t, const std::string&);
|
void removeKeybind(uint32_t, const std::string&);
|
||||||
uint32_t stringToModMask(std::string);
|
uint32_t stringToModMask(std::string);
|
||||||
|
|
|
@ -594,7 +594,9 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||||
for (int i = 0; i < syms; ++i)
|
for (int i = 0; i < syms; ++i)
|
||||||
found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i]) || found;
|
found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found;
|
||||||
|
|
||||||
|
found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE) || found;
|
||||||
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||||
// hee hee
|
// hee hee
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue