Compare commits
2 Commits
be3af73cac
...
b5e77c1e31
Author | SHA1 | Date | |
---|---|---|---|
b5e77c1e31 | |||
c14f537a88 |
33
autopon.py
33
autopon.py
@@ -3,11 +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",
|
||||
"type",
|
||||
str(key)
|
||||
"key",
|
||||
str(key) + ":1",
|
||||
str(key) + ":0",
|
||||
"--key-delay",
|
||||
str(100 / multiplier)
|
||||
])
|
||||
|
||||
def main():
|
||||
@@ -37,10 +43,10 @@ def main():
|
||||
# A mapping of characters in our encoded songs to keys to send to ydotool
|
||||
# These should be the default bindings for PPSSPP
|
||||
keymapping = {
|
||||
"U": "s",
|
||||
"D": "z",
|
||||
"L": "a",
|
||||
"R": "x"
|
||||
"U": "31",
|
||||
"D": "44",
|
||||
"L": "30",
|
||||
"R": "45"
|
||||
}
|
||||
drummapping = {
|
||||
"U": '\033[32mCHAKA\033[0m',
|
||||
@@ -49,15 +55,20 @@ def main():
|
||||
"R": '\033[34mPON\033[0m'
|
||||
}
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Play a sequence of Patapon commands on repeat forever"
|
||||
description="Play a sequence of Patapon commands on repeat"
|
||||
)
|
||||
parser.add_argument('song',default="R-R-L-R-",nargs="+",choices=songs,help="The song to play. Defaults to Aria of Attack. When expressing a song, use eighth notes, dashes, and cardinal directions to designate the drums. For example, party would be \"L-R-D-U-\", and djinn would be \"D-DD-DD-\"")
|
||||
parser.add_argument('--bpm',type=int,default=120,help="The BPM of Patapon. Change if you're running the game at a higher speed")
|
||||
parser.add_argument('--bpm',type=float,default=1,help="Multiplier for the BPM. Change if you're running the game at a higher speed")
|
||||
parser.add_argument('--iterations',type=int,default=10000,help="Number of iterations of the sequence to run. Defaults to 10,000")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Schedule out our beat interval
|
||||
beat_interval = 60 / (args.bpm * 2)
|
||||
# 120 Naiive, does not work
|
||||
# 119.905 Still fast
|
||||
# 119.900 Still fast
|
||||
# 119.890
|
||||
bpm_constant = 119.890
|
||||
beat_interval = 60 / (bpm_constant * args.bpm * 2)
|
||||
print(f"Beat interval: {beat_interval}")
|
||||
|
||||
# Set up the environment
|
||||
@@ -78,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)
|
||||
|
Reference in New Issue
Block a user