Modulate ydotool delay, fix bug, comment
This commit is contained in:
11
autopon.py
11
autopon.py
@@ -3,14 +3,17 @@ import argparse
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
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([
|
subprocess.run([
|
||||||
"ydotool",
|
"ydotool",
|
||||||
"key",
|
"key",
|
||||||
str(key) + ":1",
|
str(key) + ":1",
|
||||||
str(key) + ":0",
|
str(key) + ":0",
|
||||||
"--key-delay",
|
"--key-delay",
|
||||||
"100"
|
str(100 / multiplier)
|
||||||
])
|
])
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -65,7 +68,7 @@ def main():
|
|||||||
# 119.900 Still fast
|
# 119.900 Still fast
|
||||||
# 119.890
|
# 119.890
|
||||||
bpm_constant = 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}")
|
print(f"Beat interval: {beat_interval}")
|
||||||
|
|
||||||
# Set up the environment
|
# Set up the environment
|
||||||
@@ -86,7 +89,7 @@ def main():
|
|||||||
lastbeat += beat_interval
|
lastbeat += beat_interval
|
||||||
button = keymapping.get(key, '-')
|
button = keymapping.get(key, '-')
|
||||||
if button != '-':
|
if button != '-':
|
||||||
ydotool(button)
|
ydotool(button, multiplier=args.bpm)
|
||||||
print(drummapping.get(key, '-'), end="", flush=True)
|
print(drummapping.get(key, '-'), end="", flush=True)
|
||||||
else:
|
else:
|
||||||
print(" ", end="", flush=True)
|
print(" ", end="", flush=True)
|
||||||
|
Reference in New Issue
Block a user