-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.2row.h
86 lines (75 loc) · 2.35 KB
/
config.2row.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
75
76
77
78
79
80
81
82
83
84
85
86
/* config.2row.h: alternative two octave layout */
enum {
MAX_OCTAVE = 8,
MIN_OCTAVE = 0,
};
static opcode_t keybinds[MAX_KEYCODE + 1];
struct SymBind {
KeySym key;
opcode_t opcode;
};
static struct SymBind symbinds[] = {
/* key opcode */
/* row 1 white keys */
{ XK_Z, OP_C },
{ XK_X, OP_D },
{ XK_C, OP_E },
{ XK_V, OP_F },
{ XK_B, OP_G },
{ XK_N, OP_A },
{ XK_M, OP_B },
{ XK_comma, OP_C + 12 }, /* next octave */
{ XK_period, OP_D + 12 },
{ XK_slash, OP_E + 12 },
/* row 1 black keys */
{ XK_S, OP_CSHARP },
{ XK_D, OP_DSHARP },
{ XK_G, OP_FSHARP },
{ XK_H, OP_GSHARP },
{ XK_J, OP_ASHARP },
{ XK_L, OP_CSHARP + 12 },
{ XK_semicolon, OP_DSHARP + 12 },
/* row 2 white keys */
{ XK_Q, OP_C + 12 },
{ XK_W, OP_D + 12 },
{ XK_E, OP_E + 12 },
{ XK_R, OP_F + 12 },
{ XK_T, OP_G + 12 },
{ XK_Y, OP_A + 12 },
{ XK_U, OP_B + 12 },
{ XK_I, OP_C + 24 }, /* next octave */
{ XK_O, OP_D + 24 },
{ XK_P, OP_E + 24 },
{ XK_bracketleft, OP_F + 24 },
{ XK_bracketright, OP_G + 24 },
/* row 2 black keys */
{ XK_2, OP_CSHARP + 12 },
{ XK_3, OP_DSHARP + 12 },
{ XK_5, OP_FSHARP + 12 },
{ XK_6, OP_GSHARP + 12 },
{ XK_7, OP_ASHARP + 12 },
{ XK_9, OP_CSHARP + 24 },
{ XK_0, OP_DSHARP + 24 },
{ XK_plus, OP_FSHARP + 24 },
/* function keys */
{ XK_Up, OP_INC_OCTAVE },
{ XK_Down, OP_DEC_OCTAVE },
{ XK_Right, OP_INC_VELOCITY },
{ XK_Left, OP_DEC_VELOCITY },
{ XK_F4, OP_INC_PROG },
{ XK_F3, OP_DEC_PROG },
{ XK_F2, OP_INC_BANK },
{ XK_F1, OP_DEC_BANK },
{ XK_Escape, OP_PANIC },
};
void
keybinds_init(Display *d)
{
size_t i;
for (i = 0; i < sizeof(keybinds)/sizeof(keybinds[0]); ++i) {
keybinds[i] = OP_INVALID;
}
for (i = 0; i < sizeof(symbinds)/sizeof(symbinds[0]); ++i) {
keybinds[XKeysymToKeycode(d, symbinds[i].key)] = symbinds[i].opcode;
}
}