forked from mirror/joycontrol
Merge branch 'pulls/326281544/44'
This commit is contained in:
@@ -145,6 +145,25 @@ async def set_amiibo(controller_state, file_path):
|
|||||||
controller_state.set_nfc(content)
|
controller_state.set_nfc(content)
|
||||||
|
|
||||||
|
|
||||||
|
async def mash_button(controller_state, button, interval):
|
||||||
|
# waits until controller is fully connected
|
||||||
|
await controller_state.connect()
|
||||||
|
|
||||||
|
if button not in controller_state.button_state.get_available_buttons():
|
||||||
|
raise ValueError(f'Button {button} does not exist on {controller_state.get_controller()}')
|
||||||
|
|
||||||
|
user_input = asyncio.ensure_future(
|
||||||
|
ainput(prompt=f'Pressing the {button} button every {interval} seconds... Press <enter> to stop.')
|
||||||
|
)
|
||||||
|
# push a button repeatedly until user input
|
||||||
|
while not user_input.done():
|
||||||
|
await button_push(controller_state, button)
|
||||||
|
await asyncio.sleep(float(interval))
|
||||||
|
|
||||||
|
# await future to trigger exceptions in case something went wrong
|
||||||
|
await user_input
|
||||||
|
|
||||||
|
|
||||||
async def _main(args):
|
async def _main(args):
|
||||||
# parse the spi flash
|
# parse the spi flash
|
||||||
if args.spi_flash:
|
if args.spi_flash:
|
||||||
@@ -180,6 +199,23 @@ 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 call_mash_button(*args):
|
||||||
|
"""
|
||||||
|
mash - Mash a specified button at a set interval
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
mash <button> <interval>
|
||||||
|
"""
|
||||||
|
if not len(args) == 2:
|
||||||
|
raise ValueError('"mash_button" command requires a button and interval as arguments!')
|
||||||
|
|
||||||
|
button, interval = args
|
||||||
|
await mash_button(controller_state, button, interval)
|
||||||
|
|
||||||
|
# add the script from above
|
||||||
|
cli.add_command('mash', call_mash_button)
|
||||||
|
|
||||||
# Create amiibo command
|
# Create amiibo command
|
||||||
async def amiibo(*args):
|
async def amiibo(*args):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user