mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 11:19:17 +01:00
Correct controller calibration data
This commit is contained in:
parent
5918bea536
commit
0bed750923
@ -68,36 +68,32 @@ void WiiPointer::Draw(GuiTrigger *t)
|
|||||||
{
|
{
|
||||||
angle = 0.0f;
|
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
|
// GC PAD
|
||||||
// x-axis
|
// 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;
|
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;
|
lastActivity = 0;
|
||||||
}
|
}
|
||||||
// y-axis
|
// 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;
|
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;
|
lastActivity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wpadX = t->WPAD_Stick(0, 0);
|
s8 wpadX = t->WPAD_Stick(0, 0);
|
||||||
int wpadY = t->WPAD_Stick(0, 1);
|
s8 wpadY = t->WPAD_Stick(0, 1);
|
||||||
|
|
||||||
// Wii Extensions
|
// Wii Extensions
|
||||||
// x-axis
|
// x-axis
|
||||||
|
@ -72,55 +72,66 @@ void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
|||||||
*
|
*
|
||||||
* Get X/Y value from Wii Joystick (classic, nunchuk) input
|
* Get X/Y value from Wii Joystick (classic, nunchuk) input
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
||||||
{
|
{
|
||||||
float mag = 0.0;
|
struct joystick_t *js = NULL;
|
||||||
float ang = 0.0;
|
|
||||||
|
|
||||||
switch (wpad.exp.type)
|
switch (wpad.exp.type)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case WPAD_EXP_NUNCHUK:
|
case WPAD_EXP_NUNCHUK:
|
||||||
|
js = right ? NULL : &wpad.exp.nunchuk.js;
|
||||||
|
break;
|
||||||
case WPAD_EXP_GUITARHERO3:
|
case WPAD_EXP_GUITARHERO3:
|
||||||
{
|
js = right ? NULL : &wpad.exp.nunchuk.js;
|
||||||
if ( right == 0 )
|
break;
|
||||||
{
|
case WPAD_EXP_CLASSIC:
|
||||||
mag = wpad.exp.nunchuk.js.mag;
|
js = right ? &wpad.exp.classic.rjs : &wpad.exp.classic.ljs;
|
||||||
ang = wpad.exp.nunchuk.js.ang;
|
break;
|
||||||
}
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WPAD_EXP_CLASSIC:
|
|
||||||
|
if (js)
|
||||||
{
|
{
|
||||||
if ( right == 0 )
|
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))
|
||||||
{
|
{
|
||||||
mag = wpad.exp.classic.ljs.mag;
|
if (axis)
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
mag = wpad.exp.classic.rjs.mag;
|
min = js->min.x = 0;
|
||||||
ang = wpad.exp.classic.rjs.ang;
|
max = js->max.x = right ? 32 : 64;
|
||||||
}
|
center = js->center.x = right ? 16 : 32;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate x/y value (angle need to be converted into radian) */
|
// Limit values
|
||||||
if ( mag > 1.0 )
|
if (pos > max)
|
||||||
mag = 1.0;
|
return 127;
|
||||||
else if ( mag < -1.0 )
|
if (pos < min)
|
||||||
mag = -1.0;
|
return -128;
|
||||||
|
|
||||||
float val;
|
// Adjust against center position
|
||||||
|
pos -= center;
|
||||||
|
|
||||||
if ( axis == 0 ) // x-axis
|
// Return interpolated range
|
||||||
val = (float) (mag * sin( (PI * ang) / 180.0f ));
|
if (pos > 0)
|
||||||
else // y-axis
|
return (s8)(127.0 * ((float)pos / (float)(max - center)));
|
||||||
val = (float) (mag * cos( (PI * ang) / 180.0f ));
|
else
|
||||||
|
return (s8)(128.0 * ((float)pos / (float)(center - min)));
|
||||||
|
}
|
||||||
|
|
||||||
return ( s8 )( val * 128.0f );
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiTrigger::Left()
|
bool GuiTrigger::Left()
|
||||||
@ -129,11 +140,9 @@ bool GuiTrigger::Left()
|
|||||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||||
wiibtn |= WPAD_CLASSIC_BUTTON_LEFT;
|
wiibtn |= WPAD_CLASSIC_BUTTON_LEFT;
|
||||||
|
|
||||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT))
|
||||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT))
|
|
||||||
{
|
{
|
||||||
if( (wpad.btns_d & wiibtn)
|
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_LEFT))
|
||||||
|| (pad.btns_d & PAD_BUTTON_LEFT))
|
|
||||||
{
|
{
|
||||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||||
return true;
|
return true;
|
||||||
@ -153,11 +162,9 @@ bool GuiTrigger::Right()
|
|||||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||||
wiibtn |= WPAD_CLASSIC_BUTTON_RIGHT;
|
wiibtn |= WPAD_CLASSIC_BUTTON_RIGHT;
|
||||||
|
|
||||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT))
|
||||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT))
|
|
||||||
{
|
{
|
||||||
if( (wpad.btns_d & wiibtn)
|
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_RIGHT))
|
||||||
|| (pad.btns_d & PAD_BUTTON_RIGHT))
|
|
||||||
{
|
{
|
||||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||||
return true;
|
return true;
|
||||||
@ -177,11 +184,9 @@ bool GuiTrigger::Up()
|
|||||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||||
wiibtn |= WPAD_CLASSIC_BUTTON_UP;
|
wiibtn |= WPAD_CLASSIC_BUTTON_UP;
|
||||||
|
|
||||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_UP))
|
||||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_UP))
|
|
||||||
{
|
{
|
||||||
if( (wpad.btns_d & wiibtn)
|
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_UP))
|
||||||
|| (pad.btns_d & PAD_BUTTON_UP))
|
|
||||||
{
|
{
|
||||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||||
return true;
|
return true;
|
||||||
@ -201,11 +206,9 @@ bool GuiTrigger::Down()
|
|||||||
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
if (wpad.exp.type == WPAD_EXP_CLASSIC)
|
||||||
wiibtn |= WPAD_CLASSIC_BUTTON_DOWN;
|
wiibtn |= WPAD_CLASSIC_BUTTON_DOWN;
|
||||||
|
|
||||||
if( ((wpad.btns_d | wpad.btns_h) & wiibtn)
|
if (((wpad.btns_d | wpad.btns_h) & wiibtn) || ((pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN))
|
||||||
|| ((pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN))
|
|
||||||
{
|
{
|
||||||
if( (wpad.btns_d & wiibtn)
|
if ((wpad.btns_d & wiibtn) || (pad.btns_d & PAD_BUTTON_DOWN))
|
||||||
|| (pad.btns_d & PAD_BUTTON_DOWN))
|
|
||||||
{
|
{
|
||||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||||
return true;
|
return true;
|
||||||
|
@ -75,8 +75,21 @@ void UpdatePads()
|
|||||||
userInput[0].pad.btns_u |= wiidrc_to_pad(WiiDRC_ButtonsUp());
|
userInput[0].pad.btns_u |= wiidrc_to_pad(WiiDRC_ButtonsUp());
|
||||||
userInput[0].pad.btns_h |= wiidrc_to_pad(WiiDRC_ButtonsHeld());
|
userInput[0].pad.btns_h |= wiidrc_to_pad(WiiDRC_ButtonsHeld());
|
||||||
// DRC stick state written to gamecube pad data
|
// 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.substickX = WiiDRC_rStickX();
|
||||||
userInput[0].pad.substickY = WiiDRC_rStickY();
|
userInput[0].pad.substickY = WiiDRC_rStickY();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user