修改添加按键KEY_EVENT
1.在frameworks/base/core/java/android/view/KeyEvent.java中添加键值,病修改LAST_KEYCODE
/* And W key for Winew*/
public static final int KEYCODE_WKEY = 263;
private static final int LAST_KEYCODE = KEYCODE_WKEY;
2.在frameworks/native/include/android/keycodes.h添加和KeyEvent.java中对应键值的AKEY
AKEYCODE_WKEY = 263
3.frameworks/native/include/input/InputEventLabels.h的KEYCODES数组中添加DEFINE_KEYCODE
static const InputEventLabel KEYCODES[] = {
...
DEFINE_KEYCODE(WKEY),
{ NULL, 0 }
};
4.在例如device/qcom/l932/gpio-keys.kl的kl文件中添加和驱动硬件对应的gpio的键值
一定要确保在kl文件中定义的键在上层framework中有定义,不然会在加载kl文件的时候报错。
key 250 WKEY
5.查看驱动按键消息
apu@apu-pc:~/l910$ adb root
restarting adbd as root
apu@apu-pc:~/l910$ adb remount
remount succeeded
apu@apu-pc:~/l910$ adb shell
root@550:/ # getevent
add device 1: /dev/input/event5
name: "msm8x10-skuaa-snd-card Headset Jack"
add device 2: /dev/input/event4
name: "msm8x10-skuaa-snd-card Button Jack"
add device 3: /dev/input/event3
name: "qpnp_pon"
add device 4: /dev/input/event2
name: "accelerometer"
add device 5: /dev/input/event1
name: "speed_keypad"
add device 6: /dev/input/event0
name: "synaptics_rmi4_i2c"
^C
130|root@550:/ # getevent -lt /dev/input/event1
[ 887.617253] EV_KEY KEY_F7 DOWN
[ 887.617297] EV_SYN SYN_REPORT 00000000
[ 887.861869] EV_KEY KEY_F7 UP
[ 895.531064] EV_SYN SYN_REPORT 00000000
[ 896.273882] EV_KEY KEY_REPLY DOWN
[ 896.273923] EV_SYN SYN_REPORT 00000000
[ 896.518718] EV_KEY KEY_REPLY UP