android系统添加KeyEvent

1.确认驱动中的键值定义

kernel-3.18/include/uapi/linux/input.h

#define KEY_F13                 183

驱动中会上报KEY_F13,对应键值就是183,驱动上报的键值android层会映射成android Keycode

2.*.kl文件中添加键值

/frameworks/base/data/keyboards/Generic.kl

key 183   F13

/frameworks/base/data/keyboards/qwerty.kl

key 183   F13

3.定义键值映射

/frameworks/native/include/input/InputEventLabels.h

数组中添加

static const InputEventLabel KEYCODES[] = {

…..

DEFINE_KEYCODE(F13),

}

/frameworks/native/include/android/keycodes.h

enum {

….

AKEYCODE_F13 = 280

}

4.

/frameworks/base/core/java/android/view/KeyEvent.java

public class KeyEvent extends InputEvent implements Parcelable {

……

 public static final int KEYCODE_F13 = 280;

}

/frameworks/base/core/res/res/values/attrs.xml

<enum name=”KEYCODE_F13″ value=”280″/> 

5.mtk中的定义(current.txt)(根据具体项目添加)
frameworks/base/api/current.txt
field public static final int KEYCODE_F13 = 266;

    原文作者:lz强
    原文地址: https://blog.csdn.net/liu362732346/article/details/79893657
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞