Skip to content

Commit 225e13c

Browse files
author
nyx
authored
InputManager: add config option to disable keybinds per device (#10064)
1 parent 3fa6320 commit 225e13c

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/config/ConfigManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ CConfigManager::CConfigManager() {
759759
m_pConfig->addSpecialConfigValue("device", "active_area_size", Hyprlang::VEC2{0, 0}); // only for tablets
760760
m_pConfig->addSpecialConfigValue("device", "flip_x", Hyprlang::INT{0}); // only for touchpads
761761
m_pConfig->addSpecialConfigValue("device", "flip_y", Hyprlang::INT{0}); // only for touchpads
762+
m_pConfig->addSpecialConfigValue("device", "keybinds", Hyprlang::INT{1}); // enable/disable keybinds
762763

763764
// keywords
764765
m_pConfig->registerHandler(&::handleExec, "exec", {false});

src/devices/IKeyboard.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ class IKeyboard : public IHID {
7474
void updateXkbStateWithKey(uint32_t xkbKey, bool pressed);
7575
void updateKeymapFD();
7676

77-
bool active = false;
78-
bool enabled = true;
77+
bool active = false;
78+
bool enabled = true;
79+
bool allowBinds = true;
7980

8081
// if the keymap is overridden by the implementation,
8182
// don't try to set keyboard rules anymore, to avoid overwriting the requested one.

src/managers/KeybindManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,10 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
432432
return true;
433433
}
434434

435-
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
435+
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
436+
437+
if (!pKeyboard->allowBinds)
438+
return true;
436439

437440
const auto KEYCODE = e.keycode + 8; // Because to xkbcommon it's +8 from libinput
438441

src/managers/input/InputManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,12 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
10221022
const auto VARIANT = g_pConfigManager->getDeviceString(devname, "kb_variant", "input:kb_variant");
10231023
const auto OPTIONS = g_pConfigManager->getDeviceString(devname, "kb_options", "input:kb_options");
10241024

1025-
const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true;
1025+
const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true;
1026+
const auto ALLOWBINDS = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "keybinds") : true;
10261027

10271028
pKeyboard->enabled = ENABLED;
10281029
pKeyboard->resolveBindsBySym = RESOLVEBINDSBYSYM;
1030+
pKeyboard->allowBinds = ALLOWBINDS;
10291031

10301032
try {
10311033
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" &&
@@ -1538,6 +1540,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
15381540
if (!kb->enabled)
15391541
continue;
15401542

1543+
if (!kb->allowBinds)
1544+
continue;
1545+
15411546
finalMask |= kb->getModifiers();
15421547
}
15431548

0 commit comments

Comments
 (0)