Git init
[platform/core/uifw/e17.git] / src / modules / illume-keyboard / e_kbd_send.c
1 #include "e.h"
2 #include "e_kbd_send.h"
3
4 static const char *
5 _string_to_keysym(const char *str)
6 {
7    int glyph;
8
9    /* utf8 -> glyph id (unicode - ucs4) */
10    glyph = 0;
11    evas_string_char_next_get(str, 0, &glyph);
12    if (glyph <= 0) return NULL;
13    /* glyph id -> keysym */
14    if (glyph > 0xff) glyph |= 0x1000000;
15    return ecore_x_keysym_string_get(glyph);
16 }
17
18 EAPI void
19 e_kbd_send_string_press(const char *str, Kbd_Mod mod)
20 {
21    const char *key = NULL;
22
23    key = _string_to_keysym(str);
24    if (!key) return;
25    e_kbd_send_keysym_press(key, mod);
26 }
27
28 EAPI void
29 e_kbd_send_keysym_press(const char *key, Kbd_Mod mod)
30 {
31    if (mod & KBD_MOD_CTRL) ecore_x_test_fake_key_down("Control_L");
32    if (mod & KBD_MOD_ALT) ecore_x_test_fake_key_down("Alt_L");
33    if (mod & KBD_MOD_WIN) ecore_x_test_fake_key_down("Super_L");
34    ecore_x_test_fake_key_press(key);
35    if (mod & KBD_MOD_WIN) ecore_x_test_fake_key_up("Super_L");
36    if (mod & KBD_MOD_ALT) ecore_x_test_fake_key_up("Alt_L");
37    if (mod & KBD_MOD_CTRL) ecore_x_test_fake_key_up("Control_L");
38 }