Android下添加新的自定义键值和按键处理流程【转】

时间:2023-12-21 10:36:32

本文转载自:

Android下添加新的自定义键值和按键处理流程

    说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我一个问题,请你详细描述一下怎么在Android下添加自定义键值和详细描述下Android的按键处理流程。现在回想起来当时回答的确实不是很好,乘着现在比较空闲的时机就来分析下上述的两个问题。
    首先分析下Android下怎么添加新的自定义键值。在Android的原生系统中键值默认情况下是92个,从0-91;一般情况下,这些键值是够用的,但是如果想扩充的话,还是需要添加新的键值的,那么如何将一个新的键值从驱动的设置映射到上层,使应用可以对我们自定义的键值进行相应的处理呢?
    在介绍Android怎么添加新的键值以前先介绍下Android下INPUT子系统FLOW的流程,下面就是精简的流程图示意图:Android下添加新的自定义键值和按键处理流程【转】
Android下添加新的自定义键值和按键处理流程【转】
Android下添加新的自定义键值和按键处理流程【转】
Android下添加新的自定义键值和按键处理流程【转】
    1.添加按键及其映射
    1)如果系统有新的按键需要添加,玛门是怎么添加并上报到系统上层去的呢(这里的上层主要指的是Android应用层),首先要确定的是我们的遥控设备是通过/dev/input目录下那个event调用那个kl文件,这里可以通过如下命令超看cat /proc/bus/input/devices,下面是在终端下的打印信息
  1. <span style="font-family:FangSong_GB2312;font-size:18px;">shell@orange:/ # cat /proc/bus/input/devices
  2. I: Bus=0018 Vendor=3697 Product=0001 Version=0001
  3. N: Name="MStar Smart TV IR Receiver"
  4. P: Phys=/dev/ir
  5. S: Sysfs=/devices/virtual/rc/rc0/input0
  6. U: Uniq=
  7. H: Handlers=kbd event0
  8. B: PROP=0
  9. B: EV=13
  10. B: KEY=fc0000 0 fc900 142851 0 0 0 0 108000 1a8 c0000c01 9e37c0 48007 f8000000 10000ffc
  11. B: MSC=10
  12. I: Bus=0000 Vendor=0000 Product=0000 Version=0000
  13. N: Name="MCE IR Keyboard/Mouse (ir)"
  14. P: Phys=/input0
  15. S: Sysfs=/devices/virtual/input/input1
  16. U: Uniq=
  17. H: Handlers=kbd mouse0 event1
  18. B: PROP=0
  19. B: EV=100017
  20. B: KEY=30000 0 7 ff87207a c14057ff febeffdf ffefffff ffffffff fffffffe
  21. B: REL=3
  22. B: MSC=10
  23. shell@orange:/ #
  24. shell@orange:/ # </span>

通过打印信息我们可以知道,我们的终端设备使用的是Vendor_3697_Product_0001.kl文件,我这里只分析IT遥控设备,那我们的Vendor_3697_Product_0001.kl里面又是啥呢,我们可以通过cat命令查看,具体的信息如下:

  1. <span style="font-family:FangSong_GB2312;font-size:18px;"># Copyright (C) 2010 The Android Open Source Project
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. #      http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #
  15. # MStar Smart TV IR Receiver.
  16. #
  17. key 116     POWER                   WAKE
  18. key 11      0
  19. key 2       1
  20. key 3       2
  21. key 4       3
  22. key 5       4
  23. key 6       5
  24. key 7       6
  25. key 8       7
  26. key 9       8
  27. key 10      9
  28. key 398     PROG_RED
  29. key 399     PROG_GREEN
  30. key 400     PROG_YELLOW
  31. key 401     PROG_BLUE
  32. key 103     DPAD_UP
  33. key 108     DPAD_DOWN
  34. key 105     DPAD_LEFT
  35. key 106     DPAD_RIGHT
  36. key 28      ENTER
  37. key 402     CHANNEL_UP              WAKE_DROPPED
  38. key 403     CHANNEL_DOWN            WAKE_DROPPED
  39. key 115     VOLUME_UP               WAKE_DROPPED
  40. key 114     VOLUME_DOWN             WAKE_DROPPED
  41. key 104     PAGE_UP
  42. key 109     PAGE_DOWN
  43. key 102     HOME                    WAKE_DROPPED
  44. key 139     MENU                    WAKE_DROPPED
  45. key 158     BACK
  46. key 113     VOLUME_MUTE
  47. key 167     DVR
  48. key 138     GUIDE
  49. key 358     INFO
  50. #key 82      WINDOW
  51. #key 79      TV_INPUT
  52. key 168     MEDIA_REWIND
  53. key 159     MEDIA_FAST_FORWARD
  54. key 165     MEDIA_PREVIOUS
  55. key 163     MEDIA_NEXT
  56. key 207     MEDIA_PLAY
  57. key 119     MEDIA_PAUSE
  58. key 128     MEDIA_STOP
  59. # Common extended
  60. key 392     SOUND_MODE
  61. key 212     PICTURE_MODE
  62. key 372     ASPECT_RATIO
  63. key 363     CHANNEL_RETURN
  64. key 142     SLEEP
  65. key 365     EPG
  66. key 395     LIST
  67. #key 370     SUBTITLE
  68. key 466     MTS
  69. key 467     FREEZE
  70. key 468     TTX
  71. key 469     CC
  72. key 470     TV_SETTING
  73. key 471     SCREENSHOT
  74. key 356     TV_POWER
  75. # Mstar extended
  76. key 59      MSTAR_BALANCE
  77. key 60      MSTAR_INDEX
  78. key 61      MSTAR_HOLD
  79. key 62      MSTAR_UPDATE
  80. key 63      MSTAR_REVEAL
  81. key 64      MSTAR_SUBCODE
  82. key 65      MSTAR_SIZE
  83. 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的按键值是就是我们新添加的键值了。
  1. <span style="font-family:FangSong_GB2312;font-size:18px;">/*
  2. * Copyright (C) 2008 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. *      http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _LIBINPUT_KEYCODE_LABELS_H
  17. #define _LIBINPUT_KEYCODE_LABELS_H
  18. #include <android/keycodes.h>
  19. struct KeycodeLabel {
  20. const char *literal;
  21. int value;
  22. };
  23. static const KeycodeLabel KEYCODES[] = {
  24. { "SOFT_LEFT", 1 },
  25. { "SOFT_RIGHT", 2 },
  26. { "HOME", 3 },
  27. { "BACK", 4 },
  28. { "CALL", 5 },
  29. { "ENDCALL", 6 },
  30. { "0", 7 },
  31. { "1", 8 },
  32. { "2", 9 },
  33. { "3", 10 },
  34. { "4", 11 },
  35. { "5", 12 },
  36. { "6", 13 },
  37. { "7", 14 },
  38. { "8", 15 },
  39. { "9", 16 },
  40. { "STAR", 17 },
  41. { "POUND", 18 },
  42. { "DPAD_UP", 19 },
  43. { "DPAD_DOWN", 20 },
  44. { "DPAD_LEFT", 21 },
  45. { "DPAD_RIGHT", 22 },
  46. { "DPAD_CENTER", 23 },
  47. { "VOLUME_UP", 24 },
  48. { "VOLUME_DOWN", 25 },
  49. { "POWER", 26 },
  50. { "CAMERA", 27 },
  51. { "CLEAR", 28 },
  52. { "A", 29 },
  53. { "B", 30 },
  54. { "C", 31 },
  55. { "D", 32 },
  56. { "E", 33 },
  57. { "F", 34 },
  58. { "G", 35 },
  59. { "H", 36 },
  60. { "I", 37 },
  61. { "J", 38 },
  62. { "K", 39 },
  63. { "L", 40 },
  64. { "M", 41 },
  65. { "N", 42 },
  66. { "O", 43 },
  67. { "P", 44 },
  68. { "Q", 45 },
  69. { "R", 46 },
  70. { "S", 47 },
  71. { "T", 48 },
  72. { "U", 49 },
  73. { "V", 50 },
  74. { "W", 51 },
  75. { "X", 52 },
  76. { "Y", 53 },
  77. { "Z", 54 },
  78. { "COMMA", 55 },
  79. { "PERIOD", 56 },
  80. { "ALT_LEFT", 57 },
  81. { "ALT_RIGHT", 58 },
  82. { "SHIFT_LEFT", 59 },
  83. { "SHIFT_RIGHT", 60 },
  84. { "TAB", 61 },
  85. { "SPACE", 62 },
  86. { "SYM", 63 },
  87. { "EXPLORER", 64 },
  88. { "ENVELOPE", 65 },
  89. { "ENTER", 66 },
  90. { "DEL", 67 },
  91. { "GRAVE", 68 },
  92. { "MINUS", 69 },
  93. { "EQUALS", 70 },
  94. { "LEFT_BRACKET", 71 },
  95. { "RIGHT_BRACKET", 72 },
  96. { "BACKSLASH", 73 },
  97. { "SEMICOLON", 74 },
  98. { "APOSTROPHE", 75 },
  99. { "SLASH", 76 },
  100. { "AT", 77 },
  101. { "NUM", 78 },
  102. { "HEADSETHOOK", 79 },
  103. { "FOCUS", 80 },
  104. { "PLUS", 81 },
  105. { "MENU", 82 },
  106. { "NOTIFICATION", 83 },
  107. { "SEARCH", 84 },
  108. { "MEDIA_PLAY_PAUSE", 85 },
  109. { "MEDIA_STOP", 86 },
  110. { "MEDIA_NEXT", 87 },
  111. { "MEDIA_PREVIOUS", 88 },
  112. { "MEDIA_REWIND", 89 },
  113. { "MEDIA_FAST_FORWARD", 90 },
  114. { "MUTE", 91 },
  115. { "PAGE_UP", 92 },
  116. { "PAGE_DOWN", 93 },
  117. { "PICTSYMBOLS", 94 },
  118. { "SWITCH_CHARSET", 95 },
  119. { "BUTTON_A", 96 },
  120. { "BUTTON_B", 97 },
  121. { "BUTTON_C", 98 },
  122. { "BUTTON_X", 99 },
  123. { "BUTTON_Y", 100 },
  124. { "BUTTON_Z", 101 },
  125. { "BUTTON_L1", 102 },
  126. { "BUTTON_R1", 103 },
  127. { "BUTTON_L2", 104 },
  128. { "BUTTON_R2", 105 },
  129. { "BUTTON_THUMBL", 106 },
  130. { "BUTTON_THUMBR", 107 },
  131. { "BUTTON_START", 108 },
  132. { "BUTTON_SELECT", 109 },
  133. { "BUTTON_MODE", 110 },
  134. { "ESCAPE", 111 },
  135. { "FORWARD_DEL", 112 },
  136. { "CTRL_LEFT", 113 },
  137. { "CTRL_RIGHT", 114 },
  138. { "CAPS_LOCK", 115 },
  139. { "SCROLL_LOCK", 116 },
  140. { "META_LEFT", 117 },
  141. { "META_RIGHT", 118 },
  142. { "FUNCTION", 119 },
  143. { "SYSRQ", 120 },
  144. { "BREAK", 121 },
  145. { "MOVE_HOME", 122 },
  146. { "MOVE_END", 123 },
  147. { "INSERT", 124 },
  148. { "FORWARD", 125 },
  149. { "MEDIA_PLAY", 126 },
  150. { "MEDIA_PAUSE", 127 },
  151. { "MEDIA_CLOSE", 128 },
  152. { "MEDIA_EJECT", 129 },
  153. { "MEDIA_RECORD", 130 },
  154. { "F1", 131 },
  155. { "F2", 132 },
  156. { "F3", 133 },
  157. { "F4", 134 },
  158. { "F5", 135 },
  159. { "F6", 136 },
  160. { "F7", 137 },
  161. { "F8", 138 },
  162. { "F9", 139 },
  163. { "F10", 140 },
  164. { "F11", 141 },
  165. { "F12", 142 },
  166. { "NUM_LOCK", 143 },
  167. { "NUMPAD_0", 144 },
  168. { "NUMPAD_1", 145 },
  169. { "NUMPAD_2", 146 },
  170. { "NUMPAD_3", 147 },
  171. { "NUMPAD_4", 148 },
  172. { "NUMPAD_5", 149 },
  173. { "NUMPAD_6", 150 },
  174. { "NUMPAD_7", 151 },
  175. { "NUMPAD_8", 152 },
  176. { "NUMPAD_9", 153 },
  177. { "NUMPAD_DIVIDE", 154 },
  178. { "NUMPAD_MULTIPLY", 155 },
  179. { "NUMPAD_SUBTRACT", 156 },
  180. { "NUMPAD_ADD", 157 },
  181. { "NUMPAD_DOT", 158 },
  182. { "NUMPAD_COMMA", 159 },
  183. { "NUMPAD_ENTER", 160 },
  184. { "NUMPAD_EQUALS", 161 },
  185. { "NUMPAD_LEFT_PAREN", 162 },
  186. { "NUMPAD_RIGHT_PAREN", 163 },
  187. { "VOLUME_MUTE", 164 },
  188. { "INFO", 165 },
  189. { "CHANNEL_UP", 166 },
  190. { "CHANNEL_DOWN", 167 },
  191. { "ZOOM_IN", 168 },
  192. { "ZOOM_OUT", 169 },
  193. { "TV", 170 },
  194. { "WINDOW", 171 },
  195. { "GUIDE", 172 },
  196. { "DVR", 173 },
  197. { "BOOKMARK", 174 },
  198. { "CAPTIONS", 175 },
  199. { "SETTINGS", 176 },
  200. { "TV_POWER", 177 },
  201. { "TV_INPUT", 178 },
  202. { "STB_POWER", 179 },
  203. { "STB_INPUT", 180 },
  204. { "AVR_POWER", 181 },
  205. { "AVR_INPUT", 182 },
  206. { "PROG_RED", 183 },
  207. { "PROG_GREEN", 184 },
  208. { "PROG_YELLOW", 185 },
  209. { "PROG_BLUE", 186 },
  210. { "APP_SWITCH", 187 },
  211. { "BUTTON_1", 188 },
  212. { "BUTTON_2", 189 },
  213. { "BUTTON_3", 190 },
  214. { "BUTTON_4", 191 },
  215. { "BUTTON_5", 192 },
  216. { "BUTTON_6", 193 },
  217. { "BUTTON_7", 194 },
  218. { "BUTTON_8", 195 },
  219. { "BUTTON_9", 196 },
  220. { "BUTTON_10", 197 },
  221. { "BUTTON_11", 198 },
  222. { "BUTTON_12", 199 },
  223. { "BUTTON_13", 200 },
  224. { "BUTTON_14", 201 },
  225. { "BUTTON_15", 202 },
  226. { "BUTTON_16", 203 },
  227. { "LANGUAGE_SWITCH", 204 },
  228. { "MANNER_MODE", 205 },
  229. { "3D_MODE", 206 },
  230. { "CONTACTS", 207 },
  231. { "CALENDAR", 208 },
  232. { "MUSIC", 209 },
  233. { "CALCULATOR", 210 },
  234. { "ZENKAKU_HANKAKU", 211 },
  235. { "EISU", 212 },
  236. { "MUHENKAN", 213 },
  237. { "HENKAN", 214 },
  238. { "KATAKANA_HIRAGANA", 215 },
  239. { "YEN", 216 },
  240. { "RO", 217 },
  241. { "KANA", 218 },
  242. { "ASSIST", 219 },
  243. { "BRIGHTNESS_DOWN", 220 },
  244. { "BRIGHTNESS_UP", 221 },
  245. { "MEDIA_AUDIO_TRACK", 222 },
  246. // MStar Android Patch Begin
  247. // Common section, range 251-300
  248. { "SOUND_MODE", 251 },
  249. { "PICTURE_MODE", 252 },
  250. { "ASPECT_RATIO", 253 },
  251. { "CHANNEL_RETURN", 254 },
  252. { "SLEEP", 255 },
  253. { "EPG", 256 },
  254. { "LIST", 257 },
  255. { "SUBTITLE", 258 },
  256. { "FAVORITE", 259 },
  257. { "MTS", 260 },
  258. { "FREEZE", 261 },
  259. { "TTX", 262 },
  260. { "CC", 263 },
  261. { "TV_SETTING", 264 },
  262. { "SCREENSHOT", 265 },
  263. { "CLOUD", 266 },
  264. { "VOICE", 267 },
  265. { "USB", 268 },
  266. { "HDMI", 269 },
  267. { "DISPLAY_MODE", 270 },
  268. { "SONG_SYSTEM", 271 },
  269. { "GINGA_BACK", 272},
  270. { "NETFLIX", 273},
  271. { "AMAZONE", 274},
  272. // MStar section, range 301-400
  273. { "MSTAR_BALANCE", 301 },
  274. { "MSTAR_INDEX", 302 },
  275. { "MSTAR_HOLD", 303 },
  276. { "MSTAR_UPDATE", 304 },
  277. { "MSTAR_REVEAL", 305 },
  278. { "MSTAR_SUBCODE", 306 },
  279. { "MSTAR_SIZE", 307 },
  280. { "MSTAR_CLOCK", 308 },
  281. { "MSTAR_STORE_UP", 309 },
  282. { "MSTAR_TRIANGLE_UP", 310 },
  283. { "MSTAR_MOVIE", 311 },
  284. { "MSTAR_FILE", 312 },
  285. { "MSTAR_STAR_PLUS", 313 },
  286. { "MSTAR_AUDIO_TRACK", 314 },
  287. { "MSTAR_OPTIONAL_TIME", 315 },
  288. { "MSTAR_LOOP", 316 },
  289. { "MSTAR_INBOX", 317 },
  290. { "MSTAR_VVOIP", 318 },
  291. { "MSTAR_PVR_BROWSER", 319 },
  292. // Haier section, range 401-500
  293. { "HAIER_TASK", 401 },
  294. { "HAIER_USB", 402 },
  295. { "HAIER_TOOLS", 403 },
  296. { "HAIER_POWERSLEEP", 404 },
  297. { "HAIER_WAKEUP", 405 },
  298. { "HAIER_UNMUTE", 406 },
  299. { "HAIER_CLEANSEARCH", 407 },
  300. // Konka section, range 501-600
  301. { "KONKA_YPBPR", 501 },
  302. { "KONKA_THREEPOINT_LOONPRESS", 502 },
  303. { "KONKA_THREEPOINT_COLLECT", 503 },
  304. { "KONKA_THREEPOINT_DISPERSE", 504 },
  305. { "KONKA_VOICESWITCH", 505 },
  306. { "KONKA_FLYIMEFINGER_SELECT", 506 },
  307. { "KONKA_FLYIMEFINGER_CANCEL", 507 },
  308. { "KONKA_SOUNDOUTPUT_ENABLE", 508 },
  309. { "KONKA_SOUNDOUTPUT_DISABLE", 509 },
  310. { "KONKA_BESTV_EXIT", 510 },
  311. { "KONKA_BESTV_FORWARD", 511 },
  312. { "KONKA_BESTV_BACKWARD", 512 },
  313. { "KONKA_ENTER_FACTORY", 513 },
  314. { "KONKA_FACTORY_BAKE_TV", 514 },
  315. // Skyworth section, range 601-700
  316. // Tcl section, range 4001-4099
  317. { "TCL_MITV", 4001 },
  318. { "TCL_USB_MENU", 4002 },
  319. { "TCL_SWING_R1", 4003 },
  320. { "TCL_SWING_R2", 4004 },
  321. { "TCL_SWING_R3", 4005 },
  322. { "TCL_SWING_R4", 4006 },
  323. { "TCL_SWING_L1", 4007 },
  324. { "TCL_SWING_L2", 4008 },
  325. { "TCL_SWING_L3", 4009 },
  326. { "TCL_SWING_L4", 4010},
  327. { "TCL_WIDGET", 4011},
  328. { "TCL_VGR_LEFT", 4012},
  329. { "TCL_VGR_RIGHT", 4013 },
  330. { "TCL_VGR_TAP", 4014 },
  331. { "TCL_VGR_WAVE", 4015 },
  332. { "TCL_VGR_WAVE_LEFT", 4016 },
  333. { "TCL_VGR_WAVE_RIGHT", 4017 },
  334. { "TCL_VGR_ACTIVE", 4018 },
  335. { "TCL_VGR_DEACTIVE", 4019 },
  336. { "TCL_BODY_SENSOR", 4020 },
  337. { "TCL_CIRCLE_CLOCKWISE", 4021 },
  338. { "TCL_CIRCLE_CTR_CLOCKWISE", 4022 },
  339. { "TCL_GESTURE_X", 4023 },
  340. { "TCL_GESTURE_ALPHA", 4024 },
  341. { "TCL_GESTURE_MUTE", 4025 },
  342. { "TCL_UP", 4026 },
  343. { "TCL_DOWN", 4027 },
  344. { "TCL_LEFT", 4028 },
  345. { "TCL_RIGHT", 4029 },
  346. { "TCL_UP_LEFT", 4030 },
  347. { "TCL_UP_RIGHT", 4031 },
  348. { "TCL_DOWN_LEFT", 4032 },
  349. { "TCL_DOWN_RIGHT", 4033 },
  350. // Changhong section, range 4101-4199
  351. { "CHANGHONGIR_MUTE", 4101 },
  352. { "CHANGHONGIR_INPUT", 4102 },
  353. { "CHANGHONGIR_DEL", 4103 },
  354. { "CHANGHONGIR_MENU", 4104 },
  355. { "CHANGHONGIR_CORN", 4105 },
  356. { "CHANGHONGIR_OK", 4106 },
  357. { "CHANGHONGIR_FLCK_FU", 4107 },
  358. { "CHANGHONGIR_FLCK_FD", 4108 },
  359. { "CHANGHONGIR_FLCK_FL", 4109 },
  360. { "CHANGHONGIR_FLCK_FR", 4110 },
  361. { "CHANGHONGIR_FLCK_SU", 4111 },
  362. { "CHANGHONGIR_FLCK_SD", 4112 },
  363. { "CHANGHONGIR_FLCK_SL", 4113 },
  364. { "CHANGHONGIR_FLCK_SR", 4114 },
  365. { "CHANGHONGIR_PINCH", 4115 },
  366. { "CHANGHONGIR_SPREAD", 4116 },
  367. { "CHANGHONGIR_VOICE", 4117 },
  368. { "CHANGHONGIR_HAND", 4118 },
  369. { "CHANGHONGIR_3D", 4119 },
  370. { "CHANGHONGIR_HELP", 4120 },
  371. { "CHANGHONGIR_APP", 4121 },
  372. { "CHANGHONGIR_MOUSE", 4122 },
  373. { "CHANGHONGIR_EPG", 4123 },
  374. { "CHANGHONGIR_HOME", 4124 },
  375. { "CHANGHONGIR_SETTINGS", 4125 },
  376. // Hisense section, range 4201-4299
  377. { "HISENSE_G_SENSOR", 4201 },
  378. { "HISENSE_LOW_BATTERY", 4202 },
  379. { "HISENSE_SLIDEUP", 4203 },
  380. { "HISENSE_SLIDEDOWN", 4204 },
  381. { "HISENSE_SLIDELEFT", 4205 },
  382. { "HISENSE_SLIDERIGHT", 4206 },
  383. { "HISENSE_RAPID_SLIDEUP", 4207 },
  384. { "HISENSE_RAPID_SLIDEDOWN", 4208 },
  385. { "HISENSE_RAPID_SLIDELEFT", 4209 },
  386. { "HISENSE_RAPID_SLIDERIGHT", 4210 },
  387. { "HISENSE_FAC_NEC_M", 4211 },
  388. { "HISENSE_FAC_NEC_IP", 4212 },
  389. { "HISENSE_FAC_NEC_SAVE", 4213 },
  390. { "HISENSE_FAC_NEC_3D", 4214 },
  391. { "HISENSE_FAC_NEC_PC", 4215 },
  392. { "HISENSE_FAC_NEC_LOGO", 4216 },
  393. { "HISENSE_FAC_NEC_YPBPR", 4217 },
  394. { "HISENSE_FAC_NEC_HDMI", 4218 },
  395. { "HISENSE_FAC_NEC_F1", 4219 },
  396. { "HISENSE_FAC_NEC_F2", 4220 },
  397. { "HISENSE_FAC_NEC_F3", 4221 },
  398. { "HISENSE_FAC_NEC_F4", 4222 },
  399. { "HISENSE_FAC_NEC_F5", 4223 },
  400. { "HISENSE_FAC_NEC_F6", 4224 },
  401. { "HISENSE_FAC_NEC_F7", 4225 },
  402. { "HISENSE_FAC_NEC_OK", 4226 },
  403. { "HISENSE_FAC_NEC_MAC", 4227 },
  404. { "HISENSE_FAC_NEC_AV", 4228 },
  405. { "HISENSE_FAC_NEC_PATTERN", 4229 },
  406. { "HISENSE_FAC_NEC_AGING", 4230 },
  407. { "HISENSE_FAC_NEC_BALANCE", 4231 },
  408. { "HISENSE_FAC_NEC_ADC", 4232 },
  409. { "HISENSE_FAC_NEC_RDRV_INCREASE", 4233 },
  410. { "HISENSE_FAC_NEC_RDRV_DECREASE", 4234 },
  411. { "HISENSE_FAC_NEC_GDRV_INCREASE", 4235 },
  412. { "HISENSE_FAC_NEC_GDRV_DECREASE", 4236 },
  413. { "HISENSE_FAC_NEC_BDRV_INCREASE", 4237 },
  414. { "HISENSE_FAC_NEC_BDRV_DECREASE", 4238 },
  415. { "HISENSE_FAC_NEC_RCUT_INCREASE", 4239 },
  416. { "HISENSE_FAC_NEC_RCUT_DECREASE", 4240 },
  417. { "HISENSE_FAC_NEC_GCUT_INCREASE", 4241 },
  418. { "HISENSE_FAC_NEC_GCUT_DECREASE", 4242 },
  419. { "HISENSE_FAC_NEC_BCUT_INCREASE", 4243 },
  420. { "HISENSE_FAC_NEC_BCUT_DECREASE", 4244 },
  421. { "HISENSE_PRODUCT_SCAN_START", 4245 },
  422. { "HISENSE_PRODUCT_SCAN_OVER", 4246 },
  423. { "HISENSE_TEST_BROAD_TV", 4247 },
  424. { "HISENSE_TEST_BROAD_DTV", 4248 },
  425. { "HISENSE_TEST_BROAD_AV1", 4249 },
  426. { "HISENSE_TEST_BROAD_AV2", 4250 },
  427. { "HISENSE_TEST_BROAD_AV3", 4251 },
  428. { "HISENSE_TEST_BROAD_SVIDEO1", 4252 },
  429. { "HISENSE_TEST_BROAD_SVIDEO2", 4253 },
  430. { "HISENSE_TEST_BROAD_SVIDEO3", 4254 },
  431. { "HISENSE_TEST_BROAD_SCART1", 4255 },
  432. { "HISENSE_TEST_BROAD_SCART2", 4256 },
  433. { "HISENSE_TEST_BROAD_SCART3", 4257 },
  434. { "HISENSE_TEST_BOARD_YPBPR1", 4258 },
  435. { "HISENSE_TEST_BOARD_YPBPR2", 4259 },
  436. { "HISENSE_TEST_BOARD_YPBPR3", 4260 },
  437. { "HISENSE_TEST_BOARD_VGA", 4261 },
  438. { "HISENSE_TEST_BOARD_HDMI1", 4262 },
  439. { "HISENSE_TEST_BOARD_HDMI2", 4263 },
  440. { "HISENSE_TEST_BOARD_HDMI3", 4264 },
  441. { "HISENSE_TEST_BOARD_HDMI4", 4265 },
  442. { "HISENSE_TEST_BOARD_HDMI5", 4266 },
  443. { "HISENSE_TEST_BOARD_DMP", 4267 },
  444. { "HISENSE_TEST_BOARD_EMP", 4268 },
  445. { "HISENSE_TEST_BOARD_AUTOCOLOR", 4269 },
  446. { "HISENSE_TEST_BOARD_SAVE", 4270 },
  447. { "HISENSE_TEST_BOARD_TELITEXT", 4271 },
  448. { "HISENSE_TEST_BOARD_SAPL", 4272 },
  449. { "HISENSE_TEST_BOARD_VCHIP", 4273 },
  450. { "HISENSE_TEST_BOARD_CCD", 4274 },
  451. { "HISENSE_TEST_BOARD_BTSC", 4275 },
  452. { "HISENSE_TEST_BOARD_FAC_OK", 4276 },
  453. // MStar Android Patch End
  454. // NOTE: If you add a new keycode here you must also add it to several other files.
  455. //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
  456. { NULL, 0 }
  457. };
  458. // NOTE: If you edit these flags, also edit policy flags in Input.h.
  459. static const KeycodeLabel FLAGS[] = {
  460. { "WAKE", 0x00000001 },
  461. { "WAKE_DROPPED", 0x00000002 },
  462. { "SHIFT", 0x00000004 },
  463. { "CAPS_LOCK", 0x00000008 },
  464. { "ALT", 0x00000010 },
  465. { "ALT_GR", 0x00000020 },
  466. { "MENU", 0x00000040 },
  467. { "LAUNCHER", 0x00000080 },
  468. { "VIRTUAL", 0x00000100 },
  469. { "FUNCTION", 0x00000200 },
  470. { NULL, 0 }
  471. };
  472. static const KeycodeLabel AXES[] = {
  473. { "X", 0 },
  474. { "Y", 1 },
  475. { "PRESSURE", 2 },
  476. { "SIZE", 3 },
  477. { "TOUCH_MAJOR", 4 },
  478. { "TOUCH_MINOR", 5 },
  479. { "TOOL_MAJOR", 6 },
  480. { "TOOL_MINOR", 7 },
  481. { "ORIENTATION", 8 },
  482. { "VSCROLL", 9 },
  483. { "HSCROLL", 10 },
  484. { "Z", 11 },
  485. { "RX", 12 },
  486. { "RY", 13 },
  487. { "RZ", 14 },
  488. { "HAT_X", 15 },
  489. { "HAT_Y", 16 },
  490. { "LTRIGGER", 17 },
  491. { "RTRIGGER", 18 },
  492. { "THROTTLE", 19 },
  493. { "RUDDER", 20 },
  494. { "WHEEL", 21 },
  495. { "GAS", 22 },
  496. { "BRAKE", 23 },
  497. { "DISTANCE", 24 },
  498. { "TILT", 25 },
  499. { "GENERIC_1", 32 },
  500. { "GENERIC_2", 33 },
  501. { "GENERIC_3", 34 },
  502. { "GENERIC_4", 35 },
  503. { "GENERIC_5", 36 },
  504. { "GENERIC_6", 37 },
  505. { "GENERIC_7", 38 },
  506. { "GENERIC_8", 39 },
  507. { "GENERIC_9", 40 },
  508. { "GENERIC_10", 41 },
  509. { "GENERIC_11", 42 },
  510. { "GENERIC_12", 43 },
  511. { "GENERIC_13", 44 },
  512. { "GENERIC_14", 45 },
  513. { "GENERIC_15", 46 },
  514. { "GENERIC_16", 47 },
  515. // NOTE: If you add a new axis here you must also add it to several other files.
  516. //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
  517. { NULL, -1 }
  518. };
  519. #endif // _LIBINPUT_KEYCODE_LABELS_H</span>
    3)在/frameworks/native/include/android/keycodes.h中添加如下的
    AKEYCODE_MSTAR_WLS          = 320,下面看下该文件的定义
  1. <span style="font-family:FangSong_GB2312;font-size:18px;">/*
  2. * Copyright (C) 2010 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. *      http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _ANDROID_KEYCODES_H
  17. #define _ANDROID_KEYCODES_H
  18. /******************************************************************
  19. *
  20. * IMPORTANT NOTICE:
  21. *
  22. *   This file is part of Android's set of stable system headers
  23. *   exposed by the Android NDK (Native Development Kit).
  24. *
  25. *   Third-party source AND binary code relies on the definitions
  26. *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
  27. *
  28. *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
  29. *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
  30. *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
  31. *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
  32. */
  33. #include <sys/types.h>
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /*
  38. * Key codes.
  39. */
  40. enum {
  41. AKEYCODE_UNKNOWN         = 0,
  42. AKEYCODE_SOFT_LEFT       = 1,
  43. AKEYCODE_SOFT_RIGHT      = 2,
  44. AKEYCODE_HOME            = 3,
  45. AKEYCODE_BACK            = 4,
  46. AKEYCODE_CALL            = 5,
  47. AKEYCODE_ENDCALL         = 6,
  48. AKEYCODE_0               = 7,
  49. AKEYCODE_1               = 8,
  50. AKEYCODE_2               = 9,
  51. AKEYCODE_3               = 10,
  52. AKEYCODE_4               = 11,
  53. AKEYCODE_5               = 12,
  54. AKEYCODE_6               = 13,
  55. AKEYCODE_7               = 14,
  56. AKEYCODE_8               = 15,
  57. AKEYCODE_9               = 16,
  58. AKEYCODE_STAR            = 17,
  59. AKEYCODE_POUND           = 18,
  60. AKEYCODE_DPAD_UP         = 19,
  61. AKEYCODE_DPAD_DOWN       = 20,
  62. AKEYCODE_DPAD_LEFT       = 21,
  63. AKEYCODE_DPAD_RIGHT      = 22,
  64. AKEYCODE_DPAD_CENTER     = 23,
  65. AKEYCODE_VOLUME_UP       = 24,
  66. AKEYCODE_VOLUME_DOWN     = 25,
  67. AKEYCODE_POWER           = 26,
  68. AKEYCODE_CAMERA          = 27,
  69. AKEYCODE_CLEAR           = 28,
  70. AKEYCODE_A               = 29,
  71. AKEYCODE_B               = 30,
  72. AKEYCODE_C               = 31,
  73. AKEYCODE_D               = 32,
  74. AKEYCODE_E               = 33,
  75. AKEYCODE_F               = 34,
  76. AKEYCODE_G               = 35,
  77. AKEYCODE_H               = 36,
  78. AKEYCODE_I               = 37,
  79. AKEYCODE_J               = 38,
  80. AKEYCODE_K               = 39,
  81. AKEYCODE_L               = 40,
  82. AKEYCODE_M               = 41,
  83. AKEYCODE_N               = 42,
  84. AKEYCODE_O               = 43,
  85. AKEYCODE_P               = 44,
  86. AKEYCODE_Q               = 45,
  87. AKEYCODE_R               = 46,
  88. AKEYCODE_S               = 47,
  89. AKEYCODE_T               = 48,
  90. AKEYCODE_U               = 49,
  91. AKEYCODE_V               = 50,
  92. AKEYCODE_W               = 51,
  93. AKEYCODE_X               = 52,
  94. AKEYCODE_Y               = 53,
  95. AKEYCODE_Z               = 54,
  96. AKEYCODE_COMMA           = 55,
  97. AKEYCODE_PERIOD          = 56,
  98. AKEYCODE_ALT_LEFT        = 57,
  99. AKEYCODE_ALT_RIGHT       = 58,
  100. AKEYCODE_SHIFT_LEFT      = 59,
  101. AKEYCODE_SHIFT_RIGHT     = 60,
  102. AKEYCODE_TAB             = 61,
  103. AKEYCODE_SPACE           = 62,
  104. AKEYCODE_SYM             = 63,
  105. AKEYCODE_EXPLORER        = 64,
  106. AKEYCODE_ENVELOPE        = 65,
  107. AKEYCODE_ENTER           = 66,
  108. AKEYCODE_DEL             = 67,
  109. AKEYCODE_GRAVE           = 68,
  110. AKEYCODE_MINUS           = 69,
  111. AKEYCODE_EQUALS          = 70,
  112. AKEYCODE_LEFT_BRACKET    = 71,
  113. AKEYCODE_RIGHT_BRACKET   = 72,
  114. AKEYCODE_BACKSLASH       = 73,
  115. AKEYCODE_SEMICOLON       = 74,
  116. AKEYCODE_APOSTROPHE      = 75,
  117. AKEYCODE_SLASH           = 76,
  118. AKEYCODE_AT              = 77,
  119. AKEYCODE_NUM             = 78,
  120. AKEYCODE_HEADSETHOOK     = 79,
  121. AKEYCODE_FOCUS           = 80,   // *Camera* focus
  122. AKEYCODE_PLUS            = 81,
  123. AKEYCODE_MENU            = 82,
  124. AKEYCODE_NOTIFICATION    = 83,
  125. AKEYCODE_SEARCH          = 84,
  126. AKEYCODE_MEDIA_PLAY_PAUSE= 85,
  127. AKEYCODE_MEDIA_STOP      = 86,
  128. AKEYCODE_MEDIA_NEXT      = 87,
  129. AKEYCODE_MEDIA_PREVIOUS  = 88,
  130. AKEYCODE_MEDIA_REWIND    = 89,
  131. AKEYCODE_MEDIA_FAST_FORWARD = 90,
  132. AKEYCODE_MUTE            = 91,
  133. AKEYCODE_PAGE_UP         = 92,
  134. AKEYCODE_PAGE_DOWN       = 93,
  135. AKEYCODE_PICTSYMBOLS     = 94,
  136. AKEYCODE_SWITCH_CHARSET  = 95,
  137. AKEYCODE_BUTTON_A        = 96,
  138. AKEYCODE_BUTTON_B        = 97,
  139. AKEYCODE_BUTTON_C        = 98,
  140. AKEYCODE_BUTTON_X        = 99,
  141. AKEYCODE_BUTTON_Y        = 100,
  142. AKEYCODE_BUTTON_Z        = 101,
  143. AKEYCODE_BUTTON_L1       = 102,
  144. AKEYCODE_BUTTON_R1       = 103,
  145. AKEYCODE_BUTTON_L2       = 104,
  146. AKEYCODE_BUTTON_R2       = 105,
  147. AKEYCODE_BUTTON_THUMBL   = 106,
  148. AKEYCODE_BUTTON_THUMBR   = 107,
  149. AKEYCODE_BUTTON_START    = 108,
  150. AKEYCODE_BUTTON_SELECT   = 109,
  151. AKEYCODE_BUTTON_MODE     = 110,
  152. AKEYCODE_ESCAPE          = 111,
  153. AKEYCODE_FORWARD_DEL     = 112,
  154. AKEYCODE_CTRL_LEFT       = 113,
  155. AKEYCODE_CTRL_RIGHT      = 114,
  156. AKEYCODE_CAPS_LOCK       = 115,
  157. AKEYCODE_SCROLL_LOCK     = 116,
  158. AKEYCODE_META_LEFT       = 117,
  159. AKEYCODE_META_RIGHT      = 118,
  160. AKEYCODE_FUNCTION        = 119,
  161. AKEYCODE_SYSRQ           = 120,
  162. AKEYCODE_BREAK           = 121,
  163. AKEYCODE_MOVE_HOME       = 122,
  164. AKEYCODE_MOVE_END        = 123,
  165. AKEYCODE_INSERT          = 124,
  166. AKEYCODE_FORWARD         = 125,
  167. AKEYCODE_MEDIA_PLAY      = 126,
  168. AKEYCODE_MEDIA_PAUSE     = 127,
  169. AKEYCODE_MEDIA_CLOSE     = 128,
  170. AKEYCODE_MEDIA_EJECT     = 129,
  171. AKEYCODE_MEDIA_RECORD    = 130,
  172. AKEYCODE_F1              = 131,
  173. AKEYCODE_F2              = 132,
  174. AKEYCODE_F3              = 133,
  175. AKEYCODE_F4              = 134,
  176. AKEYCODE_F5              = 135,
  177. AKEYCODE_F6              = 136,
  178. AKEYCODE_F7              = 137,
  179. AKEYCODE_F8              = 138,
  180. AKEYCODE_F9              = 139,
  181. AKEYCODE_F10             = 140,
  182. AKEYCODE_F11             = 141,
  183. AKEYCODE_F12             = 142,
  184. AKEYCODE_NUM_LOCK        = 143,
  185. AKEYCODE_NUMPAD_0        = 144,
  186. AKEYCODE_NUMPAD_1        = 145,
  187. AKEYCODE_NUMPAD_2        = 146,
  188. AKEYCODE_NUMPAD_3        = 147,
  189. AKEYCODE_NUMPAD_4        = 148,
  190. AKEYCODE_NUMPAD_5        = 149,
  191. AKEYCODE_NUMPAD_6        = 150,
  192. AKEYCODE_NUMPAD_7        = 151,
  193. AKEYCODE_NUMPAD_8        = 152,
  194. AKEYCODE_NUMPAD_9        = 153,
  195. AKEYCODE_NUMPAD_DIVIDE   = 154,
  196. AKEYCODE_NUMPAD_MULTIPLY = 155,
  197. AKEYCODE_NUMPAD_SUBTRACT = 156,
  198. AKEYCODE_NUMPAD_ADD      = 157,
  199. AKEYCODE_NUMPAD_DOT      = 158,
  200. AKEYCODE_NUMPAD_COMMA    = 159,
  201. AKEYCODE_NUMPAD_ENTER    = 160,
  202. AKEYCODE_NUMPAD_EQUALS   = 161,
  203. AKEYCODE_NUMPAD_LEFT_PAREN = 162,
  204. AKEYCODE_NUMPAD_RIGHT_PAREN = 163,
  205. AKEYCODE_VOLUME_MUTE     = 164,
  206. AKEYCODE_INFO            = 165,
  207. AKEYCODE_CHANNEL_UP      = 166,
  208. AKEYCODE_CHANNEL_DOWN    = 167,
  209. AKEYCODE_ZOOM_IN         = 168,
  210. AKEYCODE_ZOOM_OUT        = 169,
  211. AKEYCODE_TV              = 170,
  212. AKEYCODE_WINDOW          = 171,
  213. AKEYCODE_GUIDE           = 172,
  214. AKEYCODE_DVR             = 173,
  215. AKEYCODE_BOOKMARK        = 174,
  216. AKEYCODE_CAPTIONS        = 175,
  217. AKEYCODE_SETTINGS        = 176,
  218. AKEYCODE_TV_POWER        = 177,
  219. AKEYCODE_TV_INPUT        = 178,
  220. AKEYCODE_STB_POWER       = 179,
  221. AKEYCODE_STB_INPUT       = 180,
  222. AKEYCODE_AVR_POWER       = 181,
  223. AKEYCODE_AVR_INPUT       = 182,
  224. AKEYCODE_PROG_RED        = 183,
  225. AKEYCODE_PROG_GREEN      = 184,
  226. AKEYCODE_PROG_YELLOW     = 185,
  227. AKEYCODE_PROG_BLUE       = 186,
  228. AKEYCODE_APP_SWITCH      = 187,
  229. AKEYCODE_BUTTON_1        = 188,
  230. AKEYCODE_BUTTON_2        = 189,
  231. AKEYCODE_BUTTON_3        = 190,
  232. AKEYCODE_BUTTON_4        = 191,
  233. AKEYCODE_BUTTON_5        = 192,
  234. AKEYCODE_BUTTON_6        = 193,
  235. AKEYCODE_BUTTON_7        = 194,
  236. AKEYCODE_BUTTON_8        = 195,
  237. AKEYCODE_BUTTON_9        = 196,
  238. AKEYCODE_BUTTON_10       = 197,
  239. AKEYCODE_BUTTON_11       = 198,
  240. AKEYCODE_BUTTON_12       = 199,
  241. AKEYCODE_BUTTON_13       = 200,
  242. AKEYCODE_BUTTON_14       = 201,
  243. AKEYCODE_BUTTON_15       = 202,
  244. AKEYCODE_BUTTON_16       = 203,
  245. AKEYCODE_LANGUAGE_SWITCH = 204,
  246. AKEYCODE_MANNER_MODE     = 205,
  247. AKEYCODE_3D_MODE         = 206,
  248. AKEYCODE_CONTACTS        = 207,
  249. AKEYCODE_CALENDAR        = 208,
  250. AKEYCODE_MUSIC           = 209,
  251. AKEYCODE_CALCULATOR      = 210,
  252. AKEYCODE_ZENKAKU_HANKAKU = 211,
  253. AKEYCODE_EISU            = 212,
  254. AKEYCODE_MUHENKAN        = 213,
  255. AKEYCODE_HENKAN          = 214,
  256. AKEYCODE_KATAKANA_HIRAGANA = 215,
  257. AKEYCODE_YEN             = 216,
  258. AKEYCODE_RO              = 217,
  259. AKEYCODE_KANA            = 218,
  260. AKEYCODE_ASSIST          = 219,
  261. AKEYCODE_BRIGHTNESS_DOWN = 220,
  262. AKEYCODE_BRIGHTNESS_UP   = 221,
  263. AKEYCODE_MEDIA_AUDIO_TRACK = 222,
  264. // MStar Android Patch Begin
  265. // Common section, range 251-300
  266. AKEYCODE_SOUND_MODE                 = 251,
  267. AKEYCODE_PICTURE_MODE               = 252,
  268. AKEYCODE_ASPECT_RATIO               = 253,
  269. AKEYCODE_CHANNEL_RETURN             = 254,
  270. AKEYCODE_SLEEP                      = 255,
  271. AKEYCODE_EPG                        = 256,
  272. AKEYCODE_LIST                       = 257,
  273. AKEYCODE_SUBTITLE                   = 258,
  274. AKEYCODE_FAVORITE                   = 259,
  275. AKEYCODE_MTS                        = 260,
  276. AKEYCODE_FREEZE                     = 261,
  277. AKEYCODE_TTX                        = 262,
  278. AKEYCODE_CC                         = 263,
  279. AKEYCODE_TV_SETTING                 = 264,
  280. AKEYCODE_SCREENSHOT                 = 265,
  281. AKEYCODE_CLOUD                      = 266,
  282. AKEYCODE_VOICE                      = 267,
  283. AKEYCODE_USB                        = 268,
  284. AKEYCODE_HDMI                       = 269,
  285. AKEYCODE_DISPLAY_MODE               = 270,
  286. AKEYCODE_SONG_SYSTEM                = 271,
  287. AKEYCODE_GINGA_BACK                 = 272,
  288. AKEYCODE_NETFLIX                    = 273,
  289. AKEYCODE_AMAZONE                    = 274,
  290. // Mstar section, range 301-400
  291. AKEYCODE_MSTAR_BALANCE              = 301,
  292. AKEYCODE_MSTAR_INDEX                = 302,
  293. AKEYCODE_MSTAR_HOLD                 = 303,
  294. AKEYCODE_MSTAR_UPDATE               = 304,
  295. AKEYCODE_MSTAR_REVEAL               = 305,
  296. AKEYCODE_MSTAR_SUBCODE              = 306,
  297. AKEYCODE_MSTAR_SIZE                 = 307,
  298. AKEYCODE_MSTAR_CLOCK                = 308,
  299. AKEYCODE_MSTAR_STORE_UP             = 309,
  300. AKEYCODE_MSTAR_TRIANGLE_UP          = 310,
  301. AKEYCODE_MSTAR_MOVIE                = 311,
  302. AKEYCODE_MSTAR_FILE                 = 312,
  303. AKEYCODE_MSTAR_STAR_PLUS            = 313,
  304. AKEYCODE_MSTAR_AUDIO_TRACK          = 314,
  305. AKEYCODE_MSTAR_OPTIONAL_TIME        = 315,
  306. AKEYCODE_MSTAR_LOOP                 = 316,
  307. AKEYCODE_MSTAR_INBOX                = 317,
  308. AKEYCODE_MSTAR_VVOIP                = 318,
  309. AKEYCODE_MSTAR_PVR_BROWSER          = 319,
  310. // Konka section, range 501-600
  311. AKEYCODE_KONKA_YPBPR                = 501,
  312. AKEYCODE_KONKA_THREEPOINT_LOONPRESS = 502,
  313. AKEYCODE_KONKA_THREEPOINT_COLLECT   = 503,
  314. AKEYCODE_KONKA_THREEPOINT_DISPERSE  = 504,
  315. AKEYCODE_KONKA_VOICESWITCH          = 505,
  316. AKEYCODE_KONKA_FLYIMEFINGER_SELECT  = 506,
  317. AKEYCODE_KONKA_FLYIMEFINGER_CANCEL  = 507,
  318. AKEYCODE_KONKA_SOUNDOUTPUT_ENABLE   = 508,
  319. AKEYCODE_KONKA_SOUNDOUTPUT_DISABLE  = 509,
  320. AKEYCODE_KONKA_BESTV_EXIT           = 510,
  321. AKEYCODE_KONKA_BESTV_FORWARD        = 511,
  322. AKEYCODE_KONKA_BESTV_BACKWARD       = 512,
  323. AKEYCODE_KONKA_ENTER_FACTORY        = 513,
  324. AKEYCODE_KONKA_FACTORY_BAKE_TV      = 514,
  325. // Haier section, range  401-500
  326. AKEYCODE_HAIER_TASK                 = 401,
  327. AKEYCODE_HAIER_TOOLS                = 402,
  328. AKEYCODE_HAIER_POWERSLEEP           = 403,
  329. AKEYCODE_HAIER_WAKEUP               = 404,
  330. AKEYCODE_HAIER_UNMUTE               = 405,
  331. AKEYCODE_HAIER_CLEANSEARCH          = 406,
  332. // Skyworth section, range 601-700
  333. // Tcl section, range 4001-4100
  334. AKEYCODE_TCL_MITV                   = 4001,
  335. AKEYCODE_TCL_USB_MENU               = 4002,
  336. AKEYCODE_TCL_SWING_R1               = 4003,
  337. AKEYCODE_TCL_SWING_R2               = 4004,
  338. AKEYCODE_TCL_SWING_R3               = 4005,
  339. AKEYCODE_TCL_SWING_R4               = 4006,
  340. AKEYCODE_TCL_SWING_L1               = 4007,
  341. AKEYCODE_TCL_SWING_L2               = 4008,
  342. AKEYCODE_TCL_SWING_L3               = 4009,
  343. AKEYCODE_TCL_SWING_L4               = 4010,
  344. AKEYCODE_TCL_WIDGET                 = 4011,
  345. AKEYCODE_TCL_VGR_LEFT               = 4012,
  346. AKEYCODE_TCL_VGR_RIGHT              = 4013,
  347. AKEYCODE_TCL_VGR_TAP                = 4014,
  348. AKEYCODE_TCL_VGR_WAVE               = 4015,
  349. AKEYCODE_TCL_VGR_WAVE_LEFT          = 4016,
  350. AKEYCODE_TCL_VGR_WAVE_RIGHT         = 4017,
  351. AKEYCODE_TCL_VGR_ACTIVE             = 4018,
  352. AKEYCODE_TCL_VGR_DEACTIVE           = 4019,
  353. AKEYCODE_TCL_BODY_SENSOR            = 4020,
  354. AKEYCODE_TCL_CIRCLE_CLOCKWISE       = 4021,
  355. AKEYCODE_TCL_CIRCLE_CTR_CLOCKWISE   = 4022,
  356. AKEYCODE_TCL_GESTURE_X              = 4023,
  357. AKEYCODE_TCL_GESTURE_ALPHA          = 4024,
  358. AKEYCODE_TCL_GESTURE_MUTE           = 4025,
  359. AKEYCODE_TCL_UP                     = 4026,
  360. AKEYCODE_TCL_DOWN                   = 4027,
  361. AKEYCODE_TCL_LEFT                   = 4028,
  362. AKEYCODE_TCL_RIGHT                  = 4029,
  363. AKEYCODE_TCL_UP_LEFT                = 4030,
  364. AKEYCODE_TCL_UP_RIGHT               = 4031,
  365. AKEYCODE_TCL_DOWN_LEFT              = 4032,
  366. AKEYCODE_TCL_DOWN_RIGHT             = 4033,
  367. // Changhong section, range 4101-4200
  368. AKEYCODE_CHANGHONGIR_MUTE           = 4101,
  369. AKEYCODE_CHANGHONGIR_INPUT          = 4102,
  370. AKEYCODE_CHANGHONGIR_DEL            = 4103,
  371. AKEYCODE_CHANGHONGIR_MENU           = 4104,
  372. AKEYCODE_CHANGHONGIR_CORN           = 4105,
  373. AKEYCODE_CHANGHONGIR_OK             = 4106,
  374. AKEYCODE_CHANGHONGIR_FLCK_FU        = 4107,
  375. AKEYCODE_CHANGHONGIR_FLCK_FD        = 4108,
  376. AKEYCODE_CHANGHONGIR_FLCK_FL        = 4109,
  377. AKEYCODE_CHANGHONGIR_FLCK_FR        = 4110,
  378. AKEYCODE_CHANGHONGIR_FLCK_SU        = 4111,
  379. AKEYCODE_CHANGHONGIR_FLCK_SD        = 4112,
  380. AKEYCODE_CHANGHONGIR_FLCK_SL        = 4113,
  381. AKEYCODE_CHANGHONGIR_FLCK_SR        = 4114,
  382. AKEYCODE_CHANGHONGIR_PINCH          = 4115,
  383. AKEYCODE_CHANGHONGIR_SPREAD         = 4116,
  384. AKEYCODE_CHANGHONGIR_VOICE          = 4117,
  385. AKEYCODE_CHANGHONGIR_HAND           = 4118,
  386. AKEYCODE_CHANGHONGIR_3D             = 4119,
  387. AKEYCODE_CHANGHONGIR_HELP           = 4120,
  388. AKEYCODE_CHANGHONGIR_APP            = 4121,
  389. AKEYCODE_CHANGHONGIR_MOUSE          = 4122,
  390. AKEYCODE_CHANGHONGIR_EPG            = 4123,
  391. AKEYCODE_CHANGHONGIR_HOME           = 4124,
  392. AKEYCODE_CHANGHONGIR_SETTINGS       = 4125,
  393. // Hisense section, range 4201-4300
  394. AKEYCODE_HISENSE_G_SENSOR           = 4201,
  395. AKEYCODE_HISENSE_LOW_BATTERY        = 4202,
  396. AKEYCODE_HISENSE_SLIDEUP            = 4203,
  397. AKEYCODE_HISENSE_SLIDEDOWN          = 4204,
  398. AKEYCODE_HISENSE_SLIDELEFT          = 4205,
  399. AKEYCODE_HISENSE_SLIDERIGHT         = 4206,
  400. AKEYCODE_HISENSE_RAPID_SLIDEUP      = 4207,
  401. AKEYCODE_HISENSE_RAPID_SLIDEDOWN    = 4208,
  402. AKEYCODE_HISENSE_RAPID_SLIDELEFT    = 4209,
  403. AKEYCODE_HISENSE_RAPID_SLIDERIGHT   = 4210,
  404. AKEYCODE_HISENSE_FAC_NEC_M          = 4211,
  405. AKEYCODE_HISENSE_FAC_NEC_IP         = 4212,
  406. AKEYCODE_HISENSE_FAC_NEC_SAVE       = 4213,
  407. AKEYCODE_HISENSE_FAC_NEC_3D         = 4214,
  408. AKEYCODE_HISENSE_FAC_NEC_PC         = 4215,
  409. AKEYCODE_HISENSE_FAC_NEC_LOGO       = 4216,
  410. AKEYCODE_HISENSE_FAC_NEC_YPBPR      = 4217,
  411. AKEYCODE_HISENSE_FAC_NEC_HDMI       = 4218,
  412. AKEYCODE_HISENSE_FAC_NEC_F1         = 4219,
  413. AKEYCODE_HISENSE_FAC_NEC_F2         = 4220,
  414. AKEYCODE_HISENSE_FAC_NEC_F3         = 4221,
  415. AKEYCODE_HISENSE_FAC_NEC_F4         = 4222,
  416. AKEYCODE_HISENSE_FAC_NEC_F5         = 4223,
  417. AKEYCODE_HISENSE_FAC_NEC_F6         = 4224,
  418. AKEYCODE_HISENSE_FAC_NEC_F7         = 4225,
  419. AKEYCODE_HISENSE_FAC_NEC_OK         = 4226,
  420. AKEYCODE_HISENSE_FAC_NEC_MAC        = 4227,
  421. AKEYCODE_HISENSE_FAC_NEC_AV         = 4228,
  422. AKEYCODE_HISENSE_FAC_NEC_PATTERN    = 4229,
  423. AKEYCODE_HISENSE_FAC_NEC_AGING      = 4230,
  424. AKEYCODE_HISENSE_FAC_NEC_BALANCE    = 4231,
  425. AKEYCODE_HISENSE_FAC_NEC_ADC        = 4232,
  426. AKEYCODE_HISENSE_FAC_NEC_RDRV_INCREASE = 4233,
  427. AKEYCODE_HISENSE_FAC_NEC_RDRV_DECREASE = 4234,
  428. AKEYCODE_HISENSE_FAC_NEC_GDRV_INCREASE = 4235,
  429. AKEYCODE_HISENSE_FAC_NEC_GDRV_DECREASE = 4236,
  430. AKEYCODE_HISENSE_FAC_NEC_BDRV_INCREASE = 4237,
  431. AKEYCODE_HISENSE_FAC_NEC_BDRV_DECREASE = 4238,
  432. AKEYCODE_HISENSE_FAC_NEC_RCUT_INCREASE = 4239,
  433. AKEYCODE_HISENSE_FAC_NEC_RCUT_DECREASE = 4240,
  434. AKEYCODE_HISENSE_FAC_NEC_GCUT_INCREASE = 4241,
  435. AKEYCODE_HISENSE_FAC_NEC_GCUT_DECREASE = 4242,
  436. AKEYCODE_HISENSE_FAC_NEC_BCUT_INCREASE = 4243,
  437. AKEYCODE_HISENSE_FAC_NEC_BCUT_DECREASE = 4244,
  438. AKEYCODE_HISENSE_PRODUCT_SCAN_START = 4245,
  439. AKEYCODE_HISENSE_PRODUCT_SCAN_OVER  = 4246,
  440. AKEYCODE_HISENSE_TEST_BROAD_TV      = 4247,
  441. AKEYCODE_HISENSE_TEST_BROAD_DTV     = 4248,
  442. AKEYCODE_HISENSE_TEST_BROAD_AV1     = 4249,
  443. AKEYCODE_HISENSE_TEST_BROAD_AV2     = 4250,
  444. AKEYCODE_HISENSE_TEST_BROAD_AV3     = 4251,
  445. AKEYCODE_HISENSE_TEST_BROAD_SVIDEO1 = 4252,
  446. AKEYCODE_HISENSE_TEST_BROAD_SVIDEO2 = 4253,
  447. AKEYCODE_HISENSE_TEST_BROAD_SVIDEO3 = 4254,
  448. AKEYCODE_HISENSE_TEST_BROAD_SCART1  = 4255,
  449. AKEYCODE_HISENSE_TEST_BROAD_SCART2  = 4256,
  450. AKEYCODE_HISENSE_TEST_BROAD_SCART3  = 4257,
  451. AKEYCODE_HISENSE_TEST_BOARD_YPBPR1  = 4258,
  452. AKEYCODE_HISENSE_TEST_BOARD_YPBPR2  = 4259,
  453. AKEYCODE_HISENSE_TEST_BOARD_YPBPR3  = 4260,
  454. AKEYCODE_HISENSE_TEST_BOARD_VGA     = 4261,
  455. AKEYCODE_HISENSE_TEST_BOARD_HDMI1   = 4262,
  456. AKEYCODE_HISENSE_TEST_BOARD_HDMI2   = 4263,
  457. AKEYCODE_HISENSE_TEST_BOARD_HDMI3   = 4264,
  458. AKEYCODE_HISENSE_TEST_BOARD_HDMI4   = 4265,
  459. AKEYCODE_HISENSE_TEST_BOARD_HDMI5   = 4266,
  460. AKEYCODE_HISENSE_TEST_BOARD_DMP     = 4267,
  461. AKEYCODE_HISENSE_TEST_BOARD_EMP     = 4268,
  462. AKEYCODE_HISENSE_TEST_BOARD_AUTOCOLOR = 4269,
  463. AKEYCODE_HISENSE_TEST_BOARD_SAVE    = 4270,
  464. AKEYCODE_HISENSE_TEST_BOARD_TELITEXT = 4271,
  465. AKEYCODE_HISENSE_TEST_BOARD_SAPL    = 4272,
  466. AKEYCODE_HISENSE_TEST_BOARD_VCHIP   = 4273,
  467. AKEYCODE_HISENSE_TEST_BOARD_CCD     = 4274,
  468. AKEYCODE_HISENSE_TEST_BOARD_BTSC    = 4275,
  469. AKEYCODE_HISENSE_TEST_BOARD_FAC_OK  = 4276,
  470. // MStar Android Patch End
  471. // NOTE: If you add a new keycode here you must also add it to several other files.
  472. //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
  473. };
  474. #ifdef __cplusplus
  475. }
  476. #endif
  477. #endif // _ANDROID_KEYCODES_H
  478. </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()函数中,不惑该键值,至于怎么处理处决您的业务处理了。
       在这里再总结下我对Android键值处理的理解,我的理解:看了一下key character map的处理,是通过读取kl文件然后使用驱动程序提供的ioctl函数去修改来自输入设备的扫描码和系统预定义的keycode的映射关系。 这样的话,对于硬件扫描码,只需要修改这个kl文件。上层得到的都是系统预定义的keycode。
重要补充:
  映射关系:
    ir硬件扫描码在驱动里面被 映射为 kernel/include/linux/input.h里面定义的某个键值。但是这个键值只在linux系统中使用。
  Android通过源码目录下的device/xxx/xxx.kl( keylayout )文件完成linux键值到Android系统要使用的键值的映射