Merge pull request #4502 from ligfx/extractcontrolreference
InputCommon: Extract ControlReference from ControllerInterface
This commit is contained in:
@@ -52,10 +52,10 @@
|
||||
#include "DolphinWX/Input/NunchukInputConfigDiag.h"
|
||||
#include "DolphinWX/Input/TurntableInputConfigDiag.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
#include "InputCommon/ControlReference/ExpressionParser.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
#include "InputCommon/ControllerInterface/ExpressionParser.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
using namespace ciface::ExpressionParser;
|
||||
@@ -177,7 +177,7 @@ void PadSettingSpin::UpdateValue()
|
||||
}
|
||||
|
||||
ControlDialog::ControlDialog(InputConfigDialog* const parent, InputConfig& config,
|
||||
ControllerInterface::ControlReference* const ref)
|
||||
ControlReference* const ref)
|
||||
: wxDialog(parent, wxID_ANY, _("Configure Control"), wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
||||
control_reference(ref), m_config(config), m_parent(parent)
|
||||
@@ -220,8 +220,7 @@ ExtensionButton::ExtensionButton(wxWindow* const parent, ControllerEmu::Extensio
|
||||
{
|
||||
}
|
||||
|
||||
ControlButton::ControlButton(wxWindow* const parent,
|
||||
ControllerInterface::ControlReference* const _ref,
|
||||
ControlButton::ControlButton(wxWindow* const parent, ControlReference* const _ref,
|
||||
const std::string& name, const unsigned int width,
|
||||
const std::string& label)
|
||||
: wxButton(parent, wxID_ANY), control_reference(_ref), m_name(name),
|
||||
@@ -292,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())
|
||||
{
|
||||
@@ -327,7 +326,7 @@ void ControlDialog::UpdateGUI()
|
||||
m_bound_label->SetLabel(
|
||||
wxString::Format(_("Bound Controls: %lu"), (unsigned long)control_reference->BoundCount()));
|
||||
|
||||
switch (control_reference->parse_error)
|
||||
switch (control_reference->GetParseStatus())
|
||||
{
|
||||
case EXPRESSION_PARSE_SYNTAX_ERROR:
|
||||
m_error_label->SetLabel(_("Syntax error"));
|
||||
@@ -387,13 +386,13 @@ bool ControlDialog::Validate()
|
||||
control_reference->expression = WxStrToStr(textctrl->GetValue());
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
g_controller_interface.UpdateReference(control_reference,
|
||||
m_parent->GetController()->default_device);
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
UpdateGUI();
|
||||
|
||||
return (control_reference->parse_error == EXPRESSION_PARSE_SUCCESS ||
|
||||
control_reference->parse_error == EXPRESSION_PARSE_NO_DEVICE);
|
||||
return (control_reference->GetParseStatus() == EXPRESSION_PARSE_SUCCESS ||
|
||||
control_reference->GetParseStatus() == EXPRESSION_PARSE_NO_DEVICE);
|
||||
}
|
||||
|
||||
void InputConfigDialog::SetDevice(wxCommandEvent&)
|
||||
@@ -426,8 +425,8 @@ void ControlDialog::ClearControl(wxCommandEvent&)
|
||||
control_reference->expression.clear();
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
g_controller_interface.UpdateReference(control_reference,
|
||||
m_parent->GetController()->default_device);
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
@@ -485,8 +484,8 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
|
||||
control_reference->expression = textctrl->GetValue();
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
g_controller_interface.UpdateReference(control_reference,
|
||||
m_parent->GetController()->default_device);
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
@@ -521,8 +520,8 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
||||
control_reference->expression = textctrl->GetValue();
|
||||
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
g_controller_interface.UpdateReference(control_reference,
|
||||
m_parent->GetController()->default_device);
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
m_parent->GetController()->default_device);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
@@ -703,7 +702,8 @@ bool InputConfigDialog::DetectButton(ControlButton* button)
|
||||
GetExpressionForControl(expr, control_name);
|
||||
button->control_reference->expression = expr;
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
g_controller_interface.UpdateReference(button->control_reference, controller->default_device);
|
||||
button->control_reference->UpdateReference(g_controller_interface,
|
||||
controller->default_device);
|
||||
success = true;
|
||||
}
|
||||
|
||||
@@ -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."));
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
|
||||
class DolphinSlider;
|
||||
@@ -100,14 +100,13 @@ class InputConfigDialog;
|
||||
class ControlDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
ControlDialog(InputConfigDialog* const parent, InputConfig& config,
|
||||
ControllerInterface::ControlReference* const ref);
|
||||
ControlDialog(InputConfigDialog* const parent, InputConfig& config, ControlReference* const ref);
|
||||
|
||||
bool Validate() override;
|
||||
|
||||
int GetRangeSliderValue() const;
|
||||
|
||||
ControllerInterface::ControlReference* const control_reference;
|
||||
ControlReference* const control_reference;
|
||||
InputConfig& m_config;
|
||||
|
||||
private:
|
||||
@@ -151,10 +150,10 @@ public:
|
||||
class ControlButton : public wxButton
|
||||
{
|
||||
public:
|
||||
ControlButton(wxWindow* const parent, ControllerInterface::ControlReference* const _ref,
|
||||
const std::string& name, const unsigned int width, const std::string& label = {});
|
||||
ControlButton(wxWindow* const parent, ControlReference* const _ref, const std::string& name,
|
||||
const unsigned int width, const std::string& label = {});
|
||||
|
||||
ControllerInterface::ControlReference* const control_reference;
|
||||
ControlReference* const control_reference;
|
||||
const std::string m_name;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user