You have modded your Switch with a custom firmware (hopefully DeepSea) and want to write your own little program but don't know where to start? You are not the only one stuck in a flood of guides, forum posts and YouTube videos that show you how to get a massive headache. But don't worry - we will go through it and set you up in minutes!
The only thing that is a requirement for this is Docker. If you don't know what docker is, then you should definitely look it up. But to give you a general idea, you can imagine Docker as a hyper performant virtual machine that works on a huge number of operating systems. Thats not really it but it helps shape the idea of it.
Git is good to have for version control, storing source code online and collaborative development in your project. On Windows and Mac you can use GitHub Desktop for a userfriendly UI, but i wont go into more detail because its not nessesary to get you started.
For this guide i will assume that you are a windows user and can use Docker Desktop with its nice UI.
Go ahead and install Docker (desktop). Once that is done, start it and you will be greeted by something that looks like this (minus the already existing images):
If it looks like this, the Docker-engine has started and is ready to do its job. If it doesn't look like this (again, ignore the already existing images) then you might have to wait a few more minutes.
Open the start-menu, type "cmd" and press enter. A terminal window will appear. Now type "docker pull devkitpro/devkita64" and wait till it's done downloading the image. The image you just downloaded contains an operating system (Linux) and all the tools you need to compile your homebrew. It is a neat way of getting everything ready without actually installing and configuring it yourself.
You can now close the terminal window and go back to the Docker UI. Press the "RUN" button on the newly created image, give it a name and set the "host path" to a folder on your machine that contains or will contain source code. In the "container path", type "/home". It basically maps a folder on your own pc to a folder inside the docker container to share, edit and/or store files.
After you click on "Run" again, the container should be ready and already running, so head over to the "Containers" tab on the left and click on the name of the container you gave it in the previous step. In the top left corner, click on "CLI", which opens the terminal for the system you just started.
su, followed by the enter key
cd /home, followed by the enter key
git clone https://github.com/switchbrew/switch-examples.git, followed by the enter key
su is just for convinence. It means "superuser" and allows you to see more in the terminal, have path autocompletion by pressing the
tab key etc.
cd is the command for going into a directory.
git clone ... downloads the example repository
The downloaded example code is in the (host path) directory you specified when creating the image. You can go there with your favorite editor (for example Visual Studio Code) and edit everything to your heart's content.
Pick an example homebrew, for example
cd /home/switch-examples/hid/touch-screen and run the command
make -j. It will compile the sourcecode into a file named
touch-screen.nro, which you can copy to and start on your Nintendo Switch.
You have just compiled your first homebrew!
There is much more to learn and to explain but it's a little beyond the scope of this article. If you have questions, you can ask me on Discord or start a new post in the GBATemp forum. Everyone there is super helpful and it's a great place to be in.