New Wiimote Plugin: Made UDPWiimote use the regular "Nunchuk" extension setting. Having a separate "UDPNunchuk" was really ugly. -some other minor changes.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5863 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-07-09 22:11:12 +00:00
parent d0c9a38681
commit 1e4f3c589d
16 changed files with 126 additions and 148 deletions

View File

@ -172,6 +172,7 @@ void UDPConfigDiag::OKPressed(wxCommandEvent & event)
void UDPWrapper::Configure(wxWindow * parent) void UDPWrapper::Configure(wxWindow * parent)
{ {
wxDialog * diag = new UDPConfigDiag(parent,this); wxDialog * diag = new UDPConfigDiag(parent,this);
diag->Center();
diag->ShowModal(); diag->ShowModal();
diag->Destroy(); diag->Destroy();
} }

View File

@ -803,7 +803,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
break; break;
case GROUP_TYPE_UDPWII: case GROUP_TYPE_UDPWII:
{ {
wxButton* const btn = new UDPConfigButton ( parent, (UDPWrapper*)group ); wxButton* const btn = new UDPConfigButton( parent, (UDPWrapper*)group );
_connect_macro_(btn, GamepadPage::ConfigUDPWii, wxEVT_COMMAND_BUTTON_CLICKED, eventsink); _connect_macro_(btn, GamepadPage::ConfigUDPWii, wxEVT_COMMAND_BUTTON_CLICKED, eventsink);
Add(btn, 0, wxALL|wxEXPAND, 3); Add(btn, 0, wxALL|wxEXPAND, 3);
} }

View File

@ -150,10 +150,10 @@ public:
class UDPConfigButton : public wxButton class UDPConfigButton : public wxButton
{ {
public: public:
UDPWrapper * wrapper; UDPWrapper* const wrapper;
UDPConfigButton( wxWindow* const parent, UDPWrapper * udp) : UDPConfigButton( wxWindow* const parent, UDPWrapper * udp)
wxButton( parent, -1, wxT("Configure"), wxDefaultPosition ), : wxButton( parent, -1, wxT("Configure"), wxDefaultPosition )
wrapper(udp) , wrapper(udp)
{} {}
}; };

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9,00" Version="9.00"
Name="Plugin_WiimoteNew" Name="Plugin_WiimoteNew"
ProjectGUID="{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}" ProjectGUID="{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}"
RootNamespace="Plugin_WiimoteNew" RootNamespace="Plugin_WiimoteNew"
@ -603,14 +603,6 @@
RelativePath=".\Src\WiimoteEmu\Attachment\Nunchuk.h" RelativePath=".\Src\WiimoteEmu\Attachment\Nunchuk.h"
> >
</File> </File>
<File
RelativePath=".\Src\WiimoteEmu\Attachment\UDPNunchuk.cpp"
>
</File>
<File
RelativePath=".\Src\WiimoteEmu\Attachment\UDPNunchuk.h"
>
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter

View File

@ -15,7 +15,7 @@ public:
virtual void GetState( u8* const data, const bool focus = true ) {} virtual void GetState( u8* const data, const bool focus = true ) {}
std::string GetName() const; std::string GetName() const;
const char* name; const char* const name;
std::vector<u8> reg; std::vector<u8> reg;
}; };

View File

@ -13,39 +13,20 @@ static const u8 classic_calibration[] =
0x00, 0x00, 0x51, 0xa6 0x00, 0x00, 0x51, 0xa6
}; };
// classic buttons
#define CLASSIC_PAD_RIGHT 0x80
#define CLASSIC_PAD_DOWN 0x40
#define CLASSIC_TRIGGER_L 0x20
#define CLASSIC_MINUS 0x10
#define CLASSIC_HOME 0x08
#define CLASSIC_PLUS 0x04
#define CLASSIC_TRIGGER_R 0x02
#define CLASSIC_NOTHING 0x01
#define CLASSIC_ZL 0x8000
#define CLASSIC_B 0x4000
#define CLASSIC_Y 0x2000
#define CLASSIC_A 0x1000
#define CLASSIC_X 0x0800
#define CLASSIC_ZR 0x0400
#define CLASSIC_PAD_LEFT 0x0200
#define CLASSIC_PAD_UP 0x0100
const u16 classic_button_bitmasks[] = const u16 classic_button_bitmasks[] =
{ {
CLASSIC_A, Classic::BUTTON_A,
CLASSIC_B, Classic::BUTTON_B,
CLASSIC_X, Classic::BUTTON_X,
CLASSIC_Y, Classic::BUTTON_Y,
CLASSIC_ZL, Classic::BUTTON_ZL,
CLASSIC_ZR, Classic::BUTTON_ZR,
CLASSIC_MINUS, Classic::BUTTON_MINUS,
CLASSIC_PLUS, Classic::BUTTON_PLUS,
CLASSIC_HOME, Classic::BUTTON_HOME,
}; };
const char* classic_button_names[] = const char* classic_button_names[] =
@ -55,7 +36,7 @@ const char* classic_button_names[] =
const u16 classic_trigger_bitmasks[] = const u16 classic_trigger_bitmasks[] =
{ {
CLASSIC_TRIGGER_L, CLASSIC_TRIGGER_R, Classic::TRIGGER_L, Classic::TRIGGER_R,
}; };
const char* const classic_trigger_names[] = const char* const classic_trigger_names[] =
@ -65,7 +46,7 @@ const char* const classic_trigger_names[] =
const u16 classic_dpad_bitmasks[] = const u16 classic_dpad_bitmasks[] =
{ {
CLASSIC_PAD_UP, CLASSIC_PAD_DOWN, CLASSIC_PAD_LEFT, CLASSIC_PAD_RIGHT Classic::PAD_UP, Classic::PAD_DOWN, Classic::PAD_LEFT, Classic::PAD_RIGHT
}; };
Classic::Classic() : Attachment( "Classic" ) Classic::Classic() : Attachment( "Classic" )

View File

@ -9,6 +9,26 @@ public:
Classic(); Classic();
void GetState( u8* const data, const bool focus ); void GetState( u8* const data, const bool focus );
enum
{
PAD_RIGHT = 0x80,
PAD_DOWN = 0x40,
TRIGGER_L = 0x20,
BUTTON_MINUS = 0x10,
BUTTON_HOME = 0x08,
BUTTON_PLUS = 0x04,
TRIGGER_R = 0x02,
NOTHING = 0x01,
BUTTON_ZL = 0x8000,
BUTTON_B = 0x4000,
BUTTON_Y = 0x2000,
BUTTON_A = 0x1000,
BUTTON_X = 0x0800,
BUTTON_ZR = 0x0400,
PAD_LEFT = 0x0200,
PAD_UP = 0x0100,
};
private: private:
Buttons* m_buttons; Buttons* m_buttons;
Buttons* m_shake; Buttons* m_shake;

View File

@ -6,25 +6,14 @@ namespace WiimoteEmu
static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 }; static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
// drums buttons
#define DRUMS_PLUS 0x04
#define DRUMS_MINUS 0x10
#define DRUMS_BASS 0x0400
#define DRUMS_BLUE 0x0800
#define DRUMS_GREEN 0x1000
#define DRUMS_YELLOW 0x2000
#define DRUMS_RED 0x4000
#define DRUMS_ORANGE 0x8000
const u16 drum_pad_bitmasks[] = const u16 drum_pad_bitmasks[] =
{ {
DRUMS_RED, Drums::PAD_RED,
DRUMS_YELLOW, Drums::PAD_YELLOW,
DRUMS_BLUE, Drums::PAD_BLUE,
DRUMS_GREEN, Drums::PAD_GREEN,
DRUMS_ORANGE, Drums::PAD_ORANGE,
DRUMS_BASS, Drums::PAD_BASS,
}; };
const char* drum_pad_names[] = const char* drum_pad_names[] =
@ -34,8 +23,8 @@ const char* drum_pad_names[] =
const u16 drum_button_bitmasks[] = const u16 drum_button_bitmasks[] =
{ {
DRUMS_MINUS, Drums::BUTTON_MINUS,
DRUMS_PLUS, Drums::BUTTON_PLUS,
}; };
Drums::Drums() : Attachment( "Drums" ) Drums::Drums() : Attachment( "Drums" )

View File

@ -9,6 +9,19 @@ public:
Drums(); Drums();
void GetState( u8* const data, const bool focus ); void GetState( u8* const data, const bool focus );
enum
{
BUTTON_PLUS = 0x04,
BUTTON_MINUS = 0x10,
PAD_BASS = 0x0400,
PAD_BLUE = 0x0800,
PAD_GREEN = 0x1000,
PAD_YELLOW = 0x2000,
PAD_RED = 0x4000,
PAD_ORANGE = 0x8000,
};
private: private:
Buttons* m_buttons; Buttons* m_buttons;
Buttons* m_pads; Buttons* m_pads;

View File

@ -6,25 +6,13 @@ namespace WiimoteEmu
static const u8 guitar_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 }; static const u8 guitar_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 };
// guitar buttons
#define GUITAR_PLUS 0x04
#define GUITAR_MINUS 0x10
#define GUITAR_BAR_DOWN 0x40
#define GUITAR_BAR_UP 0x0100
#define GUITAR_YELLOW 0x0800
#define GUITAR_GREEN 0x1000
#define GUITAR_BLUE 0x2000
#define GUITAR_RED 0x4000
#define GUITAR_ORANGE 0x8000
const u16 guitar_fret_bitmasks[] = const u16 guitar_fret_bitmasks[] =
{ {
GUITAR_GREEN, Guitar::FRET_GREEN,
GUITAR_RED, Guitar::FRET_RED,
GUITAR_YELLOW, Guitar::FRET_YELLOW,
GUITAR_BLUE, Guitar::FRET_BLUE,
GUITAR_ORANGE, Guitar::FRET_ORANGE,
}; };
const char* guitar_fret_names[] = const char* guitar_fret_names[] =
@ -34,14 +22,14 @@ const char* guitar_fret_names[] =
const u16 guitar_button_bitmasks[] = const u16 guitar_button_bitmasks[] =
{ {
GUITAR_MINUS, Guitar::BUTTON_MINUS,
GUITAR_PLUS, Guitar::BUTTON_PLUS,
}; };
const u16 guitar_strum_bitmasks[] = const u16 guitar_strum_bitmasks[] =
{ {
GUITAR_BAR_UP, Guitar::BAR_UP,
GUITAR_BAR_DOWN, Guitar::BAR_DOWN,
}; };
Guitar::Guitar() : Attachment( "Guitar" ) Guitar::Guitar() : Attachment( "Guitar" )

View File

@ -9,6 +9,20 @@ public:
Guitar(); Guitar();
void GetState( u8* const data, const bool focus ); void GetState( u8* const data, const bool focus );
enum
{
BUTTON_PLUS = 0x04,
BUTTON_MINUS = 0x10,
BAR_DOWN = 0x40,
BAR_UP = 0x0100,
FRET_YELLOW = 0x0800,
FRET_GREEN = 0x1000,
FRET_BLUE = 0x2000,
FRET_RED = 0x4000,
FRET_ORANGE = 0x8000,
};
private: private:
Buttons* m_buttons; Buttons* m_buttons;
Buttons* m_frets; Buttons* m_frets;

View File

@ -1,5 +1,7 @@
#include "Nunchuk.h" #include "Nunchuk.h"
#include "UDPWrapper.h"
#include "UDPWiimote.h"
namespace WiimoteEmu namespace WiimoteEmu
{ {
@ -19,14 +21,10 @@ static const u8 nunchuck_calibration[] =
0xec, 0x41 // checksum on the last two bytes 0xec, 0x41 // checksum on the last two bytes
}; };
// nunchuk buttons
#define NUNCHUK_C 0x02
#define NUNCHUK_Z 0x01
const u8 nunchuk_button_bitmasks[] = const u8 nunchuk_button_bitmasks[] =
{ {
NUNCHUK_C, Nunchuk::BUTTON_C,
NUNCHUK_Z, Nunchuk::BUTTON_Z,
}; };
Nunchuk::Nunchuk() : Attachment( "Nunchuk" ) Nunchuk::Nunchuk() : Attachment( "Nunchuk" )

View File

@ -12,6 +12,12 @@ public:
Nunchuk(); Nunchuk();
virtual void GetState( u8* const data, const bool focus ); virtual void GetState( u8* const data, const bool focus );
enum
{
BUTTON_C = 0x02,
BUTTON_Z = 0x01,
};
private: private:
Tilt* m_tilt; Tilt* m_tilt;
Force* m_swing; Force* m_swing;

View File

@ -1,29 +0,0 @@
#include "UDPNunchuk.h"
#include "UDPWrapper.h"
#include "UDPWiimote.h"
#define NUNCHUK_C 0x02
#define NUNCHUK_Z 0x01
namespace WiimoteEmu
{
void UDPNunchuk::GetState( u8* const data, const bool focus )
{
Nunchuk::GetState(data, focus);
if (!(wrp->inst)) return;
wm_extension* const ncdata = (wm_extension*)data;
u8 mask;
float x, y;
wrp->inst->getNunchuck(x, y, mask);
if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C;
if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z;
if ((ncdata->jx==0x80)&&(ncdata->jy==0x80))
{
ncdata->jx=u8(0x80+x*127);
ncdata->jy=u8(0x80+y*127);
}
}
}

View File

@ -1,21 +0,0 @@
#ifndef UDPNUNCHUCK_H
#define UDPNUNCHUCK_H
#include "Nunchuk.h"
class UDPWrapper;
namespace WiimoteEmu
{
class UDPNunchuk : public Nunchuk
{
public:
UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p
virtual void GetState( u8* const data, const bool focus );
private:
UDPWrapper * wrp;
};
}
#endif

View File

@ -3,7 +3,6 @@
#include "Attachment/Nunchuk.h" #include "Attachment/Nunchuk.h"
#include "Attachment/Guitar.h" #include "Attachment/Guitar.h"
#include "Attachment/Drums.h" #include "Attachment/Drums.h"
#include "Attachment/UDPNunchuk.h"
#include "WiimoteEmu.h" #include "WiimoteEmu.h"
#include "WiimoteHid.h" #include "WiimoteHid.h"
@ -293,7 +292,6 @@ Wiimote::Wiimote( const unsigned int index )
m_extension->attachments.push_back( new WiimoteEmu::Classic() ); m_extension->attachments.push_back( new WiimoteEmu::Classic() );
m_extension->attachments.push_back( new WiimoteEmu::Guitar() ); m_extension->attachments.push_back( new WiimoteEmu::Guitar() );
m_extension->attachments.push_back( new WiimoteEmu::Drums() ); m_extension->attachments.push_back( new WiimoteEmu::Drums() );
m_extension->attachments.push_back( new WiimoteEmu::UDPNunchuk(m_udp) );
// rumble // rumble
groups.push_back( m_rumble = new ControlGroup( "Rumble" ) ); groups.push_back( m_rumble = new ControlGroup( "Rumble" ) );
@ -392,10 +390,11 @@ void Wiimote::Update()
m_status.buttons = 0; m_status.buttons = 0;
if (is_focus) if (is_focus)
{ {
m_buttons->GetState( &m_status.buttons, button_bitmasks ); m_buttons->GetState(&m_status.buttons, button_bitmasks);
m_dpad->GetState( &m_status.buttons, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks ); m_dpad->GetState(&m_status.buttons, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks);
UDPTLayer::GetButtons(m_udp, &m_status.buttons);
} }
UDPTLayer::GetButtons( m_udp, &m_status.buttons );
// check if there is a read data request // check if there is a read data request
if (m_read_requests.size()) if (m_read_requests.size())
{ {
@ -487,8 +486,10 @@ void Wiimote::Update()
// ----SHAKE---- // ----SHAKE----
if (is_focus) if (is_focus)
{
EmulateShake(data + rpt.accel, m_shake, m_shake_step); EmulateShake(data + rpt.accel, m_shake, m_shake_step);
UDPTLayer::GetAcceleration( m_udp, (wm_accel*)&data[rpt.accel], (accel_cal*)&m_eeprom[0x16]); UDPTLayer::GetAcceleration(m_udp, (wm_accel*)&data[rpt.accel], (accel_cal*)&m_eeprom[0x16]);
}
} }
// ----ir---- // ----ir----
@ -497,8 +498,10 @@ void Wiimote::Update()
float xx = 10000, yy = 0, zz = 0; float xx = 10000, yy = 0, zz = 0;
if (is_focus) if (is_focus)
{
m_ir->GetState(&xx, &yy, &zz, true); m_ir->GetState(&xx, &yy, &zz, true);
UDPTLayer::GetIR( m_udp, &xx, &yy, &zz); UDPTLayer::GetIR(m_udp, &xx, &yy, &zz);
}
xx *= (-256 * 0.95f); xx *= (-256 * 0.95f);
xx += 512; xx += 512;
@ -588,6 +591,29 @@ void Wiimote::Update()
{ {
m_extension->GetState(data + rpt.ext, is_focus); m_extension->GetState(data + rpt.ext, is_focus);
// ---- 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);
}
}
// ---- end UDP Wiimote
// i dont think anything accesses the extension data like this, but ill support it. Indeed, commercial games don't do this. // i dont think anything accesses the extension data like this, but ill support it. Indeed, commercial games don't do this.
// i think it should be unencrpyted in the register, encrypted when read. // i think it should be unencrpyted in the register, encrypted when read.
memcpy(m_reg_ext->controller_data, data + rpt.ext, sizeof(wm_extension)); memcpy(m_reg_ext->controller_data, data + rpt.ext, sizeof(wm_extension));