Wii Nunchuck Controller Emulator

Share unrelated electronics stuff, ideas, rants, etc!
Post Reply
soshimo
Posts: 51
Joined: Thu Jan 08, 2009 10:10 pm

Wii Nunchuck Controller Emulator

Post by soshimo »

Here's an idea for Yet Another Time Waster - YATW (pronounced yatwah) :mrgreen: :

The thought was to create a Wii Nunchuck controller interface which will emulate either an atari style joystick, a PSX style controller, or a NES style controller. The Wii nunchuck uses i2c protocol which can be very cpu intensive The cpu has to sit and spin looking for high/low transitions or you could hook it up to some complex interrupt mechanism which will further increase kernel complexity and will violate the KISS rule. Uzebox currently has support for NES and SNES style controllers. The protocol for these controllers is well known and documented. My idea is to create a microcontroller based circuit which will implement the i2c protocol to talk to the wii nunchuck controller. The microcontroller will also implement the S/NES protocol which will preset a facade to the uzebox that looks like an S/NES controller. The only issues I see are the fact that the Wii joystick is analog while the buttons on the S/NES controller are digital (same with Atari style joysticks) so I would have to implement logic which will represent the state as binary (on/off) rather than analog. I don't have any small avr's laying around that I can test my POC with so I'm probably going to have to go with a pic or at at168 (which is overkill for what I need). The good news is that I have a wii nunchuck library written for the at168 already so I just might go that route as a POC.
havok1919
Posts: 474
Joined: Thu Aug 28, 2008 9:44 pm
Location: Vancouver, WA
Contact:

Re: Wii Nunchuck Controller Emulator

Post by havok1919 »

soshimo wrote: The cpu has to sit and spin looking for high/low transitions or you could hook it up to some complex interrupt mechanism which will further increase kernel complexity and will violate the KISS rule.
I think we only try to apply KISS to the hardware, not the firmware. There's plenty of "unKISS" in the kernel. ;-)

A Nunchuck to SNES bridge would be cool. I really wanted an analog joystick (since I'd used the Playstation Dual Shocks on other projects), but the firmware was a significant cycle-eater when implemented directly on the Uzebox MCU.

I kinda pushed the Nunchuck (and Wii joypad) off my list figuring that the mating connectors would be impossible to source. Do you know a supplier for the Wiimote-side mating connector? That'd be pretty neat for the Uzebox (and other apps, actually).

It'd be neat to pass the analog value of the stick over to the Uzebox and just let the kernel ID the controller and deal with mapping the data. (ie, push through absolute values to use it as an analog position device, or set thresholds for an 8-way stick, or constrain the limits for four-way only. etc.)

-Clay
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Wii Nunchuck Controller Emulator

Post by uze6666 »

Great idea! Btw, I think you'll really love AVRs now...most new ones have a hardware I2C (TWI) interface right on the chip! :D That the case for the mega644, unfortunately it's pins lies on PORTC, used by the video DAC. Check out the ATtiny25, 8pin PDIP with I2C, ADCs, etc. At 2$ qty 1, it's tough to beat! :)

Uze
soshimo
Posts: 51
Joined: Thu Jan 08, 2009 10:10 pm

Re: Wii Nunchuck Controller Emulator

Post by soshimo »

@ Uze - Sweet, I'm going to check those guys out. I don't have DIP versions handy but I have some SMT's and may try to solder them on a SMD protoboard I have :mrgreen:. I was trained to solder in the Navy but it's been a few years and they didn't do surface mount "back in the day", so hobby level SMT has always been a huge hurdle for me. I'm getting my licks back up though and am confident I can try it - maybe on some junk chips to practice.

@ Clay - There is a source for a Wii Nunchuck controller adapter. I found mine at a place called FunGizmos: http://store.fungizmos.com/index.php?ma ... cts_id=212. I don't think there is one for the actual Wii controller since it's wireless. I know there was some work being done on RE'ing that but I don't think anybody has done it yet. There are some cool things about the Wiimote though - it has a camera (which is used to read the IR transmitter from the sensor bar - the bar is actually an IR transmitter). It uses that vector to calculate yaw since you can only get pitch and roll with x,y,z acceleration - you need a third vector to calculate yaw which is what the sensor bar provides. It also has a small eeprom that some think is used to store Mii data (so that would be a cool hackable thing) and a few other neat items. Those guys over at Nintendo are absolutely trend setters - who would have thought to customize the controller? You can take your Mii avatar everywhere you go now!

I forgot to add - here is a video I made of some libraries I wrote for the Propeller. I've since converted these libraries over to AVR and 168's (and went to a decent language). I don't have a video of the AVR demo but it behaves exactly the same.

http://www.youtube.com/watch?v=JkuwhKbln1M
soshimo
Posts: 51
Joined: Thu Jan 08, 2009 10:10 pm

Re: Wii Nunchuck Controller Emulator

Post by soshimo »

havok1919 wrote: It'd be neat to pass the analog value of the stick over to the Uzebox and just let the kernel ID the controller and deal with mapping the data. (ie, push through absolute values to use it as an analog position device, or set thresholds for an 8-way stick, or constrain the limits for four-way only. etc.)
-Clay
I like this idea and it simplifies development (and gives the most flexibility in the design). I think we could piggy back on the snes mouse protocol since the controller protocol is only 16 pulses long there are not enough pulses to communicate the 18 bits we need to communicate (X+Y+CBUTTON+ZBUTTON). We can send the C and Z button states on the first pulse train and then send the x/y coordinates of the joy on the second pulse train (direction is just the sign bit but the controllers have unsigned values so we can just treat it as the MSB of the position value - or use 2's complement and treat it as a direction/sign bit).
Post Reply