mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
DolphinQt: Make input mapping and output testing non-blocking.
This commit is contained in:
@ -9,13 +9,12 @@
|
||||
#include <QString>
|
||||
|
||||
#include "DolphinQt/Config/Mapping/IOWindow.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingCommon.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
|
||||
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
@ -74,7 +73,7 @@ bool MappingButton::IsInput() const
|
||||
}
|
||||
|
||||
MappingButton::MappingButton(MappingWidget* parent, ControlReference* ref, bool indicator)
|
||||
: ElidedButton(RefToDisplayString(ref)), m_parent(parent), m_reference(ref)
|
||||
: ElidedButton(RefToDisplayString(ref)), m_mapping_window(parent->GetParent()), m_reference(ref)
|
||||
{
|
||||
if (IsInput())
|
||||
{
|
||||
@ -92,17 +91,22 @@ MappingButton::MappingButton(MappingWidget* parent, ControlReference* ref, bool
|
||||
connect(parent, &MappingWidget::Update, this, &MappingButton::UpdateIndicator);
|
||||
|
||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingButton::ConfigChanged);
|
||||
connect(this, &MappingButton::ConfigChanged, [this] {
|
||||
setText(RefToDisplayString(m_reference));
|
||||
m_is_mapping = false;
|
||||
});
|
||||
}
|
||||
|
||||
void MappingButton::AdvancedPressed()
|
||||
{
|
||||
IOWindow io(m_parent, m_parent->GetController(), m_reference,
|
||||
m_mapping_window->CancelMapping();
|
||||
|
||||
IOWindow io(m_mapping_window, m_mapping_window->GetController(), m_reference,
|
||||
m_reference->IsInput() ? IOWindow::Type::Input : IOWindow::Type::Output);
|
||||
SetQWidgetWindowDecorations(&io);
|
||||
io.exec();
|
||||
|
||||
ConfigChanged();
|
||||
m_parent->SaveSettings();
|
||||
m_mapping_window->Save();
|
||||
}
|
||||
|
||||
void MappingButton::Clicked()
|
||||
@ -113,31 +117,8 @@ void MappingButton::Clicked()
|
||||
return;
|
||||
}
|
||||
|
||||
const auto default_device_qualifier = m_parent->GetController()->GetDefaultDevice();
|
||||
|
||||
QString expression;
|
||||
|
||||
if (m_parent->GetParent()->IsMappingAllDevices())
|
||||
{
|
||||
expression = MappingCommon::DetectExpression(this, g_controller_interface,
|
||||
g_controller_interface.GetAllDeviceStrings(),
|
||||
default_device_qualifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
expression = MappingCommon::DetectExpression(this, g_controller_interface,
|
||||
{default_device_qualifier.ToString()},
|
||||
default_device_qualifier);
|
||||
}
|
||||
|
||||
if (expression.isEmpty())
|
||||
return;
|
||||
|
||||
m_reference->SetExpression(expression.toStdString());
|
||||
m_parent->GetController()->UpdateSingleControlReference(g_controller_interface, m_reference);
|
||||
|
||||
ConfigChanged();
|
||||
m_parent->SaveSettings();
|
||||
m_is_mapping = true;
|
||||
m_mapping_window->QueueInputDetection(this);
|
||||
}
|
||||
|
||||
void MappingButton::Clear()
|
||||
@ -145,22 +126,21 @@ void MappingButton::Clear()
|
||||
m_reference->range = 100.0 / SLIDER_TICK_COUNT;
|
||||
|
||||
m_reference->SetExpression("");
|
||||
m_parent->GetController()->UpdateSingleControlReference(g_controller_interface, m_reference);
|
||||
m_mapping_window->GetController()->UpdateSingleControlReference(g_controller_interface,
|
||||
m_reference);
|
||||
|
||||
m_parent->SaveSettings();
|
||||
ConfigChanged();
|
||||
m_mapping_window->Save();
|
||||
|
||||
m_mapping_window->UnQueueInputDetection(this);
|
||||
}
|
||||
|
||||
void MappingButton::UpdateIndicator()
|
||||
{
|
||||
if (!isActiveWindow())
|
||||
return;
|
||||
QFont f = m_mapping_window->font();
|
||||
|
||||
QFont f = m_parent->font();
|
||||
|
||||
// If the input state is "true" (we can't know the state of outputs), show it in bold.
|
||||
if (m_reference->IsInput() && m_reference->GetState<bool>())
|
||||
if (isActiveWindow() && m_reference->IsInput() && m_reference->GetState<bool>() && !m_is_mapping)
|
||||
f.setBold(true);
|
||||
|
||||
// If the expression has failed to parse, show it in italic.
|
||||
// Some expressions still work even the failed to parse so don't prevent the GetState() above.
|
||||
if (m_reference->GetParseStatus() == ciface::ExpressionParser::ParseStatus::SyntaxError)
|
||||
@ -169,9 +149,12 @@ void MappingButton::UpdateIndicator()
|
||||
setFont(f);
|
||||
}
|
||||
|
||||
void MappingButton::ConfigChanged()
|
||||
void MappingButton::StartMapping()
|
||||
{
|
||||
setText(RefToDisplayString(m_reference));
|
||||
// Focus just makes it more clear which button is currently being mapped.
|
||||
setFocus();
|
||||
setText(tr("[ Press Now ]"));
|
||||
QtUtils::InstallKeyboardBlocker(this, this, &MappingButton::ConfigChanged);
|
||||
}
|
||||
|
||||
void MappingButton::mouseReleaseEvent(QMouseEvent* event)
|
||||
@ -189,3 +172,8 @@ void MappingButton::mouseReleaseEvent(QMouseEvent* event)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ControlReference* MappingButton::GetControlReference()
|
||||
{
|
||||
return m_reference;
|
||||
}
|
||||
|
Reference in New Issue
Block a user