From 498b6eddd3f4c78b38677fd65d3ad25afbd1b85a Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 12 Feb 2016 17:39:45 +0100 Subject: [PATCH] restructuring and more unicode --- main.c | 154 ++++++++++++++++++++++++------------- scancodes.c | 215 ++++++++++++++++++++++++++-------------------------- scancodes.h | 13 +++- 3 files changed, 222 insertions(+), 160 deletions(-) diff --git a/main.c b/main.c index 00157ee..c225792 100644 --- a/main.c +++ b/main.c @@ -11,20 +11,42 @@ parameters: #include #include "scancodes.h" -//argv-indices -#define P_EXE 0 //executable name -#define P_DEV 1 //device file -#define P_LAY 2 //layout -#define P_UNI 3//unicode method -#define P_STR 4 //string to type -#define NUM_P P_STR+1 //number of parameters +enum params = {//argv-indices: + P_EXE, //executable name + P_DEV, //device file + P_LAY, //layout + P_UNI, //unicode method + P_STR, //string to type + NUM_P //number of parameters +}; +enum kbdl = { //keyboard layouts: + na_NA, //reserved + en_US, + de_AT, + de_ND //de_AT-nodeadkeys +}; +enum uni_m = {//unicode methods: + SKIP, //ignore any keys not on the layout + GTK_HOLD, //hold ctrl and shift while entering hex values + GTK_SPACE, //end hex sequence with spacebar + WINDOWS //use alt+numpad +}; +enum errors = { + ERR_SUCCESS, //no error + ERR_ARGCOUNT, //wrong number of arguments + ERR_SYMBOL, //symbol not in look up table + ERR_LAYOUT, //parameter P_LAY does not contain a correct keyboard layout + ERR_LAZY //i haven't done this +}; void send_key (FILE* hid_dev, unsigned short key, unsigned short mod); +struct layout* tolay (struct keysym* s, enum kbdl layout); +enum errors send_unicode (FILE* hid_dev, unsigned int unicode, enum uni_m method, enum kbdl layout); int main (int argc, char** argv) { if (argc != NUM_P) { fprintf (stderr, "Usage: %s \"\"\n", argv[P_EXE]); - return 1; + return ERR_ARGCOUNT; } FILE* hid_dev = fopen ("/dev/hidg0", "w"); for (int i = 0; i < strlen (argv[P_STR]); i++) { @@ -45,52 +67,14 @@ int main (int argc, char** argv) { struct keysym* s = toscan (tmp); if (s == NULL) { fprintf (stderr, "Key Symbol not found.\n"); - return 1; + return ERR_SYMBOL; } - struct layout* l; - int ignore_deadkey = 0; - switch (atoi (argv[P_LAY])) { - case 0: - fprintf (stderr, "This keyboard layout is reserved.\n"); - return 1; - case 1: //en_us - l = &(s->en_us); - break; - case 2: //de_at - l = &(s->de_at); - break; - case 3: //de_at-nodeadkeys - l = &(s->de_at); - ignore_deadkey = 1; - break; - default: + struct layout* l = tolay (s, atoi (argv[P_LAY])); + if (l == NULL) { fprintf (stderr, "Unrecognised keyboard layout.\n"); - return 1; + return ERR_LAYOUT; } - if (l->key == 0x00) { - //key does not exist in this layout - fprintf (stderr, "Key not in this layout!\n"); - /*TODO: send unicode sequence - there are different methods to be used for gtk and - winblows. ctrl-shift-u-HEX vs. ctrl-shift-u,HEX,SPACE - vs. alt+NUMPAD vs. alt+'+'+HEX - */ - switch (atoi (argv[P_UNI])) { - case 0: //skip unicode character entry - break; - case 1: //gtk: hold ctrl and shift while entering - //TODO - break; - case 2: //gtk: use space as end marker for unicode - //TODO - case 3: //windows: alt+numpad (decimal) - //TODO - break; - default: - fprintf (stderr, "Unicode Method unknown!\n"); - return 1; - } - } else { + if (l->key != 0x00) { send_key(hid_dev, l->key, l->mod); send_key(hid_dev, '\0', '\0'); //release all keys if (l->is_dead && !ignore_deadkey) { @@ -98,13 +82,79 @@ int main (int argc, char** argv) { send_key(hid_dev, l->key, l->mod); send_key(hid_dev, '\0', '\0'); //release all keys } + } else { + //key does not exist in this layout, use unicode method + fprintf (stderr, "Warning: Key not in this layout!\n"); + send_unicode (s-> unicode, atoi (argv[P_UNI]); } } fclose (hid_dev); - return 0; + return ERR_SUCCESS; } +struct layout* get_layout (struct keysym* s, enum kbdl layout) { + switch (layout) { + case na_NA: + fprintf (stderr, "This keyboard layout is reserved.\n"); + return NULL; + case en_US: + return &(s->en_us); + case de_AT: + return &(s->de_at); + case de_ND: + return &(s->de_at); + default: + fprintf (stderr, "Unrecognised keyboard layout.\n"); + return NULL; + } + void send_key (FILE* hid_dev, unsigned short key, unsigned short mod) { fprintf (hid_dev, "%c%c%c%c%c%c%c%c", mod, '\0', key, '\0', '\0', '\0', '\0', '\0'); } + +struct layout* tolay (struct keysym* s, enum kbdl layout) { + switch (layout) { + case en_US: return &(s->en_us); + case de_AT: return &(s->de_at); + case de_ND: return &(s->de_nd); + default: return NULL; + } +} + +enum errors send_unicode (FILE* hid_dev, unsigned int unicode, enum uni_m method, enum kbdl layout) { + char buf[10]; + struct keysym* s; + struct layout* l; + + if (unicode == 0x00) { + printf ("Symbol not in lookup table!\n"); + return ERR_SYMBOL; + } + + switch (method) { + case SKIP: + break; + case GTK_HOLD: + fprintf ("Hold-down X11 not implemented!\n"); + return ERR_LAZY; + case GTK_SPACE: + sprintf (string, "%x", unicode); + s = toscan ("u"); + l = tolay (s, layout); + send_key (hid_dev, l->key, MOD_LCTRL | MOD_LSHIFT); + for (int i = 0; i < strlen (string); i++) { + s = toscan (string); + l = tolay (s, layout); + send_key (hid_dev, l->key, MOD_LCTRL | MOD_LSHIFT); + } + send_key (hid_dev, '\0', '\0'); + break; + case WINDOWS: + fprintf ("windows method not implemented!\n"); + return ERR_LAZY; + default: + fprintf ("unknown unicode method!\n"); + return ERR_LAYOUT; //TODO: better error code + } +} diff --git a/scancodes.c b/scancodes.c index 1f6592e..93551f9 100644 --- a/scancodes.c +++ b/scancodes.c @@ -2,113 +2,114 @@ #include "scancodes.h" struct keysym keysyms[] = { - /*[0] = {"", {NULL, NULL}, {NULL, NULL}},*/ - [1] = {"ä", {0x00, 0x00}, {0x34, 0x00}, .unicode = 0xe4}, - {"Ä", {0x00, 0x00}, {0x34, 0x02}, .unicode = 0xc4}, - {"ö", {0x00, 0x00}, {0x33, 0x00}, .unicode = 0xf6}, - {"Ö", {0x00, 0x00}, {0x33, 0x02}, .unicode = 0xd6}, - {"ü", {0x00, 0x00}, {0x2f, 0x00}, .unicode = 0xfc}, - {"Ü", {0x00, 0x00}, {0x2f, 0x02}, .unicode = 0xdc}, - {"ß", {0x00, 0x00}, {0x2d, 0x00}, .unicode = 0xdf}, - {"€", {0x00, 0x00}, {0x08, 0x40}, .unicode = 0x20ac}, - {"µ", {0x00, 0x00}, {0x10, 0x40}, .unicode = 0x3bc}, - {"°", {0x00, 0x00}, {0x35, 0x02}, .unicode = 0xb0}, - {"§", {0x00, 0x00}, {0x20, 0x02}, .unicode = 0xa7}, - [32] = {" ", {0x2c, 0x00}, {0x2c, 0x00}}, - {"!", {0x1e, 0x02}, {0x1e, 0x02}}, - {"\"",{0x34, 0x02}, {0x1f, 0x02}}, - {"#", {0x20, 0x02}, {0x31, 0x00}}, - {"$", {0x21, 0x02}, {0x21, 0x02}}, - {"%", {0x22, 0x02}, {0x22, 0x02}}, - {"&", {0x24, 0x02}, {0x23, 0x02}}, - {"'", {0x34, 0x00}, {0x31, 0x02}}, - {"(", {0x26, 0x02}, {0x25, 0x02}}, - {")", {0x27, 0x02}, {0x26, 0x02}}, - {"*", {0x25, 0x02}, {0x30, 0x02}}, - {"+", {0x2e, 0x02}, {0x30, 0x00}}, - {"´", {0x32, 0x00}, {0x2e, 0x00, 1}}, - {"-", {0x2d, 0x00}, {0x38, 0x00}}, - {".", {0x37, 0x00}, {0x37, 0x00}}, - {"/", {0x38, 0x00}, {0x24, 0x02}}, - {"0", {0x27, 0x00}, {0x27, 0x00}}, - {"1", {0x1e, 0x00}, {0x1e, 0x00}}, - {"2", {0x1f, 0x00}, {0x1f, 0x00}}, - {"3", {0x20, 0x00}, {0x20, 0x00}}, - {"4", {0x21, 0x00}, {0x21, 0x00}}, - {"5", {0x22, 0x00}, {0x22, 0x00}}, - {"6", {0x23, 0x00}, {0x23, 0x00}}, - {"7", {0x24, 0x00}, {0x24, 0x00}}, - {"8", {0x25, 0x00}, {0x25, 0x00}}, - {"9", {0x26, 0x00}, {0x26, 0x00}}, - {":", {0x33, 0x02}, {0x37, 0x02}}, - {";", {0x33, 0x00}, {0x36, 0x02}}, - {"<", {0x36, 0x02}, {0x64, 0x00}}, - {"=", {0x2e, 0x00}, {0x27, 0x02}}, - {">", {0x37, 0x02}, {0x64, 0x02}}, - {"?", {0x38, 0x02}, {0x2d, 0x02}}, - {"@", {0x1f, 0x02}, {0x14, 0x40}}, - {"A", {0x04, 0x02}, {0x04, 0x02}}, - {"B", {0x05, 0x02}, {0x05, 0x02}}, - {"C", {0x06, 0x02}, {0x06, 0x02}}, - {"D", {0x07, 0x02}, {0x07, 0x02}}, - {"E", {0x08, 0x02}, {0x08, 0x02}}, - {"F", {0x09, 0x02}, {0x09, 0x02}}, - {"G", {0x0a, 0x02}, {0x0a, 0x02}}, - {"H", {0x0b, 0x02}, {0x0b, 0x02}}, - {"I", {0x0c, 0x02}, {0x0c, 0x02}}, - {"J", {0x0d, 0x02}, {0x0d, 0x02}}, - {"K", {0x0e, 0x02}, {0x0e, 0x02}}, - {"L", {0x0f, 0x02}, {0x0f, 0x02}}, - {"M", {0x10, 0x02}, {0x10, 0x02}}, - {"N", {0x11, 0x02}, {0x11, 0x02}}, - {"O", {0x12, 0x02}, {0x12, 0x02}}, - {"P", {0x13, 0x02}, {0x13, 0x02}}, - {"Q", {0x14, 0x02}, {0x14, 0x02}}, - {"R", {0x15, 0x02}, {0x15, 0x02}}, - {"S", {0x16, 0x02}, {0x16, 0x02}}, - {"T", {0x17, 0x02}, {0x17, 0x02}}, - {"U", {0x18, 0x02}, {0x18, 0x02}}, - {"V", {0x19, 0x02}, {0x19, 0x02}}, - {"W", {0x1a, 0x02}, {0x1a, 0x02}}, - {"X", {0x1b, 0x02}, {0x1b, 0x02}}, - {"Y", {0x1c, 0x02}, {0x1d, 0x02}}, - {"Z", {0x1d, 0x02}, {0x1c, 0x02}}, - {"[", {0x2f, 0x00}, {0x25, 0x40}}, - {"\\",{0x31, 0x00}, {0x2d, 0x40}}, - {"]", {0x30, 0x00}, {0x26, 0x40}}, - {"^", {0x23, 0x02}, {0x35, 0x00, 1}}, - {"_", {0x2d, 0x02}, {0x38, 0x02}}, - {"`", {0x35, 0x00}, {0x2e, 0x02, 1}}, - {"a", {0x04, 0x00}, {0x04, 0x00}}, - {"b", {0x05, 0x00}, {0x05, 0x00}}, - {"c", {0x06, 0x00}, {0x06, 0x00}}, - {"d", {0x07, 0x00}, {0x07, 0x00}}, - {"e", {0x08, 0x00}, {0x08, 0x00}}, - {"f", {0x09, 0x00}, {0x09, 0x00}}, - {"g", {0x0a, 0x00}, {0x0a, 0x00}}, - {"h", {0x0b, 0x00}, {0x0b, 0x00}}, - {"i", {0x0c, 0x00}, {0x0c, 0x00}}, - {"j", {0x0d, 0x00}, {0x0d, 0x00}}, - {"k", {0x0e, 0x00}, {0x0e, 0x00}}, - {"l", {0x0f, 0x00}, {0x0f, 0x00}}, - {"m", {0x10, 0x00}, {0x10, 0x00}}, - {"n", {0x11, 0x00}, {0x11, 0x00}}, - {"o", {0x12, 0x00}, {0x12, 0x00}}, - {"p", {0x13, 0x00}, {0x13, 0x00}}, - {"q", {0x14, 0x00}, {0x14, 0x00}}, - {"r", {0x15, 0x00}, {0x15, 0x00}}, - {"s", {0x16, 0x00}, {0x16, 0x00}}, - {"t", {0x17, 0x00}, {0x17, 0x00}}, - {"u", {0x18, 0x00}, {0x18, 0x00}}, - {"v", {0x19, 0x00}, {0x19, 0x00}}, - {"w", {0x1a, 0x00}, {0x1a, 0x00}}, - {"x", {0x1b, 0x00}, {0x1b, 0x00}}, - {"y", {0x1c, 0x00}, {0x1d, 0x00}}, - {"z", {0x1d, 0x00}, {0x1c, 0x00}}, - {"{", {0x2f, 0x02}, {0x24, 0x40}}, - {"|", {0x31, 0x02}, {0x64, 0x40}}, - {"}", {0x30, 0x02}, {0x27, 0x40}}, - {"~", {0x35, 0x02}, {0x30, 0x40}} + [0] = {"", {0x00, 0x00}, {0x00, 0x00}}, + //using [1]..[31] for non-ascii (utf-8) characters + [1] = {"ä", {0x00, 0x00}, {0x34, 0x00}, {0x34, 0x00}, .unicode = 0xe4}, + {"Ä", {0x00, 0x00}, {0x34, 0x02}, {0x34, 0x02}, .unicode = 0xc4}, + {"ö", {0x00, 0x00}, {0x33, 0x00}, {0x33, 0x00}, .unicode = 0xf6}, + {"Ö", {0x00, 0x00}, {0x33, 0x02}, {0x33, 0x02}, .unicode = 0xd6}, + {"ü", {0x00, 0x00}, {0x2f, 0x00}, {0x2f, 0x00}, .unicode = 0xfc}, + {"Ü", {0x00, 0x00}, {0x2f, 0x02}, {0x2f, 0x02}, .unicode = 0xdc}, + {"ß", {0x00, 0x00}, {0x2d, 0x00}, {0x2d, 0x00}, .unicode = 0xdf}, + {"€", {0x00, 0x00}, {0x08, 0x40}, {0x08, 0x40}, .unicode = 0x20ac}, + {"µ", {0x00, 0x00}, {0x10, 0x40}, {0x10, 0x40}, .unicode = 0x3bc}, + {"°", {0x00, 0x00}, {0x35, 0x02}, {0x35, 0x02}, .unicode = 0xb0}, + {"§", {0x00, 0x00}, {0x20, 0x02}, {0x20, 0x02}, .unicode = 0xa7}, + [32] = {" ", {0x2c, 0x00}, {0x2c, 0x00}, {0x2c, 0x00}}, + {"!", {0x1e, 0x02}, {0x1e, 0x02}, {0x1e, 0x02}}, + {"\"",{0x34, 0x02}, {0x1f, 0x02}, {0x1f, 0x02}}, + {"#", {0x20, 0x02}, {0x31, 0x00}, {0x31, 0x00}}, + {"$", {0x21, 0x02}, {0x21, 0x02}, {0x21, 0x02}}, + {"%", {0x22, 0x02}, {0x22, 0x02}, {0x22, 0x02}}, + {"&", {0x24, 0x02}, {0x23, 0x02}, {0x23, 0x02}}, + {"'", {0x34, 0x00}, {0x31, 0x02}, {0x31, 0x02}}, + {"(", {0x26, 0x02}, {0x25, 0x02}, {0x25, 0x02}}, + {")", {0x27, 0x02}, {0x26, 0x02}, {0x26, 0x02}}, + {"*", {0x25, 0x02}, {0x30, 0x02}, {0x30, 0x02}}, + {"+", {0x2e, 0x02}, {0x30, 0x00}, {0x30, 0x00}}, + {"´", {0x32, 0x00}, {0x2e, 0x00, .is_dead = 1}, {0x2e, 0x00}}, + {"-", {0x2d, 0x00}, {0x38, 0x00}, {0x38, 0x00}}, + {".", {0x37, 0x00}, {0x37, 0x00}, {0x37, 0x00}}, + {"/", {0x38, 0x00}, {0x24, 0x02}, {0x24, 0x02}}, + {"0", {0x27, 0x00}, {0x27, 0x00}, {0x27, 0x00}}, + {"1", {0x1e, 0x00}, {0x1e, 0x00}, {0x1e, 0x00}}, + {"2", {0x1f, 0x00}, {0x1f, 0x00}, {0x1f, 0x00}}, + {"3", {0x20, 0x00}, {0x20, 0x00}, {0x20, 0x00}}, + {"4", {0x21, 0x00}, {0x21, 0x00}, {0x21, 0x00}}, + {"5", {0x22, 0x00}, {0x22, 0x00}, {0x22, 0x00}}, + {"6", {0x23, 0x00}, {0x23, 0x00}, {0x23, 0x00}}, + {"7", {0x24, 0x00}, {0x24, 0x00}, {0x24, 0x00}}, + {"8", {0x25, 0x00}, {0x25, 0x00}, {0x25, 0x00}}, + {"9", {0x26, 0x00}, {0x26, 0x00}, {0x26, 0x00}}, + {":", {0x33, 0x02}, {0x37, 0x02}, {0x37, 0x02}}, + {";", {0x33, 0x00}, {0x36, 0x02}, {0x36, 0x02}}, + {"<", {0x36, 0x02}, {0x64, 0x00}, {0x64, 0x00}}, + {"=", {0x2e, 0x00}, {0x27, 0x02}, {0x27, 0x02}}, + {">", {0x37, 0x02}, {0x64, 0x02}, {0x64, 0x02}}, + {"?", {0x38, 0x02}, {0x2d, 0x02}, {0x2d, 0x02}}, + {"@", {0x1f, 0x02}, {0x14, 0x40}, {0x14, 0x40}}, + {"A", {0x04, 0x02}, {0x04, 0x02}, {0x04, 0x02}}, + {"B", {0x05, 0x02}, {0x05, 0x02}, {0x05, 0x02}}, + {"C", {0x06, 0x02}, {0x06, 0x02}, {0x06, 0x02}}, + {"D", {0x07, 0x02}, {0x07, 0x02}, {0x07, 0x02}}, + {"E", {0x08, 0x02}, {0x08, 0x02}, {0x08, 0x02}}, + {"F", {0x09, 0x02}, {0x09, 0x02}, {0x09, 0x02}}, + {"G", {0x0a, 0x02}, {0x0a, 0x02}, {0x0a, 0x02}}, + {"H", {0x0b, 0x02}, {0x0b, 0x02}, {0x0b, 0x02}}, + {"I", {0x0c, 0x02}, {0x0c, 0x02}, {0x0c, 0x02}}, + {"J", {0x0d, 0x02}, {0x0d, 0x02}, {0x0d, 0x02}}, + {"K", {0x0e, 0x02}, {0x0e, 0x02}, {0x0e, 0x02}}, + {"L", {0x0f, 0x02}, {0x0f, 0x02}, {0x0f, 0x02}}, + {"M", {0x10, 0x02}, {0x10, 0x02}, {0x10, 0x02}}, + {"N", {0x11, 0x02}, {0x11, 0x02}, {0x11, 0x02}}, + {"O", {0x12, 0x02}, {0x12, 0x02}, {0x12, 0x02}}, + {"P", {0x13, 0x02}, {0x13, 0x02}, {0x13, 0x02}}, + {"Q", {0x14, 0x02}, {0x14, 0x02}, {0x14, 0x02}}, + {"R", {0x15, 0x02}, {0x15, 0x02}, {0x15, 0x02}}, + {"S", {0x16, 0x02}, {0x16, 0x02}, {0x16, 0x02}}, + {"T", {0x17, 0x02}, {0x17, 0x02}, {0x17, 0x02}}, + {"U", {0x18, 0x02}, {0x18, 0x02}, {0x18, 0x02}}, + {"V", {0x19, 0x02}, {0x19, 0x02}, {0x19, 0x02}}, + {"W", {0x1a, 0x02}, {0x1a, 0x02}, {0x1a, 0x02}}, + {"X", {0x1b, 0x02}, {0x1b, 0x02}, {0x1b, 0x02}}, + {"Y", {0x1c, 0x02}, {0x1d, 0x02}, {0x1d, 0x02}}, + {"Z", {0x1d, 0x02}, {0x1c, 0x02}, {0x1c, 0x02}}, + {"[", {0x2f, 0x00}, {0x25, 0x40}, {0x25, 0x40}}, + {"\\",{0x31, 0x00}, {0x2d, 0x40}, {0x2d, 0x40}}, + {"]", {0x30, 0x00}, {0x26, 0x40}, {0x26, 0x40}}, + {"^", {0x23, 0x02}, {0x35, 0x00, .is_dead = 1}, {0x35, 0x00}}, + {"_", {0x2d, 0x02}, {0x38, 0x02}, {0x38, 0x02}}, + {"`", {0x35, 0x00}, {0x2e, 0x02, .is_dead = 1}, {0x2e, 0x02}}, + {"a", {0x04, 0x00}, {0x04, 0x00}, {0x04, 0x00}}, + {"b", {0x05, 0x00}, {0x05, 0x00}, {0x05, 0x00}}, + {"c", {0x06, 0x00}, {0x06, 0x00}, {0x06, 0x00}}, + {"d", {0x07, 0x00}, {0x07, 0x00}, {0x07, 0x00}}, + {"e", {0x08, 0x00}, {0x08, 0x00}, {0x08, 0x00}}, + {"f", {0x09, 0x00}, {0x09, 0x00}, {0x09, 0x00}}, + {"g", {0x0a, 0x00}, {0x0a, 0x00}, {0x0a, 0x00}}, + {"h", {0x0b, 0x00}, {0x0b, 0x00}, {0x0b, 0x00}}, + {"i", {0x0c, 0x00}, {0x0c, 0x00}, {0x0c, 0x00}}, + {"j", {0x0d, 0x00}, {0x0d, 0x00}, {0x0d, 0x00}}, + {"k", {0x0e, 0x00}, {0x0e, 0x00}, {0x0e, 0x00}}, + {"l", {0x0f, 0x00}, {0x0f, 0x00}, {0x0f, 0x00}}, + {"m", {0x10, 0x00}, {0x10, 0x00}, {0x10, 0x00}}, + {"n", {0x11, 0x00}, {0x11, 0x00}, {0x11, 0x00}}, + {"o", {0x12, 0x00}, {0x12, 0x00}, {0x12, 0x00}}, + {"p", {0x13, 0x00}, {0x13, 0x00}, {0x13, 0x00}}, + {"q", {0x14, 0x00}, {0x14, 0x00}, {0x14, 0x00}}, + {"r", {0x15, 0x00}, {0x15, 0x00}, {0x15, 0x00}}, + {"s", {0x16, 0x00}, {0x16, 0x00}, {0x16, 0x00}}, + {"t", {0x17, 0x00}, {0x17, 0x00}, {0x17, 0x00}}, + {"u", {0x18, 0x00}, {0x18, 0x00}, {0x18, 0x00}}, + {"v", {0x19, 0x00}, {0x19, 0x00}, {0x19, 0x00}}, + {"w", {0x1a, 0x00}, {0x1a, 0x00}, {0x1a, 0x00}}, + {"x", {0x1b, 0x00}, {0x1b, 0x00}, {0x1b, 0x00}}, + {"y", {0x1c, 0x00}, {0x1d, 0x00}, {0x1d, 0x00}}, + {"z", {0x1d, 0x00}, {0x1c, 0x00}, {0x1c, 0x00}}, + {"{", {0x2f, 0x02}, {0x2f, 0x02}, {0x24, 0x40}}, + {"|", {0x31, 0x02}, {0x64, 0x40}, {0x64, 0x40}}, + {"}", {0x30, 0x02}, {0x27, 0x40}, {0x27, 0x40}}, + {"~", {0x35, 0x02}, {0x30, 0x40}, {0x30, 0x40}} }; struct keysym* toscan (const char* utf8) { diff --git a/scancodes.h b/scancodes.h index b4e461f..85dbcfa 100644 --- a/scancodes.h +++ b/scancodes.h @@ -3,6 +3,16 @@ #define UTF8_MAX_LENGTH 4 +#define MOD_NONE 0 +#define MOD_LCTRL 1<<0 +#define MOD_LSHIFT 1<<1 +#define MOD_LALT 1<<2 +#define MOD_LSUPER 1<<3 +#define MOD_RCTRL 1<<4 +#define MOD_RSHIFT 1<<5 +#define MOD_RALT 1<<6 +#define MOD_RSUPER 1<<7 + struct layout { unsigned short key; //scancode of normal key //if this is NULL, the key does not exist in this layout. @@ -13,7 +23,8 @@ struct keysym { char sym [UTF8_MAX_LENGTH]; //utf-8 encoded key symbol struct layout en_us; //substructure for this layout struct layout de_at; - long int unicode; //the unicode number to send via alt+numpad or ^U if char is not available in a keyboard layout + struct layout de_nd; + unsigned int unicode; //the unicode number to send via alt+numpad or ^U if char is not available in a keyboard layout }; struct keysym* toscan (const char* utf8);//returns the layout struct of a keysym -- 2.39.3