1.kernel-4.4/arch/arm64/boot/dts/mediatek/tb8788p1_64_bsp.dts
其中633与634为自定义按键
&keypad {
+ mediatek,kpd-hw-init-map = <114 633 0 0 0 0 0 0 0 580 634 0 0 0 0 0 0 0 102 158 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
};
2.kernel-4.4/include/uapi/linux/input-event-codes.h
其中0x279与0x280是633与634的十六进制。
#define KEY_KBDINPUTASSIST_CANCEL 0x265
+#define KEY_NEOSTRA_P 0x279
+#define KEY_NEOSTRA_F 0x280
#define BTN_TRIGGER_HAPPY 0x2c0
3.device/mediateksample/tb8788p1_64_bsp/mtk-kpd.kl
其中633与634要和第1点kernel中配置一致,NEOSTRA_P和NEOSTRA_F为上层调用的自定义名称。
key 602 HALL_AWAY
+key 633 NEOSTRA_P
+key 634 NEOSTRA_F
4.frameworks/native/include/input/InputEventLabels.h
DEFINE_KEYCODE(REFRESH),
+ DEFINE_KEYCODE(NEOSTRA_P),
+ DEFINE_KEYCODE(NEOSTRA_F),
5.frameworks/native/include/android/keycodes.h
其中286与287是285的叠加
- AKEYCODE_REFRESH = 285
+ AKEYCODE_REFRESH = 285,
+ AKEYCODE_NEOSTRA_P = 286,
+ AKEYCODE_NEOSTRA_F = 287
6.frameworks/base/core/res/res/values/attrs.xml
其中286与287是285的叠加
<enum name="KEYCODE_REFRESH" value="285" />
+ <enum name="KEYCODE_NEOSTRA_P" value="286" />
+ <enum name="KEYCODE_NEOSTRA_F" value="287" />
7.frameworks/base/core/java/android/view/KeyEvent.java
其中286与287是285的叠加
public static final int KEYCODE_REFRESH = 285;
- private static final int LAST_KEYCODE = KEYCODE_REFRESH;
+ public static final int KEYCODE_NEOSTRA_P = 286;
+ public static final int KEYCODE_NEOSTRA_F = 287;
+
+ private static final int LAST_KEYCODE = KEYCODE_NEOSTRA_F;
8.frameworks/base/api/current.txt
其中286与287是285的叠加
field public static final int KEYCODE_REFRESH = 285; // 0x11d
+ field public static final int KEYCODE_NEOSTRA_P = 286; // 0x11e
+ field public static final int KEYCODE_NEOSTRA_F = 287; // 0x11f
field public static final int KEYCODE_RIGHT_BRACKET = 72; // 0x48
9.最后在上层检测自定义按键响应事件,做对应的逻辑处理
if(keyCode == KeyEvent.KEYCODE_NEOSTRA_P){
......
}
if(keyCode == KeyEvent.KEYCODE_NEOSTRA_F){
......
}