## Teensy 2.0 WII U Joystick range

Arduino/Teensy software/code questions and discussion
banjokazooie
Posts: 211
Joined: Thu May 19, 2016 1:14 pm
Been thanked: 164 times

### Teensy 2.0 WII U Joystick range

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

banjokazooie
Posts: 211
Joined: Thu May 19, 2016 1:14 pm
Been thanked: 164 times

### Re: Teensy 2.0 WII U Joystick range

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() {

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

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

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

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);

### Who is online

Users browsing this forum: No registered users and 1 guest