mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-21 18:59:15 +01:00
Correct controller calibration data
This commit is contained in:
parent
5918bea536
commit
0bed750923
@ -67,37 +67,33 @@ void WiiPointer::Draw(GuiTrigger *t)
|
||||
else
|
||||
{
|
||||
angle = 0.0f;
|
||||
|
||||
// dynamic deadzone value required for WiiU gamepad when using Virtual Console Wii channels. Fixes diagonal sticks.
|
||||
// dirty fix. could be in input.h ?
|
||||
u8 deadzone = isWiiVC ? 20 : PADCAL;
|
||||
|
||||
|
||||
// GC PAD
|
||||
// x-axis
|
||||
if(t->pad.stickX < -deadzone)
|
||||
if(t->pad.stickX < -PADCAL)
|
||||
{
|
||||
posX += (t->pad.stickX + deadzone) * Settings.PointerSpeed;
|
||||
posX += (t->pad.stickX + PADCAL) * Settings.PointerSpeed;
|
||||
lastActivity = 0;
|
||||
}
|
||||
else if(t->pad.stickX > deadzone)
|
||||
else if(t->pad.stickX > PADCAL)
|
||||
{
|
||||
posX += (t->pad.stickX - deadzone) * Settings.PointerSpeed;
|
||||
posX += (t->pad.stickX - PADCAL) * Settings.PointerSpeed;
|
||||
lastActivity = 0;
|
||||
}
|
||||
// y-axis
|
||||
if(t->pad.stickY < -deadzone)
|
||||
if(t->pad.stickY < -PADCAL)
|
||||
{
|
||||
posY -= (t->pad.stickY + deadzone) * Settings.PointerSpeed;
|
||||
posY -= (t->pad.stickY + PADCAL) * Settings.PointerSpeed;
|
||||
lastActivity = 0;
|
||||
}
|
||||
else if(t->pad.stickY > deadzone)
|
||||
else if(t->pad.stickY > PADCAL)
|
||||
{
|
||||
posY -= (t->pad.stickY - deadzone) * Settings.PointerSpeed;
|
||||
posY -= (t->pad.stickY - PADCAL) * Settings.PointerSpeed;
|
||||
lastActivity = 0;
|
||||
}
|
||||
|
||||
int wpadX = t->WPAD_Stick(0, 0);
|
||||
int wpadY = t->WPAD_Stick(0, 1);
|
||||
s8 wpadX = t->WPAD_Stick(0, 0);
|
||||
s8 wpadY = t->WPAD_Stick(0, 1);
|
||||
|
||||
// Wii Extensions
|
||||
// x-axis
|
||||
|
@ -72,68 +72,77 @@ void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
*
|
||||
* Get X/Y value from Wii Joystick (classic, nunchuk) input
|
||||
***************************************************************************/
|
||||
|
||||
s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
||||
{
|
||||
float mag = 0.0;
|
||||
float ang = 0.0;
|
||||
struct joystick_t *js = NULL;
|
||||
|
||||
switch ( wpad.exp.type )
|
||||
switch (wpad.exp.type)
|
||||
{
|
||||
default:
|
||||
case WPAD_EXP_NUNCHUK:
|
||||
case WPAD_EXP_GUITARHERO3:
|
||||
case WPAD_EXP_NUNCHUK:
|
||||
js = right ? NULL : &wpad.exp.nunchuk.js;
|
||||
break;
|
||||
case WPAD_EXP_GUITARHERO3:
|
||||
js = right ? NULL : &wpad.exp.nunchuk.js;
|
||||
break;
|
||||
case WPAD_EXP_CLASSIC:
|
||||
js = right ? &wpad.exp.classic.rjs : &wpad.exp.classic.ljs;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (js)
|
||||
{
|
||||
int pos = axis ? js->pos.y : js->pos.x;
|
||||
int min = axis ? js->min.y : js->min.x;
|
||||
int max = axis ? js->max.y : js->max.x;
|
||||
int center = axis ? js->center.y : js->center.x;
|
||||
|
||||
// Fix bad calibration values (libogc 2.2.0 also fixes this)
|
||||
if ((min >= center) || (max <= center))
|
||||
{
|
||||
if ( right == 0 )
|
||||
if (axis)
|
||||
{
|
||||
mag = wpad.exp.nunchuk.js.mag;
|
||||
ang = wpad.exp.nunchuk.js.ang;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WPAD_EXP_CLASSIC:
|
||||
{
|
||||
if ( right == 0 )
|
||||
{
|
||||
mag = wpad.exp.classic.ljs.mag;
|
||||
ang = wpad.exp.classic.ljs.ang;
|
||||
min = js->min.y = 0;
|
||||
max = js->max.y = right ? 32 : 64;
|
||||
center = js->center.y = right ? 16 : 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
mag = wpad.exp.classic.rjs.mag;
|
||||
ang = wpad.exp.classic.rjs.ang;
|
||||
min = js->min.x = 0;
|
||||
max = js->max.x = right ? 32 : 64;
|
||||
center = js->center.x = right ? 16 : 32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Limit values
|
||||
if (pos > max)
|
||||
return 127;
|
||||
if (pos < min)
|
||||
return -128;
|
||||
|
||||
// Adjust against center position
|
||||
pos -= center;
|
||||
|
||||
// Return interpolated range
|
||||
if (pos > 0)
|
||||
return (s8)(127.0 * ((float)pos / (float)(max - center)));
|
||||
else
|
||||
return (s8)(128.0 * ((float)pos / (float)(center - min)));
|
||||
}
|
||||
|
||||
/* calculate x/y value (angle need to be converted into radian) */
|
||||
if ( mag > 1.0 )
|
||||
mag = 1.0;
|
||||
else if ( mag < -1.0 )
|
||||
mag = -1.0;
|
||||
|
||||
float val;
|
||||
|
||||
if ( axis == 0 ) // x-axis
|
||||
val = (float) (mag * sin( (PI * ang) / 180.0f ));
|
||||
else // y-axis
|
||||
val = (float) (mag * cos( (PI * ang) / 180.0f ));
|
||||
|
||||
return ( s8 )( val * 128.0f );
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool GuiTrigger::Left()
|
||||
{
|
||||
u32 wiibtn = WPAD_BUTTON_LEFT;
|
||||
if(wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
wiibtn |= WPAD_CLASSIC_BUTTON_LEFT;
|
||||
|
||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT))
|
||||
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT))
|
||||
{
|
||||
if( (wpad.btns_d & wiibtn)
|
||||
|| (pad.btns_d & PAD_BUTTON_LEFT))
|
||||
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_LEFT))
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
return true;
|
||||
@ -150,14 +159,12 @@ bool GuiTrigger::Left()
|
||||
bool GuiTrigger::Right()
|
||||
{
|
||||
u32 wiibtn = WPAD_BUTTON_RIGHT;
|
||||
if(wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
wiibtn |= WPAD_CLASSIC_BUTTON_RIGHT;
|
||||
|
||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT))
|
||||
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT))
|
||||
{
|
||||
if( (wpad.btns_d & wiibtn)
|
||||
|| (pad.btns_d & PAD_BUTTON_RIGHT))
|
||||
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_RIGHT))
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
return true;
|
||||
@ -174,14 +181,12 @@ bool GuiTrigger::Right()
|
||||
bool GuiTrigger::Up()
|
||||
{
|
||||
u32 wiibtn = WPAD_BUTTON_UP;
|
||||
if(wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
wiibtn |= WPAD_CLASSIC_BUTTON_UP;
|
||||
|
||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_UP))
|
||||
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_UP))
|
||||
{
|
||||
if( (wpad.btns_d & wiibtn)
|
||||
|| (pad.btns_d & PAD_BUTTON_UP))
|
||||
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_UP))
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
return true;
|
||||
@ -198,14 +203,12 @@ bool GuiTrigger::Up()
|
||||
bool GuiTrigger::Down()
|
||||
{
|
||||
u32 wiibtn = WPAD_BUTTON_DOWN;
|
||||
if(wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||
wiibtn |= WPAD_CLASSIC_BUTTON_DOWN;
|
||||
|
||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN))
|
||||
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN))
|
||||
{
|
||||
if( (wpad.btns_d & wiibtn)
|
||||
|| (pad.btns_d & PAD_BUTTON_DOWN))
|
||||
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_DOWN))
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
return true;
|
||||
|
@ -75,8 +75,21 @@ void UpdatePads()
|
||||
userInput[0].pad.btns_u |= wiidrc_to_pad(WiiDRC_ButtonsUp());
|
||||
userInput[0].pad.btns_h |= wiidrc_to_pad(WiiDRC_ButtonsHeld());
|
||||
// DRC stick state written to gamecube pad data
|
||||
userInput[0].pad.stickX = WiiDRC_lStickX();
|
||||
userInput[0].pad.stickY = WiiDRC_lStickY();
|
||||
|
||||
int x = 0, y = 0;
|
||||
x = (WiiDRC_lStickX() * 128) / 75;
|
||||
y = (WiiDRC_lStickY() * 128) / 75;
|
||||
if (x > 127)
|
||||
x = 127;
|
||||
else if (x < -128)
|
||||
x = -128;
|
||||
if (y > 127)
|
||||
y = 127;
|
||||
else if (y < -128)
|
||||
y = -128;
|
||||
|
||||
userInput[0].pad.stickX = x;
|
||||
userInput[0].pad.stickY = y;
|
||||
userInput[0].pad.substickX = WiiDRC_rStickX();
|
||||
userInput[0].pad.substickY = WiiDRC_rStickY();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user