~ubuntu-branches/ubuntu/karmic/ibus/karmic-updates

« back to all changes in this revision

Viewing changes to src/test-keymap.c

  • Committer: Bazaar Package Importer
  • Author(s): LI Daobing
  • Date: 2009-07-23 20:22:09 UTC
  • mfrom: (1.1.4 upstream) (6.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090723202209-bmgqa80g1umg8l2p
Tags: 1.2.0.20090723-1
new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <linux/input.h>
 
2
#include <sys/types.h>
 
3
#include <sys/stat.h>
 
4
#include <fcntl.h>
 
5
#include <unistd.h>
 
6
#include "ibus.h"
 
7
 
 
8
#define KEYBOARDPATH "/dev/input/event4"
 
9
 
 
10
int main (int argc, char **argv)
 
11
{
 
12
    gint fd;
 
13
    struct input_event e;
 
14
 
 
15
    g_type_init ();
 
16
 
 
17
    IBusKeymap *keymap = ibus_keymap_new (argc > 1 ? argv[1] : "us");
 
18
 
 
19
    g_object_unref (keymap);
 
20
        return 0;
 
21
 
 
22
    fd = open (KEYBOARDPATH, O_RDONLY);
 
23
 
 
24
 
 
25
    while (fd >= 0 && read (fd, &e, sizeof (e)) == sizeof (e)) {
 
26
        if (e.type != EV_KEY)
 
27
            continue;
 
28
        if (e.value != 0)
 
29
            continue;
 
30
 
 
31
        g_debug ("=========================================================================");
 
32
        g_debug ("keycode = %d, %s %s %s %s %s", e.code,
 
33
                    ibus_keyval_name (ibus_keymap_lookup_keysym (keymap, e.code, 0)),
 
34
                    ibus_keyval_name (ibus_keymap_lookup_keysym (keymap, e.code, IBUS_SHIFT_MASK)),
 
35
                    ibus_keyval_name (ibus_keymap_lookup_keysym (keymap, e.code, IBUS_MOD5_MASK)),
 
36
                    ibus_keyval_name (ibus_keymap_lookup_keysym (keymap, e.code, IBUS_MOD5_MASK | IBUS_SHIFT_MASK)),
 
37
                    ibus_keyval_name (ibus_keymap_lookup_keysym (keymap, e.code, IBUS_MOD2_MASK))
 
38
        );
 
39
    }
 
40
 
 
41
    g_object_unref (keymap);
 
42
        return 0;
 
43
 
 
44
}