android kl 文件的作用

生也有涯,知也无涯。这篇文章主要讲述android kl 文件的作用相关的知识,希望能为你提供帮助。
本文转载自:http://blog.csdn.net/u013308744/article/details/49274069
首先看touchscreen的kl文件


# Copyright (c) 2014, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
#       copyright notice, this list of conditions and the following
#       disclaimer in the documentation and/or other materials provided
#       with the distribution.
#     * Neither the name of The Linux Foundation nor the names of its
#       contributors may be used to endorse or promote products derived
#       from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
# ARE DISCLAIMED.   IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


key 158     BACK               VIRTUAL  WAKE
key 102     HOME               VIRTUAL  WAKE
key 580     APP_SWITCH         VIRTUAL  WAKE
key 116     GESTURE_DOUBLE_CLICK             VIRTUAL  WAKE
key 46       GESTURE_C                 VIRTUAL  WAKE
key 18       GESTURE_E                 VIRTUAL  WAKE
key 31       GESTURE_S                 VIRTUAL  WAKE
key 47       GESTURE_V                 VIRTUAL  WAKE
key 17       GESTURE_W                 VIRTUAL  WAKE
key 44       GESTURE_Z                 VIRTUAL  WAKE





那么这个kl有啥用呢,众所周知,android kernel和framework是不同的两层,也就是说,kernel里认识的
key值是158之类的这种数字,这个158是scankode,它往framework上报的时候也只会报这样的数字,但是framework不认识这个数字是什么,所以framework需要先解析kl文件,map起来,这样kernel传值上来的时候才会知道到底是什么key,也就是说转换scancode 158变成KeyCodeLabel也就是BACK,然后back再转换成4这个keycode
首先
key 580     APP_SWITCH         VIRTUAL  WAKE
这里的580是scancode,转换撑了APP_SWITCH这个keycodelabel
InputEventLabels.h里的
  DEFINE_KEYCODE(APP_SWITCH),
#define DEFINE_KEYCODE(key) { #key, AKEYCODE_##key }
这里拼接了AKEYCODE_APP_SWITCH
 
Keycodes.h (native\include\android):     AKEYCODE_APP_SWITCH       = 187,
KeyEvent.java (base\core\java\android\view):     public static final int KEYCODE_APP_SWITCH       = 187;
【android kl 文件的作用】然后就变成了keycode 187

    推荐阅读