website/content/blog/20231214-intercepting bluetooth keyboard events.md

66 lines
2.2 KiB
Markdown
Raw Normal View History

+++
title = "Intercepting Bluetooth Keyboard Events"
date = 2023-12-14
[taxonomies]
tags = ["linux"]
categories = ["keyboard", "bluetooth"]
+++
# Intercepting Bluetooth Keyboard Events
I like keyboards and I like custom keyboards. However many do not allow sufficient configuration to let
a key be Ctrl on hold and Esc on top. Notably the HHKB.
USB devices are nicely listed in */dev/input/by-id/* folder but on my system the event device is anonymously placed in */dev/input/*.
## Figuring out the name
```
for dev in /dev/input/*; do udevadm info --attribute-walk $dev; done | grep -A10 -B10 Keyboard
Unknown device "/dev/input/by-id": No such device
Unknown device "/dev/input/by-path": No such device
ATTRS{capabilities/led}=="1f"
ATTRS{capabilities/msc}=="10"
ATTRS{capabilities/rel}=="0"
ATTRS{capabilities/snd}=="0"
ATTRS{capabilities/sw}=="0"
ATTRS{id/bustype}=="0005"
ATTRS{id/product}=="0021"
ATTRS{id/vendor}=="04fe"
ATTRS{id/version}=="0001"
ATTRS{inhibited}=="0"
ATTRS{name}=="HHKB-Hybrid_1 Keyboard"
ATTRS{phys}=="04:33:c2:f4:e9:70"
ATTRS{power/control}=="auto"
ATTRS{power/runtime_active_time}=="0"
ATTRS{power/runtime_status}=="unsupported"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{properties}=="0"
ATTRS{uniq}=="cb:7a:7c:03:2d:f2"
```
for other keyboards a bit of finagling for searching with grep might be needed or pipe into *less* and scroll till you find it.
Now I can add it to my */etc/interception/udevmon.d/ctrl_tap_esc.yaml :
```
- JOB: "intercept -g $DEVNODE | dual-function-keys -c /etc/interception/dual-function-keys.yaml | uinput -d $DEVNODE"
DEVICE:
NAME: "PFU Limited HHKB-Hybrid"
EVENTS:
EV_KEY: [KEY_LEFTCTRL]
- JOB: "intercept -g $DEVNODE | dual-function-keys -c /etc/interception/dual-function-keys.yaml | uinput -d $DEVNODE"
DEVICE:
NAME: "PFU Limited HHKB-Hybrid Keyboard"
EVENTS:
EV_KEY: [KEY_LEFTCTRL]
- JOB: "intercept -g $DEVNODE | dual-function-keys -c /etc/interception/dual-function-keys.yaml | uinput -d $DEVNODE"
DEVICE:
NAME: "HHKB-Hybrid_1 Keyboard"
EVENTS:
EV_KEY: [KEY_LEFTCTRL]
```
The first 2 are for USB but that is still a work in progress