You are not logged in.

#1 2022-05-03 15:18:56

martor
Member
Registered: 2017-10-01
Posts: 4

[SOLVED] Remap Thinkpad VOIP and Notification fn keys

So I have a Lenovo Thinkpad T15 Gen 2. This Series of laptop have some useless function keys for answering and hanging voip calls and to open the notifications. The problem at hand is that I wish to remap this keys to media keys, playpause, previoussong and nextsong. The events are handled by the thinkpad_acpi driver and generate the following output when running

# evtest /dev/input/event4
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x17aa product 0x5054 version 0x4101
Input device name: "ThinkPad Extra Buttons"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 120 (KEY_SCALE)
    Event code 140 (KEY_CALC)
    Event code 142 (KEY_SLEEP)
    Event code 144 (KEY_FILE)
    Event code 148 (KEY_PROG1)
    Event code 152 (KEY_SCREENLOCK)
    Event code 156 (KEY_BOOKMARKS)
    Event code 158 (KEY_BACK)
    Event code 171 (KEY_CONFIG)
    Event code 173 (KEY_REFRESH)
    Event code 190 (KEY_F20)
    Event code 191 (KEY_F21)
    Event code 194 (KEY_F24)
    Event code 205 (KEY_SUSPEND)
    Event code 212 (KEY_CAMERA)
    Event code 217 (KEY_SEARCH)
    Event code 224 (KEY_BRIGHTNESSDOWN)
    Event code 225 (KEY_BRIGHTNESSUP)
    Event code 227 (KEY_SWITCHVIDEOMODE)
    Event code 228 (KEY_KBDILLUMTOGGLE)
    Event code 236 (KEY_BATTERY)
    Event code 237 (KEY_BLUETOOTH)
    Event code 238 (KEY_WLAN)
    Event code 240 (KEY_UNKNOWN)
    Event code 372 (KEY_ZOOM)
    Event code 374 (KEY_KEYBOARD)
    Event code 444 (?)
    Event code 445 (?)
    Event code 446 (?)
    Event code 466 (KEY_FN_F1)
    Event code 475 (KEY_FN_F10)
    Event code 476 (KEY_FN_F11)
    Event code 485 (?)
    Event code 582 (KEY_VOICECOMMAND)
    Event code 592 (KEY_BRIGHTNESS_MIN)
    Event code 634 (?)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
  Event type 5 (EV_SW)
    Event code 3 (SW_RFKILL_ALL) state 1
Properties:
Testing ... (interrupt to exit)
Event: time 1651590498.360825, type 4 (EV_MSC), code 4 (MSC_SCAN), value 4b
Event: time 1651590498.360825, type 1 (EV_KEY), code 444 (?), value 1
Event: time 1651590498.360825, -------------- SYN_REPORT ------------
Event: time 1651590498.360843, type 4 (EV_MSC), code 4 (MSC_SCAN), value 4b
Event: time 1651590498.360843, type 1 (EV_KEY), code 444 (?), value 0
Event: time 1651590498.360843, -------------- SYN_REPORT ------------
Event: time 1651590498.554188, type 4 (EV_MSC), code 4 (MSC_SCAN), value 4c
Event: time 1651590498.554188, type 1 (EV_KEY), code 445 (?), value 1
Event: time 1651590498.554188, -------------- SYN_REPORT ------------
Event: time 1651590498.554204, type 4 (EV_MSC), code 4 (MSC_SCAN), value 4c
Event: time 1651590498.554204, type 1 (EV_KEY), code 445 (?), value 0
Event: time 1651590498.554204, -------------- SYN_REPORT ------------
Event: time 1651590498.804208, type 4 (EV_MSC), code 4 (MSC_SCAN), value 4d
Event: time 1651590498.804208, type 1 (EV_KEY), code 446 (?), value 1
Event: time 1651590498.804208, -------------- SYN_REPORT ------------
Event: time 1651590498.804224, type 4 (EV_MSC), code 4 (MSC_SCAN), value 4d
Event: time 1651590498.804224, type 1 (EV_KEY), code 446 (?), value 0
Event: time 1651590498.804224, -------------- SYN_REPORT ------------

I tried remapping those scancodes (4b,4c,4d) using hwdb but it doens't work. I followed this guide. I tried modifying the /lib/udev/hwdb.d/60-keyboard.hwdb and creating a new one (e.g.: /etc/udev/hwdb.d/99-custom.hwdb.
I later tried using the setkeycodes tools in the following way

# setkeycodes 4b 165 4c 164 4d 163

But still no luck. So is this even possible? Is there another method to remap scancodes? Do I have to modify the driver?

Last edited by martor (2022-05-03 15:31:34)

Offline

#2 2022-05-03 15:27:40

martor
Member
Registered: 2017-10-01
Posts: 4

Re: [SOLVED] Remap Thinkpad VOIP and Notification fn keys

I found the answer. I was modifying the thinkpad_acpi driver's ibm section in the /lib/udev/hwdb.d/60-keyboard.hwdb. After moving my modifications to the Lenovo section I was able to correctly remap the voip and notification fn-keys to the media keys I desired. Here is the part of the file I modified. (starting at line 779)

###########################################################
# Lenovo
###########################################################

# thinkpad_acpi driver
evdev:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*:*
 KEYBOARD_KEY_01=screenlock
 KEYBOARD_KEY_02=battery
 KEYBOARD_KEY_03=sleep
 KEYBOARD_KEY_04=wlan
 KEYBOARD_KEY_06=switchvideomode
 KEYBOARD_KEY_07=f21
 KEYBOARD_KEY_08=f24
 KEYBOARD_KEY_0b=suspend
 KEYBOARD_KEY_0f=brightnessup
 KEYBOARD_KEY_10=brightnessdown
 KEYBOARD_KEY_11=kbdillumtoggle
 KEYBOARD_KEY_13=zoom
 KEYBOARD_KEY_14=volumeup
 KEYBOARD_KEY_15=volumedown
 KEYBOARD_KEY_16=mute
 KEYBOARD_KEY_17=prog1
 KEYBOARD_KEY_1a=f20                                    # Microphone mute button; should be micmute
 KEYBOARD_KEY_4b=previoussong                   # Notification key
 KEYBOARD_KEY_4c=playpause                        # Answer Voip call key
 KEYBOARD_KEY_4d=nextsong                         # Hang Voip call key
 KEYBOARD_KEY_45=bookmarks

Offline

Board footer

Powered by FluxBB