-
Notifications
You must be signed in to change notification settings - Fork 0
/
ezppt.py
executable file
·61 lines (51 loc) · 1.32 KB
/
ezppt.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
#!/usr/bin/env python
from keyboard import *
import yaml
idx = 0
leng = 0
data = []
hotkeys = ["a", "s", "d", "f", "g", "h"]
labels = ["Verse1", "Verse2", "Chorus", "Bridge", "Outro", "Other"]
def priv_s(_):
print(_)
global idx
idx -= 1
idx %= leng
print('song {}'.format(idx))
def next_s(_):
print(_)
global idx
idx += 1
idx %= leng
print('song {}'.format(idx))
def transkey(x):
l = labels[hotkeys.index(x)]
num = data[idx][l]
if num is None:
return x
else:
num = str(num)
keynum = [num[i] for i in range(len(num))]
k = ','.join(keynum) + ',enter'
return k
def setup_key():
on_press_key('a', lambda _: send(transkey('a')))
on_press_key('s', lambda _: send(transkey('s')))
on_press_key('d', lambda _: send(transkey('d')))
on_press_key('f', lambda _: send(transkey('f')))
on_press_key('g', lambda _: send(transkey('g')))
on_press_key('h', lambda _: send(transkey('h')))
on_press_key('z', priv_s)
on_press_key('x', next_s)
# Blocks until you press esc.
wait('esc')
def load_conf():
global data
with open("./config.yml") as fd:
data = yaml.load(fd, Loader = yaml.SafeLoader)["Songs"]
global leng
leng = len(data)
print(data)
if __name__ == "__main__":
load_conf()
setup_key()