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):
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.
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.