参考 验证按键映射工具 ,
使用 validatekeymaps 工具,
可以很方便的验证 Generic.kl 、Vendor_0079_Product_0011.kl 、Generic.kcm 等输入设备配置文件、按键布局文件、按键字符映射文件和虚拟按键定义文件的语法。
在源码下 source
、lunch
后,执行 validatekeymaps
可看到提示,
Keymap Validation Tool
Usage:
validatekeymaps [-q] [*.kl] [*.kcm] [*.idc] [virtualkeys.*] [...]
Validates the specified key layouts, key character maps,
input device configurations, or virtual key definitions.
-q Quiet; do not write anything to standard out.
执行 validatekeymaps frameworks/base/data/keyboards/Generic.kl
,提示
Validating file 'frameworks/base/data/keyboards/Generic.kl'...
libvintf W 01-29 01:42:18 1504118 1504118 RuntimeInfo-host.cpp:27] Should not run fetchAllInformation on host.
Success.
修改该文件,
diff --git a/frameworks/base/data/keyboards/Generic.kl b/frameworks/base/data/keyboards/Generic.kl
index c81473ddcf..c2edfe9683 100644
--- a/frameworks/base/data/keyboards/Generic.kl
+++ b/frameworks/base/data/keyboards/Generic.kl
@@ -21,7 +21,7 @@
#
key 1 ESCAPE
-key 2 1
+key 1 1
key 3 2
key 4 3
key 5 4
特地改成错误的,再执行 validatekeymaps frameworks/base/data/keyboards/Generic.kl
就会提示
KeyLayoutMap E 01-29 01:42:51 1504168 1504168] frameworks/base/data/keyboards/Generic.kl:24: Duplicate entry for key scan code '1'.
Error Load KeyLayoutMap failed -22. parsing key layout file.
Failed!
报错也明显,重复定义了 key 1 。