1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #ifndef _android_charmap_h 13 #define _android_charmap_h 14 15 #include "android/keycode.h" 16 17 /* this defines a structure used to describe an Android keyboard charmap */ 18 typedef struct AKeyEntry { 19 unsigned short code; 20 unsigned short base; 21 unsigned short caps; 22 unsigned short fn; 23 unsigned short caps_fn; 24 unsigned short number; 25 } AKeyEntry; 26 27 /* Defines size of name buffer in AKeyCharmap entry. */ 28 #define AKEYCHARMAP_NAME_SIZE 32 29 30 typedef struct AKeyCharmap { 31 const AKeyEntry* entries; 32 int num_entries; 33 char name[ AKEYCHARMAP_NAME_SIZE ]; 34 } AKeyCharmap; 35 36 /* Array of charmaps available in the current emulator session. */ 37 extern const AKeyCharmap** android_charmaps; 38 39 /* Number of entries in android_charmaps array. */ 40 extern int android_charmap_count; 41 42 /* Extracts charmap name from .kcm file name. 43 * Charmap name, extracted by this routine is a name of the kcm file, trimmed 44 * of file name extension, and shrinked (if necessary) to fit into the name 45 * buffer. Here are examples on how this routine extracts charmap name: 46 * /a/path/to/kcmfile.kcm -> kcmfile 47 * /a/path/to/kcmfile.ext.kcm -> kcmfile.ext 48 * /a/path/to/kcmfile -> kcmfile 49 * /a/path/to/.kcmfile -> kcmfile 50 * /a/path/to/.kcmfile.kcm -> .kcmfile 51 * kcm_file_path - Path to key charmap file to extract charmap name from. 52 * charmap_name - Buffer, where to save extracted charname. 53 * max_len - charmap_name buffer size. 54 */ 55 void kcm_extract_charmap_name(const char* kcm_file_path, 56 char* charmap_name, 57 int max_len); 58 59 /* Initialzes key charmap array. 60 * Key charmap array always contains two maps: one for qwerty, and 61 * another for qwerty2 keyboard layout. However, a custom layout can 62 * be requested with -charmap option. In tha case kcm_file_path 63 * parameter contains path to a .kcm file that defines that custom 64 * layout, and as the result, key charmap array will contain another 65 * entry built from that file. If -charmap option was not specified, 66 * kcm_file_path is NULL and final key charmap array will contain only 67 * two default entries. 68 * Returns a zero value on success, or -1 on failure. 69 */ 70 int android_charmap_setup(const char* kcm_file_path); 71 72 /* Cleanups initialization performed in android_charmap_setup routine. */ 73 void android_charmap_done(void); 74 75 #endif /* _android_charmap_h */ 76