-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlayout.h
76 lines (58 loc) · 1.04 KB
/
layout.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
#pragma once
#include <string_view>
#include <vector>
struct KeyInfo {
std::string_view name;
int code;
std::string_view altName{};
int altCode = 0;
int width = 1;
int longPressCode = 0;
};
struct Layout {
std::vector<std::vector<KeyInfo>> rows;
std::size_t numRows() const { return rows.size(); }
std::size_t numCols() const;
};
enum SpecialKeys {
Escape = 0x1000000,
Tab,
Backspace,
Enter,
Del,
Home,
End,
Left,
Up,
Right,
Down,
PageUp,
PageDown,
Mod1,
Mod2,
Callback = 0x1100000,
};
inline bool
isCallback(int code) {
return (code & Callback) == Callback;
}
inline int
getCallback(int code) {
return code & 0x00fffff;
}
inline int
makeCallback(int num) {
return num | Callback;
}
enum ModifierKeys {
Shift = 0x2000000,
Ctrl = 0x4000000,
Alt = 0x8000000,
};
extern const Layout qwerty_layout;
extern const Layout hidden_layout;
extern const Layout empty_layout;
const std::initializer_list<std::pair<std::string_view, const Layout*>>
layouts = {
{ "qwerty", &qwerty_layout },
};