(gx_joypad.c) Declare variables at top

This commit is contained in:
twinaphex 2015-12-04 12:00:00 +01:00
parent 0b9df5a069
commit 35da6073df
1 changed files with 35 additions and 34 deletions

View File

@ -301,45 +301,46 @@ static int16_t WPAD_StickX(WPADData *data, u8 right)
static int16_t WPAD_StickY(WPADData *data, u8 right) static int16_t WPAD_StickY(WPADData *data, u8 right)
{ {
float mag = 0.0f; double val;
float ang = 0.0f; float mag = 0.0f;
float ang = 0.0f;
switch (data->exp.type) switch (data->exp.type)
{ {
case WPAD_EXP_NUNCHUK: case WPAD_EXP_NUNCHUK:
case WPAD_EXP_GUITARHERO3: case WPAD_EXP_GUITARHERO3:
if (right == 0) if (right == 0)
{ {
mag = data->exp.nunchuk.js.mag; mag = data->exp.nunchuk.js.mag;
ang = data->exp.nunchuk.js.ang; ang = data->exp.nunchuk.js.ang;
} }
break; break;
case WPAD_EXP_CLASSIC: case WPAD_EXP_CLASSIC:
if (right == 0) if (right == 0)
{ {
mag = data->exp.classic.ljs.mag; mag = data->exp.classic.ljs.mag;
ang = data->exp.classic.ljs.ang; ang = data->exp.classic.ljs.ang;
} }
else else
{ {
mag = data->exp.classic.rjs.mag; mag = data->exp.classic.rjs.mag;
ang = data->exp.classic.rjs.ang; ang = data->exp.classic.rjs.ang;
} }
break; break;
default: default:
break; break;
} }
/* calculate Y value (angle need to be converted into radian) */ /* calculate Y value (angle need to be converted into radian) */
if (mag > 1.0f) if (mag > 1.0f)
mag = 1.0f; mag = 1.0f;
else if (mag < -1.0f) else if (mag < -1.0f)
mag = -1.0f; mag = -1.0f;
double val = -mag * cos(PI * ang/180.0f); val = -mag * cos(PI * ang/180.0f);
return (int16_t)(val * 32767.0f); return (int16_t)(val * 32767.0f);
} }
#endif #endif