diff --git a/run_controller_cli.py b/run_controller_cli.py index 64901c3..a6dc278 100644 --- a/run_controller_cli.py +++ b/run_controller_cli.py @@ -22,7 +22,7 @@ logger = logging.getLogger(__name__) While running the cli, call "help" for an explanation of available commands. Usage: - run_controller_cli.py [--device_id | -d ] + run_controller_cli.py [--device_id | -d ] [--spi_flash ] [--reconnect_bt_addr | -r ] [--log | -l ] @@ -33,7 +33,7 @@ Arguments: Options: -d --device_id ID of the bluetooth adapter. Integer matching the digit in the hci* notation - (e.g. hci0, hci1, ...) or Bluetooth mac address of the adapter in string + (e.g. hci0, hci1, ...) or Bluetooth mac address of the adapter in string notation (e.g. "FF:FF:FF:FF:FF:FF"). Note: Selection of adapters may not work if the bluez "input" plugin is enabled. @@ -41,11 +41,11 @@ Options: --spi_flash Memory dump of a real Switch controller. Required for joystick emulation. Allows displaying of JoyCon colors. Memory dumps can be created using the dump_spi_flash.py script. - - -r --reconnect_bt_addr Previously connected Switch console Bluetooth address in string + + -r --reconnect_bt_addr Previously connected Switch console Bluetooth address in string notation (e.g. "FF:FF:FF:FF:FF:FF") for reconnection. Does not require the "Change Grip/Order" menu to be opened, - + -l --log Write hid communication (input reports and output reports) to a file. """ @@ -145,6 +145,25 @@ async def set_amiibo(controller_state, file_path): 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 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): # parse the spi flash if args.spi_flash: @@ -180,6 +199,23 @@ async def _main(args): # add the script from above 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