## 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: 170 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: 170 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
{"ft_lang_label":"__label__en","ft_lang_prob":0.63605046,"math_prob":0.8291272,"size":2172,"snap":"2020-34-2020-40","text_gpt3_token_len":874,"char_repetition_ratio":0.17712177,"word_repetition_ratio":0.5627907,"special_character_ratio":0.4263352,"punctuation_ratio":0.16293278,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9514121,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-09T22:50:15Z\",\"WARC-Record-ID\":\"<urn:uuid:a67ae5da-6d5d-4ee5-847a-62e367d5505c>\",\"Content-Length\":\"41518\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a5b19f46-9373-4cff-9764-692c1fa50328>\",\"WARC-Concurrent-To\":\"<urn:uuid:681649c3-22e6-4079-a4ff-dd8cd7670950>\",\"WARC-IP-Address\":\"3.14.138.89\",\"WARC-Target-URI\":\"https://sudomod.com/forum/viewtopic.php?f=18&t=1361\",\"WARC-Payload-Digest\":\"sha1:XIZYP7RV2FU4IHQRXBKBWMJB3KUV4UOJ\",\"WARC-Block-Digest\":\"sha1:W6BD2AUXQ7LI447UV4F6ECFUJWMN3LXM\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439738595.30_warc_CC-MAIN-20200809222112-20200810012112-00566.warc.gz\"}"}