本文转载自:
Android下添加新的自定义键值和按键处理流程
说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我一个问题,请你详细描述一下怎么在Android下添加自定义键值和详细描述下Android的按键处理流程。现在回想起来当时回答的确实不是很好,乘着现在比较空闲的时机就来分析下上述的两个问题。
首先分析下Android下怎么添加新的自定义键值。在Android的原生系统中键值默认情况下是92个,从0-91;一般情况下,这些键值是够用的,但是如果想扩充的话,还是需要添加新的键值的,那么如何将一个新的键值从驱动的设置映射到上层,使应用可以对我们自定义的键值进行相应的处理呢?
首先分析下Android下怎么添加新的自定义键值。在Android的原生系统中键值默认情况下是92个,从0-91;一般情况下,这些键值是够用的,但是如果想扩充的话,还是需要添加新的键值的,那么如何将一个新的键值从驱动的设置映射到上层,使应用可以对我们自定义的键值进行相应的处理呢?
在介绍Android怎么添加新的键值以前先介绍下Android下INPUT子系统FLOW的流程,下面就是精简的流程图示意图:
1.添加按键及其映射
1)如果系统有新的按键需要添加,玛门是怎么添加并上报到系统上层去的呢(这里的上层主要指的是Android应用层),首先要确定的是我们的遥控设备是通过/dev/input目录下那个event调用那个kl文件,这里可以通过如下命令超看cat /proc/bus/input/devices,下面是在终端下的打印信息
- <span style="font-family:FangSong_GB2312;font-size:18px;">shell@orange:/ # cat /proc/bus/input/devices
- I: Bus=0018 Vendor=3697 Product=0001 Version=0001
- N: Name="MStar Smart TV IR Receiver"
- P: Phys=/dev/ir
- S: Sysfs=/devices/virtual/rc/rc0/input0
- U: Uniq=
- H: Handlers=kbd event0
- B: PROP=0
- B: EV=13
- B: KEY=fc0000 0 fc900 142851 0 0 0 0 108000 1a8 c0000c01 9e37c0 48007 f8000000 10000ffc
- B: MSC=10
- I: Bus=0000 Vendor=0000 Product=0000 Version=0000
- N: Name="MCE IR Keyboard/Mouse (ir)"
- P: Phys=/input0
- S: Sysfs=/devices/virtual/input/input1
- U: Uniq=
- H: Handlers=kbd mouse0 event1
- B: PROP=0
- B: EV=100017
- B: KEY=30000 0 7 ff87207a c14057ff febeffdf ffefffff ffffffff fffffffe
- B: REL=3
- B: MSC=10
- shell@orange:/ #
- shell@orange:/ # </span>
通过打印信息我们可以知道,我们的终端设备使用的是Vendor_3697_Product_0001.kl文件,我这里只分析IT遥控设备,那我们的Vendor_3697_Product_0001.kl里面又是啥呢,我们可以通过cat命令查看,具体的信息如下:
- <span style="font-family:FangSong_GB2312;font-size:18px;"># Copyright (C) 2010 The Android Open Source Project
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
- # MStar Smart TV IR Receiver.
- #
- key 116 POWER WAKE
- key 11 0
- key 2 1
- key 3 2
- key 4 3
- key 5 4
- key 6 5
- key 7 6
- key 8 7
- key 9 8
- key 10 9
- key 398 PROG_RED
- key 399 PROG_GREEN
- key 400 PROG_YELLOW
- key 401 PROG_BLUE
- key 103 DPAD_UP
- key 108 DPAD_DOWN
- key 105 DPAD_LEFT
- key 106 DPAD_RIGHT
- key 28 ENTER
- key 402 CHANNEL_UP WAKE_DROPPED
- key 403 CHANNEL_DOWN WAKE_DROPPED
- key 115 VOLUME_UP WAKE_DROPPED
- key 114 VOLUME_DOWN WAKE_DROPPED
- key 104 PAGE_UP
- key 109 PAGE_DOWN
- key 102 HOME WAKE_DROPPED
- key 139 MENU WAKE_DROPPED
- key 158 BACK
- key 113 VOLUME_MUTE
- key 167 DVR
- key 138 GUIDE
- key 358 INFO
- #key 82 WINDOW
- #key 79 TV_INPUT
- key 168 MEDIA_REWIND
- key 159 MEDIA_FAST_FORWARD
- key 165 MEDIA_PREVIOUS
- key 163 MEDIA_NEXT
- key 207 MEDIA_PLAY
- key 119 MEDIA_PAUSE
- key 128 MEDIA_STOP
- # Common extended
- key 392 SOUND_MODE
- key 212 PICTURE_MODE
- key 372 ASPECT_RATIO
- key 363 CHANNEL_RETURN
- key 142 SLEEP
- key 365 EPG
- key 395 LIST
- #key 370 SUBTITLE
- key 466 MTS
- key 467 FREEZE
- key 468 TTX
- key 469 CC
- key 470 TV_SETTING
- key 471 SCREENSHOT
- key 356 TV_POWER
- # Mstar extended
- key 59 MSTAR_BALANCE
- key 60 MSTAR_INDEX
- key 61 MSTAR_HOLD
- key 62 MSTAR_UPDATE
- key 63 MSTAR_REVEAL
- key 64 MSTAR_SUBCODE
- key 65 MSTAR_SIZE
- key 66 MSTAR_CLOCK</span>
2)在Vendor_3697_Product_0001.kl文件中添加映射
key 123 WLS
说明:
key -- 是关键字。固定值,不需要改变。
123 -- 该按键在linux驱动中对应的键值,我在这里只是假设的这个值,至于具体对应的是那个可以查看“include/linux/input.h”
WLS -- 123按键映射到Android中的按键,它对应是“KeycodeLabels.h”文件中的KEYCODES表格元素的“literal”值。
其中KeycodeLabels.h的定义如下,我们可以在"MSTAR_PVR_BROWSER", 319后面添加我们需要向Android上层抛的键值,我们这里定义为"WLS", 320,所以当Android上层监听到320的按键值是就是我们新添加的键值了。
123 -- 该按键在linux驱动中对应的键值,我在这里只是假设的这个值,至于具体对应的是那个可以查看“include/linux/input.h”
WLS -- 123按键映射到Android中的按键,它对应是“KeycodeLabels.h”文件中的KEYCODES表格元素的“literal”值。
其中KeycodeLabels.h的定义如下,我们可以在"MSTAR_PVR_BROWSER", 319后面添加我们需要向Android上层抛的键值,我们这里定义为"WLS", 320,所以当Android上层监听到320的按键值是就是我们新添加的键值了。
- <span style="font-family:FangSong_GB2312;font-size:18px;">/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #ifndef _LIBINPUT_KEYCODE_LABELS_H
- #define _LIBINPUT_KEYCODE_LABELS_H
- #include <android/keycodes.h>
- struct KeycodeLabel {
- const char *literal;
- int value;
- };
- static const KeycodeLabel KEYCODES[] = {
- { "SOFT_LEFT", 1 },
- { "SOFT_RIGHT", 2 },
- { "HOME", 3 },
- { "BACK", 4 },
- { "CALL", 5 },
- { "ENDCALL", 6 },
- { "0", 7 },
- { "1", 8 },
- { "2", 9 },
- { "3", 10 },
- { "4", 11 },
- { "5", 12 },
- { "6", 13 },
- { "7", 14 },
- { "8", 15 },
- { "9", 16 },
- { "STAR", 17 },
- { "POUND", 18 },
- { "DPAD_UP", 19 },
- { "DPAD_DOWN", 20 },
- { "DPAD_LEFT", 21 },
- { "DPAD_RIGHT", 22 },
- { "DPAD_CENTER", 23 },
- { "VOLUME_UP", 24 },
- { "VOLUME_DOWN", 25 },
- { "POWER", 26 },
- { "CAMERA", 27 },
- { "CLEAR", 28 },
- { "A", 29 },
- { "B", 30 },
- { "C", 31 },
- { "D", 32 },
- { "E", 33 },
- { "F", 34 },
- { "G", 35 },
- { "H", 36 },
- { "I", 37 },
- { "J", 38 },
- { "K", 39 },
- { "L", 40 },
- { "M", 41 },
- { "N", 42 },
- { "O", 43 },
- { "P", 44 },
- { "Q", 45 },
- { "R", 46 },
- { "S", 47 },
- { "T", 48 },
- { "U", 49 },
- { "V", 50 },
- { "W", 51 },
- { "X", 52 },
- { "Y", 53 },
- { "Z", 54 },
- { "COMMA", 55 },
- { "PERIOD", 56 },
- { "ALT_LEFT", 57 },
- { "ALT_RIGHT", 58 },
- { "SHIFT_LEFT", 59 },
- { "SHIFT_RIGHT", 60 },
- { "TAB", 61 },
- { "SPACE", 62 },
- { "SYM", 63 },
- { "EXPLORER", 64 },
- { "ENVELOPE", 65 },
- { "ENTER", 66 },
- { "DEL", 67 },
- { "GRAVE", 68 },
- { "MINUS", 69 },
- { "EQUALS", 70 },
- { "LEFT_BRACKET", 71 },
- { "RIGHT_BRACKET", 72 },
- { "BACKSLASH", 73 },
- { "SEMICOLON", 74 },
- { "APOSTROPHE", 75 },
- { "SLASH", 76 },
- { "AT", 77 },
- { "NUM", 78 },
- { "HEADSETHOOK", 79 },
- { "FOCUS", 80 },
- { "PLUS", 81 },
- { "MENU", 82 },
- { "NOTIFICATION", 83 },
- { "SEARCH", 84 },
- { "MEDIA_PLAY_PAUSE", 85 },
- { "MEDIA_STOP", 86 },
- { "MEDIA_NEXT", 87 },
- { "MEDIA_PREVIOUS", 88 },
- { "MEDIA_REWIND", 89 },
- { "MEDIA_FAST_FORWARD", 90 },
- { "MUTE", 91 },
- { "PAGE_UP", 92 },
- { "PAGE_DOWN", 93 },
- { "PICTSYMBOLS", 94 },
- { "SWITCH_CHARSET", 95 },
- { "BUTTON_A", 96 },
- { "BUTTON_B", 97 },
- { "BUTTON_C", 98 },
- { "BUTTON_X", 99 },
- { "BUTTON_Y", 100 },
- { "BUTTON_Z", 101 },
- { "BUTTON_L1", 102 },
- { "BUTTON_R1", 103 },
- { "BUTTON_L2", 104 },
- { "BUTTON_R2", 105 },
- { "BUTTON_THUMBL", 106 },
- { "BUTTON_THUMBR", 107 },
- { "BUTTON_START", 108 },
- { "BUTTON_SELECT", 109 },
- { "BUTTON_MODE", 110 },
- { "ESCAPE", 111 },
- { "FORWARD_DEL", 112 },
- { "CTRL_LEFT", 113 },
- { "CTRL_RIGHT", 114 },
- { "CAPS_LOCK", 115 },
- { "SCROLL_LOCK", 116 },
- { "META_LEFT", 117 },
- { "META_RIGHT", 118 },
- { "FUNCTION", 119 },
- { "SYSRQ", 120 },
- { "BREAK", 121 },
- { "MOVE_HOME", 122 },
- { "MOVE_END", 123 },
- { "INSERT", 124 },
- { "FORWARD", 125 },
- { "MEDIA_PLAY", 126 },
- { "MEDIA_PAUSE", 127 },
- { "MEDIA_CLOSE", 128 },
- { "MEDIA_EJECT", 129 },
- { "MEDIA_RECORD", 130 },
- { "F1", 131 },
- { "F2", 132 },
- { "F3", 133 },
- { "F4", 134 },
- { "F5", 135 },
- { "F6", 136 },
- { "F7", 137 },
- { "F8", 138 },
- { "F9", 139 },
- { "F10", 140 },
- { "F11", 141 },
- { "F12", 142 },
- { "NUM_LOCK", 143 },
- { "NUMPAD_0", 144 },
- { "NUMPAD_1", 145 },
- { "NUMPAD_2", 146 },
- { "NUMPAD_3", 147 },
- { "NUMPAD_4", 148 },
- { "NUMPAD_5", 149 },
- { "NUMPAD_6", 150 },
- { "NUMPAD_7", 151 },
- { "NUMPAD_8", 152 },
- { "NUMPAD_9", 153 },
- { "NUMPAD_DIVIDE", 154 },
- { "NUMPAD_MULTIPLY", 155 },
- { "NUMPAD_SUBTRACT", 156 },
- { "NUMPAD_ADD", 157 },
- { "NUMPAD_DOT", 158 },
- { "NUMPAD_COMMA", 159 },
- { "NUMPAD_ENTER", 160 },
- { "NUMPAD_EQUALS", 161 },
- { "NUMPAD_LEFT_PAREN", 162 },
- { "NUMPAD_RIGHT_PAREN", 163 },
- { "VOLUME_MUTE", 164 },
- { "INFO", 165 },
- { "CHANNEL_UP", 166 },
- { "CHANNEL_DOWN", 167 },
- { "ZOOM_IN", 168 },
- { "ZOOM_OUT", 169 },
- { "TV", 170 },
- { "WINDOW", 171 },
- { "GUIDE", 172 },
- { "DVR", 173 },
- { "BOOKMARK", 174 },
- { "CAPTIONS", 175 },
- { "SETTINGS", 176 },
- { "TV_POWER", 177 },
- { "TV_INPUT", 178 },
- { "STB_POWER", 179 },
- { "STB_INPUT", 180 },
- { "AVR_POWER", 181 },
- { "AVR_INPUT", 182 },
- { "PROG_RED", 183 },
- { "PROG_GREEN", 184 },
- { "PROG_YELLOW", 185 },
- { "PROG_BLUE", 186 },
- { "APP_SWITCH", 187 },
- { "BUTTON_1", 188 },
- { "BUTTON_2", 189 },
- { "BUTTON_3", 190 },
- { "BUTTON_4", 191 },
- { "BUTTON_5", 192 },
- { "BUTTON_6", 193 },
- { "BUTTON_7", 194 },
- { "BUTTON_8", 195 },
- { "BUTTON_9", 196 },
- { "BUTTON_10", 197 },
- { "BUTTON_11", 198 },
- { "BUTTON_12", 199 },
- { "BUTTON_13", 200 },
- { "BUTTON_14", 201 },
- { "BUTTON_15", 202 },
- { "BUTTON_16", 203 },
- { "LANGUAGE_SWITCH", 204 },
- { "MANNER_MODE", 205 },
- { "3D_MODE", 206 },
- { "CONTACTS", 207 },
- { "CALENDAR", 208 },
- { "MUSIC", 209 },
- { "CALCULATOR", 210 },
- { "ZENKAKU_HANKAKU", 211 },
- { "EISU", 212 },
- { "MUHENKAN", 213 },
- { "HENKAN", 214 },
- { "KATAKANA_HIRAGANA", 215 },
- { "YEN", 216 },
- { "RO", 217 },
- { "KANA", 218 },
- { "ASSIST", 219 },
- { "BRIGHTNESS_DOWN", 220 },
- { "BRIGHTNESS_UP", 221 },
- { "MEDIA_AUDIO_TRACK", 222 },
- // MStar Android Patch Begin
- // Common section, range 251-300
- { "SOUND_MODE", 251 },
- { "PICTURE_MODE", 252 },
- { "ASPECT_RATIO", 253 },
- { "CHANNEL_RETURN", 254 },
- { "SLEEP", 255 },
- { "EPG", 256 },
- { "LIST", 257 },
- { "SUBTITLE", 258 },
- { "FAVORITE", 259 },
- { "MTS", 260 },
- { "FREEZE", 261 },
- { "TTX", 262 },
- { "CC", 263 },
- { "TV_SETTING", 264 },
- { "SCREENSHOT", 265 },
- { "CLOUD", 266 },
- { "VOICE", 267 },
- { "USB", 268 },
- { "HDMI", 269 },
- { "DISPLAY_MODE", 270 },
- { "SONG_SYSTEM", 271 },
- { "GINGA_BACK", 272},
- { "NETFLIX", 273},
- { "AMAZONE", 274},
- // MStar section, range 301-400
- { "MSTAR_BALANCE", 301 },
- { "MSTAR_INDEX", 302 },
- { "MSTAR_HOLD", 303 },
- { "MSTAR_UPDATE", 304 },
- { "MSTAR_REVEAL", 305 },
- { "MSTAR_SUBCODE", 306 },
- { "MSTAR_SIZE", 307 },
- { "MSTAR_CLOCK", 308 },
- { "MSTAR_STORE_UP", 309 },
- { "MSTAR_TRIANGLE_UP", 310 },
- { "MSTAR_MOVIE", 311 },
- { "MSTAR_FILE", 312 },
- { "MSTAR_STAR_PLUS", 313 },
- { "MSTAR_AUDIO_TRACK", 314 },
- { "MSTAR_OPTIONAL_TIME", 315 },
- { "MSTAR_LOOP", 316 },
- { "MSTAR_INBOX", 317 },
- { "MSTAR_VVOIP", 318 },
- { "MSTAR_PVR_BROWSER", 319 },
- // Haier section, range 401-500
- { "HAIER_TASK", 401 },
- { "HAIER_USB", 402 },
- { "HAIER_TOOLS", 403 },
- { "HAIER_POWERSLEEP", 404 },
- { "HAIER_WAKEUP", 405 },
- { "HAIER_UNMUTE", 406 },
- { "HAIER_CLEANSEARCH", 407 },
- // Konka section, range 501-600
- { "KONKA_YPBPR", 501 },
- { "KONKA_THREEPOINT_LOONPRESS", 502 },
- { "KONKA_THREEPOINT_COLLECT", 503 },
- { "KONKA_THREEPOINT_DISPERSE", 504 },
- { "KONKA_VOICESWITCH", 505 },
- { "KONKA_FLYIMEFINGER_SELECT", 506 },
- { "KONKA_FLYIMEFINGER_CANCEL", 507 },
- { "KONKA_SOUNDOUTPUT_ENABLE", 508 },
- { "KONKA_SOUNDOUTPUT_DISABLE", 509 },
- { "KONKA_BESTV_EXIT", 510 },
- { "KONKA_BESTV_FORWARD", 511 },
- { "KONKA_BESTV_BACKWARD", 512 },
- { "KONKA_ENTER_FACTORY", 513 },
- { "KONKA_FACTORY_BAKE_TV", 514 },
- // Skyworth section, range 601-700
- // Tcl section, range 4001-4099
- { "TCL_MITV", 4001 },
- { "TCL_USB_MENU", 4002 },
- { "TCL_SWING_R1", 4003 },
- { "TCL_SWING_R2", 4004 },
- { "TCL_SWING_R3", 4005 },
- { "TCL_SWING_R4", 4006 },
- { "TCL_SWING_L1", 4007 },
- { "TCL_SWING_L2", 4008 },
- { "TCL_SWING_L3", 4009 },
- { "TCL_SWING_L4", 4010},
- { "TCL_WIDGET", 4011},
- { "TCL_VGR_LEFT", 4012},
- { "TCL_VGR_RIGHT", 4013 },
- { "TCL_VGR_TAP", 4014 },
- { "TCL_VGR_WAVE", 4015 },
- { "TCL_VGR_WAVE_LEFT", 4016 },
- { "TCL_VGR_WAVE_RIGHT", 4017 },
- { "TCL_VGR_ACTIVE", 4018 },
- { "TCL_VGR_DEACTIVE", 4019 },
- { "TCL_BODY_SENSOR", 4020 },
- { "TCL_CIRCLE_CLOCKWISE", 4021 },
- { "TCL_CIRCLE_CTR_CLOCKWISE", 4022 },
- { "TCL_GESTURE_X", 4023 },
- { "TCL_GESTURE_ALPHA", 4024 },
- { "TCL_GESTURE_MUTE", 4025 },
- { "TCL_UP", 4026 },
- { "TCL_DOWN", 4027 },
- { "TCL_LEFT", 4028 },
- { "TCL_RIGHT", 4029 },
- { "TCL_UP_LEFT", 4030 },
- { "TCL_UP_RIGHT", 4031 },
- { "TCL_DOWN_LEFT", 4032 },
- { "TCL_DOWN_RIGHT", 4033 },
- // Changhong section, range 4101-4199
- { "CHANGHONGIR_MUTE", 4101 },
- { "CHANGHONGIR_INPUT", 4102 },
- { "CHANGHONGIR_DEL", 4103 },
- { "CHANGHONGIR_MENU", 4104 },
- { "CHANGHONGIR_CORN", 4105 },
- { "CHANGHONGIR_OK", 4106 },
- { "CHANGHONGIR_FLCK_FU", 4107 },
- { "CHANGHONGIR_FLCK_FD", 4108 },
- { "CHANGHONGIR_FLCK_FL", 4109 },
- { "CHANGHONGIR_FLCK_FR", 4110 },
- { "CHANGHONGIR_FLCK_SU", 4111 },
- { "CHANGHONGIR_FLCK_SD", 4112 },
- { "CHANGHONGIR_FLCK_SL", 4113 },
- { "CHANGHONGIR_FLCK_SR", 4114 },
- { "CHANGHONGIR_PINCH", 4115 },
- { "CHANGHONGIR_SPREAD", 4116 },
- { "CHANGHONGIR_VOICE", 4117 },
- { "CHANGHONGIR_HAND", 4118 },
- { "CHANGHONGIR_3D", 4119 },
- { "CHANGHONGIR_HELP", 4120 },
- { "CHANGHONGIR_APP", 4121 },
- { "CHANGHONGIR_MOUSE", 4122 },
- { "CHANGHONGIR_EPG", 4123 },
- { "CHANGHONGIR_HOME", 4124 },
- { "CHANGHONGIR_SETTINGS", 4125 },
- // Hisense section, range 4201-4299
- { "HISENSE_G_SENSOR", 4201 },
- { "HISENSE_LOW_BATTERY", 4202 },
- { "HISENSE_SLIDEUP", 4203 },
- { "HISENSE_SLIDEDOWN", 4204 },
- { "HISENSE_SLIDELEFT", 4205 },
- { "HISENSE_SLIDERIGHT", 4206 },
- { "HISENSE_RAPID_SLIDEUP", 4207 },
- { "HISENSE_RAPID_SLIDEDOWN", 4208 },
- { "HISENSE_RAPID_SLIDELEFT", 4209 },
- { "HISENSE_RAPID_SLIDERIGHT", 4210 },
- { "HISENSE_FAC_NEC_M", 4211 },
- { "HISENSE_FAC_NEC_IP", 4212 },
- { "HISENSE_FAC_NEC_SAVE", 4213 },
- { "HISENSE_FAC_NEC_3D", 4214 },
- { "HISENSE_FAC_NEC_PC", 4215 },
- { "HISENSE_FAC_NEC_LOGO", 4216 },
- { "HISENSE_FAC_NEC_YPBPR", 4217 },
- { "HISENSE_FAC_NEC_HDMI", 4218 },
- { "HISENSE_FAC_NEC_F1", 4219 },
- { "HISENSE_FAC_NEC_F2", 4220 },
- { "HISENSE_FAC_NEC_F3", 4221 },
- { "HISENSE_FAC_NEC_F4", 4222 },
- { "HISENSE_FAC_NEC_F5", 4223 },
- { "HISENSE_FAC_NEC_F6", 4224 },
- { "HISENSE_FAC_NEC_F7", 4225 },
- { "HISENSE_FAC_NEC_OK", 4226 },
- { "HISENSE_FAC_NEC_MAC", 4227 },
- { "HISENSE_FAC_NEC_AV", 4228 },
- { "HISENSE_FAC_NEC_PATTERN", 4229 },
- { "HISENSE_FAC_NEC_AGING", 4230 },
- { "HISENSE_FAC_NEC_BALANCE", 4231 },
- { "HISENSE_FAC_NEC_ADC", 4232 },
- { "HISENSE_FAC_NEC_RDRV_INCREASE", 4233 },
- { "HISENSE_FAC_NEC_RDRV_DECREASE", 4234 },
- { "HISENSE_FAC_NEC_GDRV_INCREASE", 4235 },
- { "HISENSE_FAC_NEC_GDRV_DECREASE", 4236 },
- { "HISENSE_FAC_NEC_BDRV_INCREASE", 4237 },
- { "HISENSE_FAC_NEC_BDRV_DECREASE", 4238 },
- { "HISENSE_FAC_NEC_RCUT_INCREASE", 4239 },
- { "HISENSE_FAC_NEC_RCUT_DECREASE", 4240 },
- { "HISENSE_FAC_NEC_GCUT_INCREASE", 4241 },
- { "HISENSE_FAC_NEC_GCUT_DECREASE", 4242 },
- { "HISENSE_FAC_NEC_BCUT_INCREASE", 4243 },
- { "HISENSE_FAC_NEC_BCUT_DECREASE", 4244 },
- { "HISENSE_PRODUCT_SCAN_START", 4245 },
- { "HISENSE_PRODUCT_SCAN_OVER", 4246 },
- { "HISENSE_TEST_BROAD_TV", 4247 },
- { "HISENSE_TEST_BROAD_DTV", 4248 },
- { "HISENSE_TEST_BROAD_AV1", 4249 },
- { "HISENSE_TEST_BROAD_AV2", 4250 },
- { "HISENSE_TEST_BROAD_AV3", 4251 },
- { "HISENSE_TEST_BROAD_SVIDEO1", 4252 },
- { "HISENSE_TEST_BROAD_SVIDEO2", 4253 },
- { "HISENSE_TEST_BROAD_SVIDEO3", 4254 },
- { "HISENSE_TEST_BROAD_SCART1", 4255 },
- { "HISENSE_TEST_BROAD_SCART2", 4256 },
- { "HISENSE_TEST_BROAD_SCART3", 4257 },
- { "HISENSE_TEST_BOARD_YPBPR1", 4258 },
- { "HISENSE_TEST_BOARD_YPBPR2", 4259 },
- { "HISENSE_TEST_BOARD_YPBPR3", 4260 },
- { "HISENSE_TEST_BOARD_VGA", 4261 },
- { "HISENSE_TEST_BOARD_HDMI1", 4262 },
- { "HISENSE_TEST_BOARD_HDMI2", 4263 },
- { "HISENSE_TEST_BOARD_HDMI3", 4264 },
- { "HISENSE_TEST_BOARD_HDMI4", 4265 },
- { "HISENSE_TEST_BOARD_HDMI5", 4266 },
- { "HISENSE_TEST_BOARD_DMP", 4267 },
- { "HISENSE_TEST_BOARD_EMP", 4268 },
- { "HISENSE_TEST_BOARD_AUTOCOLOR", 4269 },
- { "HISENSE_TEST_BOARD_SAVE", 4270 },
- { "HISENSE_TEST_BOARD_TELITEXT", 4271 },
- { "HISENSE_TEST_BOARD_SAPL", 4272 },
- { "HISENSE_TEST_BOARD_VCHIP", 4273 },
- { "HISENSE_TEST_BOARD_CCD", 4274 },
- { "HISENSE_TEST_BOARD_BTSC", 4275 },
- { "HISENSE_TEST_BOARD_FAC_OK", 4276 },
- // MStar Android Patch End
- // NOTE: If you add a new keycode here you must also add it to several other files.
- // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
- { NULL, 0 }
- };
- // NOTE: If you edit these flags, also edit policy flags in Input.h.
- static const KeycodeLabel FLAGS[] = {
- { "WAKE", 0x00000001 },
- { "WAKE_DROPPED", 0x00000002 },
- { "SHIFT", 0x00000004 },
- { "CAPS_LOCK", 0x00000008 },
- { "ALT", 0x00000010 },
- { "ALT_GR", 0x00000020 },
- { "MENU", 0x00000040 },
- { "LAUNCHER", 0x00000080 },
- { "VIRTUAL", 0x00000100 },
- { "FUNCTION", 0x00000200 },
- { NULL, 0 }
- };
- static const KeycodeLabel AXES[] = {
- { "X", 0 },
- { "Y", 1 },
- { "PRESSURE", 2 },
- { "SIZE", 3 },
- { "TOUCH_MAJOR", 4 },
- { "TOUCH_MINOR", 5 },
- { "TOOL_MAJOR", 6 },
- { "TOOL_MINOR", 7 },
- { "ORIENTATION", 8 },
- { "VSCROLL", 9 },
- { "HSCROLL", 10 },
- { "Z", 11 },
- { "RX", 12 },
- { "RY", 13 },
- { "RZ", 14 },
- { "HAT_X", 15 },
- { "HAT_Y", 16 },
- { "LTRIGGER", 17 },
- { "RTRIGGER", 18 },
- { "THROTTLE", 19 },
- { "RUDDER", 20 },
- { "WHEEL", 21 },
- { "GAS", 22 },
- { "BRAKE", 23 },
- { "DISTANCE", 24 },
- { "TILT", 25 },
- { "GENERIC_1", 32 },
- { "GENERIC_2", 33 },
- { "GENERIC_3", 34 },
- { "GENERIC_4", 35 },
- { "GENERIC_5", 36 },
- { "GENERIC_6", 37 },
- { "GENERIC_7", 38 },
- { "GENERIC_8", 39 },
- { "GENERIC_9", 40 },
- { "GENERIC_10", 41 },
- { "GENERIC_11", 42 },
- { "GENERIC_12", 43 },
- { "GENERIC_13", 44 },
- { "GENERIC_14", 45 },
- { "GENERIC_15", 46 },
- { "GENERIC_16", 47 },
- // NOTE: If you add a new axis here you must also add it to several other files.
- // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
- { NULL, -1 }
- };
- #endif // _LIBINPUT_KEYCODE_LABELS_H</span>
3)在/frameworks/native/include/android/keycodes.h中添加如下的
AKEYCODE_MSTAR_WLS = 320,下面看下该文件的定义
- <span style="font-family:FangSong_GB2312;font-size:18px;">/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #ifndef _ANDROID_KEYCODES_H
- #define _ANDROID_KEYCODES_H
- /******************************************************************
- *
- * IMPORTANT NOTICE:
- *
- * This file is part of Android's set of stable system headers
- * exposed by the Android NDK (Native Development Kit).
- *
- * Third-party source AND binary code relies on the definitions
- * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
- *
- * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
- * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
- * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
- * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
- */
- #include <sys/types.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- /*
- * Key codes.
- */
- enum {
- AKEYCODE_UNKNOWN = 0,
- AKEYCODE_SOFT_LEFT = 1,
- AKEYCODE_SOFT_RIGHT = 2,
- AKEYCODE_HOME = 3,
- AKEYCODE_BACK = 4,
- AKEYCODE_CALL = 5,
- AKEYCODE_ENDCALL = 6,
- AKEYCODE_0 = 7,
- AKEYCODE_1 = 8,
- AKEYCODE_2 = 9,
- AKEYCODE_3 = 10,
- AKEYCODE_4 = 11,
- AKEYCODE_5 = 12,
- AKEYCODE_6 = 13,
- AKEYCODE_7 = 14,
- AKEYCODE_8 = 15,
- AKEYCODE_9 = 16,
- AKEYCODE_STAR = 17,
- AKEYCODE_POUND = 18,
- AKEYCODE_DPAD_UP = 19,
- AKEYCODE_DPAD_DOWN = 20,
- AKEYCODE_DPAD_LEFT = 21,
- AKEYCODE_DPAD_RIGHT = 22,
- AKEYCODE_DPAD_CENTER = 23,
- AKEYCODE_VOLUME_UP = 24,
- AKEYCODE_VOLUME_DOWN = 25,
- AKEYCODE_POWER = 26,
- AKEYCODE_CAMERA = 27,
- AKEYCODE_CLEAR = 28,
- AKEYCODE_A = 29,
- AKEYCODE_B = 30,
- AKEYCODE_C = 31,
- AKEYCODE_D = 32,
- AKEYCODE_E = 33,
- AKEYCODE_F = 34,
- AKEYCODE_G = 35,
- AKEYCODE_H = 36,
- AKEYCODE_I = 37,
- AKEYCODE_J = 38,
- AKEYCODE_K = 39,
- AKEYCODE_L = 40,
- AKEYCODE_M = 41,
- AKEYCODE_N = 42,
- AKEYCODE_O = 43,
- AKEYCODE_P = 44,
- AKEYCODE_Q = 45,
- AKEYCODE_R = 46,
- AKEYCODE_S = 47,
- AKEYCODE_T = 48,
- AKEYCODE_U = 49,
- AKEYCODE_V = 50,
- AKEYCODE_W = 51,
- AKEYCODE_X = 52,
- AKEYCODE_Y = 53,
- AKEYCODE_Z = 54,
- AKEYCODE_COMMA = 55,
- AKEYCODE_PERIOD = 56,
- AKEYCODE_ALT_LEFT = 57,
- AKEYCODE_ALT_RIGHT = 58,
- AKEYCODE_SHIFT_LEFT = 59,
- AKEYCODE_SHIFT_RIGHT = 60,
- AKEYCODE_TAB = 61,
- AKEYCODE_SPACE = 62,
- AKEYCODE_SYM = 63,
- AKEYCODE_EXPLORER = 64,
- AKEYCODE_ENVELOPE = 65,
- AKEYCODE_ENTER = 66,
- AKEYCODE_DEL = 67,
- AKEYCODE_GRAVE = 68,
- AKEYCODE_MINUS = 69,
- AKEYCODE_EQUALS = 70,
- AKEYCODE_LEFT_BRACKET = 71,
- AKEYCODE_RIGHT_BRACKET = 72,
- AKEYCODE_BACKSLASH = 73,
- AKEYCODE_SEMICOLON = 74,
- AKEYCODE_APOSTROPHE = 75,
- AKEYCODE_SLASH = 76,
- AKEYCODE_AT = 77,
- AKEYCODE_NUM = 78,
- AKEYCODE_HEADSETHOOK = 79,
- AKEYCODE_FOCUS = 80, // *Camera* focus
- AKEYCODE_PLUS = 81,
- AKEYCODE_MENU = 82,
- AKEYCODE_NOTIFICATION = 83,
- AKEYCODE_SEARCH = 84,
- AKEYCODE_MEDIA_PLAY_PAUSE= 85,
- AKEYCODE_MEDIA_STOP = 86,
- AKEYCODE_MEDIA_NEXT = 87,
- AKEYCODE_MEDIA_PREVIOUS = 88,
- AKEYCODE_MEDIA_REWIND = 89,
- AKEYCODE_MEDIA_FAST_FORWARD = 90,
- AKEYCODE_MUTE = 91,
- AKEYCODE_PAGE_UP = 92,
- AKEYCODE_PAGE_DOWN = 93,
- AKEYCODE_PICTSYMBOLS = 94,
- AKEYCODE_SWITCH_CHARSET = 95,
- AKEYCODE_BUTTON_A = 96,
- AKEYCODE_BUTTON_B = 97,
- AKEYCODE_BUTTON_C = 98,
- AKEYCODE_BUTTON_X = 99,
- AKEYCODE_BUTTON_Y = 100,
- AKEYCODE_BUTTON_Z = 101,
- AKEYCODE_BUTTON_L1 = 102,
- AKEYCODE_BUTTON_R1 = 103,
- AKEYCODE_BUTTON_L2 = 104,
- AKEYCODE_BUTTON_R2 = 105,
- AKEYCODE_BUTTON_THUMBL = 106,
- AKEYCODE_BUTTON_THUMBR = 107,
- AKEYCODE_BUTTON_START = 108,
- AKEYCODE_BUTTON_SELECT = 109,
- AKEYCODE_BUTTON_MODE = 110,
- AKEYCODE_ESCAPE = 111,
- AKEYCODE_FORWARD_DEL = 112,
- AKEYCODE_CTRL_LEFT = 113,
- AKEYCODE_CTRL_RIGHT = 114,
- AKEYCODE_CAPS_LOCK = 115,
- AKEYCODE_SCROLL_LOCK = 116,
- AKEYCODE_META_LEFT = 117,
- AKEYCODE_META_RIGHT = 118,
- AKEYCODE_FUNCTION = 119,
- AKEYCODE_SYSRQ = 120,
- AKEYCODE_BREAK = 121,
- AKEYCODE_MOVE_HOME = 122,
- AKEYCODE_MOVE_END = 123,
- AKEYCODE_INSERT = 124,
- AKEYCODE_FORWARD = 125,
- AKEYCODE_MEDIA_PLAY = 126,
- AKEYCODE_MEDIA_PAUSE = 127,
- AKEYCODE_MEDIA_CLOSE = 128,
- AKEYCODE_MEDIA_EJECT = 129,
- AKEYCODE_MEDIA_RECORD = 130,
- AKEYCODE_F1 = 131,
- AKEYCODE_F2 = 132,
- AKEYCODE_F3 = 133,
- AKEYCODE_F4 = 134,
- AKEYCODE_F5 = 135,
- AKEYCODE_F6 = 136,
- AKEYCODE_F7 = 137,
- AKEYCODE_F8 = 138,
- AKEYCODE_F9 = 139,
- AKEYCODE_F10 = 140,
- AKEYCODE_F11 = 141,
- AKEYCODE_F12 = 142,
- AKEYCODE_NUM_LOCK = 143,
- AKEYCODE_NUMPAD_0 = 144,
- AKEYCODE_NUMPAD_1 = 145,
- AKEYCODE_NUMPAD_2 = 146,
- AKEYCODE_NUMPAD_3 = 147,
- AKEYCODE_NUMPAD_4 = 148,
- AKEYCODE_NUMPAD_5 = 149,
- AKEYCODE_NUMPAD_6 = 150,
- AKEYCODE_NUMPAD_7 = 151,
- AKEYCODE_NUMPAD_8 = 152,
- AKEYCODE_NUMPAD_9 = 153,
- AKEYCODE_NUMPAD_DIVIDE = 154,
- AKEYCODE_NUMPAD_MULTIPLY = 155,
- AKEYCODE_NUMPAD_SUBTRACT = 156,
- AKEYCODE_NUMPAD_ADD = 157,
- AKEYCODE_NUMPAD_DOT = 158,
- AKEYCODE_NUMPAD_COMMA = 159,
- AKEYCODE_NUMPAD_ENTER = 160,
- AKEYCODE_NUMPAD_EQUALS = 161,
- AKEYCODE_NUMPAD_LEFT_PAREN = 162,
- AKEYCODE_NUMPAD_RIGHT_PAREN = 163,
- AKEYCODE_VOLUME_MUTE = 164,
- AKEYCODE_INFO = 165,
- AKEYCODE_CHANNEL_UP = 166,
- AKEYCODE_CHANNEL_DOWN = 167,
- AKEYCODE_ZOOM_IN = 168,
- AKEYCODE_ZOOM_OUT = 169,
- AKEYCODE_TV = 170,
- AKEYCODE_WINDOW = 171,
- AKEYCODE_GUIDE = 172,
- AKEYCODE_DVR = 173,
- AKEYCODE_BOOKMARK = 174,
- AKEYCODE_CAPTIONS = 175,
- AKEYCODE_SETTINGS = 176,
- AKEYCODE_TV_POWER = 177,
- AKEYCODE_TV_INPUT = 178,
- AKEYCODE_STB_POWER = 179,
- AKEYCODE_STB_INPUT = 180,
- AKEYCODE_AVR_POWER = 181,
- AKEYCODE_AVR_INPUT = 182,
- AKEYCODE_PROG_RED = 183,
- AKEYCODE_PROG_GREEN = 184,
- AKEYCODE_PROG_YELLOW = 185,
- AKEYCODE_PROG_BLUE = 186,
- AKEYCODE_APP_SWITCH = 187,
- AKEYCODE_BUTTON_1 = 188,
- AKEYCODE_BUTTON_2 = 189,
- AKEYCODE_BUTTON_3 = 190,
- AKEYCODE_BUTTON_4 = 191,
- AKEYCODE_BUTTON_5 = 192,
- AKEYCODE_BUTTON_6 = 193,
- AKEYCODE_BUTTON_7 = 194,
- AKEYCODE_BUTTON_8 = 195,
- AKEYCODE_BUTTON_9 = 196,
- AKEYCODE_BUTTON_10 = 197,
- AKEYCODE_BUTTON_11 = 198,
- AKEYCODE_BUTTON_12 = 199,
- AKEYCODE_BUTTON_13 = 200,
- AKEYCODE_BUTTON_14 = 201,
- AKEYCODE_BUTTON_15 = 202,
- AKEYCODE_BUTTON_16 = 203,
- AKEYCODE_LANGUAGE_SWITCH = 204,
- AKEYCODE_MANNER_MODE = 205,
- AKEYCODE_3D_MODE = 206,
- AKEYCODE_CONTACTS = 207,
- AKEYCODE_CALENDAR = 208,
- AKEYCODE_MUSIC = 209,
- AKEYCODE_CALCULATOR = 210,
- AKEYCODE_ZENKAKU_HANKAKU = 211,
- AKEYCODE_EISU = 212,
- AKEYCODE_MUHENKAN = 213,
- AKEYCODE_HENKAN = 214,
- AKEYCODE_KATAKANA_HIRAGANA = 215,
- AKEYCODE_YEN = 216,
- AKEYCODE_RO = 217,
- AKEYCODE_KANA = 218,
- AKEYCODE_ASSIST = 219,
- AKEYCODE_BRIGHTNESS_DOWN = 220,
- AKEYCODE_BRIGHTNESS_UP = 221,
- AKEYCODE_MEDIA_AUDIO_TRACK = 222,
- // MStar Android Patch Begin
- // Common section, range 251-300
- AKEYCODE_SOUND_MODE = 251,
- AKEYCODE_PICTURE_MODE = 252,
- AKEYCODE_ASPECT_RATIO = 253,
- AKEYCODE_CHANNEL_RETURN = 254,
- AKEYCODE_SLEEP = 255,
- AKEYCODE_EPG = 256,
- AKEYCODE_LIST = 257,
- AKEYCODE_SUBTITLE = 258,
- AKEYCODE_FAVORITE = 259,
- AKEYCODE_MTS = 260,
- AKEYCODE_FREEZE = 261,
- AKEYCODE_TTX = 262,
- AKEYCODE_CC = 263,
- AKEYCODE_TV_SETTING = 264,
- AKEYCODE_SCREENSHOT = 265,
- AKEYCODE_CLOUD = 266,
- AKEYCODE_VOICE = 267,
- AKEYCODE_USB = 268,
- AKEYCODE_HDMI = 269,
- AKEYCODE_DISPLAY_MODE = 270,
- AKEYCODE_SONG_SYSTEM = 271,
- AKEYCODE_GINGA_BACK = 272,
- AKEYCODE_NETFLIX = 273,
- AKEYCODE_AMAZONE = 274,
- // Mstar section, range 301-400
- AKEYCODE_MSTAR_BALANCE = 301,
- AKEYCODE_MSTAR_INDEX = 302,
- AKEYCODE_MSTAR_HOLD = 303,
- AKEYCODE_MSTAR_UPDATE = 304,
- AKEYCODE_MSTAR_REVEAL = 305,
- AKEYCODE_MSTAR_SUBCODE = 306,
- AKEYCODE_MSTAR_SIZE = 307,
- AKEYCODE_MSTAR_CLOCK = 308,
- AKEYCODE_MSTAR_STORE_UP = 309,
- AKEYCODE_MSTAR_TRIANGLE_UP = 310,
- AKEYCODE_MSTAR_MOVIE = 311,
- AKEYCODE_MSTAR_FILE = 312,
- AKEYCODE_MSTAR_STAR_PLUS = 313,
- AKEYCODE_MSTAR_AUDIO_TRACK = 314,
- AKEYCODE_MSTAR_OPTIONAL_TIME = 315,
- AKEYCODE_MSTAR_LOOP = 316,
- AKEYCODE_MSTAR_INBOX = 317,
- AKEYCODE_MSTAR_VVOIP = 318,
- AKEYCODE_MSTAR_PVR_BROWSER = 319,
- // Konka section, range 501-600
- AKEYCODE_KONKA_YPBPR = 501,
- AKEYCODE_KONKA_THREEPOINT_LOONPRESS = 502,
- AKEYCODE_KONKA_THREEPOINT_COLLECT = 503,
- AKEYCODE_KONKA_THREEPOINT_DISPERSE = 504,
- AKEYCODE_KONKA_VOICESWITCH = 505,
- AKEYCODE_KONKA_FLYIMEFINGER_SELECT = 506,
- AKEYCODE_KONKA_FLYIMEFINGER_CANCEL = 507,
- AKEYCODE_KONKA_SOUNDOUTPUT_ENABLE = 508,
- AKEYCODE_KONKA_SOUNDOUTPUT_DISABLE = 509,
- AKEYCODE_KONKA_BESTV_EXIT = 510,
- AKEYCODE_KONKA_BESTV_FORWARD = 511,
- AKEYCODE_KONKA_BESTV_BACKWARD = 512,
- AKEYCODE_KONKA_ENTER_FACTORY = 513,
- AKEYCODE_KONKA_FACTORY_BAKE_TV = 514,
- // Haier section, range 401-500
- AKEYCODE_HAIER_TASK = 401,
- AKEYCODE_HAIER_TOOLS = 402,
- AKEYCODE_HAIER_POWERSLEEP = 403,
- AKEYCODE_HAIER_WAKEUP = 404,
- AKEYCODE_HAIER_UNMUTE = 405,
- AKEYCODE_HAIER_CLEANSEARCH = 406,
- // Skyworth section, range 601-700
- // Tcl section, range 4001-4100
- AKEYCODE_TCL_MITV = 4001,
- AKEYCODE_TCL_USB_MENU = 4002,
- AKEYCODE_TCL_SWING_R1 = 4003,
- AKEYCODE_TCL_SWING_R2 = 4004,
- AKEYCODE_TCL_SWING_R3 = 4005,
- AKEYCODE_TCL_SWING_R4 = 4006,
- AKEYCODE_TCL_SWING_L1 = 4007,
- AKEYCODE_TCL_SWING_L2 = 4008,
- AKEYCODE_TCL_SWING_L3 = 4009,
- AKEYCODE_TCL_SWING_L4 = 4010,
- AKEYCODE_TCL_WIDGET = 4011,
- AKEYCODE_TCL_VGR_LEFT = 4012,
- AKEYCODE_TCL_VGR_RIGHT = 4013,
- AKEYCODE_TCL_VGR_TAP = 4014,
- AKEYCODE_TCL_VGR_WAVE = 4015,
- AKEYCODE_TCL_VGR_WAVE_LEFT = 4016,
- AKEYCODE_TCL_VGR_WAVE_RIGHT = 4017,
- AKEYCODE_TCL_VGR_ACTIVE = 4018,
- AKEYCODE_TCL_VGR_DEACTIVE = 4019,
- AKEYCODE_TCL_BODY_SENSOR = 4020,
- AKEYCODE_TCL_CIRCLE_CLOCKWISE = 4021,
- AKEYCODE_TCL_CIRCLE_CTR_CLOCKWISE = 4022,
- AKEYCODE_TCL_GESTURE_X = 4023,
- AKEYCODE_TCL_GESTURE_ALPHA = 4024,
- AKEYCODE_TCL_GESTURE_MUTE = 4025,
- AKEYCODE_TCL_UP = 4026,
- AKEYCODE_TCL_DOWN = 4027,
- AKEYCODE_TCL_LEFT = 4028,
- AKEYCODE_TCL_RIGHT = 4029,
- AKEYCODE_TCL_UP_LEFT = 4030,
- AKEYCODE_TCL_UP_RIGHT = 4031,
- AKEYCODE_TCL_DOWN_LEFT = 4032,
- AKEYCODE_TCL_DOWN_RIGHT = 4033,
- // Changhong section, range 4101-4200
- AKEYCODE_CHANGHONGIR_MUTE = 4101,
- AKEYCODE_CHANGHONGIR_INPUT = 4102,
- AKEYCODE_CHANGHONGIR_DEL = 4103,
- AKEYCODE_CHANGHONGIR_MENU = 4104,
- AKEYCODE_CHANGHONGIR_CORN = 4105,
- AKEYCODE_CHANGHONGIR_OK = 4106,
- AKEYCODE_CHANGHONGIR_FLCK_FU = 4107,
- AKEYCODE_CHANGHONGIR_FLCK_FD = 4108,
- AKEYCODE_CHANGHONGIR_FLCK_FL = 4109,
- AKEYCODE_CHANGHONGIR_FLCK_FR = 4110,
- AKEYCODE_CHANGHONGIR_FLCK_SU = 4111,
- AKEYCODE_CHANGHONGIR_FLCK_SD = 4112,
- AKEYCODE_CHANGHONGIR_FLCK_SL = 4113,
- AKEYCODE_CHANGHONGIR_FLCK_SR = 4114,
- AKEYCODE_CHANGHONGIR_PINCH = 4115,
- AKEYCODE_CHANGHONGIR_SPREAD = 4116,
- AKEYCODE_CHANGHONGIR_VOICE = 4117,
- AKEYCODE_CHANGHONGIR_HAND = 4118,
- AKEYCODE_CHANGHONGIR_3D = 4119,
- AKEYCODE_CHANGHONGIR_HELP = 4120,
- AKEYCODE_CHANGHONGIR_APP = 4121,
- AKEYCODE_CHANGHONGIR_MOUSE = 4122,
- AKEYCODE_CHANGHONGIR_EPG = 4123,
- AKEYCODE_CHANGHONGIR_HOME = 4124,
- AKEYCODE_CHANGHONGIR_SETTINGS = 4125,
- // Hisense section, range 4201-4300
- AKEYCODE_HISENSE_G_SENSOR = 4201,
- AKEYCODE_HISENSE_LOW_BATTERY = 4202,
- AKEYCODE_HISENSE_SLIDEUP = 4203,
- AKEYCODE_HISENSE_SLIDEDOWN = 4204,
- AKEYCODE_HISENSE_SLIDELEFT = 4205,
- AKEYCODE_HISENSE_SLIDERIGHT = 4206,
- AKEYCODE_HISENSE_RAPID_SLIDEUP = 4207,
- AKEYCODE_HISENSE_RAPID_SLIDEDOWN = 4208,
- AKEYCODE_HISENSE_RAPID_SLIDELEFT = 4209,
- AKEYCODE_HISENSE_RAPID_SLIDERIGHT = 4210,
- AKEYCODE_HISENSE_FAC_NEC_M = 4211,
- AKEYCODE_HISENSE_FAC_NEC_IP = 4212,
- AKEYCODE_HISENSE_FAC_NEC_SAVE = 4213,
- AKEYCODE_HISENSE_FAC_NEC_3D = 4214,
- AKEYCODE_HISENSE_FAC_NEC_PC = 4215,
- AKEYCODE_HISENSE_FAC_NEC_LOGO = 4216,
- AKEYCODE_HISENSE_FAC_NEC_YPBPR = 4217,
- AKEYCODE_HISENSE_FAC_NEC_HDMI = 4218,
- AKEYCODE_HISENSE_FAC_NEC_F1 = 4219,
- AKEYCODE_HISENSE_FAC_NEC_F2 = 4220,
- AKEYCODE_HISENSE_FAC_NEC_F3 = 4221,
- AKEYCODE_HISENSE_FAC_NEC_F4 = 4222,
- AKEYCODE_HISENSE_FAC_NEC_F5 = 4223,
- AKEYCODE_HISENSE_FAC_NEC_F6 = 4224,
- AKEYCODE_HISENSE_FAC_NEC_F7 = 4225,
- AKEYCODE_HISENSE_FAC_NEC_OK = 4226,
- AKEYCODE_HISENSE_FAC_NEC_MAC = 4227,
- AKEYCODE_HISENSE_FAC_NEC_AV = 4228,
- AKEYCODE_HISENSE_FAC_NEC_PATTERN = 4229,
- AKEYCODE_HISENSE_FAC_NEC_AGING = 4230,
- AKEYCODE_HISENSE_FAC_NEC_BALANCE = 4231,
- AKEYCODE_HISENSE_FAC_NEC_ADC = 4232,
- AKEYCODE_HISENSE_FAC_NEC_RDRV_INCREASE = 4233,
- AKEYCODE_HISENSE_FAC_NEC_RDRV_DECREASE = 4234,
- AKEYCODE_HISENSE_FAC_NEC_GDRV_INCREASE = 4235,
- AKEYCODE_HISENSE_FAC_NEC_GDRV_DECREASE = 4236,
- AKEYCODE_HISENSE_FAC_NEC_BDRV_INCREASE = 4237,
- AKEYCODE_HISENSE_FAC_NEC_BDRV_DECREASE = 4238,
- AKEYCODE_HISENSE_FAC_NEC_RCUT_INCREASE = 4239,
- AKEYCODE_HISENSE_FAC_NEC_RCUT_DECREASE = 4240,
- AKEYCODE_HISENSE_FAC_NEC_GCUT_INCREASE = 4241,
- AKEYCODE_HISENSE_FAC_NEC_GCUT_DECREASE = 4242,
- AKEYCODE_HISENSE_FAC_NEC_BCUT_INCREASE = 4243,
- AKEYCODE_HISENSE_FAC_NEC_BCUT_DECREASE = 4244,
- AKEYCODE_HISENSE_PRODUCT_SCAN_START = 4245,
- AKEYCODE_HISENSE_PRODUCT_SCAN_OVER = 4246,
- AKEYCODE_HISENSE_TEST_BROAD_TV = 4247,
- AKEYCODE_HISENSE_TEST_BROAD_DTV = 4248,
- AKEYCODE_HISENSE_TEST_BROAD_AV1 = 4249,
- AKEYCODE_HISENSE_TEST_BROAD_AV2 = 4250,
- AKEYCODE_HISENSE_TEST_BROAD_AV3 = 4251,
- AKEYCODE_HISENSE_TEST_BROAD_SVIDEO1 = 4252,
- AKEYCODE_HISENSE_TEST_BROAD_SVIDEO2 = 4253,
- AKEYCODE_HISENSE_TEST_BROAD_SVIDEO3 = 4254,
- AKEYCODE_HISENSE_TEST_BROAD_SCART1 = 4255,
- AKEYCODE_HISENSE_TEST_BROAD_SCART2 = 4256,
- AKEYCODE_HISENSE_TEST_BROAD_SCART3 = 4257,
- AKEYCODE_HISENSE_TEST_BOARD_YPBPR1 = 4258,
- AKEYCODE_HISENSE_TEST_BOARD_YPBPR2 = 4259,
- AKEYCODE_HISENSE_TEST_BOARD_YPBPR3 = 4260,
- AKEYCODE_HISENSE_TEST_BOARD_VGA = 4261,
- AKEYCODE_HISENSE_TEST_BOARD_HDMI1 = 4262,
- AKEYCODE_HISENSE_TEST_BOARD_HDMI2 = 4263,
- AKEYCODE_HISENSE_TEST_BOARD_HDMI3 = 4264,
- AKEYCODE_HISENSE_TEST_BOARD_HDMI4 = 4265,
- AKEYCODE_HISENSE_TEST_BOARD_HDMI5 = 4266,
- AKEYCODE_HISENSE_TEST_BOARD_DMP = 4267,
- AKEYCODE_HISENSE_TEST_BOARD_EMP = 4268,
- AKEYCODE_HISENSE_TEST_BOARD_AUTOCOLOR = 4269,
- AKEYCODE_HISENSE_TEST_BOARD_SAVE = 4270,
- AKEYCODE_HISENSE_TEST_BOARD_TELITEXT = 4271,
- AKEYCODE_HISENSE_TEST_BOARD_SAPL = 4272,
- AKEYCODE_HISENSE_TEST_BOARD_VCHIP = 4273,
- AKEYCODE_HISENSE_TEST_BOARD_CCD = 4274,
- AKEYCODE_HISENSE_TEST_BOARD_BTSC = 4275,
- AKEYCODE_HISENSE_TEST_BOARD_FAC_OK = 4276,
- // MStar Android Patch End
- // NOTE: If you add a new keycode here you must also add it to several other files.
- // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
- };
- #ifdef __cplusplus
- }
- #endif
- #endif // _ANDROID_KEYCODES_H
- </span>
4)在frameworks/base/core/res/res/values/attrs.xml添加如下
<enum name="KEYCODE_WLS" value="320" />
5)在 frameworks/base/core/java/android/view/KeyEvent.java添加对应的
public static final int KEYCODE_WLS = 320;
经过如上的步骤就将"123"按键和Android系统中的KEYCODE_WLS就对应起来了,注意这里的"123“键值并不是真正意义上的123键值,他只是linux驱动向上层抛出的键值。
6)在Android的framework层的键值处理函数中,捕获按键,并进行相应处理。
在framework层的input系统中,加入对wifi按键的捕获。
添加的文件是:frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
添加的具体方法:在PhoneWindowManager.java的interceptKeyBeforeQueueing()函数中,不惑该键值,至于怎么处理处决您的业务处理了。
在framework层的input系统中,加入对wifi按键的捕获。
添加的文件是:frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
添加的具体方法:在PhoneWindowManager.java的interceptKeyBeforeQueueing()函数中,不惑该键值,至于怎么处理处决您的业务处理了。
在这里再总结下我对Android键值处理的理解,我的理解:看了一下key character map的处理,是通过读取kl文件然后使用驱动程序提供的ioctl函数去修改来自输入设备的扫描码和系统预定义的keycode的映射关系。 这样的话,对于硬件扫描码,只需要修改这个kl文件。上层得到的都是系统预定义的keycode。
重要补充:
映射关系:
重要补充:
映射关系:
ir硬件扫描码在驱动里面被 映射为 kernel/include/linux/input.h里面定义的某个键值。但是这个键值只在linux系统中使用。
Android通过源码目录下的device/xxx/xxx.kl( keylayout )文件完成linux键值到Android系统要使用的键值的映射
Android通过源码目录下的device/xxx/xxx.kl( keylayout )文件完成linux键值到Android系统要使用的键值的映射