Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
celesrenata opened this issue Jul 9, 2024 · 6 comments
Open

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

celesrenata opened this issue Jul 9, 2024 · 6 comments

Comments

@celesrenata
Copy link

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
Copy link
Owner

rvaiya commented Jul 26, 2024

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 evtest1 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.

Footnotes

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

@szabba
Copy link

szabba commented Aug 10, 2024

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
Copy link

themg95 commented Oct 9, 2024

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

@fathonix
Copy link

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 evtest1 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.

Footnotes

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

M1 MacBook but having the same issue. keyd emitting 254 breaks tiny-dfr Touch Bar Fn layer functionality.

keyd monitor detects Fn but evtest detects 254. Tested with blank config ([ids]\n*)

$ sudo keyd monitor
device added: 05ac:0341:c3080866 Apple Internal Keyboard / Trackpad (/dev/input/event0)
device added: 0000:0000:1bf3eacc MacBookPro17,1 Touch Bar (/dev/input/event1)
device added: 05ac:0341:3179765c Apple Internal Keyboard / Trackpad (/dev/input/event2)
device added: 1209:316e:2b020ae1 Dynamic Function Row Virtual Input Device (/dev/input/event5)
device added: 0fac:0ade:efba1ddf keyd virtual keyboard (/dev/input/event6)
device added: 0fac:1ade:d2b36ae6 keyd virtual pointer (/dev/input/event7)
keyd virtual keyboard	0fac:0ade:efba1ddf	enter up
keyd virtual keyboard	0fac:0ade:efba1ddf	fn down
keyd virtual keyboard	0fac:0ade:efba1ddf	fn up
$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:	Apple Internal Keyboard / Trackpad
/dev/input/event1:	MacBookPro17,1 Touch Bar
/dev/input/event2:	Apple Internal Keyboard / Trackpad
/dev/input/event3:	Apple SMC power/lid events
/dev/input/event4:	MacBook Pro J293 Headphone Jack
/dev/input/event5:	Dynamic Function Row Virtual Input Device
/dev/input/event6:	keyd virtual keyboard
/dev/input/event7:	keyd virtual pointer
Select the device event number [0-7]: 6
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xfac product 0xade version 0x0
Input device name: "keyd virtual keyboard"
Supported events:
  Event type 0 (EV_SYN)
  <truncated>
Properties:
Testing ... (interrupt to exit)
Event: time 1732936447.877785, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1732936447.877785, -------------- SYN_REPORT ------------
Event: time 1732936448.119416, type 1 (EV_KEY), code 254 (?), value 1
Event: time 1732936448.119416, -------------- SYN_REPORT ------------
Event: time 1732936448.271307, type 1 (EV_KEY), code 254 (?), value 0
$ sudo systemctl stop keyd
$ sudo keyd monitor
device added: 05ac:0341:c3080866 Apple Internal Keyboard / Trackpad (/dev/input/event0)
device added: 0000:0000:1bf3eacc MacBookPro17,1 Touch Bar (/dev/input/event1)
device added: 05ac:0341:3179765c Apple Internal Keyboard / Trackpad (/dev/input/event2)
device added: 1209:316e:2b020ae1 Dynamic Function Row Virtual Input Device (/dev/input/event5)
Apple Internal Keyboard / Trackpad	05ac:0341:c3080866	enter up
Apple Internal Keyboard / Trackpad	05ac:0341:c3080866	fn down
Apple Internal Keyboard / Trackpad	05ac:0341:c3080866	fn up
$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:	Apple Internal Keyboard / Trackpad
/dev/input/event1:	MacBookPro17,1 Touch Bar
/dev/input/event2:	Apple Internal Keyboard / Trackpad
/dev/input/event3:	Apple SMC power/lid events
/dev/input/event4:	MacBook Pro J293 Headphone Jack
/dev/input/event5:	Dynamic Function Row Virtual Input Device
Select the device event number [0-5]: 0
Input driver version is 1.0.1
Input device ID: bus 0x1c vendor 0x5ac product 0x341 version 0x175
Input device name: "Apple Internal Keyboard / Trackpad"
Supported events:
  Event type 0 (EV_SYN)
  <truncated>
Properties:
Testing ... (interrupt to exit)
Event: time 1732936876.378020, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70028
Event: time 1732936876.378020, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1732936876.378020, -------------- SYN_REPORT ------------
Event: time 1732936877.134727, type 4 (EV_MSC), code 4 (MSC_SCAN), value ff0003
Event: time 1732936877.134727, type 1 (EV_KEY), code 464 (KEY_FN), value 1
Event: time 1732936877.134727, -------------- SYN_REPORT ------------
Event: time 1732936877.290671, type 4 (EV_MSC), code 4 (MSC_SCAN), value ff0003
Event: time 1732936877.290671, type 1 (EV_KEY), code 464 (KEY_FN), value 0

@ftelnov
Copy link

ftelnov commented Dec 12, 2024

+1. Keyd correctly detects FN key, but after remapping it stops working as it worked before - for instance, I can't use top row with it.

@ftelnov
Copy link

ftelnov commented Dec 12, 2024

Any progress or workaround on this? Maybe we can somehow tell keyd that we remap fn to specific keycode? Is operation with keycodes in keyd even possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants