-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkeypress.py
57 lines (45 loc) · 1.92 KB
/
keypress.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
from evdev import uinput, ecodes as e
# moves = "fFbBlLrRuUdD"
# moves = list(moves)
def wail(moves):
if moves is not '':
moves = list(reversed(list(moves.swapcase())))
for move in moves:
with uinput.UInput() as ui:
if move == 'f':
ui.write(e.EV_KEY, e.KEY_F, 1)
ui.write(e.EV_KEY, e.KEY_F, 0)
elif move == 'F':
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1)
ui.write(e.EV_KEY, e.KEY_F, 1)
elif move == 'b':
ui.write(e.EV_KEY, e.KEY_B, 1)
ui.write(e.EV_KEY, e.KEY_B, 0)
elif move == 'B':
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1)
ui.write(e.EV_KEY, e.KEY_B, 1)
elif move == 'l':
ui.write(e.EV_KEY, e.KEY_L, 1)
ui.write(e.EV_KEY, e.KEY_L, 0)
elif move == 'L':
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1)
ui.write(e.EV_KEY, e.KEY_L, 1)
elif move == 'r':
ui.write(e.EV_KEY, e.KEY_R, 1)
ui.write(e.EV_KEY, e.KEY_R, 0)
elif move == 'R':
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1)
ui.write(e.EV_KEY, e.KEY_R, 1)
elif move == 'u':
ui.write(e.EV_KEY, e.KEY_U, 1)
ui.write(e.EV_KEY, e.KEY_U, 0)
elif move == 'U':
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1)
ui.write(e.EV_KEY, e.KEY_U, 1)
elif move == 'd':
ui.write(e.EV_KEY, e.KEY_D, 1)
ui.write(e.EV_KEY, e.KEY_D, 0)
elif move == 'D':
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1)
ui.write(e.EV_KEY, e.KEY_D, 1)
ui.syn()