From e20a0265dec84005637f869cd0a4281bd963af7e Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 17 Jun 2014 17:09:10 -0400 Subject: [PATCH] Remove UDPWiimote feature It substantially complicates the code and doesn't really provide any functionality. According to the forums, the Android app is out of date and has been broken for quite a while. If we want to add this back, I'd write an app that speaks a more native Wiimote protocol, and we can hook that up to the backend quite easily. It could even be over our NetPlay protocol! --- Source/Core/Core/Core.vcxproj | 3 +- Source/Core/Core/Core.vcxproj.filters | 5 +- .../Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp | 35 +- .../Core/HW/WiimoteEmu/Attachment/Nunchuk.h | 6 +- Source/Core/Core/HW/WiimoteEmu/UDPTLayer.h | 54 --- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 9 +- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h | 3 - Source/Core/DolphinWX/CMakeLists.txt | 1 - Source/Core/DolphinWX/DolphinWX.vcxproj | 6 +- .../Core/DolphinWX/DolphinWX.vcxproj.filters | 10 +- Source/Core/DolphinWX/InputConfigDiag.cpp | 16 - Source/Core/DolphinWX/InputConfigDiag.h | 13 - Source/Core/DolphinWX/UDPConfigDiag.cpp | 86 ---- Source/Core/DolphinWX/UDPConfigDiag.h | 27 -- Source/Core/InputCommon/CMakeLists.txt | 2 - Source/Core/InputCommon/ControllerEmu.h | 1 - Source/Core/InputCommon/InputCommon.vcxproj | 8 +- .../InputCommon/InputCommon.vcxproj.filters | 8 +- Source/Core/InputCommon/UDPWiimote.cpp | 439 ------------------ Source/Core/InputCommon/UDPWiimote.h | 64 --- Source/Core/InputCommon/UDPWrapper.cpp | 96 ---- Source/Core/InputCommon/UDPWrapper.h | 27 -- 22 files changed, 13 insertions(+), 906 deletions(-) delete mode 100644 Source/Core/Core/HW/WiimoteEmu/UDPTLayer.h delete mode 100644 Source/Core/DolphinWX/UDPConfigDiag.cpp delete mode 100644 Source/Core/DolphinWX/UDPConfigDiag.h delete mode 100644 Source/Core/InputCommon/UDPWiimote.cpp delete mode 100644 Source/Core/InputCommon/UDPWiimote.h delete mode 100644 Source/Core/InputCommon/UDPWrapper.cpp delete mode 100644 Source/Core/InputCommon/UDPWrapper.h diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index d6fc66049d..66926be20f 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -1,4 +1,4 @@ - + @@ -357,7 +357,6 @@ - diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 05e4529aee..789f44a418 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -1005,9 +1005,6 @@ HW %28Flipper/Hollywood%29\Wiimote\Emu - - HW %28Flipper/Hollywood%29\Wiimote\Emu - HW %28Flipper/Hollywood%29\Wiimote\Emu diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp index 0bd5b65f83..339a1d0e0e 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp @@ -4,9 +4,6 @@ #include "Core/HW/WiimoteEmu/Attachment/Nunchuk.h" -#include "InputCommon/UDPWiimote.h" -#include "InputCommon/UDPWrapper.h" - namespace WiimoteEmu { @@ -31,8 +28,7 @@ static const u8 nunchuk_button_bitmasks[] = Nunchuk::BUTTON_Z, }; -Nunchuk::Nunchuk(UDPWrapper *wrp, WiimoteEmu::ExtensionReg& _reg) - : Attachment(_trans("Nunchuk"), _reg) , m_udpWrap(wrp) +Nunchuk::Nunchuk(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Nunchuk"), _reg) { // buttons groups.emplace_back(m_buttons = new Buttons("Buttons")); @@ -124,35 +120,6 @@ void Nunchuk::GetState(u8* const data, const bool focus) // flip the button bits :/ ncdata->bt ^= 0x03; - if (m_udpWrap->inst) - { - if (m_udpWrap->updNun) - { - u8 mask; - float x, y; - m_udpWrap->inst->getNunchuck(&x, &y, &mask); - // buttons - if (mask & UDPWM_NC) - ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_C; - if (mask & UDPWM_NZ) - ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_Z; - // stick - if (ncdata->jx == 0x80 && ncdata->jy == 0x80) - { - ncdata->jx = u8(0x80 + x*127); - ncdata->jy = u8(0x80 + y*127); - } - } - if (m_udpWrap->updNunAccel) - { - float x, y, z; - m_udpWrap->inst->getNunchuckAccel(&x, &y, &z); - accel.x = x; - accel.y = y; - accel.z = z; - } - } - FillRawAccelFromGForceData(*(wm_accel*)&ncdata->ax, *(accel_cal*)®.calibration, accel); } diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h index 83a7540c46..a4a5530ead 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h @@ -6,15 +6,13 @@ #include "Core/HW/WiimoteEmu/Attachment/Attachment.h" -class UDPWrapper; - namespace WiimoteEmu { class Nunchuk : public Attachment { public: - Nunchuk(UDPWrapper * wrp, WiimoteEmu::ExtensionReg& _reg); + Nunchuk(WiimoteEmu::ExtensionReg& _reg); virtual void GetState(u8* const data, const bool focus) override; @@ -36,8 +34,6 @@ private: AnalogStick* m_stick; u8 m_shake_step[3]; - - UDPWrapper* const m_udpWrap; }; } diff --git a/Source/Core/Core/HW/WiimoteEmu/UDPTLayer.h b/Source/Core/Core/HW/WiimoteEmu/UDPTLayer.h deleted file mode 100644 index 52ff2b7f79..0000000000 --- a/Source/Core/Core/HW/WiimoteEmu/UDPTLayer.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -//UDP Wiimote Translation Layer - -#pragma once - -#include "Core/HW/WiimoteEmu/WiimoteEmu.h" -#include "InputCommon/UDPWiimote.h" - -namespace UDPTLayer -{ - static void GetButtons(UDPWrapper * m , wm_core * butt) - { - if (!(m->inst)) return; - if (!(m->updButt)) return; - u32 mask = m->inst->getButtons(); - *butt |= (mask & UDPWM_BA) ? WiimoteEmu::Wiimote::BUTTON_A : 0; - *butt |= (mask & UDPWM_BB) ? WiimoteEmu::Wiimote::BUTTON_B : 0; - *butt |= (mask & UDPWM_B1) ? WiimoteEmu::Wiimote::BUTTON_ONE : 0; - *butt |= (mask & UDPWM_B2) ? WiimoteEmu::Wiimote::BUTTON_TWO : 0; - *butt |= (mask & UDPWM_BP) ? WiimoteEmu::Wiimote::BUTTON_PLUS : 0; - *butt |= (mask & UDPWM_BM) ? WiimoteEmu::Wiimote::BUTTON_MINUS : 0; - *butt |= (mask & UDPWM_BH) ? WiimoteEmu::Wiimote::BUTTON_HOME : 0; - *butt |= (mask & UDPWM_BU) ? WiimoteEmu::Wiimote::PAD_UP : 0; - *butt |= (mask & UDPWM_BD) ? WiimoteEmu::Wiimote::PAD_DOWN : 0; - *butt |= (mask & UDPWM_BL) ? WiimoteEmu::Wiimote::PAD_LEFT : 0; - *butt |= (mask & UDPWM_BR) ? WiimoteEmu::Wiimote::PAD_RIGHT : 0; - } - - static void GetAcceleration(UDPWrapper * m , WiimoteEmu::AccelData * const data) - { - if (!(m->inst)) return; - if (!(m->updAccel)) return; - float x, y, z; - m->inst->getAccel(&x, &y, &z); - data->x = x; - data->y = y; - data->z = z; - } - - static void GetIR( UDPWrapper * m, float * x, float * y, float * z) - { - if (!(m->inst)) return; - if (!(m->updIR)) return; - if ((*x >= -0.999) && (*x <= 0.999) && (*y >= -0.999) && (*y <= 0.999)) return; //the received values are used ONLY when the normal pointer is offscreen - float _x, _y; - m->inst->getIR(&_x, &_y); - *x = _x * 2 - 1; - *y = -(_y * 2 - 1); - *z = 0; - } -} diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index 6c6943d2f3..e502ba077b 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -13,7 +13,6 @@ #include "Core/NetPlayClient.h" #include "Core/HW/WiimoteEmu/MatrixMath.h" -#include "Core/HW/WiimoteEmu/UDPTLayer.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "Core/HW/WiimoteEmu/WiimoteHid.h" #include "Core/HW/WiimoteEmu/Attachment/Classic.h" @@ -266,9 +265,6 @@ Wiimote::Wiimote( const unsigned int index ) for (auto& named_button : named_buttons) m_buttons->controls.emplace_back(new ControlGroup::Input( named_button)); - // udp - groups.emplace_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote"))); - // ir groups.emplace_back(m_ir = new Cursor(_trans("IR"))); @@ -287,7 +283,7 @@ Wiimote::Wiimote( const unsigned int index ) // extension groups.emplace_back(m_extension = new Extension(_trans("Extension"))); m_extension->attachments.emplace_back(new WiimoteEmu::None(m_reg_ext)); - m_extension->attachments.emplace_back(new WiimoteEmu::Nunchuk(m_udp, m_reg_ext)); + m_extension->attachments.emplace_back(new WiimoteEmu::Nunchuk(m_reg_ext)); m_extension->attachments.emplace_back(new WiimoteEmu::Classic(m_reg_ext)); m_extension->attachments.emplace_back(new WiimoteEmu::Guitar(m_reg_ext)); m_extension->attachments.emplace_back(new WiimoteEmu::Drums(m_reg_ext)); @@ -390,7 +386,6 @@ void Wiimote::UpdateButtonsStatus(bool has_focus) const bool is_sideways = m_options->settings[1]->value != 0; 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); } } @@ -420,7 +415,6 @@ void Wiimote::GetAccelData(u8* const data) { EmulateSwing(&m_accel, m_swing, is_sideways, is_upright); EmulateShake(&m_accel, m_shake, m_shake_step); - UDPTLayer::GetAcceleration(m_udp, &m_accel); } FillRawAccelFromGForceData(*(wm_accel*)data, *(accel_cal*)&m_eeprom[0x16], m_accel); @@ -476,7 +470,6 @@ void Wiimote::GetIRData(u8* const data, bool use_accel) LowPassFilter(ir_cos,ncos,1.0f/60); m_ir->GetState(&xx, &yy, &zz, true); - UDPTLayer::GetIR(m_udp, &xx, &yy, &zz); Vertex v[4]; diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h index d3495399d1..b6f0498d23 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h @@ -12,7 +12,6 @@ #include "Core/HW/WiimoteEmu/Encryption.h" #include "Core/HW/WiimoteEmu/WiimoteHid.h" #include "InputCommon/ControllerEmu.h" -#include "InputCommon/UDPWrapper.h" // Registry sizes #define WIIMOTE_EEPROM_SIZE (16*1024) @@ -175,8 +174,6 @@ private: double ir_sin, ir_cos; //for the low pass filter - UDPWrapper* m_udp; - bool m_rumble_on; bool m_speaker_mute; bool m_motion_plus_present; diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index db4b9b16dd..dff065c84f 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -89,7 +89,6 @@ if(wxWidgets_FOUND) PHackSettings.cpp PatchAddEdit.cpp TASInputDlg.cpp - UDPConfigDiag.cpp VideoConfigDiag.cpp WXInputBase.cpp WiimoteConfigDiag.cpp diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj index 440d9ff8be..a402328cc9 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj @@ -1,4 +1,4 @@ - + @@ -95,7 +95,6 @@ Create - @@ -144,7 +143,6 @@ - @@ -230,4 +228,4 @@ - \ No newline at end of file + diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters index 9c9a656f26..654a1bf36c 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -152,9 +152,6 @@ GUI - - GUI - GUI @@ -280,9 +277,6 @@ GUI - - GUI - GUI @@ -302,4 +296,4 @@ Resources - \ No newline at end of file + diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp index 2990fdba6b..b8132882e1 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/InputConfigDiag.cpp @@ -45,7 +45,6 @@ #include "Common/MsgHandler.h" #include "Core/HW/Wiimote.h" #include "DolphinWX/InputConfigDiag.h" -#include "DolphinWX/UDPConfigDiag.h" #include "DolphinWX/WxUtils.h" #include "InputCommon/ControllerEmu.h" #include "InputCommon/InputConfig.h" @@ -53,18 +52,10 @@ #include "InputCommon/ControllerInterface/Device.h" #include "InputCommon/ControllerInterface/ExpressionParser.h" -class UDPWrapper; class wxWindow; using namespace ciface::ExpressionParser; -void GamepadPage::ConfigUDPWii(wxCommandEvent &event) -{ - UDPWrapper* const wrp = ((UDPConfigButton*)event.GetEventObject())->wrapper; - UDPConfigDiag diag(this, wrp); - diag.ShowModal(); -} - void GamepadPage::ConfigExtension(wxCommandEvent& event) { ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension; @@ -883,13 +874,6 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin Add(configure_btn, 0, wxALL|wxEXPAND, 3); } break; - case GROUP_TYPE_UDPWII: - { - wxButton* const btn = new UDPConfigButton(parent, (UDPWrapper*)group); - btn->Bind(wxEVT_BUTTON, &GamepadPage::ConfigUDPWii, eventsink); - Add(btn, 0, wxALL|wxEXPAND, 3); - } - break; default: { //options diff --git a/Source/Core/DolphinWX/InputConfigDiag.h b/Source/Core/DolphinWX/InputConfigDiag.h index 64a3ceabe6..8c0ade99bb 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.h +++ b/Source/Core/DolphinWX/InputConfigDiag.h @@ -29,7 +29,6 @@ #include "InputCommon/ControllerInterface/Device.h" class InputPlugin; -class UDPWrapper; class wxComboBox; class wxCommandEvent; class wxEvent; @@ -147,16 +146,6 @@ public: ControllerInterface::ControlReference* const control_reference; }; -class UDPConfigButton : public wxButton -{ -public: - UDPWrapper* const wrapper; - UDPConfigButton(wxWindow* const parent, UDPWrapper * udp) - : wxButton(parent, -1, _("Configure"), wxDefaultPosition) - , wrapper(udp) - {} -}; - class ControlGroupBox : public wxBoxSizer { public: @@ -200,8 +189,6 @@ public: void ConfigExtension(wxCommandEvent& event); - void ConfigUDPWii(wxCommandEvent& event); - void SetDevice(wxCommandEvent& event); void ClearAll(wxCommandEvent& event); diff --git a/Source/Core/DolphinWX/UDPConfigDiag.cpp b/Source/Core/DolphinWX/UDPConfigDiag.cpp deleted file mode 100644 index d1ed2da02e..0000000000 --- a/Source/Core/DolphinWX/UDPConfigDiag.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "DolphinWX/UDPConfigDiag.h" -#include "DolphinWX/WxUtils.h" -#include "InputCommon/UDPWrapper.h" - -class wxWindow; - -UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) : - wxDialog(parent, -1, _("UDP Wiimote")), - wrp(_wrp) -{ - wxBoxSizer *const outer_sizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer *const sizer1 = new wxBoxSizer(wxVERTICAL); - wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Update")); - - outer_sizer->Add(sizer1, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 5); - outer_sizer->Add(sizer2, 1, wxLEFT | wxRIGHT | wxEXPAND, 10); - - enable = new wxCheckBox(this, wxID_ANY, _("Enable")); - butt = new wxCheckBox(this, wxID_ANY, _("Buttons")); - accel = new wxCheckBox(this, wxID_ANY, _("Acceleration")); - point = new wxCheckBox(this, wxID_ANY, _("IR Pointer")); - nun = new wxCheckBox(this, wxID_ANY, _("Nunchuk")); - nunaccel = new wxCheckBox(this, wxID_ANY, _("Nunchuk Acceleration")); - - wxBoxSizer *const port_sizer = new wxBoxSizer(wxHORIZONTAL); - port_sizer->Add(new wxStaticText(this, wxID_ANY, _("UDP Port:")), 0, wxALIGN_CENTER); - port_tbox = new wxTextCtrl(this, wxID_ANY, StrToWxStr(wrp->port)); - port_sizer->Add(port_tbox, 1, wxLEFT | wxEXPAND, 5); - - enable->Bind(wxEVT_CHECKBOX, &UDPConfigDiag::ChangeState, this); - butt->Bind(wxEVT_CHECKBOX, &UDPConfigDiag::ChangeUpdateFlags, this); - accel->Bind(wxEVT_CHECKBOX, &UDPConfigDiag::ChangeUpdateFlags, this); - point->Bind(wxEVT_CHECKBOX, &UDPConfigDiag::ChangeUpdateFlags, this); - nun->Bind(wxEVT_CHECKBOX, &UDPConfigDiag::ChangeUpdateFlags, this); - nunaccel->Bind(wxEVT_CHECKBOX, &UDPConfigDiag::ChangeUpdateFlags, this); - port_tbox->Bind(wxEVT_TEXT, &UDPConfigDiag::ChangeState, this); - - enable->SetValue(wrp->udpEn); - 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, wxBOTTOM | 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(CreateButtonSizer(wxOK), 0, wxALL | wxALIGN_RIGHT, 5); - - SetSizerAndFit(outer_sizer); - Center(); - SetFocus(); -} - -void UDPConfigDiag::ChangeUpdateFlags(wxCommandEvent & WXUNUSED(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 & WXUNUSED(event)) -{ - wrp->udpEn = enable->GetValue(); - wrp->port = WxStrToStr(port_tbox->GetValue()); - wrp->Refresh(); -} diff --git a/Source/Core/DolphinWX/UDPConfigDiag.h b/Source/Core/DolphinWX/UDPConfigDiag.h deleted file mode 100644 index 5638599487..0000000000 --- a/Source/Core/DolphinWX/UDPConfigDiag.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include - -class UDPWrapper; -class wxCheckBox; -class wxCommandEvent; -class wxTextCtrl; -class wxWindow; - -class UDPConfigDiag : public wxDialog -{ -public: - UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp); -private: - UDPWrapper * wrp; - void ChangeUpdateFlags(wxCommandEvent & event); - void ChangeState(wxCommandEvent & event); - void OKPressed(wxCommandEvent & event); - wxCheckBox * enable; - wxCheckBox * butt; - wxCheckBox * accel; - wxCheckBox * point; - wxCheckBox * nun; - wxCheckBox * nunaccel; - wxTextCtrl * port_tbox; -}; diff --git a/Source/Core/InputCommon/CMakeLists.txt b/Source/Core/InputCommon/CMakeLists.txt index ac6e9c6e28..6b771c38e1 100644 --- a/Source/Core/InputCommon/CMakeLists.txt +++ b/Source/Core/InputCommon/CMakeLists.txt @@ -1,7 +1,5 @@ set(SRCS ControllerEmu.cpp InputConfig.cpp - UDPWiimote.cpp - UDPWrapper.cpp ControllerInterface/ControllerInterface.cpp ControllerInterface/Device.cpp ControllerInterface/ExpressionParser.cpp) diff --git a/Source/Core/InputCommon/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu.h index 874548f38a..ebfd98294a 100644 --- a/Source/Core/InputCommon/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu.h @@ -30,7 +30,6 @@ enum GROUP_TYPE_TILT, GROUP_TYPE_CURSOR, GROUP_TYPE_TRIGGERS, - GROUP_TYPE_UDPWII, GROUP_TYPE_SLIDER, }; diff --git a/Source/Core/InputCommon/InputCommon.vcxproj b/Source/Core/InputCommon/InputCommon.vcxproj index 5902db1277..85d5bff6db 100644 --- a/Source/Core/InputCommon/InputCommon.vcxproj +++ b/Source/Core/InputCommon/InputCommon.vcxproj @@ -1,4 +1,4 @@ - + @@ -48,8 +48,6 @@ Create - - @@ -64,8 +62,6 @@ - - @@ -78,4 +74,4 @@ - \ No newline at end of file + diff --git a/Source/Core/InputCommon/InputCommon.vcxproj.filters b/Source/Core/InputCommon/InputCommon.vcxproj.filters index 729f7e1866..e249ed3f79 100644 --- a/Source/Core/InputCommon/InputCommon.vcxproj.filters +++ b/Source/Core/InputCommon/InputCommon.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -17,8 +17,6 @@ - - ControllerInterface\DInput @@ -49,8 +47,6 @@ - - ControllerInterface\DInput @@ -80,4 +76,4 @@ - \ No newline at end of file + diff --git a/Source/Core/InputCommon/UDPWiimote.cpp b/Source/Core/InputCommon/UDPWiimote.cpp deleted file mode 100644 index e929e62461..0000000000 --- a/Source/Core/InputCommon/UDPWiimote.cpp +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#include -#include -#include -#include -#include -#include -#include - -#include "Common/Thread.h" -#include "Common/Timer.h" - -#include "InputCommon/UDPWiimote.h" - -#ifdef _WIN32 - -#include -#include -#define sock_t SOCKET -#define ERRNO WSAGetLastError() -#undef EWOULDBLOCK -#define EWOULDBLOCK WSAEWOULDBLOCK -#define BAD_SOCK INVALID_SOCKET -#define close(x) closesocket(x) -#define cleanup do {noinst--; if (noinst==0) WSACleanup();} while (0) -#define blockingoff(sock) ioctlsocket(sock, FIONBIO, &iMode) -#define dataz char* -#ifdef _MSC_VER -#pragma comment (lib, "Ws2_32.lib") -#endif - -#else - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define BAD_SOCK -1 -#define ERRNO errno -#define cleanup noinst-- -#define blockingoff(sock) fcntl(sock, F_SETFL, O_NONBLOCK) -#define dataz void* -#define sock_t int - -#endif - - -struct UDPWiimote::_d -{ - std::thread thread; - std::list sockfds; - std::mutex termLock, mutex, nameMutex; - volatile bool exit; - sock_t bipv4_fd, bipv6_fd; -}; - -int UDPWiimote::noinst = 0; - -UDPWiimote::UDPWiimote(const std::string& _port, const std::string& name, int _index) : - port(_port), displayName(name), d(new _d), - waX(0), waY(0), waZ(1), naX(0), naY(0), naZ(-1), nunX(0), nunY(0), - pointerX(1001.0f / 2), pointerY(0), nunMask(0), wiimoteMask(0), index(_index), int_port(atoi(_port.c_str())) -{ - - static bool sranded=false; - if (!sranded) - { - srand((unsigned int)time(nullptr)); - sranded=true; - } - bcastMagic=rand() & 0xFFFF; - - #ifdef _WIN32 - u_long iMode = 1; - #endif - struct addrinfo hints, *servinfo, *p; - int rv; - - #ifdef _WIN32 - if (noinst==0) - { - WORD sockVersion; - WSADATA wsaData; - sockVersion = MAKEWORD(2, 2); - WSAStartup(sockVersion, &wsaData); - } - #endif - - noinst++; - - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; // use my IP - - if (!int_port) - { - cleanup; - err=-1; - return; - } - - if ((rv = getaddrinfo(nullptr, _port.c_str(), &hints, &servinfo)) != 0) - { - cleanup; - err=-1; - return; - } - - // loop through all the results and bind to everything we can - for (p = servinfo; p != nullptr; p = p->ai_next) - { - sock_t sock; - if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == BAD_SOCK) - { - continue; - } - - if (bind(sock, p->ai_addr, (int)p->ai_addrlen) == -1) - { - close(sock); - continue; - } - d->sockfds.push_back(sock); - } - - if (d->sockfds.empty()) - { - cleanup; - err=-2; - return; - } - - freeaddrinfo(servinfo); - err=0; - d->exit=false; - initBroadcastIPv4(); - initBroadcastIPv6(); - - std::lock_guard lk(d->termLock); - d->thread = std::thread(std::mem_fn(&UDPWiimote::mainThread), this); - - return; -} - -void UDPWiimote::mainThread() -{ - std::unique_lock lk(d->termLock); - - Common::Timer time; - fd_set fds; - struct timeval timeout; - timeout.tv_sec=0; - timeout.tv_usec=0; - time.Update(); - do - { - int maxfd=0; - FD_ZERO(&fds); - for (auto& fd : d->sockfds) - { - FD_SET(fd,&fds); -#ifndef _WIN32 - if (fd>=maxfd) - maxfd=(fd)+1; -#endif - } - - u64 tleft=timeout.tv_sec*1000+timeout.tv_usec/1000; - u64 telapsed=time.GetTimeDifference(); - time.Update(); - if (tleft<=telapsed) - { - timeout.tv_sec=1; - timeout.tv_usec=500000; - broadcastPresence(); - } - else - { - tleft-=telapsed; - timeout.tv_sec=(long)(tleft/1000); - timeout.tv_usec=(tleft%1000)*1000; - } - - lk.unlock(); //VERY hacky. don't like it - if (d->exit) return; - int rt=select(maxfd,&fds,nullptr,nullptr,&timeout); - if (d->exit) return; - lk.lock(); - if (d->exit) return; - - if (rt) - { - for (sock_t fd : d->sockfds) - { - if (FD_ISSET(fd,&fds)) - { - u8 bf[64]; - int size=60; - size_t addr_len; - struct sockaddr_storage their_addr; - addr_len = sizeof their_addr; - if ((size = recvfrom(fd, - (dataz)bf, - size , 0,(struct sockaddr *)&their_addr, (socklen_t*)&addr_len)) == -1) - { - ERROR_LOG(WIIMOTE,"UDPWii Packet error"); - } - else - { - std::lock_guard lkm(d->mutex); - if (pharsePacket(bf,size)==0) - { - //NOTICE_LOG(WIIMOTE,"UDPWII New pack"); - } - else - { - //NOTICE_LOG(WIIMOTE,"UDPWII Wrong pack format... ignoring"); - } - } - } - } - } - } while (!(d->exit)); -} - -UDPWiimote::~UDPWiimote() -{ - d->exit = true; - { - std::lock_guard lk(d->termLock); - d->thread.join(); - } - for (auto& elem : d->sockfds) - close(elem); - close(d->bipv4_fd); - close(d->bipv6_fd); - cleanup; - delete d; -} - -#define ACCEL_FLAG (1 << 0) -#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) -{ - if (size < 3) - return -1; - - if (bf[0] != 0xde) - return -1; - //if (bf[1]==0) - // time=0; - //if (bf[1]bipv4_fd=socket(AF_INET, SOCK_DGRAM, 0); - if (d->bipv4_fd == BAD_SOCK) - { - WARN_LOG(WIIMOTE,"socket() failed"); - return; - } - - int broad=1; - if (setsockopt(d->bipv4_fd,SOL_SOCKET,SO_BROADCAST, (const dataz)(&broad), sizeof broad) == -1) - { - WARN_LOG(WIIMOTE,"setsockopt(SO_BROADCAST) failed"); - return; - } -} - -void UDPWiimote::broadcastIPv4(const void * data, size_t size) -{ - - struct sockaddr_in their_addr; - their_addr.sin_family = AF_INET; - their_addr.sin_port = htons(4431); - their_addr.sin_addr.s_addr = INADDR_BROADCAST; - memset(their_addr.sin_zero, '\0', sizeof their_addr.sin_zero); - - int num; - if ((num=sendto(d->bipv4_fd,(const dataz)data,(int)size,0,(struct sockaddr *) &their_addr, sizeof their_addr)) == -1) - { - WARN_LOG(WIIMOTE,"sendto() failed"); - return; - } -} - -void UDPWiimote::initBroadcastIPv6() -{ - //TODO: IPv6 support -} - -void UDPWiimote::broadcastIPv6(const void * data, size_t size) -{ - //TODO: IPv6 support -} - -void UDPWiimote::broadcastPresence() -{ - size_t slen; - u8 bf[512]; - bf[0]=0xdf; //magic number - *((u16*)(&(bf[1])))=htons(bcastMagic); //unique per-wiimote 16-bit ID - bf[3]=(u8)index; //wiimote index - *((u16*)(&(bf[4])))=htons(int_port); //port - { - std::lock_guard lk(d->nameMutex); - slen=displayName.size(); - if (slen>=256) - slen=255; - bf[6]=(u8)slen; //display name size (max 255) - memcpy(&(bf[7]),displayName.c_str(),slen); //display name - } - broadcastIPv4(bf,7+slen); - broadcastIPv6(bf,7+slen); -} - -void UDPWiimote::getAccel(float* x, float* y, float* z) -{ - std::lock_guard lk(d->mutex); - *x = (float)waX; - *y = (float)waY; - *z = (float)waZ; -} - -u32 UDPWiimote::getButtons() -{ - u32 msk; - std::lock_guard lk(d->mutex); - msk = wiimoteMask; - return msk; -} - -void UDPWiimote::getIR(float* x, float* y) -{ - std::lock_guard lk(d->mutex); - *x = (float)pointerX; - *y = (float)pointerY; -} - -void UDPWiimote::getNunchuck(float* x, float* y, u8* mask) -{ - std::lock_guard lk(d->mutex); - *x = (float)nunX; - *y = (float)nunY; - *mask = nunMask; -} - -void UDPWiimote::getNunchuckAccel(float* x, float* y, float* z) -{ - std::lock_guard lk(d->mutex); - *x = (float)naX; - *y = (float)naY; - *z = (float)naZ; -} - -const std::string& UDPWiimote::getPort() -{ - return port; -} - -void UDPWiimote::changeName(const std::string& name) -{ - std::lock_guard lk(d->nameMutex); - displayName = name; -} diff --git a/Source/Core/InputCommon/UDPWiimote.h b/Source/Core/InputCommon/UDPWiimote.h deleted file mode 100644 index 5dd2c500ca..0000000000 --- a/Source/Core/InputCommon/UDPWiimote.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#pragma once - -#include -#include "Common/Common.h" - -#define UDPWM_B1 (1<<0) -#define UDPWM_B2 (1<<1) -#define UDPWM_BA (1<<2) -#define UDPWM_BB (1<<3) -#define UDPWM_BP (1<<4) -#define UDPWM_BM (1<<5) -#define UDPWM_BH (1<<6) -#define UDPWM_BU (1<<7) -#define UDPWM_BD (1<<8) -#define UDPWM_BL (1<<9) -#define UDPWM_BR (1<<10) -#define UDPWM_SK (1<<11) -#define UDPWM_NC (1<<0) -#define UDPWM_NZ (1<<1) - -class UDPWiimote -{ -public: - UDPWiimote(const std::string& port, const std::string& name, int index); - virtual ~UDPWiimote(); - void getAccel(float* x, float* y, float* z); - 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 std::string& getPort(); - void changeName(const std::string& name); - - void mainThread(); -private: - std::string port,displayName; - int pharsePacket(u8* data, size_t size); - struct _d; //using pimpl because Winsock2.h doesn't have include guards -_- - _d* d; - double waX, waY, waZ; - double naX, naY, naZ; - double nunX, nunY; - double pointerX, pointerY; - u8 nunMask; - u32 wiimoteMask; - u16 bcastMagic; - int err; - int index; - int int_port; - static int noinst; - void broadcastPresence(); - void broadcastIPv4(const void* data, size_t size); - void broadcastIPv6(const void* data, size_t size); - void initBroadcastIPv4(); - void initBroadcastIPv6(); -}; diff --git a/Source/Core/InputCommon/UDPWrapper.cpp b/Source/Core/InputCommon/UDPWrapper.cpp deleted file mode 100644 index 5d34cd7624..0000000000 --- a/Source/Core/InputCommon/UDPWrapper.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#include -#include -#include - -#include "InputCommon/UDPWrapper.h" - -static const std::string DefaultPort(const int index) -{ - static std::string s; - s = "443"; - s += (char)('2' + index); - return s; -} - -UDPWrapper::UDPWrapper(int indx, const char* const _name) : - ControllerEmu::ControlGroup(_name,GROUP_TYPE_UDPWII), - inst(nullptr), index(indx), - updIR(false),updAccel(false), - updButt(false),udpEn(false) - , port(DefaultPort(indx)) -{ - //PanicAlert("UDPWrapper #%d ctor",index); -} - -void UDPWrapper::LoadConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base ) -{ - ControlGroup::LoadConfig(sec,defdev,base); - - std::string group( base + name ); group += "/"; - - int _updAccel,_updIR,_updButt,_udpEn,_updNun,_updNunAccel; - sec->Get(group + "Enable",&_udpEn, 0); - sec->Get(group + "Port", &port, DefaultPort(index)); - sec->Get(group + "Update_Accel", &_updAccel, 1); - sec->Get(group + "Update_IR", &_updIR, 1); - sec->Get(group + "Update_Butt", &_updButt, 1); - sec->Get(group + "Update_Nunchuk", &_updNun, 1); - sec->Get(group + "Update_NunchukAccel", &_updNunAccel, 0); - - udpEn=(_udpEn>0); - updAccel=(_updAccel>0); - updIR=(_updIR>0); - updButt=(_updButt>0); - updNun=(_updNun>0); - updNunAccel=(_updNunAccel>0); - - Refresh(); -} - - -void UDPWrapper::SaveConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base ) -{ - ControlGroup::SaveConfig(sec,defdev,base); - std::string group( base + name ); group += "/"; - sec->Set(group + "Enable", (int)udpEn, 0); - sec->Set(group + "Port", port, DefaultPort(index)); - sec->Set(group + "Update_Accel", (int)updAccel, 1); - sec->Set(group + "Update_IR", (int)updIR, 1); - sec->Set(group + "Update_Butt", (int)updButt, 1); - sec->Set(group + "Update_Nunchuk", (int)updNun, 1); - sec->Set(group + "Update_NunchukAccel", (int)updNunAccel, 0); -} - - -void UDPWrapper::Refresh() -{ - bool udpAEn=(inst!=nullptr); - if (udpEn && udpAEn) - { - if (inst->getPort() == port) - { - delete inst; - inst = new UDPWiimote(port, "Dolphin-Emu", index); //TODO: Changeable display name - } - return; - } - if (!udpEn) - { - if (inst) - delete inst; - inst = nullptr; - return; - } - //else - inst = new UDPWiimote(port, "Dolphin-Emu", index); -} - -UDPWrapper::~UDPWrapper() -{ - if (inst) - delete inst; -} diff --git a/Source/Core/InputCommon/UDPWrapper.h b/Source/Core/InputCommon/UDPWrapper.h deleted file mode 100644 index 728926ec3e..0000000000 --- a/Source/Core/InputCommon/UDPWrapper.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#pragma once - -#include - -#include "Common/Common.h" -#include "Common/IniFile.h" -#include "InputCommon/ControllerEmu.h" -#include "InputCommon/UDPWiimote.h" - -class UDPWrapper : public ControllerEmu::ControlGroup -{ -public: - UDPWiimote * inst; - int index; - 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); - virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "") override; - virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "") override; - void Refresh(); - virtual ~UDPWrapper(); -};