-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconversion.py
245 lines (240 loc) · 14.8 KB
/
conversion.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/usr/bin/env python3
# Author: Valentin Libouton
# Contact: [email protected]
# Github: https://github.com/ValentinLibouton
# Project: PiZeroKeystrokesInjection
# Version: V1
# Date: 03/02/2023
"""
Commands to send to /dev/hidg0
The dictionaries below need to be converted
Dictionary values are tuples of length 8 integers
the values contained in these tuples will have to be changed to unicode characters and converted to string
Ex.: ENTER = (0, 0, 40, 0, 0, 0, 0, 0)
= 'chr(0)+chr(0)+chr(40)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)'
"""
belgian_keyboard = {
"CTRL_LEFT": (1, 0, 0, 0, 0, 0, 0, 0),
"SHIFT_LEFT": (2, 0, 0, 0, 0, 0, 0, 0),
"ALT_LEFT": (4, 0, 0, 0, 0, 0, 0, 0),
"WIN": (8, 0, 0, 0, 0, 0, 0, 0),
"CTRL_RIGHT": (16, 0, 0, 0, 0, 0, 0, 0),
"SHIFT_RIGHT": (32, 0, 0, 0, 0, 0, 0, 0),
"ALT_RIGHT": (64, 0, 0, 0, 0, 0, 0, 0),
"ENTER": (0, 0, 40, 0, 0, 0, 0, 0),
"ESCAPE": (0, 0, 41, 0, 0, 0, 0, 0),
"BACK": (0, 0, 42, 0, 0, 0, 0, 0),
"TAB": (0, 0, 43, 0, 0, 0, 0, 0),
"SPACE": (0, 0, 44, 0, 0, 0, 0, 0),
"CAPS_LOCK": (0, 0, 57, 0, 0, 0, 0, 0),
"F1": (0, 0, 58, 0, 0, 0, 0, 0),
"F2": (0, 0, 59, 0, 0, 0, 0, 0),
"F3": (0, 0, 60, 0, 0, 0, 0, 0),
"F4": (0, 0, 61, 0, 0, 0, 0, 0),
"F5": (0, 0, 62, 0, 0, 0, 0, 0),
"F6": (0, 0, 63, 0, 0, 0, 0, 0),
"F7": (0, 0, 64, 0, 0, 0, 0, 0),
"F8": (0, 0, 65, 0, 0, 0, 0, 0),
"F9": (0, 0, 66, 0, 0, 0, 0, 0),
"F10": (0, 0, 67, 0, 0, 0, 0, 0),
"F11": (0, 0, 68, 0, 0, 0, 0, 0),
"F12": (0, 0, 69, 0, 0, 0, 0, 0),
"PRINT_SCREEN": (0, 0, 70, 0, 0, 0, 0, 0),
"SCROLL_LOCK": (0, 0, 71, 0, 0, 0, 0, 0),
"PAUSE": (0, 0, 72, 0, 0, 0, 0, 0),
"INSERT": (0, 0, 73, 0, 0, 0, 0, 0),
"HOME": (0, 0, 74, 0, 0, 0, 0, 0),
"PAGE_UP": (0, 0, 75, 0, 0, 0, 0, 0),
"DELETE": (0, 0, 76, 0, 0, 0, 0, 0),
"END": (0, 0, 77, 0, 0, 0, 0, 0),
"PAGE_DOWN": (0, 0, 78, 0, 0, 0, 0, 0),
"RIGHT_ARROW": (0, 0, 79, 0, 0, 0, 0, 0),
"LEFT_ARROW": (0, 0, 80, 0, 0, 0, 0, 0),
"DOWN_ARROW": (0, 0, 81, 0, 0, 0, 0, 0),
"UP_ARROW": (0, 0, 82, 0, 0, 0, 0, 0),
"NUM_LOCK": (0, 0, 83, 0, 0, 0, 0, 0),
"MENU": (0, 0, 101, 0, 0, 0, 0, 0),
'a': (0, 0, 20, 0, 0, 0, 0, 0), # Verified
'b': (0, 0, 5, 0, 0, 0, 0, 0), # Verified
'c': (0, 0, 6, 0, 0, 0, 0, 0), # Verified
'd': (0, 0, 7, 0, 0, 0, 0, 0), # Verified
'e': (0, 0, 8, 0, 0, 0, 0, 0), # Verified
'f': (0, 0, 9, 0, 0, 0, 0, 0), # Verified
'g': (0, 0, 10, 0, 0, 0, 0, 0), # Verified
'h': (0, 0, 11, 0, 0, 0, 0, 0), # Verified
'i': (0, 0, 12, 0, 0, 0, 0, 0), # Verified
'j': (0, 0, 13, 0, 0, 0, 0, 0), # Verified
'k': (0, 0, 14, 0, 0, 0, 0, 0), # Verified
'l': (0, 0, 15, 0, 0, 0, 0, 0), # Verified
'm': (0, 0, 51, 0, 0, 0, 0, 0), # Verified
'n': (0, 0, 17, 0, 0, 0, 0, 0), # Verified
'o': (0, 0, 18, 0, 0, 0, 0, 0), # Verified
'p': (0, 0, 19, 0, 0, 0, 0, 0), # Verified
'q': (0, 0, 4, 0, 0, 0, 0, 0), # Verified
'r': (0, 0, 21, 0, 0, 0, 0, 0), # Verified
's': (0, 0, 22, 0, 0, 0, 0, 0), # Verified
't': (0, 0, 23, 0, 0, 0, 0, 0), # Verified
'u': (0, 0, 24, 0, 0, 0, 0, 0), # Verified
'v': (0, 0, 25, 0, 0, 0, 0, 0), # Verified
'w': (0, 0, 29, 0, 0, 0, 0, 0), # Verified
'x': (0, 0, 27, 0, 0, 0, 0, 0), # Verified
'y': (0, 0, 28, 0, 0, 0, 0, 0), # Verified
'z': (0, 0, 26, 0, 0, 0, 0, 0), # Verified
',': (0, 0, 16, 0, 0, 0, 0, 0), # Verified
'&': (0, 0, 30, 0, 0, 0, 0, 0), # Verified
'é': (0, 0, 31, 0, 0, 0, 0, 0), # Verified
'"': (0, 0, 32, 0, 0, 0, 0, 0), # Verified
'\'': (0, 0, 33, 0, 0, 0, 0, 0), # Verified
'(': (0, 0, 34, 0, 0, 0, 0, 0), # Verified
'§': (0, 0, 35, 0, 0, 0, 0, 0), # Verified
'è': (0, 0, 36, 0, 0, 0, 0, 0), # Verified
'!': (0, 0, 37, 0, 0, 0, 0, 0), # Verified
'ç': (0, 0, 38, 0, 0, 0, 0, 0), # Verified
'à': (0, 0, 39, 0, 0, 0, 0, 0), # Verified
')': (0, 0, 45, 0, 0, 0, 0, 0), # Verified
'-': (0, 0, 46, 0, 0, 0, 0, 0), # Verified
'^': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 47, 0, 0, 0, 0, 0)), # Verified
'$': (0, 0, 48, 0, 0, 0, 0, 0), # Verified
'µ': (0, 0, 49, 0, 0, 0, 0, 0), # Verified
'ù': (0, 0, 52, 0, 0, 0, 0, 0), # Verified
'²': (0, 0, 53, 0, 0, 0, 0, 0), # Verified
';': (0, 0, 54, 0, 0, 0, 0, 0), # Verified
':': (0, 0, 55, 0, 0, 0, 0, 0), # Verified
'=': (0, 0, 56, 0, 0, 0, 0, 0), # Verified
'/': (0, 0, 84, 0, 0, 0, 0, 0), # Verified
'*': (0, 0, 85, 0, 0, 0, 0, 0), # Verified
'+': (0, 0, 87, 0, 0, 0, 0, 0), # Verified
'<': (0, 0, 100, 0, 0, 0, 0, 0), # Verified
'A': (32, 0, 20, 0, 0, 0, 0, 0), # Verified
'B': (32, 0, 5, 0, 0, 0, 0, 0), # Verified
'C': (32, 0, 6, 0, 0, 0, 0, 0), # Verified
'D': (32, 0, 7, 0, 0, 0, 0, 0), # Verified
'E': (32, 0, 8, 0, 0, 0, 0, 0), # Verified
'F': (32, 0, 9, 0, 0, 0, 0, 0), # Verified
'G': (32, 0, 10, 0, 0, 0, 0, 0), # Verified
'H': (32, 0, 11, 0, 0, 0, 0, 0), # Verified
'I': (32, 0, 12, 0, 0, 0, 0, 0), # Verified
'J': (32, 0, 13, 0, 0, 0, 0, 0), # Verified
'K': (32, 0, 14, 0, 0, 0, 0, 0), # Verified
'L': (32, 0, 15, 0, 0, 0, 0, 0), # Verified
'M': (32, 0, 51, 0, 0, 0, 0, 0), # Verified
'N': (32, 0, 17, 0, 0, 0, 0, 0), # Verified
'O': (32, 0, 18, 0, 0, 0, 0, 0), # Verified
'P': (32, 0, 19, 0, 0, 0, 0, 0), # Verified
'Q': (32, 0, 4, 0, 0, 0, 0, 0), # Verified
'R': (32, 0, 21, 0, 0, 0, 0, 0), # Verified
'S': (32, 0, 22, 0, 0, 0, 0, 0), # Verified
'T': (32, 0, 23, 0, 0, 0, 0, 0), # Verified
'U': (32, 0, 24, 0, 0, 0, 0, 0), # Verified
'V': (32, 0, 25, 0, 0, 0, 0, 0), # Verified
'W': (32, 0, 29, 0, 0, 0, 0, 0), # Verified
'X': (32, 0, 27, 0, 0, 0, 0, 0), # Verified
'Y': (32, 0, 28, 0, 0, 0, 0, 0), # Verified
'Z': (32, 0, 26, 0, 0, 0, 0, 0), # Verified
'?': (32, 0, 16, 0, 0, 0, 0, 0), # Verified
'1': (32, 0, 30, 0, 0, 0, 0, 0), # Verified
'2': (32, 0, 31, 0, 0, 0, 0, 0), # Verified
'3': (32, 0, 32, 0, 0, 0, 0, 0), # Verified
'4': (32, 0, 33, 0, 0, 0, 0, 0), # Verified
'5': (32, 0, 34, 0, 0, 0, 0, 0), # Verified
'6': (32, 0, 35, 0, 0, 0, 0, 0), # Verified
'7': (32, 0, 36, 0, 0, 0, 0, 0), # Verified
'8': (32, 0, 37, 0, 0, 0, 0, 0), # Verified
'9': (32, 0, 38, 0, 0, 0, 0, 0), # Verified
'0': (32, 0, 39, 0, 0, 0, 0, 0), # Verified
'°': (32, 0, 45, 0, 0, 0, 0, 0), # Verified
'_': (32, 0, 46, 0, 0, 0, 0, 0), # Verified
'¨': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (32, 0, 47, 0, 0, 0, 0, 0)), # Verified
'£': (32, 0, 49, 0, 0, 0, 0, 0), # Verified
'%': (32, 0, 52, 0, 0, 0, 0, 0), # Verified
'³': (32, 0, 53, 0, 0, 0, 0, 0), # Verified
'.': (32, 0, 54, 0, 0, 0, 0, 0), # Verified
'>': (32, 0, 100, 0, 0, 0, 0, 0), # Verified
'\\': (64, 0, 100, 0, 0, 0, 0, 0), # Verified
'|': (64, 0, 30, 0, 0, 0, 0, 0), # Verified
'@': (64, 0, 31, 0, 0, 0, 0, 0), # Verified
'#': (64, 0, 32, 0, 0, 0, 0, 0), # Verified
'¼': (64, 0, 33, 0, 0, 0, 0, 0), # Verified
'½': (64, 0, 34, 0, 0, 0, 0, 0), # Verified
'{': (64, 0, 38, 0, 0, 0, 0, 0), # Verified
'}': (64, 0, 39, 0, 0, 0, 0, 0), # Verified
'[': (64, 0, 47, 0, 0, 0, 0, 0), # Verified
']': (64, 0, 48, 0, 0, 0, 0, 0), # Verified
'€': (64, 0, 8, 0, 0, 0, 0, 0), # Verified
'”': (64, 0, 5, 0, 0, 0, 0, 0), # Verified
'“': (64, 0, 25, 0, 0, 0, 0, 0), # Verified
'¢': (64, 0, 0, 6, 0, 0, 0, 0), # Verified
'»': (64, 0, 27, 0, 0, 0, 0, 0), # Verified
'«': (64, 0, 29, 0, 0, 0, 0, 0), # Verified
'`': ((64, 0, 49, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (64, 0, 49, 0, 0, 0, 0, 0)), # Verified two keystrokes required = grave accent
'´': ((64, 0, 52, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (64, 0, 52, 0, 0, 0, 0, 0)), # Verified two keystrokes required = acute accent
'~': ((64, 0, 56, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (64, 0, 56, 0, 0, 0, 0, 0)), # Verified two keystrokes required = tild
'¬': (64, 0, 53, 0, 0, 0, 0, 0), # Verified
'¸': ((64, 0, 46, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (64, 0, 46, 0, 0, 0, 0, 0)), # Verified two keystrokes required = cedilla
'¶': (64, 0, 21, 0, 0, 0, 0, 0), # Verified
'ŧ': (64, 0, 23, 0, 0, 0, 0, 0), # Verified
'←': (64, 0, 28, 0, 0, 0, 0, 0), # Verified
'↓': (64, 0, 24, 0, 0, 0, 0, 0), # Verified
'→': (64, 0, 12, 0, 0, 0, 0, 0), # Verified
'œ': (64, 0, 18, 0, 0, 0, 0, 0), # Verified
'þ': (64, 0, 19, 0, 0, 0, 0, 0), # Verified
'æ': (64, 0, 4, 0, 0, 0, 0, 0), # Verified
'ß': (64, 0, 22, 0, 0, 0, 0, 0), # Verified
'ð': (64, 0, 7, 0, 0, 0, 0, 0), # Verified
'đ': (64, 0, 9, 0, 0, 0, 0, 0), # Verified
'ŋ': (64, 0, 10, 0, 0, 0, 0, 0), # Verified
'ħ': (64, 0, 11, 0, 0, 0, 0, 0), # Verified
"ĸ": (64, 0, 14, 0, 0, 0, 0, 0), # Verified
'ł': (64, 0, 15, 0, 0, 0, 0, 0), # Verified
'─': (64, 0, 54, 0, 0, 0, 0, 0), # Verified Error don't work = character must be above a letter
'·': (64, 0, 55, 0, 0, 0, 0, 0), # Verified
' ': (0, 0, 44, 0, 0, 0, 0, 0), # SPACE Verified
' ': (0, 0, 43, 0, 0, 0, 0, 0), # TAB Verified
'ä': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 20, 0, 0, 0, 0, 0)), # Verified
'ë': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 8, 0, 0, 0, 0, 0)), # Verified
'ẗ': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 23, 0, 0, 0, 0, 0)), # Verified
'ÿ': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 28, 0, 0, 0, 0, 0)), # Verified
'ü': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 24, 0, 0, 0, 0, 0)), # Verified
'ï': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 12, 0, 0, 0, 0, 0)), # Verified
'ö': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 18, 0, 0, 0, 0, 0)), # Verified
'ḧ': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 11, 0, 0, 0, 0, 0)), # Verified
'ẅ': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 29, 0, 0, 0, 0, 0)), # Verified
'ẍ': ((32, 0, 47, 0, 0, 0, 0, 0), (0, 0, 27, 0, 0, 0, 0, 0)), # Verified
'Ä': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 20, 0, 0, 0, 0, 0)), # Verified
'Ë': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 8, 0, 0, 0, 0, 0)), # Verified
'Ÿ': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 28, 0, 0, 0, 0, 0)), # Verified
'Ü': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 24, 0, 0, 0, 0, 0)), # Verified
'Ï': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 12, 0, 0, 0, 0, 0)), # Verified
'Ö': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 18, 0, 0, 0, 0, 0)), # Verified
'Ḧ': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 11, 0, 0, 0, 0, 0)), # Verified
'Ẅ': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 29, 0, 0, 0, 0, 0)), # Verified
'Ẍ': ((32, 0, 47, 0, 0, 0, 0, 0), (32, 0, 27, 0, 0, 0, 0, 0)), # Verified
'â': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 20, 0, 0, 0, 0, 0)), # Verified
'ẑ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 26, 0, 0, 0, 0, 0)), # Verified
'ê': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 8, 0, 0, 0, 0, 0)), # Verified
'ŷ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 28, 0, 0, 0, 0, 0)), # Verified
'û': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 24, 0, 0, 0, 0, 0)), # Verified
'î': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 12, 0, 0, 0, 0, 0)), # Verified
'ô': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 18, 0, 0, 0, 0, 0)), # Verified
'ŝ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 22, 0, 0, 0, 0, 0)), # Verified
'ĝ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 10, 0, 0, 0, 0, 0)), # Verified
'ĥ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 11, 0, 0, 0, 0, 0)), # Verified
'ĵ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 13, 0, 0, 0, 0, 0)), # Verified
'ŵ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 29, 0, 0, 0, 0, 0)), # Verified
'ĉ': ((0, 0, 47, 0, 0, 0, 0, 0), (0, 0, 6, 0, 0, 0, 0, 0)), # Verified
'Â': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 20, 0, 0, 0, 0, 0)), # Verified
'Ê': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 8, 0, 0, 0, 0, 0)), # Verified
'Ŷ': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 28, 0, 0, 0, 0, 0)), # Verified
'Û': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 24, 0, 0, 0, 0, 0)), # Verified
'Î': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 12, 0, 0, 0, 0, 0)), # Verified
'Ô': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 18, 0, 0, 0, 0, 0)), # Verified
'Ŝ': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 22, 0, 0, 0, 0, 0)), # Verified
'Ĝ': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 10, 0, 0, 0, 0, 0)), # Verified
'Ĥ': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 11, 0, 0, 0, 0, 0)), # Verified
'Ĵ': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 13, 0, 0, 0, 0, 0)), # Verified
'Ŵ': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 29, 0, 0, 0, 0, 0)), # Verified
'Ĉ': ((0, 0, 47, 0, 0, 0, 0, 0), (32, 0, 6, 0, 0, 0, 0, 0)), # Verified
}
# To Do List
# accent_grave, accent_aigu, tild_char, cedilla
# See https://stackoverflow.com/questions/49887540/improve-python-code