Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 07:25 05 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Wii Classic Controller

Author Message
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 06:06am 09 Sep 2014
Copy link to clipboard 
Print this post

Before I start re-inventing the wheel, is there any chance that someone here has done Micromite compatible code for the Wii Classic Controller?

Thanks
Jeff

My Propeller/Micromite mini-computer project.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 06:29am 09 Sep 2014
Copy link to clipboard 
Print this post

Jeff, take a look here for the Nunchuck.

However, regarding the Classic controller I personally have not seen anything.

WW
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 02:54pm 09 Sep 2014
Copy link to clipboard 
Print this post


I've got some spin code here for the Wii Classic controller, I'll look at starting to convert it next week.
My Propeller/Micromite mini-computer project.
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 225
Posted: 01:06am 10 Sep 2014
Copy link to clipboard 
Print this post

Hi Jeff

This is code for a WII classic controller in picaxe code.

It should not be to difficult to convert to micromite

I do not have a controller now so I can not attempt to convert and test.

[code]

' Program to read data form a Wii Classic Controller into a picaxe 28X2.
' Bill Brown Bill.b 29th July 2013
'
' I have tested the program with a 40X2 and it worked OK. The program does not work correctlly with M2 chips
' Some more work is required for M2s
'
'
' The Wii Receiver module required a 3.3volt supply.
' In my test unit i derived the 3.3v by connection two IN4001 diodes in series to the 5v supply giving approximatly 3.4v.
' 4k7 pullup reistors are unsed on the SCL and SDA - Connected to the +3.4v supply
'
' Data format for the 6 bytes of data from the Wii Classic Controller (WiiByte0 - 5)
'----------------------------------------------------------- ----
'|Byte | Bit |
'|------|--------------------------------------------------- ----|
'| | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
'|---------------------------------------------------------- ----|
'| 0 | RX<4:3> | LX<5:0> |
'|---------------------------------------------------------- ----|
'| 1 | RX<2:1> | LY<5:0> |
'|---------------------------------------------------------- ----|
'| 2 |RX<0> | LT<4:3> | RY<4:0> |
'|---------------------------------------------------------- ----|
'| 3 | LT<2:0> | RY<4:0> |
'|---------------------------------------------------------- ----|
'| 4 | BDR | BDD | BLT | B- | BH | B+ | BRT | 1 |
'|---------------------------------------------------------- ----|
'| 5 | BZL | BB | BY | BA | BX | BZR | BDL | BDU |
'!---------------------------------------------------------- ----!
'
'LX,LY are the left analogue stick, X and Y (0 - 63). RX and RY are the right analogue stick, X and Y (0 - 31).
'LT and RT are the left and right triggers (0 - 31). The left analogue stick has twice the precision of the other stick
'
' BD(L,R,U,D) are the D-Pad direction buttons. B(ZR,ZL,A,B,X,Y,+,H,-) are the discrete buttons.
'B(LT,RT) are the digital button click of the LT and RT. all Buttons are 0 when pressed.

#picaxe 28x2
setfreq m8
symbol WiiByte0 = b7 'Wii byte 0
symbol WiiByte1 = b8 'Wii byte 1
symbol WiiByte2 = b9 'Wii byte 2
symbol WiiByte3 = b10 'Wii byte 3
symbol WiiByte4 = b11 'Wii byte 4
symbol WiiByte5 = b12 'Wii byte 5
symbol WiiTemp0 = b13 'Wii Temperary storage byte
symbol WiiLeftX = b14 'Left stick X axis 0 - 63
symbol WiiLeftY = b15 'Left stick Y axis 0 - 63
symbol WiiRightX = b16 'Right stick X axis 0 - 31
symbol WiiRightY = b17 'Right stick Y axis 0 - 31
symbol WiiLeftT = b18 'Left trigger 0 - 31
symbol WiiRightT = b19 'Right trigger 0 - 31

i2cslave %010100100, i2cfast_16, i2cbyte 'I2C setup for Wii controller
hi2cout 0,($F0,$55) 'Wii Configuration bytes
pause 10
hi2cout 0,($FB,00) 'Wii Configuration bytes
pause 10
hi2cout 0, ($00) 'Wii Request data

'Main program start here

main:

hi2cout 0, ($00) 'Wii Request data
pause 70
hi2cin 0,(WiiByte0,WiiByte1,WiiByte2,WiiByte3,WiiByte4,WiiByte5) 'Data from Wii Controller

'The following section arranges the data from the Wii bytes 0 - 4 into seperate bytes for used in the program

pause 50
WiiLeftX = WiiByte0 & %00111111 'Left stick X = Bits 0 - 5 of wiibyte0
WiiLeftY = WiiByte1 & %00111111 'Left stick Y = Bits 0 - 5 of wiibyte1
WiiRightX = WiiByte2 & %00011111 'Right stick X = Bits 0 - 4 of wiibyte2
WiiRightY = WiiByte2 & %10000000 'Move bit 7 of wiibyte2 to Right stick Y
WiiRightY = WiiRightY >> 2 'shift right 2 places
WiiTemp0 = WiiByte1 & %11000000 'move bits 6 & 7 of wiibyte1 to temp
WiiRightY = WiiRightY OR WiiTemp0 'Combine temp and right stick Y
WiiRightY = WiiRightY >> 2 'Shift right 2 places
WiiTemp0 = WiiByte0 & %11000000 'move bits 6 & 7 of wiibyte0 to temp
WiiRightY = WiiRightY OR WiiTemp0 'Combine temp and right stick Y
WiiRightY = WiiRightY >> 3 'Shift right 3 places. Right stick Y byte completed
WiiRightT = WiiByte3 & %00011111 'move Right Tigger bits 0 - 5 form wiibyte 3 to wiiRightT
WiiLeftT = WiiByte3 & %11100000 'move left trigger bits 5 - 7 form wiibyte 3 to wiiLeftT
WiiLeftT = WiiLeftT >> 3 'shift right 3 positions.
WiiTemp0 = WiiByte2 & %01100000 'Move Left trigger bits 3 & 4 to temp
WiiLeftT = WiiLeftT OR WiiTemp0 ' combine wiiLeftT and Temp
WiiLeftT = WiiLeftT >> 2 'Shift right 2 positions to complete wiiLeftT byte.

'debug

goto main
[/code]

Bill
Edited by Bill.b 2014-09-11
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 03:17pm 10 Sep 2014
Copy link to clipboard 
Print this post

If I understand correctly, the Classic Controller is I2C address &hA4 which the Micromite is unwilling to accept. Have I missed something or uncovered a bug?
My Propeller/Micromite mini-computer project.
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 03:26pm 10 Sep 2014
Copy link to clipboard 
Print this post

Hi Jeff,

According to instructibles the address is &H52

Link

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 03:35pm 10 Sep 2014
Copy link to clipboard 
Print this post

Mick,

Just found that same link about the same time you posted it..

pressing on..
My Propeller/Micromite mini-computer project.
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 03:46pm 10 Sep 2014
Copy link to clipboard 
Print this post

Aha!

A word of caution.. Those china made clones do NOT work on the same as the branded Wii(R) classic controller. I just switched to an actual license product and started getting data.


My Propeller/Micromite mini-computer project.
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 03:49pm 10 Sep 2014
Copy link to clipboard 
Print this post

Jeff,

It wouldnt be because of the selected controller channel would it?

Maybe your original remote (presumably controller 1) was set at &H52, and as you added new controllers they adopted another address? For User 2,3,4 etc?

Just theorising.

Mick


Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 04:03pm 10 Sep 2014
Copy link to clipboard 
Print this post

Maybe. I'll have to do some more research after I get the real stick working.

BTW, how do I 'bit shift' on the Micromite? :)


My Propeller/Micromite mini-computer project.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 04:23pm 10 Sep 2014
Copy link to clipboard 
Print this post


  Oldbitcollector said  BTW, how do I 'bit shift' on the Micromite? :)

If x is your 'original' number then:

(x *2) AND &hFF [to shift left]
or
(x AND &hFE) / 2 [to shift right]

Use additional AND statement to extract bit required . . .

WW
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 04:52pm 10 Sep 2014
Copy link to clipboard 
Print this post

Stopping for the night.. Here's some working code that reads the Left Joystick control and most of the digital buttons.

[code]
I2C OPEN 10,100
i2caddr = &h52 'Nunchuck Address
Dim RDbuff(7)
I2C write i2caddr,0,2,&hf0,&h55
I2C write i2caddr,0,2,&hfb,&h0
I2C write i2caddr,0,1,&h0
Pause 100

readwii:
I2C write i2caddr,0,1,&h0
I2C read i2caddr,0,6,RDBuff(0)
Print Chr$(27)+"[f"; :Print Chr$(27)+"[2J";
up=0:down=0:right=0:left=0:home=0:select=0:start=0:btX=0:btY =0:btA=0:btB=0
LeftX = (RDBuff(0) And &b00111111)
LeftY = (RDBuff(1) And &b00111111)
RightX = (RDBuff(2) And &b00011111)
RightY = (RDBuff(2) And &b10000000)

If RDBuff(5) = 254 Then up=1
If RDBuff(4) = 191 Then down=1
If RDBuff(4) = 127 Then right=1
If RDBuff(5) = 253 Then left=1
If RDBuff(4) = 239 Then select=1
If RDBuff(4) = 247 Then home=1
If RDBuff(4) = 251 Then start=1
If RDbuff(5) = 247 Then BtX=1
If RDbuff(5) = 223 Then BtY=1
If RDbuff(5) = 239 Then BtA=1
If RDbuff(5) = 191 Then BtB=1


RightT = (RDBuff(3) And &b00011111)
LeftT = (RDBuff(3) And &b11100000)

Print "LX:";LeftX;
Print " LY:";LeftY;
'Print " RightX:";RightX
'Print " RightY:";RightY
Print " RT:";RightT;
Print " LT:";LeftT;
Print " Up:";up;
Print " Down:";down;
Print " Left:";left;
Print " Right:";right
Print "Select:";select;
Print " Home:";home;
Print " Start:";start;
Print " BX:";BtX;
Print " BY:";BtY;
Print " BA:";BtA;
Print " BB:";BtB
Pause 200
GoTo readwii
[/code]

My Propeller/Micromite mini-computer project.
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 04:55am 11 Sep 2014
Copy link to clipboard 
Print this post

I was looking over my digital IF statement checking code this morning and thinking that it might be a good idea to change that method to a binary 'and' method as the decimal numbers will change when multiple buttons are pressed.


My Propeller/Micromite mini-computer project.
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 05:19pm 12 Sep 2014
Copy link to clipboard 
Print this post

Here's an update which is friendly to simultaneous button presses..

[code]
'' CLASSIC.BAS V1.1 - By Jeff Ledger
'' Returns Left Controller & Digital Buttons from Wii Classic Controller.
'' Tested with licensed controller, may not work on clone controllers.

I2C OPEN 400,100
i2caddr = &h52 'Wii Classic Controller Address
Dim RDbuff(7)
I2C write i2caddr,0,2,&hf0,&h55
I2C write i2caddr,0,2,&hfb,&h0
I2C write i2caddr,0,1,&h0
Pause 100

Readwii:
I2C write i2caddr,0,1,&h0
I2C read i2caddr,0,6,RDBuff(0)
Print Chr$(27)+"[f"; :Print Chr$(27)+"[2J";
rt=0:lt=0:up=0:down=0:right=0:left=0:home=0:select=0:start=0 :btX=0:btY=0:btA=0:btB=0
LeftX = (RDBuff(0) And &b00111111)
LeftY = (RDBuff(1) And &b00111111)
If (RDBuff(3) And &b00011111) = 31 Then rt=1
If (RDBuff(3) And &b11100000) = 224 Then lt=1

If Mid$(Bin$(RDBuff(5)),8,1) = "0" Then up = 1
If Mid$(Bin$(RDBuff(4)),2,1) = "0" Then down=1
If Len(Bin$(RDBuff(4))) = 7 Then right=1
If Mid$(Bin$(RDBuff(5)),7,1) = "0" Then left=1
If Mid$(Bin$(RDBuff(4)),4,1) = "0" Then select=1
If Mid$(Bin$(RDBuff(4)),5,1) = "0" Then home=1
If Mid$(Bin$(RDBuff(4)),6,1) = "0" Then start=1
If Mid$(Bin$(RDBuff(5)),5,1) = "0" Then BtX=1
If Mid$(Bin$(RDBuff(5)),3,1) = "0" Then BtY=1
If Mid$(Bin$(RDBuff(5)),2,1) = "0" Then BtB=1
If Mid$(Bin$(RDBuff(5)),4,1) = "0" Then BtA=1

Print "LX:";LeftX;
Print " LY:";LeftY;
Print " LT:";lt;
Print " RT:";rt;
Print " Up:";up;
Print " Down:";down;
Print " Left:";left;
Print " Right:";right
Print "Select:";select;
Print " Home:";home;
Print " Start:";start;
Print " BX:";BtX;
Print " BY:";BtY;
Print " BA:";BtA;
Print " BB:";BtB
Pause 100
GoTo readwii
[/code]

My Propeller/Micromite mini-computer project.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024