mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 12:30:15 +00:00
Input GUI: Add 5 second timeout to button click.
This commit is contained in:
parent
d137ccca58
commit
cacc5b439e
@ -45,11 +45,14 @@ ConfigureInput::ConfigureInput(QWidget* parent) :
|
||||
}
|
||||
connect(ui->btnRestoreDefaults, SIGNAL(released()), this, SLOT(restoreDefaults()));
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
timer->setSingleShot(true);
|
||||
connect(timer, &QTimer::timeout, this, [&]() { key_pressed = Qt::Key_Escape; setKey(); });
|
||||
this->setConfiguration();
|
||||
}
|
||||
|
||||
ConfigureInput::~ConfigureInput()
|
||||
{
|
||||
delete timer;
|
||||
}
|
||||
|
||||
/// Event handler for all button released() event.
|
||||
@ -62,6 +65,7 @@ void ConfigureInput::handleClick()
|
||||
grabKeyboard();
|
||||
grabMouse();
|
||||
changing_button = sender;
|
||||
timer->start(5000); //Cancel after 5 seconds
|
||||
}
|
||||
|
||||
/// 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)
|
||||
{
|
||||
key_pressed = event->key();
|
||||
timer->stop();
|
||||
setKey();
|
||||
}
|
||||
}
|
||||
@ -164,4 +169,4 @@ void ConfigureInput::restoreDefaults() {
|
||||
QString keyValue = getKeyName(Config::GetDefaultInput()[i].toInt());
|
||||
input_mapping[Settings::NativeInput::Values(i)]->setText(keyValue);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +1,50 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "citra_qt/config.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure_input.h"
|
||||
|
||||
class QPushButton;
|
||||
class QString;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureInput;
|
||||
}
|
||||
|
||||
class ConfigureInput : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureInput(QWidget* parent = nullptr);
|
||||
~ConfigureInput();
|
||||
void applyConfiguration();
|
||||
|
||||
public Q_SLOTS:
|
||||
void handleClick();
|
||||
void restoreDefaults();
|
||||
private:
|
||||
std::unique_ptr<Ui::ConfigureInput> ui;
|
||||
std::map<Settings::NativeInput::Values, QPushButton*> input_mapping;
|
||||
int key_pressed;
|
||||
QPushButton* changing_button = nullptr; /// button currently waiting for key press.
|
||||
QString previous_mapping;
|
||||
|
||||
void setConfiguration();
|
||||
void setKey();
|
||||
void removeDuplicates(const QString& newValue);
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
QString getKeyName(int key_code) const;
|
||||
Qt::Key getKeyValue(const QString& text) const;
|
||||
};
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QTimer>
|
||||
|
||||
#include "citra_qt/config.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure_input.h"
|
||||
|
||||
class QPushButton;
|
||||
class QString;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureInput;
|
||||
}
|
||||
|
||||
class ConfigureInput : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureInput(QWidget* parent = nullptr);
|
||||
~ConfigureInput();
|
||||
void applyConfiguration();
|
||||
|
||||
public Q_SLOTS:
|
||||
void handleClick();
|
||||
void restoreDefaults();
|
||||
private:
|
||||
std::unique_ptr<Ui::ConfigureInput> ui;
|
||||
std::map<Settings::NativeInput::Values, QPushButton*> input_mapping;
|
||||
int key_pressed;
|
||||
QPushButton* changing_button = nullptr; /// button currently waiting for key press.
|
||||
QString previous_mapping;
|
||||
QTimer* timer = new QTimer();
|
||||
|
||||
void setConfiguration();
|
||||
void removeDuplicates(const QString& newValue);
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
QString getKeyName(int key_code) const;
|
||||
Qt::Key getKeyValue(const QString& text) const;
|
||||
private Q_SLOTS:
|
||||
void setKey();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user