DICTEE_PTT_EXTRA_DEVICES cannot override the EV_REL/EV_ABS pointer guard
Summary
DICTEE_PTT_EXTRA_DEVICES is documented in dictee.conf as the escape hatch
for keyboards that the auto-detection skips, but in find_keyboards_evdev() it
is evaluated inside the EV_REL/EV_ABS guard that does the skipping. Any
device rejected by that guard can therefore never be re-added, which makes the
setting unreachable for the exact case it exists to solve.
Keyboards with on-board mouse-key emulation (DYGMA DEFY, ZSA boards, many QMK
builds) advertise EV_REL/EV_ABS on their only keyboard node, so PTT silently
never fires from them.
Environment
- CachyOS (Arch-based), KDE Plasma 6.7.5, Wayland
dictee1.3.6-1- DYGMA DEFY Keyboard (
35ef:0012)
The code
/usr/bin/dictee-ptt:
if (EV_KEY in caps and len(caps.get(EV_KEY, [])) > 30
and EV_REL not in caps and EV_ABS not in caps):
name = dev.name.lower()
if name in EXCLUDE_KEYBOARDS:
dev.close()
elif any(x in name for x in EXTRA_KEYBOARDS): # <-- unreachable for the
devs.append(dev) # devices it targets
The EXTRA_KEYBOARDS test can only run for devices that already passed the
guard — i.e. devices that never needed it.
Reproduction
DYGMA DEFY Keyboard on /dev/input/event3 reports:
keys=282 types=['EV_SYN', 'EV_KEY', 'EV_REL', 'EV_ABS', 'EV_MSC', 'EV_LED']
With DICTEE_PTT_EXTRA_DEVICES="dygma" set, the daemon logs the whitelist but
still skips the device:
[ptt] extra keyboards whitelist: ['dygma']
[ptt] claviers: ['/dev/input/event5']
[ptt] grab: Logitech USB Receiver
Why this is worse than it looks
The device it did grab, event5, is a Logitech Bolt receiver (046d:c548)
whose HID descriptor advertises a boot-keyboard interface
(ID_USB_INTERFACES=:030101:030102:030000:). udev therefore tags it
ID_INPUT_KEYBOARD=1 and it passes the guard, even though only a mouse is
paired to it.
So on this setup the daemon grabs the mouse receiver's phantom keyboard node, logs a successful grab, and ignores the actual keyboard — the user sees a healthy-looking daemon and a hotkey that never fires.
Suggested fix
Hoist the opt-in test ahead of the guard, so an explicitly named device bypasses it while default behaviour is unchanged when the list is empty:
name = dev.name.lower()
_is_extra = any(x in name for x in EXTRA_KEYBOARDS)
if (EV_KEY in caps and len(caps.get(EV_KEY, [])) > 30
and (_is_extra or (EV_REL not in caps and EV_ABS not in caps))):
if name in EXCLUDE_KEYBOARDS:
dev.close()
elif _is_extra:
devs.append(dev)
Important warning for whoever implements this
Once such a device is grabbed, the passthrough UInput must be able to re-emit
its non-key events, or the mouse-key layer is swallowed. Do not simply copy
the grabbed device's capabilities into the UInput.
UInput(name="dictee-ptt-passthrough") currently creates an EV_KEY-only
device. I tried extending it with the union of the grabbed devices'
capabilities, and passing EV_ABS codes without their AbsInfo ranges created
an axis with min == max. KWin then rejected the whole device:
Libinput: event26 - dictee-ptt-passthrough: kernel bug: device has min == max on ABS_VOLUME
With the physical keyboards grabbed and the replacement device refused by the compositor, every keystroke is lost and the machine becomes unusable from the keyboard. Recovering needs a mouse to stop the service.
If capability passthrough is added, EV_ABS axes must carry real AbsInfo, and
it would be safer to create a second, pointer-only virtual device than to make
the keyboard node hybrid. Given the blast radius, defaulting to EV_KEY-only
and documenting that mouse-key layers are not forwarded seems the safer trade.
Workaround for affected users
None from configuration alone — it needs a code change. A user-local patched
copy of dictee-ptt plus a systemd drop-in pointing ExecStart at it works,
with the EV_KEY-only passthrough left untouched.
@farkmi yet thanks, and the receiver detail is a good one.
This is already fixed on the 1.3 branch (it came with #23 and #30): DICTEE_PTT_EXTRA_DEVICES is checked before the pointer guard, so a keyboard you name is grabbed whatever it declares. With DICTEE_PTT_EXTRA_DEVICES="dygma" your DEFY will be picked up.
Agreed on the passthrough: it stays EV_KEY only, so the mouse-key layer of a grabbed board is not forwarded. I'll note that next to the setting.
This ships in 1.3.7.
A correction to my reply above: the passthrough does not stay EV_KEY only. Since the #23 fix it copies the capabilities of the keyboards it grabs, axes included, with their real ranges. The min == max you hit came from axes set up without their ranges. So once your DEFY is in DICTEE_PTT_EXTRA_DEVICES, its mouse-key layer should keep working. If you try it with 1.3.7, I'd like to know how it goes.