You are not logged in.

#1 2024-03-12 16:42:08

supernobby
Member
Registered: 2017-07-22
Posts: 18

repurpose MacBook Pro 11,x Power Key using udev/hwdb?

Hello!
I am new to this udev mechanism. So I place this here.


My question is, if I can repurpose the Power Key of my MacBook Pro 11,3 for example as Delete Key using udev/hwdb. If this should be possible, then I struggle for now how to specify this in a hwdb file.

In systemd/logind.conf I already set:

HandlePowerKey=ignore

First confusion for me, according to "cat /proc/bus/input/devices", there are two most similar "Power Button" inputs in the system:

I: Bus=0019 Vendor=0000 Product=0001 Version=0000
N: Name="Power Button"
P: Phys=PNP0C0C/button/input0
S: Sysfs=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1
U: Uniq=
H: Handlers=kbd event1 
B: PROP=0
B: EV=3
B: KEY=10000000000000 0

I: Bus=0019 Vendor=0000 Product=0001 Version=0000
N: Name="Power Button"
P: Phys=LNXPWRBN/button/input0
S: Sysfs=/devices/LNXSYSTM:00/LNXPWRBN:00/input/input3
U: Uniq=
H: Handlers=kbd event3 
B: PROP=0
B: EV=3
B: KEY=10000000000000 0

"evemu-describe" also looks identical for both /dev/input/event1 and /dev/input/event3:

# EVEMU 1.3
# Kernel: 6.6.21-1-lts
# DMI: dmi:bvnAppleInc.:bvr478.0.0.0.0:bd01/13/2023:br0.1:svnAppleInc.:pnMacBookPro11,3:pvr1.0:rvnAppleInc.:rnMac-2BD1B31983FE1663:rvrMacBookPro11,3:cvnAppleInc.:ct10:cvrMac-2BD1B31983FE1663:skuSystemSKU#:
# Input device name: "Power Button"
# Input device ID: bus 0x19 vendor 0000 product 0x01 version 0000
# Supported events:
#   Event type 0 (EV_SYN)
#     Event code 0 (SYN_REPORT)
#     Event code 1 (SYN_CONFIG)
#     Event code 2 (SYN_MT_REPORT)
#     Event code 3 (SYN_DROPPED)
#     Event code 4 ((null))
#     Event code 5 ((null))
#     Event code 6 ((null))
#     Event code 7 ((null))
#     Event code 8 ((null))
#     Event code 9 ((null))
#     Event code 10 ((null))
#     Event code 11 ((null))
#     Event code 12 ((null))
#     Event code 13 ((null))
#     Event code 14 ((null))
#     Event code 15 (SYN_MAX)
#   Event type 1 (EV_KEY)
#     Event code 116 (KEY_POWER)
# Properties:
N: Power Button
I: 0019 0000 0001 0000
P: 00 00 00 00 00 00 00 00
B: 00 0b 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 10 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 02 00 00 00 00 00 00 00 00
B: 03 00 00 00 00 00 00 00 00
B: 04 00 00 00 00 00 00 00 00
B: 05 00 00 00 00 00 00 00 00
B: 11 00 00 00 00 00 00 00 00
B: 12 00 00 00 00 00 00 00 00
B: 14 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00

But according to "evtest" only "event3" produces events when pressing the key:

Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x1 version 0x0
Input device name: "Power Button"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 116 (KEY_POWER)
Properties:
Testing ... (interrupt to exit)
Event: time 1710260791.354952, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1710260791.354952, -------------- SYN_REPORT ------------
Event: time 1710260791.354962, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1710260791.354962, -------------- SYN_REPORT ------------

Most documentation, like Map scancodes to keycodes in the Arch Wiki describe how to map scancodes. But this Power Key has no scancode.
Also, for the "evdev:input" line in the hwdb file, how to do this when there are two identical "b<bus_id>v<vendor_id>p<product_id>e<version_id>" in the system?
And how could I map the Power Key, if the right input event can be selected? Is it something like:

 KEY_POWER=KEY_DELETE

?!?
So, can this work at all? Thank you!

Offline

#2 2024-03-13 12:08:34

supernobby
Member
Registered: 2017-07-22
Posts: 18

Re: repurpose MacBook Pro 11,x Power Key using udev/hwdb?

Meanwhile I found the tool  "evsieve" (also in the AUR) that can do this:

# evsieve --input /dev/input/event3 --map key:power key:delete --output

However, would still be interesting, if it could be done with udev/hwdb only.

Offline

Board footer

Powered by FluxBB