Baby steps

I’m using tutorials on They seem pretty good so far, but I’m still just on the first one.

A lot of what I knew from Java still seems to apply in C++, which helps, since that means I don’t have to go through the basics all over again. The first lesson I went through teaches the “cout” function, which is used to print instead of a print fuction. It also teaches variable declaration and operators with integers. If you’re not familiar with these concepts, you should probably go through the first lesson here.

I set up the Code::Blocks IDE for writing and compiling code for testing on my Windows PC. You can find a guide for doing that here. Its very simple; you pretty much just download the Code::Blocks IDE with the MinGW compiler and install. Once you open Code::Blocks, you can make a new project and start writing code. Press F9 to compile and run.

Using what I knew, I wrote this simple program:

#include <iostream>

using namespace std;

int main()

int lolcode = 0;
cout<<"Hello world! - Message number ";



It would output the following:

Hello world! - Message number 0
Hello world! - Message number 1
Hello world! - Message number 2
Hello world! - Message number 3
Hello world! - Message number 4
Hello world! - Message number 5
Hello world! - Message number 6
Hello world! - Message number 7
Hello world! - Message number 8
Hello world! - Message number 9

Process returned 0 (0x0)   execution time : 2.578 s
Press any key to continue.

Simple right? Now I tried running something really simple on the Wii. First, you’ll need to set up devkitPPC. This guide at will tell you how to set up devkitPPC on Windows. It also has links to guides for Mac and Linux at the bottom of the page.

The guide tells you how you should copy the template folder for the Wii application and compile it to test it. Go ahead and compile the .elf from the template. We’re going to launch the .elf wirelessly using The Homebrew Channel. I’ll assume you already have The Homebrew Channel installed.  Download this utility to your PC. Extract it, and open up the program. Select the .elf file you just compiled. Put in the IP address of your Wii (you can check this by hitting the Home button on your Wii remote after opening The Homebrew Channel. It’ll be listed at the top left.) Leave the Port field alone and have the Protocol set to “HB Channel”. Args should be left blank. Press “Send File!”, and you should see the application launch on your Wii, and “Hello World!” should be displayed on the screen. Press the Home button to exit back to The Homebrew Channel.

Now we can edit the Hello World template we just compiled with different code to test what we know. In the “helloworld” folder you had copied and pasted, go to the “source” folder. Rename template.c to template.cpp (since we’re using C++). Open up the template.cpp file. I added

#include <iostream>

to the top of the file with the rest of the includes. I also added a line containing

using namespace std;

below the includes. I’m not sure whether this is necessary, but I figured I should. Scroll down to where it says

if ( pressed & WPAD_BUTTON_HOME ) exit(0);

We can see now how we might be able to work with input from the Wii remote. I pulled up the wiiuse API and looked to see if I could make any sense of the code I saw in the template file. It looks like the API for Wiiuse has changed from when the library was included in devkitPPC, but its more likely that I just don’t fully understand the code I’m reading.

I decided to make it so that when I pushed a button, it would print something. So, I added the following lines:

if (pressed & WPAD_BUTTON_A)

cout<<"You pushed the A button \n";


“pressed” was defined as the controller having buttons pushed down. So, if buttons are pressed and if one of those buttons pressed is the A button on the Wii remote (WPAD_BUTTON_A), then “You pushed the A button” is printed on the screen.

Try this out yourself! Make the changes to template.c that I made, compile, and send it to your Wii. I know its not a big deal for a lot of developers, but being able to test input like this feels pretty cool.

So, like I said – this is all baby steps. Hopefully this helped out some of you. I’m going to continue learning and post more.


UPDATE: I posted a video demonstration of what was done in this post


June 22, 2008. Tags: , , , , , , , , , , , . Uncategorized.


  1. vader347 replied:

    Great tutorial.
    Check out they also have some good tutorials.

  2. Hak replied:

    Well, i like your idea of step by step, but i guess you could go a lil deeply, i started with this today, downloanding compilators, examples and tutos, but nothing for really beginners.

    One thing, can you explain how to run the .dol files on pc, i cant >_> always errors of memory or bad code even with the examples, i tried on gcube.exe and whinecube too.

    See ya.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Trackback URI

%d bloggers like this: