ControllerInterface/DolphinQt: Make mapping "all devices" way less hacky.

This commit is contained in:
Jordan Woyak
2019-02-27 18:10:18 -06:00
parent 48b69ca018
commit c389d68186
10 changed files with 192 additions and 232 deletions

View File

@ -136,8 +136,8 @@ void IOWindow::ConnectWidgets()
connect(m_or_button, &QPushButton::clicked, [this] { AppendSelectedOption(" | "); });
connect(m_not_button, &QPushButton::clicked, [this] { AppendSelectedOption("!"); });
connect(m_type == IOWindow::Type::Input ? m_detect_button : m_test_button, &QPushButton::clicked,
this, &IOWindow::OnDetectButtonPressed);
connect(m_detect_button, &QPushButton::clicked, this, &IOWindow::OnDetectButtonPressed);
connect(m_test_button, &QPushButton::clicked, this, &IOWindow::OnTestButtonPressed);
connect(m_button_box, &QDialogButtonBox::clicked, this, &IOWindow::OnDialogButtonPressed);
connect(m_devices_combo, &QComboBox::currentTextChanged, this, &IOWindow::OnDeviceChanged);
@ -180,35 +180,22 @@ void IOWindow::OnDialogButtonPressed(QAbstractButton* button)
void IOWindow::OnDetectButtonPressed()
{
installEventFilter(BlockUserInputFilter::Instance());
grabKeyboard();
grabMouse();
const auto expression =
MappingCommon::DetectExpression(m_detect_button, g_controller_interface, {m_devq.ToString()},
m_devq, MappingCommon::Quote::Off);
std::thread([this] {
auto* btn = m_type == IOWindow::Type::Input ? m_detect_button : m_test_button;
const auto old_label = btn->text();
if (expression.isEmpty())
return;
btn->setText(QStringLiteral("..."));
const auto list = m_option_list->findItems(expression, Qt::MatchFixedString);
const auto expr = MappingCommon::DetectExpression(
m_reference, g_controller_interface.FindDevice(m_devq).get(), m_devq,
MappingCommon::Quote::Off);
if (!list.empty())
m_option_list->setCurrentItem(list[0]);
}
btn->setText(old_label);
if (!expr.isEmpty())
{
const auto list = m_option_list->findItems(expr, Qt::MatchFixedString);
if (!list.empty())
m_option_list->setCurrentItem(list[0]);
}
releaseMouse();
releaseKeyboard();
removeEventFilter(BlockUserInputFilter::Instance());
})
.detach();
void IOWindow::OnTestButtonPressed()
{
MappingCommon::TestOutput(m_test_button, static_cast<OutputReference*>(m_reference));
}
void IOWindow::OnRangeChanged(int value)