Homebrew Pawnshop Joysticks on wii don't span all the way from 0 to 255

dreadpirate

New Member
OP
Newbie
Joined
May 23, 2012
Messages
4
Trophies
0
XP
58
Country
United States
Hey, this is my first post here. I noticed that while doing research gbatemp.net turned up quite a few useful threads so I figured I'd register here, but I'm not totally sure this is the right section so feel free to move it arround.

data.nunchuk.js.pos.x registers as 22 when all the way left and 220 when all the way right. Is this normal? I was thinking of setting up a game to register how far they are moving the joystick based on the distance of the joystick from origin.

My code would look something like this (I have a devkitpro environment):
Code:
joystickHandleing(){
struct expansion_t data;
WPAD_Expansion(WPAD_CHAN_0, &data); // Get expansion info from the first wiimote

joy_x = data.nunchuk.js.pos.x - 128;
joy_y = data.nunchuk.js.pos.y - 128;

double dist = getDistanceOfJoystickFromOrigin(joy_x, joy_y);
int runSpeed = setRunspeedTo(dist);
.
.
.
}


double getDistanceOfJoystickFromOrigin(int joy_x, int joy_y){
double result = sqrt(pow(joy_x, 2) + pow(joy_y, 2));
if (result > 127){ // cap it for dolphin emulation which goes beyond 127 when holding 'w' and 'd'
return 127;
}
return result;
}

But this is an icky situation since the pawnshop remote I have handy basically only goes from -108 to 92.

So if the left side of some (or most???) joysticks doesn't span as far as the right side, then I need to spend some more time on this function, don't I? So are all wii joysticks this finicky? Anyone know what the best practice is for determining the extent to which a joystick is being held so that it works symetrically?

Thanks so much.
 

tueidj

I R Expert
Member
Joined
Jan 8, 2009
Messages
2,569
Trophies
0
Website
Visit site
XP
999
Country
If you access the data via WPAD_Expansion() you are getting the "raw" values. This means the wiiuse library hasn't corrected them using either the built-in calibration data or the minimum/maximum values seen so far. Check the other values in the nunchuk struct (called min/max/center).
 
  • Like
Reactions: 1 person

dreadpirate

New Member
OP
Newbie
Joined
May 23, 2012
Messages
4
Trophies
0
XP
58
Country
United States
Thanks for the reply. I wish I had looked at that struct more closely a couple days ago before I coded all these functions. I never would have thought that the nunchuck would calibrate itself over transparently throughout runtime.

Anyway, thank god for version control, I better get to work modifying.

Btw, does this code look good for deadzone detection:

Code:
bool inDeadzone(joystick_t joy_data){
if (abs(joy_data.pos.x - joy_data.center.x) < 10 && abs(joy_data.pos.y - joy_data.center.y) < 10)
return true;
return false;
}
 

tueidj

I R Expert
Member
Joined
Jan 8, 2009
Messages
2,569
Trophies
0
Website
Visit site
XP
999
Country
For the nunchuk stick that's probably ok, if it is meant to handle the classic controller joysticks as well you might want to compare to a percentage of the min/max values instead of 10.
The reason is the classic controller sticks have much less accuracy/use a smaller range, the left stick returns values between -32:31 and the right stick is -16:15 (Nintendo really skimped out on them).
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • S @ salazarcosplay:
    how powerful does your phone have o be to run switch games
  • Skelletonike @ Skelletonike:
    My bad, misread your post due to the chat cutting the sentence
  • S @ salazarcosplay:
    emulator will let you back up your saves and also let you upscale to 1080p
    4k
  • S @ salazarcosplay:
    I wish I would have bought a large tv when they had large lcds that were 480p and 720p
  • S @ salazarcosplay:
    it would have
    made eveythign looks sharp and crisp
  • Skelletonike @ Skelletonike:
    I don't need upscale or 4k on a switch
  • Skelletonike @ Skelletonike:
    Portable is the best
  • RedColoredStars @ RedColoredStars:
    Those tvs are all over Facebook marketplace, Craigslist, and the local recycling center for free
  • RedColoredStars @ RedColoredStars:
    My daughters boyfriend just got a 36" Sony CRT for free at the recycling center. Works perfectly fine. He uses it for retro consoles and watching anime.
  • RedColoredStars @ RedColoredStars:
    I've never used my Switch outside of my home. I don't care much at all about portability. It's always docked.
  • Skelletonike @ Skelletonike:
    I'll need to get a small CRT eventually for older systems, preferably one of those with VCR
  • RedColoredStars @ RedColoredStars:
    Switch 2. 1440p baby!!!! Lol
  • Skelletonike @ Skelletonike:
    I love my portability, Steam Deck and Switch are my most used systems.
  • Skelletonike @ Skelletonike:
    Got a Series X and a PS5 but I don't use them that much.
  • RedColoredStars @ RedColoredStars:
    You must have great eyesight. I can barely read text when playing games on a 55" tv.
  • Skelletonike @ Skelletonike:
    Pre-ordered FFVII Rebirth's DE but haven't touched it yet.
  • Skelletonike @ Skelletonike:
    Not really, switch games have a pretty good hud and ui for the size, steam deck depends, fortunately some games allow to increase the HUD and UI.
  • RedColoredStars @ RedColoredStars:
    You can play both Series X and PS5 on portable devices. Including on your steam deck.
  • Skelletonike @ Skelletonike:
    I'm not a fan of streaming.
  • RedColoredStars @ RedColoredStars:
    You seem to move your goal posts quite often. Shrug.
  • Skelletonike @ Skelletonike:
    I tried streaming on the vita back in the day
  • Skelletonike @ Skelletonike:
    It was not a pleasa

    nt experience.
  • RedColoredStars @ RedColoredStars:
    A lot has changed in 13 years.
  • BakerMan @ BakerMan:
    holy shit it's storming here rn
  • BakerMan @ BakerMan:
    like a lot
    BakerMan @ BakerMan: like a lot