From 9a632ea7b92b561de8304d8446b0d1e6e7e3e842 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Fri, 9 Dec 2016 13:13:11 -0800 Subject: [PATCH] ControlReference: hide is_input behind function --- .../Core/DolphinWX/Input/InputConfigDiag.cpp | 10 +++++----- .../ControlReference/ControlReference.cpp | 18 +++++++++++++----- .../ControlReference/ControlReference.h | 6 ++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp index 9f088488b0..0d64f81ee4 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp @@ -291,7 +291,7 @@ void ControlDialog::UpdateListContents() const auto dev = g_controller_interface.FindDevice(m_devq); if (dev != nullptr) { - if (control_reference->is_input) + if (control_reference->IsInput()) { for (ciface::Core::Device::Input* input : dev->Inputs()) { @@ -720,7 +720,7 @@ bool InputConfigDialog::DetectButton(ControlButton* button) wxStaticBoxSizer* ControlDialog::CreateControlChooser(InputConfigDialog* const parent) { wxStaticBoxSizer* const main_szr = new wxStaticBoxSizer( - wxVERTICAL, this, control_reference->is_input ? _("Input") : _("Output")); + wxVERTICAL, this, control_reference->IsInput() ? _("Input") : _("Output")); const int space5 = FromDIP(5); textctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, @@ -730,7 +730,7 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(InputConfigDialog* const p textctrl->SetFont(font); wxButton* const detect_button = - new wxButton(this, wxID_ANY, control_reference->is_input ? _("Detect") : _("Test")); + new wxButton(this, wxID_ANY, control_reference->IsInput() ? _("Detect") : _("Test")); wxButton* const clear_button = new wxButton(this, wxID_ANY, _("Clear")); @@ -747,7 +747,7 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(InputConfigDialog* const p button_sizer->Add(select_button, 1); button_sizer->Add(or_button, 1); - if (control_reference->is_input) + if (control_reference->IsInput()) { // TODO: check if && is good on other OS wxButton* const and_button = new wxButton(this, wxID_ANY, _("&& AND")); @@ -964,7 +964,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin exclude_buttons.end()) eventsink->control_buttons.push_back(control_button); - if (control->control_ref->is_input) + if (control->control_ref->IsInput()) { control_button->SetToolTip( _("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options.")); diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.cpp b/Source/Core/InputCommon/ControlReference/ControlReference.cpp index 5b5d807781..5dc8c858ed 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.cpp +++ b/Source/Core/InputCommon/ControlReference/ControlReference.cpp @@ -32,7 +32,7 @@ void ControlReference::UpdateReference(ciface::Core::DeviceContainer& devices, delete parsed_expression; parsed_expression = nullptr; - ControlFinder finder(devices, default_device, is_input); + ControlFinder finder(devices, default_device, IsInput()); parse_error = ParseExpression(expression, finder, &parsed_expression); } @@ -48,19 +48,27 @@ int ControlReference::BoundCount() const return 0; } -ControlReference::ControlReference(const bool _is_input) - : range(1), is_input(_is_input), parsed_expression(nullptr) +ControlReference::ControlReference() : range(1), parsed_expression(nullptr) { } -InputReference::InputReference() : ControlReference(true) +InputReference::InputReference() : ControlReference() { } -OutputReference::OutputReference() : ControlReference(false) +OutputReference::OutputReference() : ControlReference() { } +bool InputReference::IsInput() const +{ + return true; +} +bool OutputReference::IsInput() const +{ + return false; +} + // // InputReference :: State // diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h index 64f782b2ce..4448b58701 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.h +++ b/Source/Core/InputCommon/ControlReference/ControlReference.h @@ -26,6 +26,7 @@ public: virtual ControlState State(const ControlState state = 0) = 0; virtual ciface::Core::Device::Control* Detect(const unsigned int ms, ciface::Core::Device* const device) = 0; + virtual bool IsInput() const = 0; int BoundCount() const; void UpdateReference(ciface::Core::DeviceContainer& devices, @@ -33,11 +34,10 @@ public: ControlState range; std::string expression; - const bool is_input; ciface::ExpressionParser::ExpressionParseStatus parse_error; protected: - ControlReference(const bool _is_input); + ControlReference(); ciface::ExpressionParser::Expression* parsed_expression; }; @@ -50,6 +50,7 @@ class InputReference : public ControlReference { public: InputReference(); + bool IsInput() const override; ControlState State(const ControlState state) override; ciface::Core::Device::Control* Detect(const unsigned int ms, ciface::Core::Device* const device) override; @@ -64,6 +65,7 @@ class OutputReference : public ControlReference { public: OutputReference(); + bool IsInput() const override; ControlState State(const ControlState state) override; ciface::Core::Device::Control* Detect(const unsigned int ms, ciface::Core::Device* const device) override;