Android Input kl file implements key-value mapping

Android Keyevent is defined in the KeyEvent.java screenshot corresponding to public static final int KEYCODE_SYSRQ = 120;

adb shell input keyevent SYSRQ

Linux Scancode is defined in input-event-codes.h #define KEY_SCALE 120. It can be seen that it does not correspond.
Originally, I wanted to double-click the fingerprint to realize the screenshot function, but found that reporting scancode 120 was not enough. Later, I learned that the codes of Android and Linux are different.
At the beginning, the method I thought of was to report the Linux Scancdoe volume down key and power key KEY_VOLUMEDOWN + KEY_POWER at the same time. Later, I learned that there is a key value implicit kl file

According to the above flowchart, we can know that the fingerprint does not have vendorid and prodcutid, so the name: uinput-fpc is directly passed, and all corresponding files are uinput-fpc.kl
. It is processed by EventHub.cpp, see the flow chart

(1)open /dev/uinput 
(2)ioctl UI_SET_EVBIT -> set_bit
(2)ioctl UI_SET_KEYBIT -> set_bit
(3)write udev->name(uinput-fpc) ->  uinput_setup_device_legacy 
(4)ioctl UI_DEV_CREATE  -> input_register_device
(5)write ev.type ev.code ev.value -> uinput_inject_event -> input_event

# Double Tap
-key 306   BUTTON_C
+key 306   SYSRQ
adb push uinput-fpc.kl system/usr/keylayout

insert image description here

Guess you like

Origin blog.csdn.net/qq_40405527/article/details/130329521