summaryrefslogtreecommitdiff
path: root/src/modules/illume-keyboard/e_kbd_send.c
blob: a56563646caa2186f8ef8be324b6a2e6c512de47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "e.h"
#include "e_kbd_send.h"

static const char *
_string_to_keysym(const char *str)
{
   int glyph;

   /* utf8 -> glyph id (unicode - ucs4) */
   glyph = 0;
   evas_string_char_next_get(str, 0, &glyph);
   if (glyph <= 0) return NULL;
   /* glyph id -> keysym */
   if (glyph > 0xff) glyph |= 0x1000000;
   return ecore_x_keysym_string_get(glyph);
}

EAPI void
e_kbd_send_string_press(const char *str, Kbd_Mod mod)
{
   const char *key = NULL;

   key = _string_to_keysym(str);
   if (!key) return;
   e_kbd_send_keysym_press(key, mod);
}

EAPI void
e_kbd_send_keysym_press(const char *key, Kbd_Mod mod)
{
   if (mod & KBD_MOD_CTRL) ecore_x_test_fake_key_down("Control_L");
   if (mod & KBD_MOD_ALT) ecore_x_test_fake_key_down("Alt_L");
   if (mod & KBD_MOD_WIN) ecore_x_test_fake_key_down("Super_L");
   ecore_x_test_fake_key_press(key);
   if (mod & KBD_MOD_WIN) ecore_x_test_fake_key_up("Super_L");
   if (mod & KBD_MOD_ALT) ecore_x_test_fake_key_up("Alt_L");
   if (mod & KBD_MOD_CTRL) ecore_x_test_fake_key_up("Control_L");
}