Communicating Nintendo DS with Adobe Air

Now that UDP is supported in AIR, communication with a Nintendo DS is no big deal.  Let’s start with the requirements:

–  NDS (with WFC already configured)

– A Flashcard (I have an R4, but Ezflash or M3 would be ok too)

– DS2Key (for sendig data from DS to your computer)

– Know your DS and computer’s IP.

– Of course a computer, a router, Flex (or FDT, FlashDevelop, whatever) and AIR sdk 2 beta (and runtime).

The code is very simple actually for this example, it just reads the coordinates where the stylus is pressing the touchscreen, I’m just showing the important parts:

//IP & port for this computer
private var localIP:String = “”;
private var localPort:int = 55555;

//IP & port for NDS
private var targetIP:String = “yyy.yyy.yyy.yyy”;
private var targetPort:int = 55555;

private function init():void

datagramSocket = new DatagramSocket();
datagramSocket.addEventListener(DatagramSocketDataEvent.DATA, dataReceived);

datagramSocket.bind(localPort, localIP);


//Need to actually send comething to receive data… don’t know why, sorry
var data:ByteArray = new ByteArray();
data.writeUTFBytes(“Some data”);
datagramSocket.send( data,0,0, targetIP, targetPort);

private function dataReceived(event:DatagramSocketDataEvent):void

//get the data, X and Y position of the DS stylus
var pos:String =;

// we receive for example “/m120.90.3”
// 120 is the value in the X axis, and 90.3 the value for Y

var separate:String = StringUtils.beforeFirst(pos, “.”);
var firstPart:String = StringUtils.remove(separate,”/m”);

var secondPart:String = StringUtils.afterFirst(pos, “.”);

//Your stuff


(As you can see I used Grant Skinner’s StringUtils which is here).

That’s all we need to receive and handle data from the NDS.

Now, to send data from the NDS, the DS2Key is needed (grab it here), to install it we just copy the DS2key.nds to the flashcard. Insert the flashcard into the NDS, run DS2Key to set the target computer’s IP and the port (55555 in this case).

And that’s it! Very easy. Of course, this is not limited to just reading the X and Y values of a point in the touchscreen being pressed with the stylus, button (x, y, b, a, etc. ) states can also be read. At first I had problems getting the data from the DS, so make sure the port you are using is open, that solved it for me.

I did a simple drawing application:

You can download the source here.

6 thoughts on “Communicating Nintendo DS with Adobe Air

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