android5.1 s5p4418 按键修改home 到F1

 
内核
预定义的按键值
include/linux/input.h


KEY_F1          59

修改板设备文件中

上报按键值修改KEY_F1
#define CFG_KEYPAD_KEY_CODE                                            { \
       KEY_F1,\
        KEY_POWER }


修改android系统映射文件
device/nexell/s5p4418_drone/keypad_s5p4418_drone.kl

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

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

key 59    F1
linux 59 对应 android F1

framework层添加信息

./frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

            case KeyEvent.KEYCODE_F1: {
                if (down) {
                   Log.d(TAG, "F1 down");
                } else {
                   Log.d(TAG, "F1 up");
                }
                break;
            }
添加调试信息如上。

编译烧写

应用activity获取按键值

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int key= event.getKeyCode();

    if (key==KeyEvent.KEYCODE_F1)
    {
        if (KeyEvent.ACTION_UP==event.getAction())
            Log.i(TAG,"key up");
        else if(KeyEvent.ACTION_DOWN==event.getAction())
            Log.i(TAG,"key down");
    }
    return super.dispatchKeyEvent(event);
}

你可能感兴趣的:(android底层)