mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-14 11:35:46 -07:00
InputManager: add config option to disable keybinds per device (#10064)
This commit is contained in:
@@ -759,6 +759,7 @@ CConfigManager::CConfigManager() {
|
|||||||
m_pConfig->addSpecialConfigValue("device", "active_area_size", Hyprlang::VEC2{0, 0}); // only for tablets
|
m_pConfig->addSpecialConfigValue("device", "active_area_size", Hyprlang::VEC2{0, 0}); // only for tablets
|
||||||
m_pConfig->addSpecialConfigValue("device", "flip_x", Hyprlang::INT{0}); // only for touchpads
|
m_pConfig->addSpecialConfigValue("device", "flip_x", Hyprlang::INT{0}); // only for touchpads
|
||||||
m_pConfig->addSpecialConfigValue("device", "flip_y", Hyprlang::INT{0}); // only for touchpads
|
m_pConfig->addSpecialConfigValue("device", "flip_y", Hyprlang::INT{0}); // only for touchpads
|
||||||
|
m_pConfig->addSpecialConfigValue("device", "keybinds", Hyprlang::INT{1}); // enable/disable keybinds
|
||||||
|
|
||||||
// keywords
|
// keywords
|
||||||
m_pConfig->registerHandler(&::handleExec, "exec", {false});
|
m_pConfig->registerHandler(&::handleExec, "exec", {false});
|
||||||
|
@@ -76,6 +76,7 @@ class IKeyboard : public IHID {
|
|||||||
|
|
||||||
bool active = false;
|
bool active = false;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
bool allowBinds = true;
|
||||||
|
|
||||||
// if the keymap is overridden by the implementation,
|
// if the keymap is overridden by the implementation,
|
||||||
// don't try to set keyboard rules anymore, to avoid overwriting the requested one.
|
// don't try to set keyboard rules anymore, to avoid overwriting the requested one.
|
||||||
|
@@ -434,6 +434,9 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
|
|||||||
|
|
||||||
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
|
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
|
||||||
|
|
||||||
|
if (!pKeyboard->allowBinds)
|
||||||
|
return true;
|
||||||
|
|
||||||
const auto KEYCODE = e.keycode + 8; // Because to xkbcommon it's +8 from libinput
|
const auto KEYCODE = e.keycode + 8; // Because to xkbcommon it's +8 from libinput
|
||||||
|
|
||||||
const xkb_keysym_t keysym = xkb_state_key_get_one_sym(pKeyboard->resolveBindsBySym ? pKeyboard->xkbSymState : m_pXKBTranslationState, KEYCODE);
|
const xkb_keysym_t keysym = xkb_state_key_get_one_sym(pKeyboard->resolveBindsBySym ? pKeyboard->xkbSymState : m_pXKBTranslationState, KEYCODE);
|
||||||
|
@@ -1023,9 +1023,11 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
|
|||||||
const auto OPTIONS = g_pConfigManager->getDeviceString(devname, "kb_options", "input:kb_options");
|
const auto OPTIONS = g_pConfigManager->getDeviceString(devname, "kb_options", "input:kb_options");
|
||||||
|
|
||||||
const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true;
|
const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true;
|
||||||
|
const auto ALLOWBINDS = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "keybinds") : true;
|
||||||
|
|
||||||
pKeyboard->enabled = ENABLED;
|
pKeyboard->enabled = ENABLED;
|
||||||
pKeyboard->resolveBindsBySym = RESOLVEBINDSBYSYM;
|
pKeyboard->resolveBindsBySym = RESOLVEBINDSBYSYM;
|
||||||
|
pKeyboard->allowBinds = ALLOWBINDS;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" &&
|
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" &&
|
||||||
@@ -1538,6 +1540,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
|
|||||||
if (!kb->enabled)
|
if (!kb->enabled)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!kb->allowBinds)
|
||||||
|
continue;
|
||||||
|
|
||||||
finalMask |= kb->getModifiers();
|
finalMask |= kb->getModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user