rvaiya / keyd

A key remapping daemon for linux.
MIT License
3.04k stars 173 forks source link

Doesn't seem to work on FreeBSD 13.2 #570

Closed tslight closed 7 months ago

tslight commented 1 year ago

HI there,

This could very well be a PEBKAC issue, but I've spent a good couple of hours researching and looking through past issues and reading the man page, but try as I might, I cannot figure this out...

I installed keyd via pkg install keyd on a fresh install of FreeBSD 13.2 and created this very basic config in /usr/local/etc/keyd/default.conf:

[ids]
*

[main]
capslock = esc
esc = capslock

However when I start keyd from either /usr/local/bin/keyd or /usr/local/etc/rc.d/keyd start my keyboard completely stops working until I hit ESC->BKSP->RET to force a panic (thank you for building that in BTW!)

Perhaps I can't see the wood for the trees at this point, but I can't see anything obviously wrong with my config and running keyd -m looks good and works fine:

DEBUG: src/keyd.c:230: Debug mode activated
DEBUG: src/device.c:121: capabilities of /dev/input/event0 (System mouse): 1
DEBUG: src/device.c:121: capabilities of /dev/input/event1 (System keyboard multiplexer): 4
DEBUG: src/device.c:121: capabilities of /dev/input/event2 (Control Method Lid Switch): 0
DEBUG: src/device.c:121: capabilities of /dev/input/event3 (Power Button): 0
DEBUG: src/device.c:121: capabilities of /dev/input/event4 (Sleep Button): 0
DEBUG: src/device.c:121: capabilities of /dev/input/event5 (AT keyboard): 4
DEBUG: src/device.c:121: capabilities of /dev/input/event6 (SynPS/2 Synaptics TouchPad): 3
DEBUG: src/device.c:121: capabilities of /dev/input/event7 (TPPS/2 IBM TrackPoint): 1
device added: 0000:0000 System mouse (/dev/input/event0)
device added: 0000:0000 System keyboard multiplexer (/dev/input/event1)
device added: 0001:0001 AT keyboard (/dev/input/event5)
device added: 0002:0007 SynPS/2 Synaptics TouchPad (/dev/input/event6)
device added: 0002:000a TPPS/2 IBM TrackPoint (/dev/input/event7)
DEBUG: src/device.c:448: key enter up
AT keyboard     0001:0001       enter up
DEBUG: src/device.c:448: key l down
AT keyboard     0001:0001       l down
DEBUG: src/device.c:448: key s down
AT keyboard     0001:0001       s down

Also here is the output of running keyd with KEYD_DEBUG=2 incase it helps someone figure out what is going on with my setup:

DEBUG: src/keyd.c:230: Debug mode activated
CONFIG: parsing /usr/local/etc/keyd/default.conf
Starting keyd v2.4.3
DEBUG: src/device.c:121: capabilities of /dev/input/event0 (System mouse): 1
DEBUG: src/device.c:121: capabilities of /dev/input/event1 (System keyboard multiplexer): 4
DEBUG: src/device.c:121: capabilities of /dev/input/event2 (Control Method Lid Switch): 0
DEBUG: src/device.c:121: capabilities of /dev/input/event3 (Power Button): 0
DEBUG: src/device.c:121: capabilities of /dev/input/event4 (Sleep Button): 0
DEBUG: src/device.c:121: capabilities of /dev/input/event5 (AT keyboard): 4
DEBUG: src/device.c:121: capabilities of /dev/input/event8 (keyd virtual keyboard): 4
DEBUG: src/device.c:121: capabilities of /dev/input/event9 (keyd virtual pointer): 3
DEBUG: src/device.c:121: capabilities of /dev/input/event6 (SynPS/2 Synaptics TouchPad): 3
DEBUG: src/device.c:121: capabilities of /dev/input/event7 (TPPS/2 IBM TrackPoint): 1
DEVICE: ignoring 0000:0000  (System mouse)
DEVICE: match    0000:0000  /usr/local/etc/keyd/default.conf    (System keyboard multiplexer)
DEVICE: match    0001:0001  /usr/local/etc/keyd/default.conf    (AT keyboard)
DEVICE: ignoring 0002:0007  (SynPS/2 Synaptics TouchPad)
DEVICE: ignoring 0002:000a  (TPPS/2 IBM TrackPoint)
DEVICE: ignoring 0fac:1ade  (keyd virtual pointer)
DEBUG: src/device.c:448: key k down
DEBUG: src/daemon.c:429: input k down
DEBUG: src/vkbd/uinput.c:321: output k down
DEBUG: src/device.c:448: key k down
DEBUG: src/device.c:448: key l down
DEBUG: src/daemon.c:429: input l down

So again, everything appears to be working and yet no keyboard input works until I force quit keyd.

This happens in both a TTY and under the Hikari Wayland Window manager, although interestingly in Hikari starting keyd also has the side effect of closing whatever terminal I launch it from and breaking my mouse aswell.

My hardware is pretty standard old ThinkPad X131E laptop that is fully supported by FreeBSD.

I'm really desperate for this to work as there doesn't seem to be any other easy solution for remapping keys on FreeBSD in the TTYs and under Wayland so any help/pointers greatly appreciated.

Cheers, Toby

jbeich commented 1 year ago

TTY

Not supported on FreeBSD. My guess: vt(4) expects native keyboard events instead of evdev, so either /dev/uinput needs to create vkbd(4) or kbdmux(4) needs to pull/read evdev events.

closing whatever terminal I launch it from

Try starting keyd within tmux session. Otherwise, try wayfire or labwc instead as hikari likely has many unfixed bugs due to dormant upstream.

remapping keys on FreeBSD in the TTYs

For simple cases try editing keymap(5) files under /usr/share/vt/keymaps. To get scancodes kbdscan package may help.

under Wayland

For simple cases try creating custom XKB keymap based on xkeyboard-config package. It'd also work under Xorg.

Note, your "very basic" keyd config matches export XKB_DEFAULT_OPTIONS=caps:swapescape:

// From /usr/local/share/X11/xkb/symbols/capslock
hidden partial modifier_keys
xkb_symbols "swapescape" {
    key <CAPS> { [ Escape ], type[group1] = "ONE_LEVEL" };
    key <ESC>  { [ Caps_Lock ] };
};
rvaiya commented 7 months ago

Yes, I believe FreeBSDs uinput implementation doesn't only emulates evdev devices. As far as I know there is no way to simulate native devices on FreeBSD, but PRs are welcome those who know better :P.