From b5e77c1e31850b2edb345c693c7a249d93d77094 Mon Sep 17 00:00:00 2001 From: Jacob Babor Date: Thu, 30 Jan 2025 04:02:44 -0600 Subject: [PATCH] Modulate ydotool delay, fix bug, comment --- autopon.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/autopon.py b/autopon.py index c78ac89..7ea5cc8 100755 --- a/autopon.py +++ b/autopon.py @@ -3,14 +3,17 @@ import argparse import subprocess import time -def ydotool(key): +def ydotool(key, multiplier=1): + # This runs with a 100ms delay (by default, modulated by multiplier) because + # Patapon -- the game, not the emulator or the input layer -- will drop inputs + # if it's any lower. subprocess.run([ "ydotool", "key", str(key) + ":1", str(key) + ":0", "--key-delay", - "100" + str(100 / multiplier) ]) def main(): @@ -65,7 +68,7 @@ def main(): # 119.900 Still fast # 119.890 bpm_constant = 119.890 - beat_interval = 60 / (bpm_constsant * args.bpm * 2) + beat_interval = 60 / (bpm_constant * args.bpm * 2) print(f"Beat interval: {beat_interval}") # Set up the environment @@ -86,7 +89,7 @@ def main(): lastbeat += beat_interval button = keymapping.get(key, '-') if button != '-': - ydotool(button) + ydotool(button, multiplier=args.bpm) print(drummapping.get(key, '-'), end="", flush=True) else: print(" ", end="", flush=True)