diff --git a/Source/Core/InputCommon/Src/UDPWrapper.cpp b/Source/Core/InputCommon/Src/UDPWrapper.cpp index 1442c2353e..b92ec79070 100644 --- a/Source/Core/InputCommon/Src/UDPWrapper.cpp +++ b/Source/Core/InputCommon/Src/UDPWrapper.cpp @@ -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(); } diff --git a/Source/Core/InputUICommon/Src/ConfigDiag.cpp b/Source/Core/InputUICommon/Src/ConfigDiag.cpp index 32e81d7d38..78498657a8 100644 --- a/Source/Core/InputUICommon/Src/ConfigDiag.cpp +++ b/Source/Core/InputUICommon/Src/ConfigDiag.cpp @@ -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); } diff --git a/Source/Core/InputUICommon/Src/ConfigDiag.h b/Source/Core/InputUICommon/Src/ConfigDiag.h index 831eb54ef4..1d9c80ab55 100644 --- a/Source/Core/InputUICommon/Src/ConfigDiag.h +++ b/Source/Core/InputUICommon/Src/ConfigDiag.h @@ -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) {} }; diff --git a/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj b/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj index 1c017b1bb1..64d9310d45 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj +++ b/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj @@ -1,7 +1,7 @@ - - - - reg; }; diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.cpp index 8cba7fcfe1..f257df759c 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.cpp @@ -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" ) diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.h index df5c9c9f65..ac50243d4c 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.h @@ -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; diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp index e3f0acb22c..3ee8a10faf 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp @@ -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" ) diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.h index 5976e9d6fe..eeef2fde57 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.h @@ -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; diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.cpp index 1b90185f32..1e0145855b 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.cpp @@ -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" ) diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.h index bed60bb3c1..6b96800915 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.h @@ -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; diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.cpp index b8db3ee6d2..ac02d5e475 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.cpp @@ -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" ) diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h index 6531568c85..e1b3d57c7e 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h @@ -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; diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp deleted file mode 100644 index c44b5bc20a..0000000000 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp +++ /dev/null @@ -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); - } -} - -} \ No newline at end of file diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h deleted file mode 100644 index f230cce409..0000000000 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h +++ /dev/null @@ -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 diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp index cee3863ac9..4460a0b4e4 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp @@ -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));