工作中遇到一个问题,底层上报的键值和上层的keycode对应不上,项目中是有键值表的,特此记录:
查看键值表
framework/base/data/keyboards/Generic.kl
...............//省略部分代码
key 102 MOVE_HOME
key 103 DPAD_UP
key 104 PAGE_UP
key 105 DPAD_LEFT
key 106 DPAD_RIGHT
key 107 MOVE_END
key 108 DPAD_DOWN
key 109 PAGE_DOWN
key 110 INSERT
key 111 FORWARD_DEL
# key 112 "KEY_MACRO"
key 113 VOLUME_MUTE
key 114 VOLUME_DOWN
key 115 VOLUME_UP..........//省略部分代码
以上只是监制表里面的一部分,key值是驱动层对应的值。
修改驱动层如下
bsp/kernel/kernel4.14/arm/boot/dts/sl8541e-1h10_32b.dts 下
..................................//省略代码
gpio-keys {
compatible = "gpio-keys";
/*
key-hpptt{
label = "HP Ptt Key";
linux,code = <147>;
gpios = <&ap_gpio 90 GPIO_ACTIVE_LOW>;
debounce-interval = <2>;
wakeup-source;
};
*/
key-PTT{
label = "PTT Key";
linux,code = <59>;
gpios = <&ap_gpio 73 0>; //gpio73
debounce-interval = <2>;
wakeup-source;
};key-Camera {
label = "Camera Key";
linux,code = <212>;
gpios = <&ap_gpio 137 0>; //gpio137
debounce-interval = <2>;
wakeup-source;
};
key-volumeup {
label = "Volume Up Key";
linux,code = <115>;
gpios = <&ap_gpio 72 0>; //GPIO72
debounce-interval = <20>;
wakeup-source;
};
key-sos{
label = "Sos Key";
linux,code = <66>;
gpios = <&ap_gpio 136 0>; //GPIO136
debounce-interval = <2>;
wakeup-source;
};/*key-hpdet{
label = "HP det Key";
linux,code = <68>;
gpios = <&ap_gpio 93 GPIO_ACTIVE_LOW>;
debounce-interval = <2>;
wakeup-source;
};*/
};keypad@40250000{
compatible = "sprd,s9820e-keypad";
reg = <0x40250000 0x1000>;
interrupts = <GIC_SPI 36 IRQ_TYPE_NONE>;
clocks = <&aonapb_gate CLK_KPD_EB>,
<&aonapb_gate CLK_KPD_RTC_EB>;
clock-names = "enable", "rtc";
keypad,num-rows= <3>;
keypad,num-columns = <3>;
debounce-interval = <5>;
// keymap: row << 24 | column << 16 | key-code
linux,keymap = < 0x000000ac // row:0 col:0 K1 HOME
0x00010069 // row:0 col:1 k4 DPAD LEFT 105
0x0002007f // row:0 col:2 k7 BACK 158 ??
0x01000067 // row:1 col:0 k2 UP 105
0x01010161 // row:1 col:1 k5
0x0102006c // row:1 col:2 k8 RIGHT 106
0x0200009e // row:2 col:0 k3 DOWN 108
0x0201006a // row:2 col:1 k6 PAGEDOEN 109
0x02020045 // row:2 col:2 k9 NUMLOCK 69
>;
wakeup-source;
status = "okay";
};.................................//省略代码
以上颜色部分代码是设备按键的键值设置,按键布局是九宫格,按照二维数组索引定位赋值