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.
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 of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
29 * @short_description: Keyboard mapping handling.
33 * An IBusKeymap defines the mapping between keyboard scancodes and
34 * keyboard symbols such as numbers, alphabets, and punctuation marks.
36 * Some input methods assume certain keyboard layout
37 * (such as Chewing and Wubi requires an US-QWERTY layout),
38 * and expect key symbols to be arranged in that order.
39 * These input methods should new an IBusKeymap
40 * instance and define the keyboard layout.
41 * Then ibus_keymap_lookup_keysym() can
42 * convert scancodes back to the key symbols.
44 * @see_also: #IBusComponent, #IBusEngineDesc
48 #ifndef __IBUS_KEYMAP_H_
49 #define __IBUS_KEYMAP_H_
51 #include "ibusobject.h"
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))
72 typedef struct _IBusKeymap IBusKeymap;
73 typedef struct _IBusKeymapClass IBusKeymapClass;
78 * Data structure for storing keymap.
89 /* typedef guint KEYMAP[256][7]; */
93 * @name: The name of the keymap, such as 'us', 'jp'.
94 * @keymap: Keymap table. IME developers normally don have to touch this.
96 * A keymap object in IBus.
104 guint keymap[256][7];
107 struct _IBusKeymapClass {
108 IBusObjectClass parent;
111 GType ibus_keymap_get_type (void);
115 * @name: The keymap file to be loaded, such as 'us', 'jp'.
116 * @returns: An IBusKeymap associated with the giving name; or NULL if failed.
118 * Get an IBusKeymap associated with the giving name.
120 * This function loads the keymap file specified in @name
121 * in the IBUS_DATA_DIR/keymaps directory.
123 * Deprecated: This function has been deprecated and should
124 * not be used in newly written code. Please use ibus_keymap_get().
126 IBusKeymap *ibus_keymap_new (const gchar *name)
131 * @name: The keymap file to be loaded, such as 'us', 'jp'.
132 * @returns: An IBusKeymap associated with the giving name; or NULL if failed.
134 * Get an IBusKeymap associated with the giving name.
136 * This function loads the keymap file specified in @name
137 * in the IBUS_DATA_DIR/keymaps directory.
139 IBusKeymap *ibus_keymap_get (const gchar *name);
142 * ibus_keymap_lookup_keysym:
143 * @keymap: An IBusKeymap.
144 * @keycode: A scancode to be converted.
145 * @state: Modifier flags(such as Ctrl, Shift).
146 * @returns: Corresponding keysym.
148 * Convert the scancode to keysym, given the keymap.
150 guint ibus_keymap_lookup_keysym (IBusKeymap *keymap,