-
Notifications
You must be signed in to change notification settings - Fork 1
/
code_map.py
111 lines (104 loc) · 1.94 KB
/
code_map.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
code_map = {
"Clear": -1,
"Switch": -2,
"Undef": -3,
"X2": -4,
"Esc": 1,
"1": 2,
"2": 3,
"3": 4,
"4": 5,
"5": 6,
"6": 7,
"7": 8,
"8": 9,
"9": 10,
"0": 11,
"-": 12,
"=": 13,
"BS": 14,
"Tab": 15,
"Q": 16,
"W": 17,
"E": 18,
"R": 19,
"T": 20,
"Y": 21,
"U": 22,
"I": 23,
"O": 24,
"P": 25,
"[": 26,
"]": 27,
"Enter": 28,
"Ctrl": 29,
"A": 30,
"S": 31,
"D": 32,
"F": 33,
"G": 34,
"H": 35,
"J": 36,
"K": 37,
"L": 38,
";": 39,
"'": 40,
"`": 41,
"Shift": 42,
"\\": 43,
"Z": 44,
"X": 45,
"C": 46,
"V": 47,
"B": 48,
"N": 49,
"M": 50,
",": 51,
".": 52,
"/": 53,
"Alt": 56,
"Space": 57,
"Caps": 58,
"LeftM": 90,
"RightM": 91,
"MidM": 92,
"Up": 103,
"Left": 105,
"Right": 106,
"Down": 108,
"Del": 111,
"Mute": 113,
"VolDown": 114,
"VolUp": 115,
"Scale": 120,
"Win": 125,
}
Ctrl = code_map['Ctrl']
Alt = code_map['Alt']
Shift = code_map['Shift']
Caps = code_map['Caps']
Enter = code_map['Enter']
Esc = code_map['Esc']
Switch_code = code_map['Switch']
Backspace = code_map['BS']
Space = code_map['Space']
EmptyLetterCode = code_map['Undef']
LeftMouse = code_map['LeftM']
RightMouse = code_map['RightM']
MiddleMouse = code_map['MidM']
def append_commands():
command_map = {
'Select': (Ctrl, code_map['A']),
'Undo': (Ctrl, code_map['Z']),
'Redo': (Ctrl, Shift, code_map['Z']),
'Copy': (Ctrl, code_map['C']),
'Cut': (Ctrl, code_map['X']),
'Paste': (Ctrl, code_map['V']),
'Format': (Ctrl, Alt, code_map['L']),
'Search': (Ctrl, code_map['F']),
'Replace': (Ctrl, code_map['R']),
}
for key, val in command_map.items():
code_map[key] = val
append_commands()
reverse_code_map = {val: key for key, val in code_map.items()}