mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
Added nunchuck acceleration support to UDPWii . Moved some UDPWii stuff to the nunchuck attachment because I needed calibration data for the nunchuck...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5878 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -27,7 +27,7 @@ static const u8 nunchuk_button_bitmasks[] =
|
||||
Nunchuk::BUTTON_Z,
|
||||
};
|
||||
|
||||
Nunchuk::Nunchuk() : Attachment( "Nunchuk" )
|
||||
Nunchuk::Nunchuk(UDPWrapper * wrp) : Attachment( "Nunchuk" ) , udpWrap(wrp)
|
||||
{
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
@ -80,6 +80,39 @@ void Nunchuk::GetState( u8* const data, const bool focus )
|
||||
|
||||
// flip the button bits :/
|
||||
ncdata->bt ^= 0x03;
|
||||
|
||||
//UDPNunchuk stuff
|
||||
if (udpWrap->inst)
|
||||
{
|
||||
if (udpWrap->updNun)
|
||||
{
|
||||
u8 mask;
|
||||
float x, y;
|
||||
udpWrap->inst->getNunchuck(x, y, mask);
|
||||
// buttons
|
||||
if (mask & UDPWM_NC)
|
||||
ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_C;
|
||||
if (mask & UDPWM_NZ)
|
||||
ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_Z;
|
||||
// stick
|
||||
if (ncdata->jx == 0x80 && ncdata->jy == 0x80)
|
||||
{
|
||||
ncdata->jx = u8(0x80 + x*127);
|
||||
ncdata->jy = u8(0x80 + y*127);
|
||||
}
|
||||
}
|
||||
if (udpWrap->updNunAccel)
|
||||
{
|
||||
const accel_cal * const calib = (accel_cal*)®[0x20];
|
||||
wm_accel * const accel = (wm_accel*)&ncdata->ax;
|
||||
float x,y,z;
|
||||
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);
|
||||
}
|
||||
}
|
||||
//End UDPNunchuck
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,13 +3,15 @@
|
||||
|
||||
#include "Attachment.h"
|
||||
|
||||
class UDPWrapper;
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
class Nunchuk : public Attachment
|
||||
{
|
||||
public:
|
||||
Nunchuk();
|
||||
Nunchuk(UDPWrapper * wrp);
|
||||
virtual void GetState( u8* const data, const bool focus );
|
||||
|
||||
enum
|
||||
@ -28,6 +30,8 @@ private:
|
||||
AnalogStick* m_stick;
|
||||
|
||||
unsigned int m_shake_step[3];
|
||||
|
||||
UDPWrapper * udpWrap;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace UDPTLayer
|
||||
*y=-(_y*2-1);
|
||||
*z=0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -288,7 +288,7 @@ Wiimote::Wiimote( const unsigned int index )
|
||||
// extension
|
||||
groups.push_back( m_extension = new Extension( "Extension" ) );
|
||||
m_extension->attachments.push_back( new WiimoteEmu::None() );
|
||||
m_extension->attachments.push_back( new WiimoteEmu::Nunchuk() );
|
||||
m_extension->attachments.push_back( new WiimoteEmu::Nunchuk(m_udp) );
|
||||
m_extension->attachments.push_back( new WiimoteEmu::Classic() );
|
||||
m_extension->attachments.push_back( new WiimoteEmu::Guitar() );
|
||||
m_extension->attachments.push_back( new WiimoteEmu::Drums() );
|
||||
@ -601,25 +601,10 @@ void Wiimote::Update()
|
||||
|
||||
// ---- UDP Wiimote nunchuk stuff
|
||||
// 1 == is hacky, for if nunchuk is attached
|
||||
if (is_focus && 1 == m_extension->active_extension && m_udp->inst)
|
||||
{
|
||||
wm_extension* const ncdata = (wm_extension*)(data + rpt.ext);
|
||||
|
||||
u8 mask;
|
||||
float x, y;
|
||||
m_udp->inst->getNunchuck(x, y, mask);
|
||||
// buttons
|
||||
if (mask & UDPWM_NC)
|
||||
ncdata->bt &= ~Nunchuk::BUTTON_C;
|
||||
if (mask & UDPWM_NZ)
|
||||
ncdata->bt &= ~Nunchuk::BUTTON_Z;
|
||||
// stick
|
||||
if (ncdata->jx == 0x80 && ncdata->jy == 0x80)
|
||||
{
|
||||
ncdata->jx = u8(0x80 + x*127);
|
||||
ncdata->jy = u8(0x80 + y*127);
|
||||
}
|
||||
}
|
||||
//if (is_focus && 1 == m_extension->active_extension)
|
||||
//{
|
||||
// UDPTLayer::GetNunchuk(m_udp,(wm_extension*)(data + rpt.ext));
|
||||
//}
|
||||
// ---- end UDP Wiimote
|
||||
|
||||
// i dont think anything accesses the extension data like this, but ill support it. Indeed, commercial games don't do this.
|
||||
|
Reference in New Issue
Block a user