mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -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:
@ -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();
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
u32 getButtons();
|
||||
void getNunchuck(float &x, float &y, u8 &mask);
|
||||
void getIR(float &x, float &y);
|
||||
void getNunchuckAccel(float &x, float &y, float &z);
|
||||
int getErrNo() {return err;};
|
||||
const char * getPort();
|
||||
private:
|
||||
@ -37,6 +38,7 @@ private:
|
||||
struct _d; //using pimpl because Winsock2.h doesen't have include guards -_-
|
||||
_d *d;
|
||||
double x,y,z;
|
||||
double naX,naY,naZ;
|
||||
double nunX,nunY;
|
||||
double pointerX,pointerY;
|
||||
u8 nunMask;
|
||||
|
@ -27,17 +27,21 @@ void UDPWrapper::LoadConfig(IniFile::Section *sec, const std::string& defdev, co
|
||||
|
||||
std::string group( base + name ); group += "/";
|
||||
|
||||
int _updAccel,_updIR,_updButt,_udpEn;
|
||||
int _updAccel,_updIR,_updButt,_udpEn,_updNun,_updNunAccel;
|
||||
sec->Get((group + "Enable").c_str(),&_udpEn, 0);
|
||||
sec->Get((group + "Port").c_str(), &port, DefaultPort(index));
|
||||
sec->Get((group + "Update_Accel").c_str(), &_updAccel, 1);
|
||||
sec->Get((group + "Update_IR").c_str(), &_updIR, 1);
|
||||
sec->Get((group + "Update_Butt").c_str(), &_updButt, 1);
|
||||
sec->Get((group + "Update_Nunchuk").c_str(), &_updNun, 1);
|
||||
sec->Get((group + "Update_NunchukAccel").c_str(), &_updNunAccel, 0);
|
||||
|
||||
udpEn=(_udpEn>0);
|
||||
updAccel=(_updAccel>0);
|
||||
updIR=(_updIR>0);
|
||||
updButt=(_updButt>0);
|
||||
updNun=(_updNun>0);
|
||||
updNunAccel=(_updNunAccel>0);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
@ -47,11 +51,13 @@ void UDPWrapper::SaveConfig(IniFile::Section *sec, const std::string& defdev, co
|
||||
{
|
||||
ControlGroup::SaveConfig(sec,defdev,base);
|
||||
std::string group( base + name ); group += "/";
|
||||
sec->Set((group + "Enable").c_str(), (int)udpEn, 0);
|
||||
sec->Set((group + "Port").c_str(), port, DefaultPort(index));
|
||||
sec->Set((group + "Update_Accel").c_str(), (int)updAccel, 1);
|
||||
sec->Set((group + "Update_IR").c_str(), (int)updIR, 1);
|
||||
sec->Set((group + "Update_Butt").c_str(), (int)updButt, 1);
|
||||
sec->Set((group + "Enable").c_str(), (int)udpEn);
|
||||
sec->Set((group + "Port").c_str(), port);
|
||||
sec->Set((group + "Update_Accel").c_str(), (int)updAccel);
|
||||
sec->Set((group + "Update_IR").c_str(), (int)updIR);
|
||||
sec->Set((group + "Update_Butt").c_str(), (int)updButt);
|
||||
sec->Set((group + "Update_Nunchuk").c_str(), (int)updNun);
|
||||
sec->Set((group + "Update_NunchukAccel").c_str(), (int)updNunAccel);
|
||||
}
|
||||
|
||||
|
||||
@ -101,6 +107,8 @@ public:
|
||||
wxCheckBox * butt;
|
||||
wxCheckBox * accel;
|
||||
wxCheckBox * point;
|
||||
wxCheckBox * nun;
|
||||
wxCheckBox * nunaccel;
|
||||
wxTextCtrl * port_tbox;
|
||||
};
|
||||
|
||||
@ -118,6 +126,9 @@ UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
|
||||
butt = new wxCheckBox(this,wxID_ANY,wxT("Update Buttons"));
|
||||
accel = new wxCheckBox(this,wxID_ANY,wxT("Update Acceleration"));
|
||||
point = new wxCheckBox(this,wxID_ANY,wxT("Update IR Pointer"));
|
||||
nun = new wxCheckBox(this,wxID_ANY,wxT("Update Nunchuk"));
|
||||
nunaccel = new wxCheckBox(this,wxID_ANY,wxT("Update Nunchuk Acceleration"));
|
||||
|
||||
|
||||
wxButton * ok_butt = new wxButton(this,wxID_ANY,wxT("OK"));
|
||||
|
||||
@ -130,6 +141,8 @@ UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
|
||||
_connect_macro_(butt,UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||
_connect_macro_(accel,UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||
_connect_macro_(point,UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||
_connect_macro_(nun,UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||
_connect_macro_(nunaccel,UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||
_connect_macro_(ok_butt,UDPConfigDiag::OKPressed, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
||||
_connect_macro_(port_tbox, UDPConfigDiag::ChangeState, wxEVT_COMMAND_TEXT_UPDATED, this);
|
||||
|
||||
@ -137,13 +150,17 @@ UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
|
||||
butt->SetValue(wrp->updButt);
|
||||
accel->SetValue(wrp->updAccel);
|
||||
point->SetValue(wrp->updIR);
|
||||
|
||||
nun->SetValue(wrp->updNun);
|
||||
nunaccel->SetValue(wrp->updNunAccel);
|
||||
|
||||
sizer1->Add(enable,1,wxALL | wxEXPAND,5);
|
||||
sizer1->Add(port_sizer, 1,wxDOWN | wxLEFT| wxRIGHT | wxEXPAND,5);
|
||||
|
||||
sizer2->Add(butt,1,wxALL | wxEXPAND,5);
|
||||
sizer2->Add(accel,1,wxALL | wxEXPAND,5);
|
||||
sizer2->Add(point,1,wxALL | wxEXPAND,5);
|
||||
sizer2->Add(nun,1,wxALL | wxEXPAND,5);
|
||||
sizer2->Add(nunaccel,1,wxALL | wxEXPAND,5);
|
||||
|
||||
outer_sizer->Add(ok_butt,0, wxDOWN | wxLEFT| wxRIGHT | wxALIGN_RIGHT,10);
|
||||
|
||||
@ -156,6 +173,8 @@ void UDPConfigDiag::ChangeUpdateFlags(wxCommandEvent & event)
|
||||
wrp->updAccel=accel->GetValue();
|
||||
wrp->updButt=butt->GetValue();
|
||||
wrp->updIR=point->GetValue();
|
||||
wrp->updNun=nun->GetValue();
|
||||
wrp->updNunAccel=nunaccel->GetValue();
|
||||
}
|
||||
|
||||
void UDPConfigDiag::ChangeState(wxCommandEvent & event)
|
||||
|
@ -26,7 +26,7 @@ class UDPWrapper : public ControllerEmu::ControlGroup
|
||||
public:
|
||||
UDPWiimote * inst;
|
||||
int index;
|
||||
bool updIR,updAccel,updButt,udpEn; //upd from update and udp from... well... UDP
|
||||
bool updIR,updAccel,updButt,updNun,updNunAccel,udpEn; //upd from update and udp from... well... UDP
|
||||
std::string port;
|
||||
|
||||
UDPWrapper(int index, const char* const _name);
|
||||
|
Reference in New Issue
Block a user