Just before the festive holidays I signed up to support Microsoft Research Cambridge with a technology show for local school leavers. Called ‘Think Computer Science’ it was an awesome event with both Andrew Herbert and Chris Bishop speaking. Andrew shared some great anecdotes from his many years in the computer industry (I didn’t know the Tornado on board computer was so big and underwhelming), and Chris made lots of load bangs while blowing up or setting light to things – all to show the potential of organic computing – with performance to boggle the mind (can’t wait to do robotics with that!).
Mr Sithers and I shared a small exhibit space amongst the MSR boffins with our XNA demonstrations. Notably Goblin XNA, XNA on Zune HD, a Development Xbox 360 and my Wiimote modified XNA Racing Game starter kit.
I found the Wiimote .Net assembly on Coding4fun, and couldn’t resist borrowing one my families revered controllers to make the XNA Racing Game drivable ‘just like Mario Karts(TM)’. The Coding4fun article says the Wiimote, although a BlueTooth device, only works with certain BlueTooth PC stacks. Luckily for me, the Toshiba stack on my X200 worked fine – but note, before putting in lots of effort, try pairing off a Wiimote to your PC using the instructions in the Coding4fun article (ie don’t use a pairing pin!!)
The Coding4fun stuff made the modifications trivial to do and with so little effort involved I was able to waste a good period of time playing it – complete with Wimote steering wheel :-)
Basically the Accelerometer data is easily accessible and this was used to affect the cars speed and steering. I was able to use the source from the Windows 7 Sensor Racing Game version, which already had coding changes for an accelerometer and ambient light sensor.
Most of the changes are in the Input.cs. Here the existing sensor initialisation was ripped out or replaced with the much simpler set up of the Wiimote. I discovered that to use the wiimote in the horizontal ‘Mario Kart’ style I needed to swap the use of the X and Y axis in the existing Accelerometer code.
Having removed the ambient light sensor code I had to re-instated the original PreScreenSkyCubeMapping.cs. The modified one changed the sky colour based on ambient sensor data.
I didn’t do any averaging of the Wiimote accelerometer data to smooth out rapid changes across frames, this results in a very sensitive driving style (much less Mario Karts) but worked fine.
What is clear to me, is that the fun of the WII gaming genre is entirely open to implementation on the Windows PC using XNA – as long as you have a compatible BlueTooth stack. Something to explore more of now I have a full deck of WII Motion Plus devices :-)
You can download the modified Wiimote Racing Game source here. Complete solution at 221mb.