joycontrol icon indicating copy to clipboard operation
joycontrol copied to clipboard

Extending joycontrol command line syntax

Open janreggie opened this issue 3 years ago • 2 comments

As it stands, the command line syntax is fairly limited. The syntax can be seen in my PR in #106. There are no control loops nor delays, and commands have to be either typed manually or be in a single line and executed sequentially, one after the other, without pause.

Proposal

  • Multiple commands in a single line using ;. The current syntax uses && to achieve this, thus ; may be treated as a synonym.
  • Commands are to be case-insensitive. That is, A; NFC file_name, a && nfc file_name and a ; nfC file_name (although the last one will look weird) should perform the same task.
  • Addition of sleep, with syntax sleep interval (interval as a float in seconds), which just tells the interpreter to pause/sleep for some amount of time. a; sleep 5; b will signal to the Switch to press the A button, wait for 5 seconds, and then press the B button.
  • For loops. This has been mentioned before in #84, although in Chinese. Proposing the following syntax: for COUNT ; commands ; done will repeat commands COUNT times. Example usage: for 10; a; sleep 1; b; sleep 1; done, will cause A, B, A, B, and so on to be pressed, (ideally) 1 second apart.
    • For loops can also be inside for loops: for 10; a; sleep 1; for 10; b; sleep 1; done; sleep 1; done, or graphically:
for 10
  a
  sleep 1
  for 10
    b
    sleep 1
  done
  sleep 1
done
  • For loops with delay: for COUNT DELAY; cmd1; cmd2; done is the same as for COUNT; cmd1; sleep DELAY; cmd2; sleep DELAY; done.
  • "Reading" from files using read file_path, which parses a file file_path that looks like the code block above. Comments would start with #'s.
  • Macros: Setting a macro using macro mname; cmd1; cmd2; done and using it like for COUNT; mname; done. mname shouldn't be a "reserved keyword", and be limited to not having spaces. Parameterized macros can be a thing in the future.

Breaking changes

Applications or people that already use joycontrolmust be able to still use it after the changes have been made. Nonetheless, the changes provided may introduce some bugs along the way

The addition of ; and # as key symbols and setting all commands to case-insensitive may cause issues with file_names. An intelligent parser should be able to parse the new commands.

Further changes

Comments about this proposal are welcome. I wouldn't want to make the syntax too complex, so I want this proposal to be as concise as possible. For instance, I wouldn't want to add conditional execution (if blocks) since it wouldn't really be useful.

janreggie avatar Apr 09 '21 13:04 janreggie

I dont like putting the commands in the command line. I do like the suggestion of having all these commands in a file, with comments starting with # like mentioned.

pokemon-bot avatar Apr 09 '21 15:04 pokemon-bot

I dont like putting the commands in the command line.

What do you mean by "commands"?

janreggie avatar Apr 09 '21 16:04 janreggie