summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-02-01 14:33:03 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2025-02-15 14:15:51 -0600
commit3189de6c7af808f62f622c744832b051f0f885ff (patch)
tree5f2f8bc898d7acee7980bc0cd7891762928800dc /Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
parenta8fae9b82683dd0ea766cb8c282b414707962255 (diff)
DolphinQt: Add setting to enable iterative input mappings.
Diffstat (limited to 'Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp')
-rw-r--r--Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
index 37407f2298..54a0db59ef 100644
--- a/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
+++ b/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
@@ -10,6 +10,7 @@
#include "DolphinQt/Config/Mapping/MappingButton.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
+#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
@@ -49,7 +50,10 @@ public:
const auto& default_device = m_parent->GetController()->GetDefaultDevice();
auto& button = m_clicked_mapping_buttons.front();
- button->StartMapping();
+ // Focus just makes it more clear which button is currently being mapped.
+ button->setFocus();
+ button->setText(tr("[ Press Now ]"));
+ QtUtils::InstallKeyboardBlocker(button, button, &MappingButton::ConfigChanged);
std::vector device_strings{default_device.ToString()};
if (m_parent->IsCreateOtherDeviceMappingsEnabled())
@@ -73,9 +77,17 @@ public:
if (m_input_detector->IsComplete())
{
- // No inputs detected. Cancel this and any other queued mappings.
+ auto* const button = m_clicked_mapping_buttons.back();
+
if (!FinalizeMapping(m_input_detector->TakeResults()))
+ {
+ // No inputs detected. Cancel this and any other queued mappings.
CancelMapping();
+ }
+ else if (m_parent->IsIterativeMappingEnabled() && m_clicked_mapping_buttons.empty())
+ {
+ button->QueueNextButtonMapping();
+ }
}
}
@@ -110,22 +122,20 @@ public:
m_input_detection_start_timer->start(INPUT_DETECT_INITIAL_DELAY);
}
- void UnQueueInputDetection(MappingButton* button)
+ bool UnQueueInputDetection(MappingButton* button)
{
- std::erase(m_clicked_mapping_buttons, button);
+ if (!std::erase(m_clicked_mapping_buttons, button))
+ return false;
button->ConfigChanged();
UpdateInputDetectionStartTimer();
+ return true;
}
void QueueInputDetection(MappingButton* button)
{
- // UnQueue if already queued.
- if (std::erase(m_clicked_mapping_buttons, button))
- {
- button->ConfigChanged();
- UpdateInputDetectionStartTimer();
+ // Just UnQueue if already queued.
+ if (UnQueueInputDetection(button))
return;
- }
button->setText(QStringLiteral("[ ... ]"));
m_clicked_mapping_buttons.push_back(button);