Troubleshooting:HID buttons

Phones may have some buttons. Those buttons can be configured to execute specific command when pressed.

Getting input device information using udevadm
Make sure that buttons are recognized as eventX inside  directory

To make sure that the input buttons are recognized, run the following command:

The command will print udev properties which can be used to assign udev rules, for example tagging specified device as touchscreen.

Note that HID input device doesn't trigger udev event, so the following command can't be used to detect key-presses from HID input device.

Getting input device events using evtest
evtest can be used to detect events sent by input devices. To use it, install evtest package.

Launch evtest to troubleshoot the input device

The information obtained from evtest can be used as reference to configure triggerhappy or creating acpi.map for busybox acpid

Installation
Triggerhappy can be used to handle HID input device. After postmarketOS is installed, add it with:

If you did not install it yet, you can also request it to be added to the installation in  or by using the   parameter for the install action:

Usage
Run thd on the device to find what is sent:

With  running, touch the touchscreen and press the available buttons. There will be information related to the input device printed on the ssh session.

EV_ABS	ABS_MT_TRACKING_ID	16	/dev/input/event0 EV_ABS	ABS_MT_TRACKING_ID	0	/dev/input/event0 EV_ABS	ABS_MT_POSITION_X	312	/dev/input/event0 EV_ABS	ABS_MT_POSITION_Y	1013	/dev/input/event0 EV_ABS	ABS_MT_TOUCH_MAJOR	123	/dev/input/event0 EV_ABS	ABS_MT_WIDTH_MAJOR	144	/dev/input/event0 EV_KEY KEY_POWER       1       /dev/input/event1 EV_KEY KEY_POWER       0       /dev/input/event1 EV_KEY KEY_VOLUMEDOWN  1       /dev/input/event1 EV_KEY KEY_VOLUMEDOWN  0       /dev/input/event1 EV_KEY KEY_VOLUMEUP    1       /dev/input/event2 EV_KEY KEY_VOLUMEUP    0       /dev/input/event2
 * 1) ABS_MT_TRACKING_ID	16	command
 * 1) ABS_MT_TRACKING_ID	0	command
 * 1) ABS_MT_POSITION_X	312	command
 * 1) ABS_MT_POSITION_Y	1013	command
 * 1) ABS_MT_TOUCH_MAJOR	123	command
 * 1) ABS_MT_WIDTH_MAJOR	144	command
 * 1) KEY_POWER     1       command
 * 1) KEY_POWER     0       command
 * 1) KEY_VOLUMEDOWN        1       command
 * 1) KEY_VOLUMEDOWN        0       command
 * 1) KEY_VOLUMEUP  1       command
 * 1) KEY_VOLUMEUP  0       command

The information can be used to create a triggerhappy configuration, for example assigning a command when the home touch button is pressed.

Example : KEY_POWER 1 poweroff KEY_VOLUMEDOWN+KEY_POWER 1 reboot
 * 1) ABS_MT_POSITION_Y@ 1344 @home
 * 2) ABS_MT_POSITION_X@home 360 logger "Home button is pressed"
 * 3) ABS_MT_POSITION_Y@home 1344 @

The triggerhappy service needs to be enabled to listen HID button keypresses:

Using busybox acpid
Some device buttons can trigger acpi events. Busybox acpid can be used to handle these events, for example nokia n900.

For this to work, an acpi.map is needed. Look at device-nokia-n900 for more information.