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.
  • Sicklyboy @ Sicklyboy:
    maaaaan that's so awesome but I also don't want to fork over a hundo for it
  • Veho @ Veho:
    The fuuuuu---
  • Veho @ Veho:
    I thought it was an actual xBox at that price.
  • Sicklyboy @ Sicklyboy:
    I wanna grab a 360 Slim and a 360 E one of these days. Missed the boat of getting them at their lowest though, once they were discontinued. Could've got them for cheap back when I was a broke 20 something working at Target, but then again, I was a broke 20 something working at Target
  • Veho @ Veho:
    Being broke is no fun.
  • K3Nv2 @ K3Nv2:
    @Sicklyboy, $150 isn't that bad for a jtag slim on ebay
  • Veho @ Veho:
    I only wish it was actually playable.
  • Veho @ Veho:
    There's a guy on the Tube of You that makes playable mechanical arcade games out of Lego. This could work on the same principle.
  • Veho @ Veho:
    Just a couple of guys taking their manatee out for some fresh air, why you have to molest them?
  • Veho @ Veho:
    Stupid Chinese shop switched their shipping company and this one is slooooooow.
  • LeoTCK @ LeoTCK:
    STOP BUYING CHINESE CRAP THEN
  • LeoTCK @ LeoTCK:
    SUPPORT LOCAL PRODUCTS, MAKE REVOLUTION
  • LeoTCK @ LeoTCK:
    THEY KEEP REMOVING LOCAL SHIt AND REPLACING WItH INFERIOR CHINESE CRAP
  • LeoTCK @ LeoTCK:
    THATS WHY MY PARTNER CANT GET A GOOTWEAR HIS SIZE ANYMORE
  • LeoTCK @ LeoTCK:
    HE HAS BIG FOOT AND BIG DUCK
  • LeoTCK @ LeoTCK:
    d*ck i mean*
  • LeoTCK @ LeoTCK:
    lol
  • Veho @ Veho:
    Mkay.
  • Veho @ Veho:
    I just ordered another package from China just to spite you.
  • SylverReZ @ SylverReZ:
    Leo could not withstand communism.
  • SylverReZ @ SylverReZ:
    Its OUR products to begin with lol.
    SylverReZ @ SylverReZ: Its OUR products to begin with lol.