-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeymap.h
74 lines (61 loc) · 1.6 KB
/
keymap.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
///
// keymap.h
// ========
//
// Contains methods for converting fsKey's to physical keys that can be
// queried for state.
//
// Mapped key definitions located in '/usr/include/linux/input-event-codes.h'.
///
#include <ctype.h>
#include <linux/input.h>
#define KEY_NONE (-1)
int strcmpi(const char *a, const char *b);
///
// Convert an fsKey string to a physical key.
//
// Notes:
// * Could use a perfect hashmap here.
///
static inline int fsKeyToPhysicalKey(const char *str)
{
#define S(x) M(x, x)
#define M(x, y) \
do { \
if (!strcmpi(#x, str)) \
return KEY_##y; \
} while (0)
// Number row
S(0); S(1); S(2); S(3); S(4); S(5); S(6); S(7); S(8); S(9);
// Letters
S(A); S(B); S(C); S(D); S(E); S(F); S(G); S(H); S(I); S(J); S(K); S(L); S(M);
S(N); S(O); S(P); S(Q); S(R); S(S); S(T); S(U); S(V); S(W); S(X); S(Y); S(Z);
// Special - just use the common ones
S(SPACE);
// Arrow keys
S(UP);
S(DOWN);
S(LEFT);
S(RIGHT);
S(SPACE);
M(LSHIFT, LEFTSHIFT);
M(RSHIFT, RIGHTSHIFT);
// Extra keys
M(EQUALS, EQUAL);
S(DELETE);
S(BACKSLASH);
S(COMMA);
M(ESCAPE, FN_ESC);
// Numpad
M(KP_0, KP0); M(KP_1, KP1); M(KP_2, KP2); M(KP_3, KP3); M(KP_4, KP4);
M(KP_5, KP5); M(KP_6, KP6); M(KP_7, KP7); M(KP_8, KP8); M(KP_9, KP9);
M(KP_ENTER, KPENTER);
M(KP_DIVIDE, KPSLASH);
M(KP_MINUS, KPMINUS);
M(KP_MULTIPLY, KPASTERISK);
M(KP_PLUS, KPPLUS);
M(KP_PERIOD, KPDOT);
return KEY_NONE;
#undef M
#undef S
}