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)
{
wxDialog * diag = new UDPConfigDiag(parent,this);
diag->Center();
diag->ShowModal();
diag->Destroy();
}

View File

@ -803,7 +803,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
break;
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);
Add(btn, 0, wxALL|wxEXPAND, 3);
}

View File

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

View File

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

View File

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

View File

@ -13,39 +13,20 @@ static const u8 classic_calibration[] =
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[] =
{
CLASSIC_A,
CLASSIC_B,
CLASSIC_X,
CLASSIC_Y,
Classic::BUTTON_A,
Classic::BUTTON_B,
Classic::BUTTON_X,
Classic::BUTTON_Y,
CLASSIC_ZL,
CLASSIC_ZR,
Classic::BUTTON_ZL,
Classic::BUTTON_ZR,
CLASSIC_MINUS,
CLASSIC_PLUS,
Classic::BUTTON_MINUS,
Classic::BUTTON_PLUS,
CLASSIC_HOME,
Classic::BUTTON_HOME,
};
const char* classic_button_names[] =
@ -55,7 +36,7 @@ const char* classic_button_names[] =
const u16 classic_trigger_bitmasks[] =
{
CLASSIC_TRIGGER_L, CLASSIC_TRIGGER_R,
Classic::TRIGGER_L, Classic::TRIGGER_R,
};
const char* const classic_trigger_names[] =
@ -65,7 +46,7 @@ const char* const classic_trigger_names[] =
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" )

View File

@ -9,6 +9,26 @@ public:
Classic();
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:
Buttons* m_buttons;
Buttons* m_shake;

View File

@ -6,25 +6,14 @@ namespace WiimoteEmu
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[] =
{
DRUMS_RED,
DRUMS_YELLOW,
DRUMS_BLUE,
DRUMS_GREEN,
DRUMS_ORANGE,
DRUMS_BASS,
Drums::PAD_RED,
Drums::PAD_YELLOW,
Drums::PAD_BLUE,
Drums::PAD_GREEN,
Drums::PAD_ORANGE,
Drums::PAD_BASS,
};
const char* drum_pad_names[] =
@ -34,8 +23,8 @@ const char* drum_pad_names[] =
const u16 drum_button_bitmasks[] =
{
DRUMS_MINUS,
DRUMS_PLUS,
Drums::BUTTON_MINUS,
Drums::BUTTON_PLUS,
};
Drums::Drums() : Attachment( "Drums" )

View File

@ -9,6 +9,19 @@ public:
Drums();
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:
Buttons* m_buttons;
Buttons* m_pads;

View File

@ -6,25 +6,13 @@ namespace WiimoteEmu
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[] =
{
GUITAR_GREEN,
GUITAR_RED,
GUITAR_YELLOW,
GUITAR_BLUE,
GUITAR_ORANGE,
Guitar::FRET_GREEN,
Guitar::FRET_RED,
Guitar::FRET_YELLOW,
Guitar::FRET_BLUE,
Guitar::FRET_ORANGE,
};
const char* guitar_fret_names[] =
@ -34,14 +22,14 @@ const char* guitar_fret_names[] =
const u16 guitar_button_bitmasks[] =
{
GUITAR_MINUS,
GUITAR_PLUS,
Guitar::BUTTON_MINUS,
Guitar::BUTTON_PLUS,
};
const u16 guitar_strum_bitmasks[] =
{
GUITAR_BAR_UP,
GUITAR_BAR_DOWN,
Guitar::BAR_UP,
Guitar::BAR_DOWN,
};
Guitar::Guitar() : Attachment( "Guitar" )

View File

@ -9,6 +9,20 @@ public:
Guitar();
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:
Buttons* m_buttons;
Buttons* m_frets;

View File

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

View File

@ -12,6 +12,12 @@ public:
Nunchuk();
virtual void GetState( u8* const data, const bool focus );
enum
{
BUTTON_C = 0x02,
BUTTON_Z = 0x01,
};
private:
Tilt* m_tilt;
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/Guitar.h"
#include "Attachment/Drums.h"
#include "Attachment/UDPNunchuk.h"
#include "WiimoteEmu.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::Guitar() );
m_extension->attachments.push_back( new WiimoteEmu::Drums() );
m_extension->attachments.push_back( new WiimoteEmu::UDPNunchuk(m_udp) );
// rumble
groups.push_back( m_rumble = new ControlGroup( "Rumble" ) );
@ -392,10 +390,11 @@ void Wiimote::Update()
m_status.buttons = 0;
if (is_focus)
{
m_buttons->GetState( &m_status.buttons, button_bitmasks );
m_dpad->GetState( &m_status.buttons, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks );
m_buttons->GetState(&m_status.buttons, button_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
if (m_read_requests.size())
{
@ -487,8 +486,10 @@ void Wiimote::Update()
// ----SHAKE----
if (is_focus)
{
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----
@ -497,8 +498,10 @@ void Wiimote::Update()
float xx = 10000, yy = 0, zz = 0;
if (is_focus)
{
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 += 512;
@ -588,6 +591,29 @@ void Wiimote::Update()
{
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 think it should be unencrpyted in the register, encrypted when read.
memcpy(m_reg_ext->controller_data, data + rpt.ext, sizeof(wm_extension));