mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 07:21:14 +01:00
Merge pull request #8043 from jordan-woyak/mapping-ui-event-block-fix
DolphinQt: Fix mapping of space, return, and mouse-clicks.
This commit is contained in:
commit
aee1551a55
@ -56,7 +56,7 @@ MappingButton::MappingButton(MappingWidget* parent, ControlReference* ref, bool
|
|||||||
setToolTip(
|
setToolTip(
|
||||||
tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
||||||
|
|
||||||
connect(this, &MappingButton::pressed, this, &MappingButton::Detect);
|
connect(this, &MappingButton::clicked, this, &MappingButton::Detect);
|
||||||
|
|
||||||
if (indicator)
|
if (indicator)
|
||||||
connect(parent, &MappingWidget::Update, this, &MappingButton::UpdateIndicator);
|
connect(parent, &MappingWidget::Update, this, &MappingButton::UpdateIndicator);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
|
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
|
||||||
#include "InputCommon/ControlReference/ControlReference.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 std::vector<std::string>& device_strings,
|
||||||
const ciface::Core::DeviceQualifier& default_device, Quote quote)
|
const ciface::Core::DeviceQualifier& default_device, Quote quote)
|
||||||
{
|
{
|
||||||
button->installEventFilter(BlockUserInputFilter::Instance());
|
const auto filter = new BlockUserInputFilter(button);
|
||||||
|
|
||||||
|
button->installEventFilter(filter);
|
||||||
button->grabKeyboard();
|
button->grabKeyboard();
|
||||||
button->grabMouse();
|
button->grabMouse();
|
||||||
|
|
||||||
@ -63,16 +66,23 @@ QString DetectExpression(QPushButton* button, ciface::Core::DeviceContainer& dev
|
|||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
||||||
// Avoid that the button press itself is registered as an event
|
// Avoid that the button press itself is registered as an event
|
||||||
Common::SleepCurrentThread(100);
|
Common::SleepCurrentThread(50);
|
||||||
|
|
||||||
std::shared_ptr<ciface::Core::Device> device;
|
std::shared_ptr<ciface::Core::Device> device;
|
||||||
ciface::Core::Device::Input* input;
|
ciface::Core::Device::Input* input;
|
||||||
|
|
||||||
std::tie(device, input) = device_container.DetectInput(INPUT_DETECT_TIME, device_strings);
|
std::tie(device, input) = device_container.DetectInput(INPUT_DETECT_TIME, device_strings);
|
||||||
|
|
||||||
button->releaseMouse();
|
const auto timer = new QTimer(button);
|
||||||
button->releaseKeyboard();
|
|
||||||
button->removeEventFilter(BlockUserInputFilter::Instance());
|
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);
|
button->setText(old_text);
|
||||||
|
|
||||||
|
@ -6,12 +6,6 @@
|
|||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
BlockUserInputFilter* BlockUserInputFilter::Instance()
|
|
||||||
{
|
|
||||||
static BlockUserInputFilter s_block_user_input_filter;
|
|
||||||
return &s_block_user_input_filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BlockUserInputFilter::eventFilter(QObject* object, QEvent* event)
|
bool BlockUserInputFilter::eventFilter(QObject* object, QEvent* event)
|
||||||
{
|
{
|
||||||
const QEvent::Type event_type = event->type();
|
const QEvent::Type event_type = event->type();
|
||||||
|
@ -12,9 +12,8 @@ class BlockUserInputFilter : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static BlockUserInputFilter* Instance();
|
using QObject::QObject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlockUserInputFilter() = default;
|
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user