Modulate ydotool delay, fix bug, comment

This commit is contained in:
2025-01-30 04:02:44 -06:00
parent c14f537a88
commit b5e77c1e31

View File

@@ -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)