mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
ControllerInterface/DolphinQt: Make mapping "all devices" way less hacky.
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user