mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 15:00:15 +00:00
Input GUI: Add 5 second timeout to button click.
This commit is contained in:
parent
a0b9ea36fc
commit
ee8b3cba8c
@ -45,11 +45,14 @@ ConfigureInput::ConfigureInput(QWidget* parent) :
|
|||||||
}
|
}
|
||||||
connect(ui->btnRestoreDefaults, SIGNAL(released()), this, SLOT(restoreDefaults()));
|
connect(ui->btnRestoreDefaults, SIGNAL(released()), this, SLOT(restoreDefaults()));
|
||||||
setFocusPolicy(Qt::ClickFocus);
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
|
timer->setSingleShot(true);
|
||||||
|
connect(timer, &QTimer::timeout, this, [&]() { key_pressed = Qt::Key_Escape; setKey(); });
|
||||||
this->setConfiguration();
|
this->setConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureInput::~ConfigureInput()
|
ConfigureInput::~ConfigureInput()
|
||||||
{
|
{
|
||||||
|
delete timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Event handler for all button released() event.
|
/// Event handler for all button released() event.
|
||||||
@ -62,6 +65,7 @@ void ConfigureInput::handleClick()
|
|||||||
grabKeyboard();
|
grabKeyboard();
|
||||||
grabMouse();
|
grabMouse();
|
||||||
changing_button = sender;
|
changing_button = sender;
|
||||||
|
timer->start(5000); //Cancel after 5 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save all button configurations to settings file
|
/// Save all button configurations to settings file
|
||||||
@ -89,6 +93,7 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event)
|
|||||||
if (changing_button != nullptr && event->key() != Qt::Key_unknown)
|
if (changing_button != nullptr && event->key() != Qt::Key_unknown)
|
||||||
{
|
{
|
||||||
key_pressed = event->key();
|
key_pressed = event->key();
|
||||||
|
timer->stop();
|
||||||
setKey();
|
setKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "citra_qt/config.h"
|
#include "citra_qt/config.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
@ -37,11 +38,13 @@ private:
|
|||||||
int key_pressed;
|
int key_pressed;
|
||||||
QPushButton* changing_button = nullptr; /// button currently waiting for key press.
|
QPushButton* changing_button = nullptr; /// button currently waiting for key press.
|
||||||
QString previous_mapping;
|
QString previous_mapping;
|
||||||
|
QTimer* timer = new QTimer();
|
||||||
|
|
||||||
void setConfiguration();
|
void setConfiguration();
|
||||||
void setKey();
|
|
||||||
void removeDuplicates(const QString& newValue);
|
void removeDuplicates(const QString& newValue);
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
QString getKeyName(int key_code) const;
|
QString getKeyName(int key_code) const;
|
||||||
Qt::Key getKeyValue(const QString& text) const;
|
Qt::Key getKeyValue(const QString& text) const;
|
||||||
|
private Q_SLOTS:
|
||||||
|
void setKey();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user