re-done pcb for 30 pin oled
[hardpass.git] / send_hid / scancodes.c
CommitLineData
56339ab6 1// (C) 2016 Tobias Girstmair, released under the GNU GPL
2#include <string.h>
3#include "scancodes.h"
4
5struct keysym keysyms[] = {
6 [0] = {"", {0x00, 0x00}, {0x00, 0x00}},
7 //using [1]..[31] for non-ascii (utf-8) characters
8 [1] = {"ä", {0x00, 0x00}, {0x34, 0x00}, {0x34, 0x00}, .unicode = 0xe4},
9 {"Ä", {0x00, 0x00}, {0x34, 0x02}, {0x34, 0x02}, .unicode = 0xc4},
10 {"ö", {0x00, 0x00}, {0x33, 0x00}, {0x33, 0x00}, .unicode = 0xf6},
11 {"Ö", {0x00, 0x00}, {0x33, 0x02}, {0x33, 0x02}, .unicode = 0xd6},
12 {"ü", {0x00, 0x00}, {0x2f, 0x00}, {0x2f, 0x00}, .unicode = 0xfc},
13 {"Ü", {0x00, 0x00}, {0x2f, 0x02}, {0x2f, 0x02}, .unicode = 0xdc},
14 {"ß", {0x00, 0x00}, {0x2d, 0x00}, {0x2d, 0x00}, .unicode = 0xdf},
15 {"€", {0x00, 0x00}, {0x08, 0x40}, {0x08, 0x40}, .unicode = 0x20ac},
16 [9] = {"\t", {0x2b, 0x00}, {0x2b, 0x00}, {0x2b, 0x00}},
17 [10] = {"\n", {0x28, 0x00}, {0x28, 0x00}, {0x28, 0x00}},
18 {"µ", {0x00, 0x00}, {0x10, 0x40}, {0x10, 0x40}, .unicode = 0x3bc},
19 {"°", {0x00, 0x00}, {0x35, 0x02}, {0x35, 0x02}, .unicode = 0xb0},
20 {"§", {0x00, 0x00}, {0x20, 0x02}, {0x20, 0x02}, .unicode = 0xa7},
21 [32] = {" ", {0x2c, 0x00}, {0x2c, 0x00}, {0x2c, 0x00}},
22 {"!", {0x1e, 0x02}, {0x1e, 0x02}, {0x1e, 0x02}},
23 {"\"",{0x34, 0x02}, {0x1f, 0x02}, {0x1f, 0x02}},
24 {"#", {0x20, 0x02}, {0x31, 0x00}, {0x31, 0x00}},
25 {"$", {0x21, 0x02}, {0x21, 0x02}, {0x21, 0x02}},
26 {"%", {0x22, 0x02}, {0x22, 0x02}, {0x22, 0x02}},
27 {"&", {0x24, 0x02}, {0x23, 0x02}, {0x23, 0x02}},
28 {"'", {0x34, 0x00}, {0x31, 0x02}, {0x31, 0x02}},
29 {"(", {0x26, 0x02}, {0x25, 0x02}, {0x25, 0x02}},
30 {")", {0x27, 0x02}, {0x26, 0x02}, {0x26, 0x02}},
31 {"*", {0x25, 0x02}, {0x30, 0x02}, {0x30, 0x02}},
32 {"+", {0x2e, 0x02}, {0x30, 0x00}, {0x30, 0x00}},
33 {"´", {0x32, 0x00}, {0x2e, 0x00, .is_dead = 1}, {0x2e, 0x00}},
34 {"-", {0x2d, 0x00}, {0x38, 0x00}, {0x38, 0x00}},
35 {".", {0x37, 0x00}, {0x37, 0x00}, {0x37, 0x00}},
36 {"/", {0x38, 0x00}, {0x24, 0x02}, {0x24, 0x02}},
37 {"0", {0x27, 0x00}, {0x27, 0x00}, {0x27, 0x00}},
38 {"1", {0x1e, 0x00}, {0x1e, 0x00}, {0x1e, 0x00}},
39 {"2", {0x1f, 0x00}, {0x1f, 0x00}, {0x1f, 0x00}},
40 {"3", {0x20, 0x00}, {0x20, 0x00}, {0x20, 0x00}},
41 {"4", {0x21, 0x00}, {0x21, 0x00}, {0x21, 0x00}},
42 {"5", {0x22, 0x00}, {0x22, 0x00}, {0x22, 0x00}},
43 {"6", {0x23, 0x00}, {0x23, 0x00}, {0x23, 0x00}},
44 {"7", {0x24, 0x00}, {0x24, 0x00}, {0x24, 0x00}},
45 {"8", {0x25, 0x00}, {0x25, 0x00}, {0x25, 0x00}},
46 {"9", {0x26, 0x00}, {0x26, 0x00}, {0x26, 0x00}},
47 {":", {0x33, 0x02}, {0x37, 0x02}, {0x37, 0x02}},
48 {";", {0x33, 0x00}, {0x36, 0x02}, {0x36, 0x02}},
49 {"<", {0x36, 0x02}, {0x64, 0x00}, {0x64, 0x00}},
50 {"=", {0x2e, 0x00}, {0x27, 0x02}, {0x27, 0x02}},
51 {">", {0x37, 0x02}, {0x64, 0x02}, {0x64, 0x02}},
52 {"?", {0x38, 0x02}, {0x2d, 0x02}, {0x2d, 0x02}},
53 {"@", {0x1f, 0x02}, {0x14, 0x40}, {0x14, 0x40}},
54 {"A", {0x04, 0x02}, {0x04, 0x02}, {0x04, 0x02}},
55 {"B", {0x05, 0x02}, {0x05, 0x02}, {0x05, 0x02}},
56 {"C", {0x06, 0x02}, {0x06, 0x02}, {0x06, 0x02}},
57 {"D", {0x07, 0x02}, {0x07, 0x02}, {0x07, 0x02}},
58 {"E", {0x08, 0x02}, {0x08, 0x02}, {0x08, 0x02}},
59 {"F", {0x09, 0x02}, {0x09, 0x02}, {0x09, 0x02}},
60 {"G", {0x0a, 0x02}, {0x0a, 0x02}, {0x0a, 0x02}},
61 {"H", {0x0b, 0x02}, {0x0b, 0x02}, {0x0b, 0x02}},
62 {"I", {0x0c, 0x02}, {0x0c, 0x02}, {0x0c, 0x02}},
63 {"J", {0x0d, 0x02}, {0x0d, 0x02}, {0x0d, 0x02}},
64 {"K", {0x0e, 0x02}, {0x0e, 0x02}, {0x0e, 0x02}},
65 {"L", {0x0f, 0x02}, {0x0f, 0x02}, {0x0f, 0x02}},
66 {"M", {0x10, 0x02}, {0x10, 0x02}, {0x10, 0x02}},
67 {"N", {0x11, 0x02}, {0x11, 0x02}, {0x11, 0x02}},
68 {"O", {0x12, 0x02}, {0x12, 0x02}, {0x12, 0x02}},
69 {"P", {0x13, 0x02}, {0x13, 0x02}, {0x13, 0x02}},
70 {"Q", {0x14, 0x02}, {0x14, 0x02}, {0x14, 0x02}},
71 {"R", {0x15, 0x02}, {0x15, 0x02}, {0x15, 0x02}},
72 {"S", {0x16, 0x02}, {0x16, 0x02}, {0x16, 0x02}},
73 {"T", {0x17, 0x02}, {0x17, 0x02}, {0x17, 0x02}},
74 {"U", {0x18, 0x02}, {0x18, 0x02}, {0x18, 0x02}},
75 {"V", {0x19, 0x02}, {0x19, 0x02}, {0x19, 0x02}},
76 {"W", {0x1a, 0x02}, {0x1a, 0x02}, {0x1a, 0x02}},
77 {"X", {0x1b, 0x02}, {0x1b, 0x02}, {0x1b, 0x02}},
78 {"Y", {0x1c, 0x02}, {0x1d, 0x02}, {0x1d, 0x02}},
79 {"Z", {0x1d, 0x02}, {0x1c, 0x02}, {0x1c, 0x02}},
80 {"[", {0x2f, 0x00}, {0x25, 0x40}, {0x25, 0x40}},
81 {"\\",{0x31, 0x00}, {0x2d, 0x40}, {0x2d, 0x40}},
82 {"]", {0x30, 0x00}, {0x26, 0x40}, {0x26, 0x40}},
83 {"^", {0x23, 0x02}, {0x35, 0x00, .is_dead = 1}, {0x35, 0x00}},
84 {"_", {0x2d, 0x02}, {0x38, 0x02}, {0x38, 0x02}},
85 {"`", {0x35, 0x00}, {0x2e, 0x02, .is_dead = 1}, {0x2e, 0x02}},
86 {"a", {0x04, 0x00}, {0x04, 0x00}, {0x04, 0x00}},
87 {"b", {0x05, 0x00}, {0x05, 0x00}, {0x05, 0x00}},
88 {"c", {0x06, 0x00}, {0x06, 0x00}, {0x06, 0x00}},
89 {"d", {0x07, 0x00}, {0x07, 0x00}, {0x07, 0x00}},
90 {"e", {0x08, 0x00}, {0x08, 0x00}, {0x08, 0x00}},
91 {"f", {0x09, 0x00}, {0x09, 0x00}, {0x09, 0x00}},
92 {"g", {0x0a, 0x00}, {0x0a, 0x00}, {0x0a, 0x00}},
93 {"h", {0x0b, 0x00}, {0x0b, 0x00}, {0x0b, 0x00}},
94 {"i", {0x0c, 0x00}, {0x0c, 0x00}, {0x0c, 0x00}},
95 {"j", {0x0d, 0x00}, {0x0d, 0x00}, {0x0d, 0x00}},
96 {"k", {0x0e, 0x00}, {0x0e, 0x00}, {0x0e, 0x00}},
97 {"l", {0x0f, 0x00}, {0x0f, 0x00}, {0x0f, 0x00}},
98 {"m", {0x10, 0x00}, {0x10, 0x00}, {0x10, 0x00}},
99 {"n", {0x11, 0x00}, {0x11, 0x00}, {0x11, 0x00}},
100 {"o", {0x12, 0x00}, {0x12, 0x00}, {0x12, 0x00}},
101 {"p", {0x13, 0x00}, {0x13, 0x00}, {0x13, 0x00}},
102 {"q", {0x14, 0x00}, {0x14, 0x00}, {0x14, 0x00}},
103 {"r", {0x15, 0x00}, {0x15, 0x00}, {0x15, 0x00}},
104 {"s", {0x16, 0x00}, {0x16, 0x00}, {0x16, 0x00}},
105 {"t", {0x17, 0x00}, {0x17, 0x00}, {0x17, 0x00}},
106 {"u", {0x18, 0x00}, {0x18, 0x00}, {0x18, 0x00}},
107 {"v", {0x19, 0x00}, {0x19, 0x00}, {0x19, 0x00}},
108 {"w", {0x1a, 0x00}, {0x1a, 0x00}, {0x1a, 0x00}},
109 {"x", {0x1b, 0x00}, {0x1b, 0x00}, {0x1b, 0x00}},
110 {"y", {0x1c, 0x00}, {0x1d, 0x00}, {0x1d, 0x00}},
111 {"z", {0x1d, 0x00}, {0x1c, 0x00}, {0x1c, 0x00}},
112 {"{", {0x2f, 0x02}, {0x2f, 0x02}, {0x24, 0x40}},
113 {"|", {0x31, 0x02}, {0x64, 0x40}, {0x64, 0x40}},
114 {"}", {0x30, 0x02}, {0x27, 0x40}, {0x27, 0x40}},
115 {"~", {0x35, 0x02}, {0x30, 0x40}, {0x30, 0x40}}
116};
117
118struct keysym* toscan (const char* utf8) {
119 if (utf8[1] == '\0') return &(keysyms[(int)utf8[0]]); //if char is not wide, it is on the corrent ascii position in the look up table
120 for (int i = 0; i < sizeof (keysyms)/sizeof (struct keysym); i++) {
121 if (strcmp (keysyms[i].sym, utf8) == 0) {
122 return &(keysyms[i]);
123 }
124 }
125 return NULL; // error
126}
127
128struct layout* tolay (struct keysym* s, enum kbdl layout) {
129 switch (layout) {
130 case en_US: return &(s->en_us);
131 case de_AT: return &(s->de_at);
132 case de_ND: return &(s->de_nd);
133 default: return NULL;
134 }
135}
Imprint / Impressum