rvaiya / keyd

A key remapping daemon for linux.
MIT License
2.84k stars 168 forks source link

Keyd changes the default keycode for 'Fn' on my macbook #791

Open celesrenata opened 3 months ago

celesrenata commented 3 months ago

Love your work!

I was hoping I could figure out a quick and dirty patch for my T2 Macbook.

I see that insrc/keys.h the FN key is mapped to 254, however, I need to map it to 464!

I tried changing the array to allow upto 465 to mimic your logic and changed the corresponding for loop in src/keys.c unfortunately after recompiling it comes back as key 208!

I was wondering if you had any ideas on how I could patch this to work on my mac.

Thanks! Celes

rvaiya commented 2 months ago

I see that insrc/keys.h the FN key is mapped to 254, however, I need to map it to 464!

That is keyd's internal code. It should be mapped to KEY_FN on input, which should be correctly defined by your kernel headers as 464.

Have you tried running keyd monitor and inspecting the output? You should see something like fn down with a blank config.

If not, can you post the output of sudo evtest[^1] while pressing the key? It is also possible that the hardware doesn't actually emit a distinct event for fn, which is a common problem on laptop keyboards.

[^1]: Make sure keyd is disabled and that you select your physical board from the list.

szabba commented 2 months ago

Not OP, but my situation on an M1 Macbook sounds similar. Not sure if I should open a separate issue for it.

When I run sudo keyd monitor I get entries for most remapped keys. There's not output when I press leftcontrol (remmapped to layer(alt) in the main layer.

What seems to be the relevant part of sudo evtest output (with keyd stopped) is:

Event: time 1723288312.142961, -------------- SYN_REPORT ------------
Event: time 1723288312.173686, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1723288312.173686, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time 1723288312.173686, -------------- SYN_REPORT ------------
Event: time 1723288312.827211, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1723288312.827211, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time 1723288312.827211, -------------- SYN_REPORT ------------

The config (cobbled together through trial and error)

[ids]
k:05ac:0281

[global]
default_layout = pl

[main]
delete = backspace

rightmeta = layer(altgr)
rightalt = rightcontrol

leftcontrol = layer(fn)
fn = leftcontrol
leftmeta = alt
leftalt = leftmeta

home = C-left
end = C-right
pageup = C-up
pagedown = C-down

brightnessdown = f1
brightnessup = f2
scale = f3
search = f4
record = f5
sleep = f6
previoussong = f7
playpause = f8
nextsong = f9
mute = f10
volumedown = f11
volumeup = f12

[fn]
left = home
right = end
up = pageup
down = pagedown

f1 = brightnessdown
f2 = brightnessup
f3 = scale
f4 = search
f5 = record
f6 = sleep
f7 = previoussong
f8 = playpause
f9 = nextsong
f10 = mute
f11 = volumedown
f12 = volumeup
themg95 commented 3 days ago

Are there any updates on this? I can't access the second layer of my touchbar, which seems to be related to this issue.