-------------------------------- Update on encryption/obfuscation -------------------------------- ALL data received from attachment should be decrypted before beeing used as described here. Decryption is as follows: new = (old xor 0x17) + 0x17 This includes all nunchuck and classic data. ---------------------------- Identification of attachment ---------------------------- To identify type you have to init first. When you attach / detach an attachment Wiimote sends a report to 0x20. You can also ask for this by writing 0x4 to 0x15. Data returned is like this: byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 btn btn status 00 00 battery Bit 1 of the status byte tells you if an attachment is connected or not. A value of 1 on this bit means there is an attachment connected. To identify which one, you do the following: Send a read memory request to 0x4a400fe and ask for two bytes, like this: 0x17 0x4 0xa4 0x00 0xfe 0x00 0x02 This in turn gives you a report on 0x21 with the memory read. The full format of read/write can be found in wiki, but in short it's byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 byte 7 btn btn s/e offset offset data data the two data bytes indentify the attachment (decrypt these): 0x0000 fully inserted nunchuck 0x0101 fully inserted classic controller 0x2e2e nothing attached 0xffff partially inserted attachment Partially inserted usually goes away when you plug it in fully, it has however been known to stick rarely. This seem to be a hardware fault as it also happens in games from time to time. It's possible you only need to check one of the bytes, since they're equal for the currently released attachments. This might change in the future though, so I'd check both just to be certain. ---------------------------- Initialization of attachment ---------------------------- To use the nunchuck or classic controller you first need to initialize the attachment, like this: write 0x0 to 0x4A40040. the value you write here affects the data you get back, so it's related to the xor encryption/obfuscation. once this is done you set a mode which inludes extension data, see http://www.ch0p.com/wiiki/index.php?title=User:Marcan/Wiimote for mode documentation. Nunchuck and classic both need a mode with 6 extension bytes, so any will do. Choose one that has the Wiimote data that you want. --------------------------------------- Format of nunchuck data (decrypt first) --------------------------------------- byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 stickx sticky accx accy accz lsb of acc and buttons Z is bit 0, and C is bit 1, like this: (0 when pressed) Z = ~(byte6 & 1) C = ~(byte6 & 2) 6 MSB of byte6 are lsb of acceleration data, but they're not useful really.s example output (actual captured data): byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 71 7a 22 7b 63 37 decrypted these are: byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 7d 84 4c 83 8b 37 Nunchuck was centered, and we see the center is 125, 132. a +-7 deadzone is probably a good idea, as different nun chucks can have different centers. Following these are three acc bytes, and the last byte with buttons. As we see neither buttons were pressed, as two last bits are 11, leaving Z = 0 and C = 0. ------------------------------------------------- Format of classic controller data (decrypt first) ------------------------------------------------- Init is the same as nunchuck, and it gives you 6 bytes of data. Thus set it up the same way. Return values: byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 sticks and triggers----------- btn btn Now you need to decompose each value like this: x/y are sticks t is trigger lx = byte1&0x3F ly = byte2&0x3F rx = (byte1&0xC0)>>3 | (byte2&0xC0)>>5 | (byte3&0x80)>>7 ry = byte3&0x1F lt = (byte3&0x60)>>2 | (byte4&0xE0)>>5 rt = byte4&0x1F lx and ly have ranges 0 to 63 rx and ry have ranges 0 to 31 (half the resolution) rt and lt have ranges 0 to 31 Buttons need to be decoded the same way. They are 0 when pressed. Now you have the buttons in the following order: Byte 1 Byte 2 RDL-H+R_ ZBYAXZLU T T L R Happy coding -- DesktopMan http://www.auby.no