summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2019-04-27 12:35:26 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2019-04-28 08:34:47 -0500
commit4e39d833ae412709c854486e49d4de2f9f174306 (patch)
treec178ffe45f739b582de74c6f5e2d541ea5c80aad /Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
parentd2d8d7ce90f92bb45e2d8b645ec72f104fee5e6b (diff)
DolphinQt: Fix mapping of space, return, and mouse-clicks from immediately re-activating detection.
Diffstat (limited to 'Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp')
-rw-r--r--Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
index f1a5d67c91..01aa95d3a0 100644
--- a/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
+++ b/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp
@@ -10,6 +10,7 @@
#include <QPushButton>
#include <QRegExp>
#include <QString>
+#include <QTimer>
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
#include "InputCommon/ControlReference/ControlReference.h"
@@ -52,7 +53,9 @@ QString DetectExpression(QPushButton* button, ciface::Core::DeviceContainer& dev
const std::vector<std::string>& device_strings,
const ciface::Core::DeviceQualifier& default_device, Quote quote)
{
- button->installEventFilter(BlockUserInputFilter::Instance());
+ const auto filter = new BlockUserInputFilter(button);
+
+ button->installEventFilter(filter);
button->grabKeyboard();
button->grabMouse();
@@ -63,16 +66,23 @@ QString DetectExpression(QPushButton* button, ciface::Core::DeviceContainer& dev
QApplication::processEvents();
// Avoid that the button press itself is registered as an event
- Common::SleepCurrentThread(100);
+ Common::SleepCurrentThread(50);
std::shared_ptr<ciface::Core::Device> device;
ciface::Core::Device::Input* input;
std::tie(device, input) = device_container.DetectInput(INPUT_DETECT_TIME, device_strings);
- button->releaseMouse();
- button->releaseKeyboard();
- button->removeEventFilter(BlockUserInputFilter::Instance());
+ const auto timer = new QTimer(button);
+
+ button->connect(timer, &QTimer::timeout, [button, filter] {
+ button->releaseMouse();
+ button->releaseKeyboard();
+ button->removeEventFilter(filter);
+ });
+
+ // Prevent mappings of "space", "return", or mouse clicks from re-activating detection.
+ timer->start(500);
button->setText(old_text);