Skip to content

samsung-a3|a5|klte|serranove: remap left touch key

Administrator requested to merge tm2-touchkey_remap_key into master

In the device trees of samsung-a3, samsung-a5, samsung-klte and samsung-serranove the touch keys are mapped to KEY_APPSELECT and KEY_BACK. This is the correct mapping to meet the manufacturers intension. When running Android with this kernel (native or sandboxed), the left touch key (KEY_APPSELECT) brings up the "recent apps" screen on a short click and splits the screen on a long click. The long click action is configurable in the Android settings.

However, KEY_APPSELECT has a kernel keycode of 580 (0x244) [1]. In xkb library this is keycode 588. Keycodes above 255 are not processed in X11 [2] because X11 uses 8 bit keycodes. Therefore, the left touch key (KEY_APPSELECT) is not available in X11 UIs.

Wayland uses 32 bit keycodes and does not have this limitation [3]. However (again), in Phosh assigning the left touch key to an action in Settings does not work. The key is recognized to some degree but is not processed properly. @Minecrell found out that some software packages handle it correclty and others don't. Also in Plasma Mobile assigning actions to the left key doesn't work. Package "khotkeys" needs to be installed and started by command "kcmshell5 khotkeys" but the left touch key isn't recognized there.

This MR implements an udev rule in the device packages to remap the left touch key to KEY_MENU. This is kernel keycode 139 and xkb keycode 147, therefore available in the UIs. The key has no preset functionality (tested in Phosh, Plasma Mobile, Xfce4, MATE) but is available for assignment in the UIs settings.

A drawback is the behaviour in Waydroid "show-full-ui". The left touch key behaves differently as intended by the manufacturer. A short click calls the menu of the app. A long click calls the "recent apps" screen. The option to change the long click behaviour in the Android settings has no effect. (Additional note: Long click in Phosh seems to have a window focusing problem, it only works if the Waydroid window is not focused, e.g. when hitting the top black bar before. In Plasma Mobile, long click in Waydroid works flawless.)

As the remapping is done by an udev rule, the user can override the rule and set the mapping back to KEY_APPSELECT or something else if needed.

Many thanks to @Minecrell for the support, valuable hints & applying changes to the tm2-touchkey driver.

Cc: @Mis012 @TravMurav @minlexx

  1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/uapi/linux/input-event-codes.h?h=v5.15#n608
  2. https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/blob/xkeyboard-config-2.34/keycodes/evdev#L327
  3. https://bugs.freedesktop.org/show_bug.cgi?id=11227#c56

Merge request reports

Loading