summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornyx <nnyyxxxx@protonmail.com>2025-04-16 20:19:10 -0400
committerGitHub <noreply@github.com>2025-04-17 02:19:10 +0200
commit225e13c3cc83308175f0a9aa18cfa31324155034 (patch)
treebe5d112573273e8d105f3a139d20f937c56df05d /src
parent3fa6320a391ed60779702e058f67649beb787962 (diff)
InputManager: add config option to disable keybinds per device (#10064)
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/devices/IKeyboard.hpp5
-rw-r--r--src/managers/KeybindManager.cpp5
-rw-r--r--src/managers/input/InputManager.cpp7
4 files changed, 14 insertions, 4 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 70f6701e..b9c93295 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -759,6 +759,7 @@ CConfigManager::CConfigManager() {
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_y", Hyprlang::INT{0}); // only for touchpads
+ m_pConfig->addSpecialConfigValue("device", "keybinds", Hyprlang::INT{1}); // enable/disable keybinds
// keywords
m_pConfig->registerHandler(&::handleExec, "exec", {false});
diff --git a/src/devices/IKeyboard.hpp b/src/devices/IKeyboard.hpp
index aabf4cc2..7ac71172 100644
--- a/src/devices/IKeyboard.hpp
+++ b/src/devices/IKeyboard.hpp
@@ -74,8 +74,9 @@ class IKeyboard : public IHID {
void updateXkbStateWithKey(uint32_t xkbKey, bool pressed);
void updateKeymapFD();
- bool active = false;
- bool enabled = true;
+ bool active = false;
+ bool enabled = true;
+ bool allowBinds = true;
// if the keymap is overridden by the implementation,
// don't try to set keyboard rules anymore, to avoid overwriting the requested one.
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 4ef7d229..a1ad846a 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -432,7 +432,10 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
return true;
}
- 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
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 0665e0d2..af84eb20 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1022,10 +1022,12 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
const auto VARIANT = g_pConfigManager->getDeviceString(devname, "kb_variant", "input:kb_variant");
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->resolveBindsBySym = RESOLVEBINDSBYSYM;
+ pKeyboard->allowBinds = ALLOWBINDS;
try {
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" &&
@@ -1538,6 +1540,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
if (!kb->enabled)
continue;
+ if (!kb->allowBinds)
+ continue;
+
finalMask |= kb->getModifiers();
}