Gecko codes: Added parenthesis where they were needed.(thanks to glennrics and soren) Fixed a copy paste error with write & fill 8bit codes. Also forgot to remove a return false;.(some more codes should work (fixed issue 2968)) New Wiimote Plugin: Added emulated swinging.(seems to work) Changed the emulated calibration data to some nice values. ControllerInterface: moved and constified some stuff.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5980 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2010-07-26 05:30:50 +00:00
parent 0eaa7352fd
commit 5be58c6772
17 changed files with 224 additions and 224 deletions

View File

@ -27,68 +27,70 @@ static const u8 nunchuk_button_bitmasks[] =
Nunchuk::BUTTON_Z,
};
Nunchuk::Nunchuk(UDPWrapper * wrp) : Attachment( "Nunchuk" ) , udpWrap(wrp)
Nunchuk::Nunchuk(UDPWrapper *wrp) : Attachment("Nunchuk") , m_udpWrap(wrp)
{
// buttons
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
m_buttons->controls.push_back( new ControlGroup::Input( "C" ) );
m_buttons->controls.push_back( new ControlGroup::Input( "Z" ) );
groups.push_back(m_buttons = new Buttons("Buttons"));
m_buttons->controls.push_back(new ControlGroup::Input("C"));
m_buttons->controls.push_back(new ControlGroup::Input("Z"));
// stick
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
// tilt
groups.push_back( m_tilt = new Tilt( "Tilt" ) );
groups.push_back(m_stick = new AnalogStick("Stick"));
// swing
//groups.push_back( m_swing = new Force( "Swing" ) );
groups.push_back(m_swing = new Force("Swing"));
// tilt
groups.push_back(m_tilt = new Tilt("Tilt"));
// shake
groups.push_back( m_shake = new Buttons( "Shake" ) );
m_shake->controls.push_back( new ControlGroup::Input( "X" ) );
m_shake->controls.push_back( new ControlGroup::Input( "Y" ) );
m_shake->controls.push_back( new ControlGroup::Input( "Z" ) );
groups.push_back(m_shake = new Buttons("Shake"));
m_shake->controls.push_back(new ControlGroup::Input("X"));
m_shake->controls.push_back(new ControlGroup::Input("Y"));
m_shake->controls.push_back(new ControlGroup::Input("Z"));
// set up register
// calibration
memcpy( &reg[0x20], nunchuck_calibration, sizeof(nunchuck_calibration) );
memcpy(&reg[0x20], nunchuck_calibration, sizeof(nunchuck_calibration));
// id
memcpy( &reg[0xfa], nunchuck_id, sizeof(nunchuck_id) );
memcpy(&reg[0xfa], nunchuck_id, sizeof(nunchuck_id));
// this should get set to 0 on disconnect, but it isn't, o well
memset(m_shake_step, 0, sizeof(m_shake_step));
}
void Nunchuk::GetState( u8* const data, const bool focus )
void Nunchuk::GetState(u8* const data, const bool focus)
{
wm_extension* const ncdata = (wm_extension*)data;
ncdata->bt = 0;
// stick / not using calibration data for stick, o well
m_stick->GetState( &ncdata->jx, &ncdata->jy, 0x80, focus ? 127 : 0 );
m_stick->GetState(&ncdata->jx, &ncdata->jy, 0x80, focus ? 127 : 0);
// tilt
EmulateTilt((wm_accel*)&ncdata->ax, m_tilt, (accel_cal*)&reg[0x20], focus);
if (focus)
{
// swing
EmulateSwing((wm_accel*)&ncdata->ax, m_swing, (accel_cal*)&reg[0x20]);
// shake
EmulateShake(&ncdata->ax, m_shake, m_shake_step);
// buttons
m_buttons->GetState( &ncdata->bt, nunchuk_button_bitmasks );
m_buttons->GetState(&ncdata->bt, nunchuk_button_bitmasks);
}
// flip the button bits :/
ncdata->bt ^= 0x03;
//UDPNunchuk stuff
if (udpWrap->inst)
if (m_udpWrap->inst)
{
if (udpWrap->updNun)
if (m_udpWrap->updNun)
{
u8 mask;
float x, y;
udpWrap->inst->getNunchuck(x, y, mask);
m_udpWrap->inst->getNunchuck(x, y, mask);
// buttons
if (mask & UDPWM_NC)
ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_C;
@ -101,12 +103,12 @@ void Nunchuk::GetState( u8* const data, const bool focus )
ncdata->jy = u8(0x80 + y*127);
}
}
if (udpWrap->updNunAccel)
if (m_udpWrap->updNunAccel)
{
const accel_cal * const calib = (accel_cal*)&reg[0x20];
wm_accel * const accel = (wm_accel*)&ncdata->ax;
float x,y,z;
udpWrap->inst->getNunchuckAccel(x,y,z);
m_udpWrap->inst->getNunchuckAccel(x,y,z);
accel->x=u8(x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x);
accel->y=u8(y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y);
accel->z=u8(z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z);