Adding a mash_button function

Signed-off-by: Jesse Millar <jesse.millar@microsoft.com>
This commit is contained in:
Jesse Millar
2020-05-11 12:20:29 -05:00
parent 8601dd4702
commit faf9a09229
+33
View File
@@ -180,6 +180,39 @@ async def _main(args):
# add the script from above # add the script from above
cli.add_command('test_buttons', _run_test_controller_buttons) cli.add_command('test_buttons', _run_test_controller_buttons)
# Mash a button command
async def mash_button(*args):
"""
mash_button - Mash a specified button at a set interval
Usage:
mash_button <button> <interval>
"""
if not len(args) == 2:
raise ValueError('"mash_button" command requires a button and interval as arguments!')
# waits until controller is fully connected
await controller_state.connect()
user_input = asyncio.ensure_future(
ainput(prompt='Pressing the '+args[0]+' button every '+args[1]+' seconds forever... Press <enter> to stop.')
)
# push a button repeatedly until user input
while not user_input.done():
await button_push(controller_state, args[0])
await asyncio.sleep(float(args[1]))
if user_input.done():
break
# await future to trigger exceptions in case something went wrong
await user_input
# add the script from above
cli.add_command('mash_button', mash_button)
# Create amiibo command # Create amiibo command
async def amiibo(*args): async def amiibo(*args):
""" """