Blame src/ibuskeymap.h

Packit 3ff832
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
Packit 3ff832
/* vim:set et sts=4: */
Packit 3ff832
/* IBus - The Input Bus
Packit 3ff832
 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
Packit 3ff832
 * Copyright (C) 2008-2010 Red Hat, Inc.
Packit 3ff832
 *
Packit 3ff832
 * This library is free software; you can redistribute it and/or
Packit 3ff832
 * modify it under the terms of the GNU Lesser General Public
Packit 3ff832
 * License as published by the Free Software Foundation; either
Packit 3ff832
 * version 2.1 of the License, or (at your option) any later version.
Packit 3ff832
 *
Packit 3ff832
 * This library is distributed in the hope that it will be useful,
Packit 3ff832
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 3ff832
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 3ff832
 * Lesser General Public License for more details.
Packit 3ff832
 *
Packit 3ff832
 * You should have received a copy of the GNU Lesser General Public
Packit 3ff832
 * License along with this library; if not, write to the Free Software
Packit 3ff832
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
Packit 3ff832
 * USA
Packit 3ff832
 */
Packit 3ff832
Packit 3ff832
#if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
Packit 3ff832
#error "Only <ibus.h> can be included directly"
Packit 3ff832
#endif
Packit 3ff832
Packit 3ff832
#ifndef __IBUS_KEYMAP_H_
Packit 3ff832
#define __IBUS_KEYMAP_H_
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * SECTION: ibuskeymap
Packit 3ff832
 * @short_description: Keyboard mapping handling.
Packit 3ff832
 * @title: IBusKeymap
Packit 3ff832
 * @stability: Stable
Packit 3ff832
 *
Packit 3ff832
 * An IBusKeymap defines the mapping between keyboard scancodes and
Packit 3ff832
 * keyboard symbols such as numbers, alphabets, and punctuation marks.
Packit 3ff832
 *
Packit 3ff832
 * Some input methods assume certain keyboard layout
Packit 3ff832
 * (such as Chewing and Wubi requires an US-QWERTY layout),
Packit 3ff832
 * and expect key symbols to be arranged in that order.
Packit 3ff832
 * These input methods should new an IBusKeymap
Packit 3ff832
 * instance and define the keyboard layout.
Packit 3ff832
 * Then ibus_keymap_lookup_keysym() can
Packit 3ff832
 * convert scancodes back to the key symbols.
Packit 3ff832
 *
Packit 3ff832
 * see_also: #IBusComponent, #IBusEngineDesc
Packit 3ff832
 *
Packit 3ff832
 */
Packit 3ff832
Packit 3ff832
#include "ibusobject.h"
Packit 3ff832
Packit 3ff832
/*
Packit 3ff832
 * Type macros.
Packit 3ff832
 */
Packit 3ff832
/* define IBusKeymap macros */
Packit 3ff832
#define IBUS_TYPE_KEYMAP             \
Packit 3ff832
    (ibus_keymap_get_type ())
Packit 3ff832
#define IBUS_KEYMAP(obj)             \
Packit 3ff832
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_KEYMAP, IBusKeymap))
Packit 3ff832
#define IBUS_KEYMAP_CLASS(klass)     \
Packit 3ff832
    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_KEYMAP, IBusKeymapClass))
Packit 3ff832
#define IBUS_IS_KEYMAP(obj)          \
Packit 3ff832
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_KEYMAP))
Packit 3ff832
#define IBUS_IS_KEYMAP_CLASS(klass)  \
Packit 3ff832
    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_KEYMAP))
Packit 3ff832
#define IBUS_KEYMAP_GET_CLASS(obj)   \
Packit 3ff832
    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_KEYMAP, IBusKeymapClass))
Packit 3ff832
Packit 3ff832
G_BEGIN_DECLS
Packit 3ff832
Packit 3ff832
typedef struct _IBusKeymap IBusKeymap;
Packit 3ff832
typedef struct _IBusKeymapClass IBusKeymapClass;
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * KEYMAP:
Packit 3ff832
 *
Packit 3ff832
 * Data structure for storing keymap.
Packit 3ff832
 * keymap[.][i]
Packit 3ff832
 * i:
Packit 3ff832
 *  0 - without modifer
Packit 3ff832
 *  1 - shift
Packit 3ff832
 *  2 - caplock
Packit 3ff832
 *  3 - shift caplock
Packit 3ff832
 *  4 - altgr
Packit 3ff832
 *  5 - shift altgr
Packit 3ff832
 *  6 - numlock
Packit 3ff832
 */
Packit 3ff832
/* typedef guint KEYMAP[256][7]; */
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * IBusKeymap:
Packit 3ff832
 * @name: The name of the keymap, such as 'us', 'jp'.
Packit 3ff832
 * @keymap: Keymap table. IME developers normally don have to touch this.
Packit 3ff832
 *
Packit 3ff832
 * A keymap object in IBus.
Packit 3ff832
 */
Packit 3ff832
struct _IBusKeymap {
Packit 3ff832
    /*< private >*/
Packit 3ff832
    IBusObject parent;
Packit 3ff832
    /* members */
Packit 3ff832
    /*< public >*/
Packit 3ff832
    gchar *name;
Packit 3ff832
    guint keymap[256][7];
Packit 3ff832
};
Packit 3ff832
Packit 3ff832
struct _IBusKeymapClass {
Packit 3ff832
    IBusObjectClass parent;
Packit 3ff832
};
Packit 3ff832
Packit 3ff832
GType            ibus_keymap_get_type               (void);
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_keymap_new:
Packit 3ff832
 * @name: The keymap file to be loaded, such as 'us', 'jp'.
Packit 3ff832
 *
Packit 3ff832
 * Get an #IBusKeymap associated with the giving name.
Packit 3ff832
 *
Packit 3ff832
 * This function loads the keymap file specified in @name
Packit 3ff832
 * in the IBUS_DATA_DIR/keymaps directory.
Packit 3ff832
 *
Packit 3ff832
 * Returns: An #IBusKeymap associated with the giving name; or %NULL if failed.
Packit 3ff832
 *
Packit 3ff832
 * Deprecated: This function has been deprecated and should
Packit 3ff832
 * not be used in newly written code. Please use ibus_keymap_get().
Packit 3ff832
 */
Packit 3ff832
IBusKeymap        *ibus_keymap_new                  (const gchar        *name)
Packit 3ff832
    G_GNUC_DEPRECATED;
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_keymap_get:
Packit 3ff832
 * @name: The keymap file to be loaded, such as 'us', 'jp'.
Packit 3ff832
 *
Packit 3ff832
 * Get an IBusKeymap associated with the giving name.
Packit 3ff832
 *
Packit 3ff832
 * This function loads the keymap file specified in @name
Packit 3ff832
 * in the IBUS_DATA_DIR/keymaps directory.
Packit 3ff832
 *
Packit 3ff832
 * Returns: (transfer full): An #IBusKeymap associated with the giving name;
Packit 3ff832
 * or %NULL if failed.
Packit 3ff832
 */
Packit 3ff832
IBusKeymap        *ibus_keymap_get                  (const gchar        *name);
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_keymap_lookup_keysym:
Packit 3ff832
 * @keymap: An IBusKeymap.
Packit 3ff832
 * @keycode: A scancode to be converted.
Packit 3ff832
 * @state: Modifier flags(such as Ctrl, Shift).
Packit 3ff832
 *
Packit 3ff832
 * Converts the scancode to keysym, given the keymap.
Packit 3ff832
 *
Packit 3ff832
 * Returns: Corresponding keysym.
Packit 3ff832
 */
Packit 3ff832
guint              ibus_keymap_lookup_keysym        (IBusKeymap         *keymap,
Packit 3ff832
                                                     guint16             keycode,
Packit 3ff832
                                                     guint32             state);
Packit 3ff832
Packit 3ff832
G_END_DECLS
Packit 3ff832
#endif
Packit 3ff832