2017-05-23 16:08:53 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QKeyEvent>
|
2018-01-10 16:24:21 +00:00
|
|
|
#include <chrono>
|
|
|
|
#include <thread>
|
2018-11-19 13:20:46 -05:00
|
|
|
#include "input/InputBindingManager.h"
|
|
|
|
#include "InputProviderQtKey.h"
|
2017-06-13 04:51:38 +01:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
namespace Ui
|
|
|
|
{
|
2018-01-10 16:24:21 +00:00
|
|
|
class InputEventSelectionDialog;
|
2017-05-23 16:08:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class InputEventSelectionDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-07-31 19:00:26 -04:00
|
|
|
explicit InputEventSelectionDialog(QWidget* parent = nullptr);
|
2017-05-23 16:08:53 +01:00
|
|
|
~InputEventSelectionDialog();
|
|
|
|
|
2018-11-19 13:20:46 -05:00
|
|
|
void Setup(const char*, CInputBindingManager*, CInputProviderQtKey*, PS2::CControllerInfo::BUTTON);
|
2017-05-23 16:08:53 +01:00
|
|
|
|
|
|
|
protected:
|
2018-04-30 21:01:23 +01:00
|
|
|
void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
|
|
|
|
void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE;
|
2017-05-23 16:08:53 +01:00
|
|
|
|
|
|
|
private:
|
2018-11-19 13:20:46 -05:00
|
|
|
enum class STATE
|
2018-01-10 16:24:21 +00:00
|
|
|
{
|
2018-11-19 13:20:46 -05:00
|
|
|
NONE,
|
|
|
|
SELECTED
|
2018-01-10 16:24:21 +00:00
|
|
|
};
|
2018-11-19 13:20:46 -05:00
|
|
|
|
|
|
|
void onInputEvent(const BINDINGTARGET&, uint32);
|
2018-11-21 12:41:42 -05:00
|
|
|
void startCountdown();
|
|
|
|
void cancelCountdown();
|
|
|
|
|
2018-11-19 13:20:46 -05:00
|
|
|
Ui::InputEventSelectionDialog* ui = nullptr;
|
2018-11-21 12:41:42 -05:00
|
|
|
QTimer* m_countdownTimer = nullptr;
|
|
|
|
uint32 m_countdownRemain = 0;
|
|
|
|
|
|
|
|
PS2::CControllerInfo::BUTTON m_button;
|
|
|
|
CInputBindingManager* m_inputManager = nullptr;
|
|
|
|
CInputProviderQtKey* m_qtKeyInputProvider = nullptr;
|
2018-11-19 13:20:46 -05:00
|
|
|
|
|
|
|
STATE m_state = STATE::NONE;
|
|
|
|
BINDINGTARGET m_selectedTarget;
|
|
|
|
CInputBindingManager::BINDINGTYPE m_bindingType = CInputBindingManager::BINDING_UNBOUND;
|
|
|
|
uint32 m_bindingValue = 0;
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
QString m_bindingtext = QString("Select new binding for\n%1");
|
|
|
|
QString m_countingtext = QString("Press & Hold Button for %1 Seconds to assign key");
|
2018-11-21 12:41:42 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void updateCountdown();
|
|
|
|
void completeSimpleBinding();
|
2018-01-10 16:24:21 +00:00
|
|
|
|
2018-01-10 15:45:33 +00:00
|
|
|
Q_SIGNALS:
|
2018-04-30 21:01:23 +01:00
|
|
|
void setSelectedButtonLabelText(QString);
|
2018-11-21 12:41:42 -05:00
|
|
|
void countdownComplete();
|
2017-05-23 16:08:53 +01:00
|
|
|
};
|