From b809db52d12547e154d47028200d7c9f87f96ab9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Apr 2017 06:43:57 -0400 Subject: [PATCH 1/7] TASInputDlg: Use std::array where applicable --- Source/Core/DolphinWX/TASInputDlg.cpp | 85 +++++++++++++-------------- Source/Core/DolphinWX/TASInputDlg.h | 10 ++-- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index 08b586bd97..067285ecd4 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -43,6 +43,28 @@ struct TASWiimoteReport const wiimote_key key; }; +constexpr std::array s_gc_pad_buttons_bitmask{{ + PAD_BUTTON_DOWN, PAD_BUTTON_UP, PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT, PAD_BUTTON_A, PAD_BUTTON_B, + PAD_BUTTON_X, PAD_BUTTON_Y, PAD_TRIGGER_Z, PAD_TRIGGER_L, PAD_TRIGGER_R, PAD_BUTTON_START, +}}; + +constexpr std::array s_wii_buttons_bitmask{{ + WiimoteEmu::Wiimote::PAD_DOWN, WiimoteEmu::Wiimote::PAD_UP, WiimoteEmu::Wiimote::PAD_LEFT, + WiimoteEmu::Wiimote::PAD_RIGHT, WiimoteEmu::Wiimote::BUTTON_A, WiimoteEmu::Wiimote::BUTTON_B, + WiimoteEmu::Wiimote::BUTTON_ONE, WiimoteEmu::Wiimote::BUTTON_TWO, + WiimoteEmu::Wiimote::BUTTON_PLUS, WiimoteEmu::Wiimote::BUTTON_MINUS, + WiimoteEmu::Wiimote::BUTTON_HOME, +}}; + +constexpr std::array s_cc_buttons_bitmask{{ + WiimoteEmu::Classic::PAD_DOWN, WiimoteEmu::Classic::PAD_UP, WiimoteEmu::Classic::PAD_LEFT, + WiimoteEmu::Classic::PAD_RIGHT, WiimoteEmu::Classic::BUTTON_A, WiimoteEmu::Classic::BUTTON_B, + WiimoteEmu::Classic::BUTTON_X, WiimoteEmu::Classic::BUTTON_Y, WiimoteEmu::Classic::BUTTON_PLUS, + WiimoteEmu::Classic::BUTTON_MINUS, WiimoteEmu::Classic::TRIGGER_L, + WiimoteEmu::Classic::TRIGGER_R, WiimoteEmu::Classic::BUTTON_ZR, WiimoteEmu::Classic::BUTTON_ZL, + WiimoteEmu::Classic::BUTTON_HOME, +}}; + TASInputDlg::TASInputDlg(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) @@ -51,12 +73,9 @@ TASInputDlg::TASInputDlg(wxWindow* parent, wxWindowID id, const wxString& title, void TASInputDlg::CreateBaseLayout() { - for (unsigned int i = 0; i < ArraySize(m_controls); ++i) - m_controls[i] = nullptr; - for (unsigned int i = 0; i < ArraySize(m_buttons); ++i) - m_buttons[i] = nullptr; - for (unsigned int i = 0; i < ArraySize(m_cc_controls); ++i) - m_cc_controls[i] = nullptr; + m_controls = {}; + m_buttons = {}; + m_cc_controls = {}; m_buttons[0] = &m_dpad_down; m_buttons[1] = &m_dpad_up; @@ -93,31 +112,6 @@ void TASInputDlg::CreateBaseLayout() m_buttons_dpad->Add(space20, space20); } -static constexpr int s_gc_pad_buttons_bitmask[12] = { - PAD_BUTTON_DOWN, PAD_BUTTON_UP, PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT, - PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_X, PAD_BUTTON_Y, - PAD_TRIGGER_Z, PAD_TRIGGER_L, PAD_TRIGGER_R, PAD_BUTTON_START}; - -static constexpr int s_wii_buttons_bitmask[11] = { - WiimoteEmu::Wiimote::PAD_DOWN, WiimoteEmu::Wiimote::PAD_UP, - WiimoteEmu::Wiimote::PAD_LEFT, WiimoteEmu::Wiimote::PAD_RIGHT, - WiimoteEmu::Wiimote::BUTTON_A, WiimoteEmu::Wiimote::BUTTON_B, - WiimoteEmu::Wiimote::BUTTON_ONE, WiimoteEmu::Wiimote::BUTTON_TWO, - WiimoteEmu::Wiimote::BUTTON_PLUS, WiimoteEmu::Wiimote::BUTTON_MINUS, - WiimoteEmu::Wiimote::BUTTON_HOME, -}; - -static constexpr int s_cc_buttons_bitmask[15] = { - WiimoteEmu::Classic::PAD_DOWN, WiimoteEmu::Classic::PAD_UP, - WiimoteEmu::Classic::PAD_LEFT, WiimoteEmu::Classic::PAD_RIGHT, - WiimoteEmu::Classic::BUTTON_A, WiimoteEmu::Classic::BUTTON_B, - WiimoteEmu::Classic::BUTTON_X, WiimoteEmu::Classic::BUTTON_Y, - WiimoteEmu::Classic::BUTTON_PLUS, WiimoteEmu::Classic::BUTTON_MINUS, - WiimoteEmu::Classic::TRIGGER_L, WiimoteEmu::Classic::TRIGGER_R, - WiimoteEmu::Classic::BUTTON_ZR, WiimoteEmu::Classic::BUTTON_ZL, - WiimoteEmu::Classic::BUTTON_HOME, -}; - void TASInputDlg::CreateWiiLayout(int num) { if (m_has_layout) @@ -209,10 +203,13 @@ void TASInputDlg::CreateWiiLayout(int num) m_ext_szr->AddSpacer(space5); m_ext_szr->Add(nunchukaxisBox, 0, wxBOTTOM, space5); + // Add non-DPad related buttons first. wxGridSizer* const buttons_grid = new wxGridSizer(4); - for (unsigned int i = 4; i < ArraySize(m_buttons); ++i) + for (size_t i = 4; i < m_buttons.size(); ++i) + { if (m_buttons[i] != nullptr) buttons_grid->Add(m_buttons[i]->checkbox); + } buttons_grid->Add(space5, space5); wxStaticBoxSizer* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); @@ -405,10 +402,13 @@ void TASInputDlg::CreateGCLayout() const int space5 = FromDIP(5); + // Add non-DPad related buttons first. wxGridSizer* const buttons_grid = new wxGridSizer(4); - for (unsigned int i = 4; i < ArraySize(m_buttons); ++i) + for (size_t i = 4; i < m_buttons.size(); ++i) + { if (m_buttons[i] != nullptr) buttons_grid->Add(m_buttons[i]->checkbox, false); + } buttons_grid->Add(space5, space5); wxStaticBoxSizer* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); @@ -636,7 +636,7 @@ void TASInputDlg::SetButtonValue(Button* button, bool CurrentState) // NOTE: Host / CPU Thread void TASInputDlg::SetWiiButtons(u16* butt) { - for (unsigned int i = 0; i < 11; ++i) + for (size_t i = 0; i < s_wii_buttons_bitmask.size(); ++i) { if (m_buttons[i] != nullptr) *butt |= (m_buttons[i]->is_checked) ? s_wii_buttons_bitmask[i] : 0; @@ -655,7 +655,7 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus) SetSliderValue(&m_l_cont, PadStatus->triggerLeft); SetSliderValue(&m_r_cont, PadStatus->triggerRight); - for (unsigned int i = 0; i < ArraySize(m_buttons); ++i) + for (size_t i = 0; i < m_buttons.size(); ++i) { if (m_buttons[i] != nullptr) SetButtonValue(m_buttons[i], ((PadStatus->button & s_gc_pad_buttons_bitmask[i]) != 0)); @@ -677,7 +677,7 @@ void TASInputDlg::GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, in if (coreData) { - for (unsigned int i = 0; i < 11; ++i) + for (size_t i = 0; i < s_wii_buttons_bitmask.size(); ++i) { if (m_buttons[i] != nullptr) SetButtonValue(m_buttons[i], @@ -719,7 +719,7 @@ void TASInputDlg::GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, in wm_classic_extension& cc = *(wm_classic_extension*)extData; WiimoteDecrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension)); cc.bt.hex = cc.bt.hex ^ 0xFFFF; - for (unsigned int i = 0; i < 15; ++i) + for (size_t i = 0; i < m_cc_buttons.size(); ++i) { SetButtonValue(&m_cc_buttons[i], ((cc.bt.hex & s_cc_buttons_bitmask[i]) != 0)); } @@ -776,11 +776,10 @@ void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, } if (irData) { - u16 x[4]; - u16 y; + std::array x; + u16 y = m_main_stick.y_cont.value; x[0] = m_main_stick.x_cont.value; - y = m_main_stick.y_cont.value; x[1] = x[0] + 100; x[2] = x[0] - 10; x[3] = x[1] + 10; @@ -820,7 +819,7 @@ void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, { memset(data, 0xFF, sizeof(wm_ir_extended) * 4); wm_ir_extended* const ir_data = (wm_ir_extended*)irData; - for (unsigned int i = 0; i < 4; ++i) + for (size_t i = 0; i < x.size(); ++i) { if (x[i] < 1024 && y < 768) { @@ -866,7 +865,7 @@ void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, WiimoteDecrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension)); cc.bt.hex = 0; - for (unsigned int i = 0; i < ArraySize(m_cc_buttons); ++i) + for (size_t i = 0; i < m_cc_buttons.size(); ++i) { cc.bt.hex |= (m_cc_buttons[i].is_checked) ? s_cc_buttons_bitmask[i] : 0; } @@ -905,7 +904,7 @@ void TASInputDlg::GetValues(GCPadStatus* PadStatus) PadStatus->triggerLeft = m_l.is_checked ? 255 : m_l_cont.value; PadStatus->triggerRight = m_r.is_checked ? 255 : m_r_cont.value; - for (unsigned int i = 0; i < ArraySize(m_buttons); ++i) + for (size_t i = 0; i < m_buttons.size(); ++i) { if (m_buttons[i] != nullptr) { diff --git a/Source/Core/DolphinWX/TASInputDlg.h b/Source/Core/DolphinWX/TASInputDlg.h index 5fee27b792..c10d69e460 100644 --- a/Source/Core/DolphinWX/TASInputDlg.h +++ b/Source/Core/DolphinWX/TASInputDlg.h @@ -4,6 +4,8 @@ #pragma once +#include + #include #include #include @@ -124,10 +126,10 @@ private: Stick m_cc_l_stick, m_cc_r_stick; - Button* m_buttons[13]; - Button m_cc_buttons[15]; - Control* m_controls[10]; - Control* m_cc_controls[6]; + std::array m_buttons; + std::array m_cc_buttons; + std::array m_controls; + std::array m_cc_controls; u8 m_ext = 0; wxBoxSizer* m_main_szr; wxBoxSizer* m_wiimote_szr; From 2af5b64f322960fc24e35067061600cf3244e8c0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Apr 2017 07:17:42 -0400 Subject: [PATCH 2/7] TASInputDlg: Apply auto to UI control initializations where appropriate As all UI controls are essentially constructed with new expressions, the type is already visible on the right-hand side, so repeating the type twice isn't necessary. --- Source/Core/DolphinWX/TASInputDlg.cpp | 50 +++++++++++++-------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index 067285ecd4..7b021b6366 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -204,7 +204,7 @@ void TASInputDlg::CreateWiiLayout(int num) m_ext_szr->Add(nunchukaxisBox, 0, wxBOTTOM, space5); // Add non-DPad related buttons first. - wxGridSizer* const buttons_grid = new wxGridSizer(4); + auto* const buttons_grid = new wxGridSizer(4); for (size_t i = 4; i < m_buttons.size(); ++i) { if (m_buttons[i] != nullptr) @@ -212,7 +212,7 @@ void TASInputDlg::CreateWiiLayout(int num) } buttons_grid->Add(space5, space5); - wxStaticBoxSizer* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); + auto* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); buttons_box->Add(buttons_grid); buttons_box->Add(m_buttons_dpad, 0, wxTOP, space5); @@ -275,14 +275,13 @@ wxBoxSizer* TASInputDlg::CreateCCLayout() const int space5 = FromDIP(5); const int space20 = FromDIP(20); - wxStaticBoxSizer* const shoulder_box = - new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); + auto* const shoulder_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); shoulder_box->Add(m_cc_l.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_l.text, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_r.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_r.text, 0, wxALIGN_CENTER_VERTICAL); - wxGridSizer* const cc_buttons_dpad = new wxGridSizer(3); + auto* const cc_buttons_dpad = new wxGridSizer(3); cc_buttons_dpad->Add(space20, space20); cc_buttons_dpad->Add(m_cc_buttons[1].checkbox); cc_buttons_dpad->Add(space20, space20); @@ -293,17 +292,17 @@ wxBoxSizer* TASInputDlg::CreateCCLayout() cc_buttons_dpad->Add(m_cc_buttons[0].checkbox); cc_buttons_dpad->Add(space20, space20); - wxGridSizer* const cc_buttons_grid = new wxGridSizer(4); + auto* const cc_buttons_grid = new wxGridSizer(4); for (auto& button : m_cc_buttons) if (!button.checkbox->GetContainingSizer()) cc_buttons_grid->Add(button.checkbox); cc_buttons_grid->Add(space5, space5); - wxStaticBoxSizer* const cc_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); + auto* const cc_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); cc_buttons_box->Add(cc_buttons_grid); cc_buttons_box->Add(cc_buttons_dpad, 0, wxTOP, space5); - wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL); + auto* const szr = new wxBoxSizer(wxHORIZONTAL); szr->AddSpacer(space5); szr->Add(m_cc_l_stick_szr, 0, wxTOP | wxBOTTOM, space5); szr->AddSpacer(space5); @@ -372,8 +371,7 @@ void TASInputDlg::CreateGCLayout() m_c_stick = CreateStick(ID_C_STICK, 255, 255, 128, 128, false, true); wxStaticBoxSizer* const c_box = CreateStickLayout(&m_c_stick, _("C Stick")); - wxStaticBoxSizer* const shoulder_box = - new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); + auto* const shoulder_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); m_l_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 255, 0); m_r_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 255, 0); shoulder_box->Add(m_l_cont.slider, 0, wxALIGN_CENTER_VERTICAL); @@ -403,7 +401,7 @@ void TASInputDlg::CreateGCLayout() const int space5 = FromDIP(5); // Add non-DPad related buttons first. - wxGridSizer* const buttons_grid = new wxGridSizer(4); + auto* const buttons_grid = new wxGridSizer(4); for (size_t i = 4; i < m_buttons.size(); ++i) { if (m_buttons[i] != nullptr) @@ -411,19 +409,19 @@ void TASInputDlg::CreateGCLayout() } buttons_grid->Add(space5, space5); - wxStaticBoxSizer* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); + auto* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); buttons_box->Add(buttons_grid); buttons_box->Add(m_buttons_dpad); - wxBoxSizer* const top_box = new wxBoxSizer(wxHORIZONTAL); + auto* const top_box = new wxBoxSizer(wxHORIZONTAL); top_box->Add(main_box); top_box->Add(c_box, 0, wxLEFT, space5); - wxBoxSizer* const bottom_box = new wxBoxSizer(wxHORIZONTAL); + auto* const bottom_box = new wxBoxSizer(wxHORIZONTAL); bottom_box->Add(shoulder_box); bottom_box->Add(buttons_box, 0, wxLEFT, space5); - wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL); + auto* const main_szr = new wxBoxSizer(wxVERTICAL); main_szr->AddSpacer(space5); main_szr->Add(top_box, 0, wxLEFT | wxRIGHT, space5); main_szr->AddSpacer(space5); @@ -473,8 +471,8 @@ wxStaticBoxSizer* TASInputDlg::CreateStickLayout(Stick* stick, const wxString& t { const int space3 = FromDIP(3); - wxStaticBoxSizer* const temp_box = new wxStaticBoxSizer(wxVERTICAL, this, title); - wxFlexGridSizer* const layout = new wxFlexGridSizer(2, space3, space3); + auto* const temp_box = new wxStaticBoxSizer(wxVERTICAL, this, title); + auto* const layout = new wxFlexGridSizer(2, space3, space3); layout->Add(stick->x_cont.slider, 0, wxEXPAND); layout->Add(stick->x_cont.text, 0, wxALIGN_CENTER); @@ -492,10 +490,10 @@ wxStaticBoxSizer* TASInputDlg::CreateStickLayout(Stick* stick, const wxString& t wxStaticBoxSizer* TASInputDlg::CreateAccelLayout(Control* x, Control* y, Control* z, const wxString& title) { - wxStaticBoxSizer* const temp_box = new wxStaticBoxSizer(wxHORIZONTAL, this, title); - wxStaticBoxSizer* const xBox = new wxStaticBoxSizer(wxVERTICAL, this, _("X")); - wxStaticBoxSizer* const yBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Y")); - wxStaticBoxSizer* const zBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Z")); + auto* const temp_box = new wxStaticBoxSizer(wxHORIZONTAL, this, title); + auto* const xBox = new wxStaticBoxSizer(wxVERTICAL, this, _("X")); + auto* const yBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Y")); + auto* const zBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Z")); const int space5 = FromDIP(5); xBox->Add(x->slider, 0, wxALIGN_CENTER_HORIZONTAL); @@ -518,7 +516,7 @@ TASInputDlg::Button TASInputDlg::CreateButton(const wxString& name) { Button temp; temp.id = m_eleID++; - wxCheckBox* checkbox = new wxCheckBox(this, temp.id, name); + auto* checkbox = new wxCheckBox(this, temp.id, name); checkbox->Bind(wxEVT_RIGHT_DOWN, &TASInputDlg::SetTurbo, this); checkbox->Bind(wxEVT_LEFT_DOWN, &TASInputDlg::SetTurbo, this); checkbox->Bind(wxEVT_CHECKBOX, &TASInputDlg::OnCheckboxToggle, this); @@ -1156,7 +1154,7 @@ void TASInputDlg::InvalidateButton(Button* button) { if (!wxIsMainThread()) { - wxCommandEvent* evt = new wxCommandEvent(INVALIDATE_BUTTON_EVENT, button->id); + auto* evt = new wxCommandEvent(INVALIDATE_BUTTON_EVENT, button->id); evt->SetClientData(button); wxQueueEvent(this, evt); return; @@ -1170,7 +1168,7 @@ void TASInputDlg::InvalidateControl(Control* control) { if (!wxIsMainThread()) { - wxCommandEvent* evt = new wxCommandEvent(INVALIDATE_CONTROL_EVENT, control->text_id); + auto* evt = new wxCommandEvent(INVALIDATE_CONTROL_EVENT, control->text_id); evt->SetClientData(control); wxQueueEvent(this, evt); return; @@ -1192,7 +1190,7 @@ void TASInputDlg::InvalidateExtension() void TASInputDlg::UpdateFromInvalidatedButton(wxCommandEvent& event) { - Button* button = static_cast(event.GetClientData()); + auto* button = static_cast(event.GetClientData()); _assert_msg_(PAD, button->id == button->checkbox->GetId(), "Button ids do not match: %i != %i", button->id, button->checkbox->GetId()); button->checkbox->SetValue(button->value); @@ -1201,7 +1199,7 @@ void TASInputDlg::UpdateFromInvalidatedButton(wxCommandEvent& event) void TASInputDlg::UpdateFromInvalidatedControl(wxCommandEvent& event) { - Control* control = static_cast(event.GetClientData()); + auto* control = static_cast(event.GetClientData()); _assert_msg_(PAD, control->text_id == control->text->GetId(), "Control ids do not match: %i != %i", control->text_id, control->text->GetId()); control->text->SetValue(std::to_string(control->value)); From 598a92426f49ad8c1097f1f59455f53cf4bcea9e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Apr 2017 07:44:08 -0400 Subject: [PATCH 3/7] TASInputDlg: Get rid of unnecessary event casts wxCommandEvent already stores the necessary data; the control object itself doesn't need to be retrieved and casted. --- Source/Core/DolphinWX/TASInputDlg.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index 7b021b6366..f6d313dd3a 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -941,16 +941,19 @@ void TASInputDlg::UpdateFromSliders(wxCommandEvent& event) if (control != nullptr && event.GetId() == control->slider_id) text = control->text; } - int value = ((wxSlider*)event.GetEventObject())->GetValue(); - if (text) - text->SetValue(std::to_string(value)); + + if (!text) + return; + + const int slider_value = event.GetInt(); + text->SetValue(std::to_string(slider_value)); } void TASInputDlg::UpdateFromText(wxCommandEvent& event) { unsigned long value; - if (!((wxTextCtrl*)event.GetEventObject())->GetValue().ToULong(&value)) + if (!event.GetString().ToULong(&value)) return; for (Control* const control : m_controls) From 28395c63020a8a9323f5a0c6c80d8050a025cce5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Apr 2017 08:02:45 -0400 Subject: [PATCH 4/7] TASInputDlg: Simplify event queueing calls wxQueueEvent/wxPostEvent are useful when the event is being dispatched to another separate window, but aren't really necessary when the event will be handled by the same window it's dispatched from. GetEventHandler() is unnecessary here for the same reason. It's an event intended to be handled by the dialog itself. --- Source/Core/DolphinWX/TASInputDlg.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index f6d313dd3a..4fa046653f 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -1159,7 +1159,7 @@ void TASInputDlg::InvalidateButton(Button* button) { auto* evt = new wxCommandEvent(INVALIDATE_BUTTON_EVENT, button->id); evt->SetClientData(button); - wxQueueEvent(this, evt); + QueueEvent(evt); return; } @@ -1173,7 +1173,7 @@ void TASInputDlg::InvalidateControl(Control* control) { auto* evt = new wxCommandEvent(INVALIDATE_CONTROL_EVENT, control->text_id); evt->SetClientData(control); - wxQueueEvent(this, evt); + QueueEvent(evt); return; } @@ -1184,7 +1184,7 @@ void TASInputDlg::InvalidateExtension() { if (!wxIsMainThread()) { - GetEventHandler()->QueueEvent(new wxThreadEvent(INVALIDATE_EXTENSION_EVENT)); + QueueEvent(new wxThreadEvent(INVALIDATE_EXTENSION_EVENT)); return; } From 2a968f02d79a0cb6922b97a86b35a80a7219df57 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Apr 2017 08:14:19 -0400 Subject: [PATCH 5/7] TASInputDlg: Make constructor explicit --- Source/Core/DolphinWX/TASInputDlg.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.h b/Source/Core/DolphinWX/TASInputDlg.h index c10d69e460..ea77486473 100644 --- a/Source/Core/DolphinWX/TASInputDlg.h +++ b/Source/Core/DolphinWX/TASInputDlg.h @@ -23,9 +23,10 @@ class wxTextCtrl; class TASInputDlg : public wxDialog { public: - TASInputDlg(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("TAS Input"), - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP); + explicit TASInputDlg(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxString& title = _("TAS Input"), + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP); void GetValues(GCPadStatus* PadStatus); void GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key); From 9dd29895cd249a75e4f576cf6f8acacae3e0f6a2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Apr 2017 08:16:26 -0400 Subject: [PATCH 6/7] TASInputDlg: Replace includes with forward declarations --- Source/Core/DolphinWX/TASInputDlg.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.h b/Source/Core/DolphinWX/TASInputDlg.h index ea77486473..8696a5a1be 100644 --- a/Source/Core/DolphinWX/TASInputDlg.h +++ b/Source/Core/DolphinWX/TASInputDlg.h @@ -6,20 +6,23 @@ #include -#include -#include #include #include #include "Common/CommonTypes.h" -#include "Core/HW/WiimoteEmu/WiimoteEmu.h" -#include "InputCommon/GCPadStatus.h" class DolphinSlider; +struct GCPadStatus; +class wxBitmap; class wxCheckBox; class wxStaticBitmap; class wxTextCtrl; +namespace WiimoteEmu +{ +struct ReportFeatures; +} + class TASInputDlg : public wxDialog { public: From f3ab0fc3f880c95c697afb60fb9b1c5d17476b28 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Apr 2017 08:27:31 -0400 Subject: [PATCH 7/7] TASInputDlg: Use an enum for ID constants These are all related constants (and it doesn't make sense to allow taking the address of them). --- Source/Core/DolphinWX/TASInputDlg.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.h b/Source/Core/DolphinWX/TASInputDlg.h index 8696a5a1be..e371259301 100644 --- a/Source/Core/DolphinWX/TASInputDlg.h +++ b/Source/Core/DolphinWX/TASInputDlg.h @@ -39,10 +39,17 @@ public: void CreateWiiLayout(int num); private: - static constexpr int ID_C_STICK = 1001; - static constexpr int ID_MAIN_STICK = 1002; - static constexpr int ID_CC_L_STICK = 1003; - static constexpr int ID_CC_R_STICK = 1004; + enum : int + { + ID_C_STICK = 1001, + ID_MAIN_STICK = 1002, + ID_CC_L_STICK = 1003, + ID_CC_R_STICK = 1004 + }; + + // Used in the context of creating controls on the fly + // This is greater than the last stick enum constant to + // prevent ID clashing in wx's event system. int m_eleID = 1005; struct Control