forked from mirror/joycontrol
Adding a mash_button function
Signed-off-by: Jesse Millar <jesse.millar@microsoft.com>
This commit is contained in:
@@ -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):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user