samsung-a3|a5|klte|serranove: remap left touch key
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
Merge request reports
Activity
- Resolved by Administrator
This is super cool!
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.
Have you looked into the option of adding this behavior? I believe at this point Phosh is really not implementing many keybindings, so could be the reason and probably not a very hard fix. But anyway this solution fixes it for all UIs, which is a great plus :)
By Pablo Correa Gomez on 2021-12-02T19:06:52
Edited by Ghost User
Thank you very much @jakko and everyone who helped you with this, thanks to both you and @pabloyoyoista for the detailed comments above!
Let's get this merged. As I understand, this should be backported to v21.12, right? (I think you mentioned it in the release party chat). I'll do that, if not leave a reply here and we could revert it.
By Oliver Smith on 2021-12-05T22:49:43
Edited by Ghost User
added 6 commits
-
dd0d351d...415ff553 - 5 commits from branch
postmarketOS:master
- c655f5cc - samsung-a3|a5|klte|serranove: remap left touch key (MR 2718)
By Oliver Smith on 2021-12-05T20:34:44
-
dd0d351d...415ff553 - 5 commits from branch
enabled an automatic merge when the pipeline for c655f5cc succeeds
By Oliver Smith on 2021-12-05T20:35:32
added backport-to-v21.12 label
I now see red error in dmesg on klte:
[ 15.122578] udevd[1598]: Error calling EVIOCSKEYCODE on device node '/dev/input/event3' (scan code 0x0, key code 139): Invalid argument
where event3 is tm2-touchkey.
Is it result of this MR?
By Alexey Min on 2021-12-14T00:20:05
Edited by Ghost Userleft tkey is still appselect
samsung-klte [~]$ evtest No device specified, trying to scan all of /dev/input/event* Not running as root, no devices may be available. Available devices: /dev/input/event0: soc:gpio-keys /dev/input/event1: pm8941_pwrkey /dev/input/event2: Synaptics s5100 A3 F /dev/input/event3: tm2-touchkey Select the device event number [0-3]: 3 Input driver version is 1.0.1 Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0 Input device name: "tm2-touchkey" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 158 (KEY_BACK) Event code 580 (KEY_APPSELECT) Properties: Testing ... (interrupt to exit) Event: time 1639440918.038323, type 1 (EV_KEY), code 580 (KEY_APPSELECT), value 1 Event: time 1639440918.038323, -------------- SYN_REPORT ------------ Event: time 1639440918.152734, type 1 (EV_KEY), code 580 (KEY_APPSELECT), value 0 Event: time 1639440918.152734, -------------- SYN_REPORT ------------
By Alexey Min on 2021-12-14T00:20:05
Any chance that you miss this patch?
By Nikita Travkin on 2021-12-14T04:51:46
Oh. There are two patches. In upstream kernel they were implemented in 5.16-rc1. In msm8916-mainline, @Minecrell added them to v5.15-msm8916. I didn't think far enough for samsung-klte, sorry
(Edit: 5.16-rc1, not 5.16-rc5)
By Jakko on 2021-12-15T02:18:07
Edited by Administrator
mentioned in issue #1422 (closed)
By Jakko on 2022-02-10T20:16:46