From 28406315e212b93c354e177a08f2a4b8eab5099d Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 12 Feb 2016 18:15:27 +0100 Subject: [PATCH] working unicode x11 support --- main.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 79549c0..46d3bc8 100644 --- a/main.c +++ b/main.c @@ -67,11 +67,13 @@ int main (int argc, char** argv) { struct keysym* s = toscan (tmp); if (s == NULL) { fprintf (stderr, "Key Symbol not found.\n"); +fclose (hid_dev); return ERR_SYMBOL; } struct layout* l = tolay (s, atoi (argv[P_LAY])); if (l == NULL) { fprintf (stderr, "Unrecognised keyboard layout.\n"); +fclose (hid_dev); return ERR_LAYOUT; } if (l->key != 0x00) { @@ -84,7 +86,7 @@ int main (int argc, char** argv) { } } else { //key does not exist in this layout, use unicode method - fprintf (stderr, "Warning: Key not in this layout!\n"); + fprintf (stderr, "Warning: Key '%s'(0x%x) not in this layout!\n", s->sym, s->unicode); send_unicode (hid_dev, s->unicode, atoi (argv[P_UNI]), atoi(argv[P_LAY])); } } @@ -120,20 +122,31 @@ enum errors send_unicode (FILE* hid_dev, unsigned int unicode, enum uni_m method case SKIP: break; case GTK_HOLD: - fprintf (stderr, "Hold-down X11 not implemented!\n"); - return ERR_LAZY; - case GTK_SPACE: sprintf (buf, "%x", unicode); + fprintf (stderr, "attempting to send: %s", buf); s = toscan ("u"); l = tolay (s, layout); send_key (hid_dev, l->key, MOD_LCTRL | MOD_LSHIFT); for (int i = 0; i < strlen (buf); i++) { - s = toscan (buf); + s = toscan ((char[2]){buf[i], '\0'}); l = tolay (s, layout); send_key (hid_dev, l->key, MOD_LCTRL | MOD_LSHIFT); } send_key (hid_dev, '\0', '\0'); break; + case GTK_SPACE: + sprintf (buf, "%x ", unicode); + fprintf (stderr, "attempting to send: %s", buf); + s = toscan ("u"); + l = tolay (s, layout); + send_key (hid_dev, l->key, MOD_LCTRL | MOD_LSHIFT); + for (int i = 0; i < strlen (buf); i++) { + s = toscan ((char[2]){buf[i], '\0'}); + l = tolay (s, layout); + send_key (hid_dev, l->key, MOD_NONE); + } + send_key (hid_dev, '\0', '\0'); + break; case WINDOWS: fprintf (stderr, "windows method not implemented!\n"); return ERR_LAZY; -- 2.39.3