From 9065504a63d6bf37bf621191fda1d1fe4da76ee3 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 2 Dec 2010 13:50:46 -0800 Subject: Improve support for external keyboards. Use Vendor ID, Product ID and optionally the Version to locate keymaps and configuration files for external devices. Moved virtual key definition parsing to native code so that EventHub can identify touch screens with virtual keys and load the appropriate key layout file. Cleaned up a lot of old code in EventHub. Fixed a regression in ViewRoot's fallback event handling. Fixed a minor bug in FileMap that caused it to try to munmap or close invalid handled when released if the attempt to map the file failed. Added a couple of new String8 conveniences for formatting strings. Modified Tokenizer to fall back to open+read when mmap fails since we can't mmap sysfs files as needed to open the virtual key definition files in /sys/board_properties/. Change-Id: I6ca5e5f9547619fd082ddac47e87ce185da69ee6 --- tools/validatekeymaps/Main.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'tools/validatekeymaps/Main.cpp') diff --git a/tools/validatekeymaps/Main.cpp b/tools/validatekeymaps/Main.cpp index 6ec223b05420..097b109ab1f3 100644 --- a/tools/validatekeymaps/Main.cpp +++ b/tools/validatekeymaps/Main.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -30,6 +31,7 @@ enum FileType { FILETYPE_UNKNOWN, FILETYPE_KEYLAYOUT, FILETYPE_KEYCHARACTERMAP, + FILETYPE_VIRTUALKEYDEFINITION, }; @@ -37,8 +39,10 @@ static void usage() { fprintf(stderr, "Keymap Validation Tool\n\n"); fprintf(stderr, "Usage:\n"); fprintf(stderr, - " %s [FILENAME.kl] [FILENAME.kcm] [...]\n" - " Validates the specified key layout and/or key character map files.\n\n", gProgName); + " %s [*.kl] [*.kcm] [virtualkeys.*] [...]\n" + " Validates the specified key layouts, key character maps \n" + " or virtual key definitions.\n\n", + gProgName); } static FileType getFileType(const char* filename) { @@ -51,6 +55,11 @@ static FileType getFileType(const char* filename) { return FILETYPE_KEYCHARACTERMAP; } } + + if (strstr(filename, "virtualkeys.")) { + return FILETYPE_VIRTUALKEYDEFINITION; + } + return FILETYPE_UNKNOWN; } @@ -60,7 +69,7 @@ static bool validateFile(const char* filename) { FileType fileType = getFileType(filename); switch (fileType) { case FILETYPE_UNKNOWN: - fprintf(stderr, "File extension must be .kl or .kcm.\n\n"); + fprintf(stderr, "Supported file types: *.kl, *.kcm, virtualkeys.*\n\n"); return false; case FILETYPE_KEYLAYOUT: { @@ -82,6 +91,16 @@ static bool validateFile(const char* filename) { } break; } + + case FILETYPE_VIRTUALKEYDEFINITION: { + VirtualKeyMap* map; + status_t status = VirtualKeyMap::load(String8(filename), &map); + if (status) { + fprintf(stderr, "Error %d parsing virtual key definition file.\n\n", status); + return false; + } + break; + } } fputs("No errors.\n\n", stdout); -- cgit v1.2.3-59-g8ed1b