Wii Remote Hacking

On June 11, 2010, in Blog, Interactive Media, by Vlad Cazan

Since I have started my new postion at the DMZ my main focus has been hacking the Wii Remote to use in an external application. I have explored a great deal of different software and I have found a combination that seems to be working very well.

A piece of software called OSCulator that does a great job in connecting to the Wii remote and letting you manage what you want to do with these signals. Some of the basic options include mapping the X and Y co-ordinates to the X and Y values of the mouse, letting the user use his Wii Remote with his mouse and so on. On of the more advanced features includes converting the Wii Remote values to a communication protocol called OSC (Open Sound Control).

With this new signal I found another very important program called Oscar which converts this signal from OSC to standard XML which almost every external language would understand. A simple XML parse can be written in any language to parse the XML data into the appropriate variables.

Using the common 3D Flash library called Papervision I have managed to create some examples.

If you would like to try anything out just add my SVN repository : http://vladcazan.svn.beanstalkapp.com/wiixmlparse/

Here is a basic Wii Remote XML Parse to use in flash with OSCulator and OScar:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.XMLSocket;
 
    public class WiiXMLParse extends Sprite {
 
        private var hostName:String = "141.117.255.247";
        private var port:uint = 3000;
        private var socket:XMLSocket;
 
		var myXML:XML; //
 
		var xPos;
		var yPos;
 
		var x2Pos;
		var y2Pos;
 
		var size;
 
		var xPos2;
		var yPos2;
 
		var x2Pos2;
		var y2Pos2;
 
		var size2;
 
		var oldX;
		var oldY;
 
		var xMovement;
		var yMovement;
 
		private var movement:Object;
 
		private const FACTOR_XY:uint = 200;
		private const FACTOR_Z:uint = 10;
 
        public function WiiXMLParse() {
            socket = new XMLSocket();
            configureListeners(socket);
            socket.connect(hostName, port);
 
        }
 
        public function send(data:Object):void {
            socket.send(data);
        }
 
        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.CLOSE, closeHandler);
            dispatcher.addEventListener(Event.CONNECT, connectHandler);
            dispatcher.addEventListener(DataEvent.DATA, dataHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
        }
 
        private function closeHandler(event:Event):void {
            trace("closeHandler: " + event);
        }
 
        private function connectHandler(event:Event):void {
            trace("connectHandler: " + event);
        }
 
        private function dataHandler(event:DataEvent):void {
 
			myXML = new XML(event.data);
			//trace(myXML);
 
			movement = new Object();
			movement.newX = 0;
			movement.newY = 0;
			movement.newZ = 0;
			movement.oldX = 0;
			movement.oldY = 0;
			movement.oldZ = 0;
 
			//irXY(); //Checking One Point Per Controler
 
			rawIR(1); //Checking Two Points Per Controler, Params # of Players
        }
 
		function rawIR(numPlayers:int):void{
 
			switch(numPlayers)
			{
				case 1:
 
			////////Player One  - Point One
			if ([email protected] == "/wii/1/ir/xys/1/0"){
				xPos = ([email protected]);
			}
			if ([email protected] == "/wii/1/ir/xys/1/1"){
				yPos = ([email protected]);
			}
			if ([email protected] == "/wii/1/ir/xys/1/3"){
				size = ([email protected]);
			}
			////////Player One  - Point Two
			if ([email protected] == "/wii/1/ir/xys/2/0"){
				x2Pos = ([email protected]);
			}
			if ([email protected] == "/wii/1/ir/xys/2/1"){
				y2Pos = ([email protected]);
			}
			if ([email protected] == "/wii/1/ir/xys/2/2"){
				size = ([email protected]);
			}
			//trace(xPos + ","+ yPos+ "," + x2Pos + ","+ y2Pos + ","+ size)
				break;
				case 2:
 
			////////Player Two  - Point One
			if ([email protected] == "/wii/2/ir/xys/1/0"){
				xPos2 = ([email protected]);
			}
			if ([email protected] == "/wii/2/ir/xys/1/1"){
				yPos2 = ([email protected]);
			}
			if ([email protected] == "/wii/2/ir/xys/1/2"){
				size2 = ([email protected]);
			}
			////////Player Two  - Point Two
			if ([email protected] == "/wii/2/ir/xys/2/0"){
				x2Pos2 = ([email protected]);
			}
			if ([email protected] == "/wii/2/ir/xys/2/1"){
				y2Pos2 = ([email protected]);
			}
			if ([email protected] == "/wii/2/ir/xys/2/2"){
				size2 = ([email protected]);
			}
				break;
				default:
				break;
 
			}
 
			movement.newX = ((xPos + x2Pos)-1)/2;
			movement.newY = ((yPos + y2Pos)+1)/2;
			movement.newZ = Math.abs(xPos - x2Pos) * 100;
			movement.newX *=   -  FACTOR_XY;
			movement.newY *=   -  FACTOR_XY;
			movement.newZ *=  FACTOR_Z;
			movement.newX = (int)((movement.newX+movement.oldX)/2);
			movement.newY = (int)((movement.newY+movement.oldY)/2);
			movement.newZ = (int)((movement.newZ+movement.oldZ)/2);
			movement.oldX = movement.newX;
			movement.oldY = movement.newY;
			movement.oldZ = movement.newZ;
 
			trace("X: "+movement.oldX + " Y: " + movement.oldY + " Z: " + movement.newZ);
 
 
 
		}
 
		function irXY():void{
 
			////////Player One
			if ([email protected] == "/wii/1/ir/0"){
				xPos = ([email protected]);
				xMovement = oldX - xPos;
 
			}
			if ([email protected] == "/wii/1/ir/1"){
				yPos = ([email protected]);
				yMovement = oldY - yPos;
			}
			//////Player Two
			if ([email protected] == "/wii/2/ir/0"){
				xPos2 = ([email protected]);
			}
			if ([email protected] == "/wii/2/ir/1"){
				yPos2 = ([email protected]);
			}
 
 
			if (xMovement < 0)
			{
				trace("X moved to the right by: " + xMovement)
 
			}
			else{
				trace("X moved to the left by: " + xMovement)
 
			}
			if (yMovement < 0)
			{
				trace("Y moved up by: " + yMovement)
 
			}
			else{
				trace("Y moved down by: " + yMovement)
 
			}
 
			//trace(" |Current XY of Controler One:" + xPos + ","+ yPos + " | Current XY of Controler Two:" + xPos2 + ","+yPos2+"|");
			trace("X Movment is: " + xMovement + "Y Movment is: " + yMovement);
 
			oldX = xPos;
			oldY = yPos;
 
		}
 
 
        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }
 
        private function progressHandler(event:ProgressEvent):void {
           trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
        }
 
        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }
 
 
    }
}


 

1 Response » to “Wii Remote Hacking”

  1. Dess says:

    you genius you

Leave a Reply

WordPress Blog

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

Highslide for Wordpress Plugin Free WordPress Theme