106 lines
3.6 KiB
HTML
106 lines
3.6 KiB
HTML
<html devsite>
|
|
<head>
|
|
<title>Validate Keymaps Tool</title>
|
|
<meta name="project_path" value="/_project.yaml" />
|
|
<meta name="book_path" value="/_book.yaml" />
|
|
</head>
|
|
<body>
|
|
<!--
|
|
Copyright 2017 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.
|
|
-->
|
|
|
|
|
|
|
|
<p>The Android framework has a small tool called <code>validatekeymaps</code> to validate the
|
|
syntax of input device configuration files, key layout files, key character
|
|
maps files and virtual key definition files.</p>
|
|
<h2 id="compilation">Compilation</h2>
|
|
<p>To compile <code>validatekeymaps</code>, set up the development environment, download
|
|
the Android source tree, compile it, then run:</p>
|
|
<pre class="devsite-terminal devsite-click-to-copy">
|
|
mmm frameworks/base/tools/validatekeymaps
|
|
</pre>
|
|
<p>This command should compile a host tool called validatekeymaps into the
|
|
<code>out/host/<os>/bin</code> directory.</p>
|
|
<h2 id="usage">Usage</h2>
|
|
<p>If you ran <code>envsetup.sh</code> to set up your development environment, then the
|
|
<code>validatekeymaps</code> tool should already be on your path. You can verify
|
|
this by running <code>validatekeymaps</code>.</p>
|
|
<pre class="devsite-terminal devsite-click-to-copy">
|
|
validatekeymaps
|
|
</pre>
|
|
<p>You should see the following output:</p>
|
|
<pre>
|
|
Keymap Validation Tool
|
|
|
|
Usage:
|
|
validatekeymaps [*.kl] [*.kcm] [*.idc] [virtualkeys.*] [...]
|
|
Validates the specified key layouts, key character maps,
|
|
input device configurations, or virtual key definitions.
|
|
</pre>
|
|
<p>Then all you need to do is run <code>validatekeymaps</code> and give it the path of
|
|
one or more files to validate.</p>
|
|
<pre class="devsite-terminal devsite-click-to-copy">
|
|
validatekeymaps frameworks/base/data/keyboards/Generic.kl
|
|
</pre>
|
|
<p>Example:</p>
|
|
<pre>
|
|
Validating file 'frameworks/base/data/keyboards/Generic.kl'...
|
|
No errors.
|
|
|
|
Success.
|
|
</pre>
|
|
<p>And if there is an error...</p>
|
|
<pre class="devsite-terminal devsite-click-to-copy">
|
|
validatekeymaps Bad.kl
|
|
</pre>
|
|
<p>Example:</p>
|
|
<pre>
|
|
Validating file 'Bad.kl'...
|
|
E/KeyLayoutMap(87688): Bad.kl:24: Expected keyword, got 'ke'.
|
|
Error -22 parsing key layout file.
|
|
|
|
Failed!
|
|
</pre>
|
|
<h2 id="automation">Automation</h2>
|
|
<p>It is a <em>very</em> good idea to run <code>validatekeymaps</code> on all configuration files
|
|
before installing them on a device.</p>
|
|
<p>The process can easily be automated as part of the build system by using a
|
|
script or a makefile.</p>
|
|
<p>The following sample makefile is based on the contents of
|
|
<code>frameworks/base/data/keyboards/Android.mk</code>.</p>
|
|
<pre class="devsite-click-to-copy">
|
|
# This makefile performs build time validation of framework keymap files.
|
|
|
|
LOCAL_PATH := $(call my-dir)
|
|
|
|
# Validate all key maps.
|
|
include $(CLEAR_VARS)
|
|
|
|
validatekeymaps := $(HOST_OUT_EXECUTABLES)/validatekeymaps$(HOST_EXECUTABLE_SUFFIX)
|
|
files := MyKeyboard.kl MyKeyboard.kcm MyTouchScreen.idc
|
|
|
|
LOCAL_MODULE := validate_framework_keymaps
|
|
LOCAL_MODULE_TAGS := optional
|
|
LOCAL_REQUIRED_MODULES := validatekeymaps
|
|
|
|
validate_framework_keymaps: $(files)
|
|
$(hide) $(validatekeymaps) $(files)
|
|
|
|
include $(BUILD_PHONY_PACKAGE)
|
|
</pre>
|
|
|
|
</body>
|
|
</html>
|