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:
dapetcu21
2010-07-14 17:33:14 +00:00
parent 61bd545f80
commit bbb48603be
8 changed files with 97 additions and 32 deletions

View File

@ -66,7 +66,7 @@ THREAD_RETURN UDPWiiThread(void* arg)
UDPWiimote::UDPWiimote(const char *_port) :
port(_port),
d(new _d) ,x(0),y(0),z(0),nunX(0),nunY(0),
d(new _d) ,x(0),y(0),z(0),naX(0),naY(0),naZ(0),nunX(0),nunY(0),
pointerX(-0.1),pointerY(-0.1),nunMask(0),mask(0),time(0)
{
#ifdef _WIN32
@ -212,6 +212,7 @@ UDPWiimote::~UDPWiimote()
#define BUTT_FLAG (1<<1)
#define IR_FLAG (1<<2)
#define NUN_FLAG (1<<3)
#define NUNACCEL_FLAG (1<<4)
int UDPWiimote::pharsePacket(u8 * bf, size_t size)
{
@ -253,6 +254,17 @@ int UDPWiimote::pharsePacket(u8 * bf, size_t size)
nunX=((double)((s32)ntohl(*p)))/1048576; p++;
nunY=((double)((s32)ntohl(*p)))/1048576; p++;
}
if (bf[2]&NUNACCEL_FLAG)
{
if ((size-(((u8*)p)-bf))<12) return -1;
double ux,uy,uz;
ux=(double)((s32)ntohl(*p)); p++;
uy=(double)((s32)ntohl(*p)); p++;
uz=(double)((s32)ntohl(*p)); p++;
naX=ux/1048576; //packet accel data
naY=uy/1048576;
naZ=uz/1048576;
}
return 0;
}
@ -298,6 +310,16 @@ void UDPWiimote::getNunchuck(float &_x, float &_y, u8 &_mask)
d->mutex.Leave();
}
void UDPWiimote::getNunchuckAccel(float &_x, float &_y, float &_z)
{
d->mutex.Enter();
_x=(float)naX;
_y=(float)naY;
_z=(float)naZ;
d->mutex.Leave();
}
const char * UDPWiimote::getPort()
{
return port.c_str();