Compare commits

..

2 Commits

Author SHA1 Message Date
86641f9959 Wait less busily
This resolution is still fine for perfect inputs as it's a much higher frequency than the polling rate of the game
2025-01-30 14:47:31 -06:00
38915249af Fancy output displays 2025-01-30 14:46:13 -06:00

View File

@@ -49,10 +49,22 @@ def main():
"R": "45"
}
drummapping = {
"U": '\033[32mCHAKA\033[0m',
"D": '\033[33mDON\033[0m',
"L": '\033[31mPATA\033[0m',
"R": '\033[34mPON\033[0m'
"U": {
"string": "CHAKA",
"color": 32
},
"D": {
"string": "DON",
"color": 33
},
"L": {
"string": "PATA",
"color": 31
},
"R": {
"string": "PON",
"color": 34
},
}
parser = argparse.ArgumentParser(
description="Play a sequence of Patapon commands on repeat"
@@ -88,6 +100,12 @@ def main():
remaining_iterations = args.iterations
lastbeat = 0
# Get a ghost string to use for fancy input display stuffs
ghoststring="\033[37m"
for i, key in enumerate(sequence):
ghoststring += drummapping.get(key,{}).get('string',' ')
ghoststring+="\033[0m"
# Wait for user confirmation
input("Press enter on-beat to sync up with Patapon...")
synctime = time.perf_counter() + startup_delay
@@ -95,19 +113,21 @@ def main():
# Play da notes
try:
while remaining_iterations > 0:
print(ghoststring, end="\r", flush=True)
for i, key in enumerate(sequence):
while time.perf_counter() < synctime + lastbeat:
time.sleep(0.01)
pass
lastbeat += beat_interval
button = keymapping.get(key, '-')
if button != '-':
if not args.dry_run:
ydotool(key=button, delay=args.key_delay, multiplier=args.bpm)
print(drummapping.get(key, '-'), end="", flush=True)
print(f"\033[{drummapping.get(key,{}).get('color',0)}m{drummapping.get(key,{}).get('string','-')}\033[0m", end="", flush=True)
else:
print(" ", end="", flush=True)
remaining_iterations -= 1
print(f"~ ({remaining_iterations} remaining)")
print(f"~ ({remaining_iterations} remaining)" + " " * len(str(args.iterations)), end="\r")
except KeyboardInterrupt as e:
print("Interrupt")
pass