doc:appunti:linux:sa:remap_keyboard_keys
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:linux:sa:remap_keyboard_keys [2021/12/07 10:26] – [Customize events using udev] niccolo | doc:appunti:linux:sa:remap_keyboard_keys [2021/12/07 11:50] (current) – [xmodmap] niccolo | ||
|---|---|---|---|
| Line 17: | Line 17: | ||
| </ | </ | ||
| - | It is possibile to customize the ACPI events to reassign the brightness keys to plain function keys, but it is not the preferred way (see [[# | + | It is possibile to customize the ACPI events to reassign the brightness keys to plain function keys, but it is not the preferred way (see [[# |
| It seems that the LCD (DISPLAYTOGGLE) multimedia function is intercepted by the hardware and it is not handled as an input event nor as an ACPI event by the operating system. | It seems that the LCD (DISPLAYTOGGLE) multimedia function is intercepted by the hardware and it is not handled as an input event nor as an ACPI event by the operating system. | ||
| Line 111: | Line 111: | ||
| </ | </ | ||
| - | ===== Customize events using udev ===== | + | ===== Customize events using udev and hwdb ===== |
| We will use **udev** and **hwdb** to customize the actions associated to the input events, basically to swap the effects of keys from **F2** to **F12** keys with the effects of the same keys combined with the **Fn** key. | We will use **udev** and **hwdb** to customize the actions associated to the input events, basically to swap the effects of keys from **F2** to **F12** keys with the effects of the same keys combined with the **Fn** key. | ||
| Line 146: | Line 146: | ||
| We have two **device selector** lines (the ones starting with '' | We have two **device selector** lines (the ones starting with '' | ||
| - | After each selector there is a list of **key=value** entries one per line, they must be indented by one space and cannot contain comments. The //key// is the **MSC_SCAN** | + | After each selector there is a list of **key=value** entries, one per line; they must be indented by one space and cannot contain comments. The //key// is the **MSC_SCAN** code generated when a key is pressed on the input device. The //value// is an **EV_KEY** event code that will be acted upon by the input subsystem. |
| - | You can get the label of **event codes** (to be placed | + | To know the **MSC_SCAN** codes (to be placed |
| + | |||
| + | Also the **EV_KEY** | ||
| To update the **hardware database** and to trigger a kernel device **coldplug event**: | To update the **hardware database** and to trigger a kernel device **coldplug event**: | ||
| Line 155: | Line 157: | ||
| systemd-hwdb update | systemd-hwdb update | ||
| udevadm trigger --verbose / | udevadm trigger --verbose / | ||
| + | udevadm trigger --verbose / | ||
| </ | </ | ||
| + | |||
| You can also check that your changes were effective using **udevadm**: | You can also check that your changes were effective using **udevadm**: | ||
| Line 164: | Line 168: | ||
| P: / | P: / | ||
| ... | ... | ||
| + | E: KEYBOARD_KEY_3d=volumedown | ||
| E: KEYBOARD_KEY_3e=volumeup | E: KEYBOARD_KEY_3e=volumeup | ||
| + | E: KEYBOARD_KEY_40=brightnessdown | ||
| + | E: KEYBOARD_KEY_41=brightnessup | ||
| + | ... | ||
| E: KEYBOARD_KEY_b0=f4 | E: KEYBOARD_KEY_b0=f4 | ||
| ... | ... | ||
| Line 173: | Line 181: | ||
| ===== Configuration example for the Teclast F6 notebook ===== | ===== Configuration example for the Teclast F6 notebook ===== | ||
| - | The following is the file **/ | + | The following is the file **/ |
| < | < | ||
| - | # / | + | # / |
| - | # | + | # |
| # Keyboard remapping for the Teclast F6 notebook. | # Keyboard remapping for the Teclast F6 notebook. | ||
| - | # 2021-05-13 Niccolo Rigacci < | + | # 2021-12-07 Niccolo Rigacci < |
| # | # | ||
| # The following udev hwdb configuration swaps the Fn behaviour | # The following udev hwdb configuration swaps the Fn behaviour | ||
| - | # on keys F2, F3, F4, F8, F9, F10, F11 and F12. | + | # on keys F2, F3, F4, F6, F7, F8, F9, F10, F11 and F12. |
| # It also binds the Fn+ESC to Ctrl+LeftWinLogo+Esc, | # It also binds the Fn+ESC to Ctrl+LeftWinLogo+Esc, | ||
| # be used as keyboard shortcut into XFCE or other desktop | # be used as keyboard shortcut into XFCE or other desktop | ||
| # environments to execute a script and toggle the touchpad. | # environments to execute a script and toggle the touchpad. | ||
| # | # | ||
| - | # Function | + | # Function |
| - | # udev Hardware Database (as far as I know). | + | # Database (as far as I know). |
| # | # | ||
| - | # To make this file effective execute: | + | # To make this file effective execute |
| + | # input number using lsinput): | ||
| # | # | ||
| # | # | ||
| + | # | ||
| # | # | ||
| - | # To view current | + | # To view current |
| # | # | ||
| # | # | ||
| Line 209: | Line 219: | ||
| # | # | ||
| # | # | ||
| - | # Function keys F1, F6 and F7 do not generate events | + | # Fn+F6 and Fn+F7 produce keys 64 and 65 (0x40 and 0x41). |
| - | # (verified with evtest | + | |
| - | # be remapped. | + | |
| - | # | + | |
| - | # The following EV_KEY do not work: | + | |
| - | # | + | |
| - | # | + | |
| - | # | + | |
| # | # | ||
| + | # Function keys F1 does not generate events (verified with | ||
| + | # evtest and showkey), so it cannot be remapped. | ||
| + | |||
| + | # Teclast AT Keyboard input device. | ||
| evdev: | evdev: | ||
| | | ||
| Line 230: | Line 237: | ||
| | | ||
| | | ||
| + | | ||
| + | | ||
| | | ||
| | | ||
| Line 236: | Line 245: | ||
| | | ||
| | | ||
| + | |||
| + | # F6 and F7 are connected to input "Intel HID events", | ||
| + | evdev: | ||
| + | | ||
| + | | ||
| </ | </ | ||
| Line 279: | Line 293: | ||
| </ | </ | ||
| - | These keysyms do not produce the expected action; i.e. they don't do anything, despite I associate them to a key and depite | + | These keysyms do not produce the expected action; i.e. they don't do anything, despite I associate them to a key and despite |
| * XF86TouchpadToggle, | * XF86TouchpadToggle, | ||
| Line 285: | Line 299: | ||
| ===== ACPI and evemu ===== | ===== ACPI and evemu ===== | ||
| + | |||
| + | **WARNING**: | ||
| With this recipe we simulate a **keyboard event** (e.g. a function key press/ | With this recipe we simulate a **keyboard event** (e.g. a function key press/ | ||
| Line 322: | Line 338: | ||
| WARNING: The **sleep** command was determined empirically, | WARNING: The **sleep** command was determined empirically, | ||
| - | Once the acpid service is restarted, every time you press the **BrightnessDown** and **BrightnessUp** keys, you get the brightness adjusted and also the key **F6** or **F7** simulated events. | + | Once the acpid service is restarted, every time you press the **BrightnessDown** and **BrightnessUp** keys, you get the key **F6** or **F7** simulated events |
| - | Now you have to disable the default brightness control behaviour. | + | To disable |
| - | If the brightness keys are sent as **keyboard | + | On different hardware, if the multimedia key generates a plain **keyboard |
| - | + | ||
| - | < | + | |
| - | xmodmap -display :0.0 -pke | grep -i monbright | + | |
| - | keycode 232 = XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown | + | |
| - | keycode 233 = XF86MonBrightnessUp NoSymbol XF86MonBrightnessUp NoSymbol XF86MonBrightnessUp | + | |
| - | </ | + | |
| - | + | ||
| - | So we can disable keycodes 232 and 233: | + | |
| - | + | ||
| - | < | + | |
| - | xmodmap -e 'keycode 232 =' | + | |
| - | xmodmap | + | |
| - | </ | + | |
| - | + | ||
| - | Unfortunately this is not the case with the Teclast F6; the BrightnessDown and BrightnessUp events are not reported as keyboard keycodes. They are instead input events generated by the **Intel HID events** device. Use **lsinput** and **input-events** | + | |
| - | + | ||
| - | < | + | |
| - | lsinput | + | |
| - | ... | + | |
| - | / | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | bits ev : (null) (null) (null) | + | |
| - | </ | + | |
| - | + | ||
| - | < | + | |
| - | input-events -t 10 7 | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | 18: | + | |
| - | </ | + | |
| - | + | ||
| - | It is possible | + | |
| - | + | ||
| - | < | + | |
| - | xinput | + | |
| - | ... | + | |
| - | ↳ Intel HID events | + | |
| - | </ | + | |
| - | + | ||
| - | and disable it: | + | |
| - | + | ||
| - | < | + | |
| - | xinput disable 12 | + | |
| - | </ | + | |
| ===== Web References ===== | ===== Web References ===== | ||
doc/appunti/linux/sa/remap_keyboard_keys.1638869165.txt.gz · Last modified: by niccolo
