If you have any questions following the tutorial, feel free to ask us in our Discord server.
Tutorial to Build a Button Script Program:
This tutorial lets you write code that can send a series of hardcoded button commands to Switch to control a game. Function-wise it's like a programmable smart Switch controller. Note it is a non-feedback program because no video or audio detection is used.
-
Build the source code of our codebase. See the Git guide for how to download and prepare for source code version control. If successful, you can run the built program SerialPrograms(.exe) to run existing automation programs.
-
To write a new program, the easiest way is to study the existing non-feedback program PokemonLA_BraviaryHeightGlitch. The program applys an exploit while the player character rides on Braviary so that the player can gain unlimited height in the overworld. See its Wiki page on how to use the program.
- A more complex program example is PokemonLA_ApplyGrits (Wiki).
-
Copy the code in PokemonLA_BraviaryHeightGlitch to create a new program listed in SerialPrograms/Source/PokemonLA/Programs/ and compile it. If successful, you can run SerialPrograms and notice a new program appears under the LA panel.
-
Change the code in function
BraviaryHeightGlitch::program()
to add your own code by trying somepbf_xxx()
function calls. Those functions send button commands to Switch. They are defined in NintendoSwitch_Commands_PushButtons.h to control the game. Example button commands arepbf_press_button()
andpbf_press_dpad()
. You can read the comments of those functions to understand how to use them. -
Compile the program and test it on your Switch.
-
Congratulations! You now have a working Switch controller button script program! You can write button sequence of arbitrary complexity to control your Switch game!
-
If you find an interesting use case of your script in one of the Pokémon games, you are welcome to submit this script to our team to be used by our users. See the Git guide for how to submit code.
- After your new program is accepted to our codebase, there is also a need to write a wiki for the program so that users know how to use it! Our program wiki is actually a Github repo ComputerControl. Each wiki page is written as a .md file in the repo. It should be fairly easy to learn the .md writing format. You can use the similiar Github development cycle in the Git guide to submit your new wiki page.