blob: 7f1e959f6a8a50d9b128d4ef7191d88409ef79b5 [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001/* 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
David 'Digit' Turner87250c22009-09-17 16:45:03 -070015#include "android/keycode.h"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080016
17/* this defines a structure used to describe an Android keyboard charmap */
18typedef 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
vchtchetkine9085a282009-09-14 15:29:20 -070027/* Defines size of name buffer in AKeyCharmap entry. */
28#define AKEYCHARMAP_NAME_SIZE 32
29
30typedef struct AKeyCharmap {
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080031 const AKeyEntry* entries;
32 int num_entries;
vchtchetkine9085a282009-09-14 15:29:20 -070033 char name[ AKEYCHARMAP_NAME_SIZE ];
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080034} AKeyCharmap;
35
vchtchetkine9085a282009-09-14 15:29:20 -070036/* Array of charmaps available in the current emulator session. */
37extern const AKeyCharmap** android_charmaps;
38
39/* Number of entries in android_charmaps array. */
40extern int android_charmap_count;
41
42/* Custom character map created with -charmap option. */
43extern AKeyCharmap android_custom_charmap;
44
45/* Extracts charmap name from .kcm file name.
46 * Charmap name, extracted by this routine is a name of the kcm file, trimmed
47 * of file name extension, and shrinked (if necessary) to fit into the name
48 * buffer. Here are examples on how this routine extracts charmap name:
49 * /a/path/to/kcmfile.kcm -> kcmfile
50 * /a/path/to/kcmfile.ext.kcm -> kcmfile.ext
51 * /a/path/to/kcmfile -> kcmfile
52 * /a/path/to/.kcmfile -> kcmfile
53 * /a/path/to/.kcmfile.kcm -> .kcmfile
54 * kcm_file_path - Path to key charmap file to extract charmap name from.
55 * charmap_name - Buffer, where to save extracted charname.
56 * max_len - charmap_name buffer size.
57*/
58void kcm_extract_charmap_name(const char* kcm_file_path,
59 char* charmap_name,
60 int max_len);
61
62/* Initialzes key charmap array.
63 * Key charmap array always contains two maps: one for qwerty, and
64 * another for qwerty2 keyboard layout. However, a custom layout can
65 * be requested with -charmap option. In tha case kcm_file_path
66 * parameter contains path to a .kcm file that defines that custom
67 * layout, and as the result, key charmap array will contain another
68 * entry built from that file. If -charmap option was not specified,
69 * kcm_file_path is NULL and final key charmap array will contain only
70 * two default entries.
71 * Returns a zero value on success, or -1 on failure.
72*/
73int android_charmap_setup(const char* kcm_file_path);
74
75/* Cleanups initialization performed in android_charmap_setup routine. */
76void android_charmap_done(void);
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080077
78#endif /* _android_charmap_h */