1 | /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ |
2 | /* vim:set et sts=4: */ |
3 | /* IBus - The Input Bus |
4 | * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> |
5 | * Copyright (C) 2008-2010 Red Hat, Inc. |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2.1 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Lesser General Public |
18 | * License along with this library; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
20 | * USA |
21 | */ |
22 | |
23 | #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION) |
24 | #error "Only <ibus.h> can be included directly" |
25 | #endif |
26 | |
27 | #ifndef __IBUS_KEYMAP_H_ |
28 | #define __IBUS_KEYMAP_H_ |
29 | |
30 | /** |
31 | * SECTION: ibuskeymap |
32 | * @short_description: Keyboard mapping handling. |
33 | * @title: IBusKeymap |
34 | * @stability: Stable |
35 | * |
36 | * An IBusKeymap defines the mapping between keyboard scancodes and |
37 | * keyboard symbols such as numbers, alphabets, and punctuation marks. |
38 | * |
39 | * Some input methods assume certain keyboard layout |
40 | * (such as Chewing and Wubi requires an US-QWERTY layout), |
41 | * and expect key symbols to be arranged in that order. |
42 | * These input methods should new an IBusKeymap |
43 | * instance and define the keyboard layout. |
44 | * Then ibus_keymap_lookup_keysym() can |
45 | * convert scancodes back to the key symbols. |
46 | * |
47 | * see_also: #IBusComponent, #IBusEngineDesc |
48 | * |
49 | */ |
50 | |
51 | #include "ibusobject.h" |
52 | |
53 | /* |
54 | * Type macros. |
55 | */ |
56 | /* define IBusKeymap macros */ |
57 | #define IBUS_TYPE_KEYMAP \ |
58 | (ibus_keymap_get_type ()) |
59 | #define IBUS_KEYMAP(obj) \ |
60 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_KEYMAP, IBusKeymap)) |
61 | #define IBUS_KEYMAP_CLASS(klass) \ |
62 | (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_KEYMAP, IBusKeymapClass)) |
63 | #define IBUS_IS_KEYMAP(obj) \ |
64 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_KEYMAP)) |
65 | #define IBUS_IS_KEYMAP_CLASS(klass) \ |
66 | (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_KEYMAP)) |
67 | #define IBUS_KEYMAP_GET_CLASS(obj) \ |
68 | (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_KEYMAP, IBusKeymapClass)) |
69 | |
70 | G_BEGIN_DECLS |
71 | |
72 | typedef struct _IBusKeymap IBusKeymap; |
73 | typedef struct _IBusKeymapClass IBusKeymapClass; |
74 | |
75 | /** |
76 | * KEYMAP: |
77 | * |
78 | * Data structure for storing keymap. |
79 | * keymap[.][i] |
80 | * i: |
81 | * 0 - without modifer |
82 | * 1 - shift |
83 | * 2 - caplock |
84 | * 3 - shift caplock |
85 | * 4 - altgr |
86 | * 5 - shift altgr |
87 | * 6 - numlock |
88 | */ |
89 | /* typedef guint KEYMAP[256][7]; */ |
90 | |
91 | /** |
92 | * IBusKeymap: |
93 | * @name: The name of the keymap, such as 'us', 'jp'. |
94 | * @keymap: Keymap table. IME developers normally don have to touch this. |
95 | * |
96 | * A keymap object in IBus. |
97 | */ |
98 | struct _IBusKeymap { |
99 | /*< private >*/ |
100 | IBusObject parent; |
101 | /* members */ |
102 | /*< public >*/ |
103 | gchar *name; |
104 | guint keymap[256][7]; |
105 | }; |
106 | |
107 | struct _IBusKeymapClass { |
108 | IBusObjectClass parent; |
109 | }; |
110 | |
111 | GType ibus_keymap_get_type (void); |
112 | |
113 | /** |
114 | * ibus_keymap_new: |
115 | * @name: The keymap file to be loaded, such as 'us', 'jp'. |
116 | * |
117 | * Get an #IBusKeymap associated with the giving name. |
118 | * |
119 | * This function loads the keymap file specified in @name |
120 | * in the IBUS_DATA_DIR/keymaps directory. |
121 | * |
122 | * Returns: An #IBusKeymap associated with the giving name; or %NULL if failed. |
123 | * |
124 | * Deprecated: This function has been deprecated and should |
125 | * not be used in newly written code. Please use ibus_keymap_get(). |
126 | */ |
127 | IBusKeymap *ibus_keymap_new (const gchar *name) |
128 | G_GNUC_DEPRECATED; |
129 | |
130 | /** |
131 | * ibus_keymap_get: |
132 | * @name: The keymap file to be loaded, such as 'us', 'jp'. |
133 | * |
134 | * Get an IBusKeymap associated with the giving name. |
135 | * |
136 | * This function loads the keymap file specified in @name |
137 | * in the IBUS_DATA_DIR/keymaps directory. |
138 | * |
139 | * Returns: (transfer full): An #IBusKeymap associated with the giving name; |
140 | * or %NULL if failed. |
141 | */ |
142 | IBusKeymap *ibus_keymap_get (const gchar *name); |
143 | |
144 | /** |
145 | * ibus_keymap_lookup_keysym: |
146 | * @keymap: An IBusKeymap. |
147 | * @keycode: A scancode to be converted. |
148 | * @state: Modifier flags(such as Ctrl, Shift). |
149 | * |
150 | * Converts the scancode to keysym, given the keymap. |
151 | * |
152 | * Returns: Corresponding keysym. |
153 | */ |
154 | guint ibus_keymap_lookup_keysym (IBusKeymap *keymap, |
155 | guint16 keycode, |
156 | guint32 state); |
157 | |
158 | G_END_DECLS |
159 | #endif |
160 | |
161 | |