Page 1 of 1

Teensy 2.0 WII U Joystick range

Posted: Sat Sep 03, 2016 2:59 pm
Hi
I'm trying to program teensy to use WII U joystick.

This working fine in windows but in retropie it will not detect joystick movement as the maximum range is too small.
The standard arduino joystick module is around 10 kOhm but wii u is around 5k

So I used some code from net to double the range

Joystick.X(((analogRead(0) -512) * 2) + 512);
Joystick.Y(((analogRead(1) -512) * 2) + 512);

Again this solve the range issue but some axis doing strange things when moved to max position. When the analog X reaches max position it jumps to maximum value on analog Y.

So the question is how to control the max value or limit the max range on X,Y.?

Any sample code for Tennsy 2.0 will be appreciated

Re: Teensy 2.0 WII U Joystick range

Posted: Sun Sep 18, 2016 11:55 am
So finally found a solution for those wii u joystick. Feel free to use or let me know how it can be tweaked even more ?

void loop() {

int rX = analogRead(0);
rX = (rX - 512) * 2 + 512;
if (rX > 1023)
rX=1023;
if (rX < 0)
rX = 0;

int rY = analogRead(1);
rY = (rY - 512) * 2 + 512;
if (rY > 1023)
rY=1023;
if (rY < 0)
rY = 0;

int rL = analogRead(4);
rL = (rL - 512) * 2 + 512;
if (rL > 1023)
rL=1023;
if (rL < 0)
rL = 0;

int rR = analogRead(5);
rR = (rR - 512) * 2 + 512;
if (rR > 1023)
rR=1023;
if (rR < 0)
rR = 0;
rR=abs(1023-rR);

Joystick.X(rL);
Joystick.Y(rR);
Joystick.sliderLeft(rY);
Joystick.sliderRight(rX);