Play-/Source/ui_unix/ControllerConfig/inputeventselectiondialog.h

63 lines
1.7 KiB
C
Raw Normal View History

#pragma once
#include <QDialog>
#include <QKeyEvent>
#include <chrono>
#include <thread>
#include "ui_unix/PH_HidUnix.h"
2018-05-23 03:11:24 +03:00
#ifdef HAS_LIBEVDEV
#include "GamePad/GamePadInputEventListener.h"
#include "GamePad/GamePadDeviceListener.h"
2018-10-23 01:40:35 +01:00
#elif defined(__APPLE__)
#include "GamePad/GamePadDeviceListener_OSX.h"
2018-05-23 03:11:24 +03:00
#endif
2018-04-30 21:01:23 +01:00
namespace Ui
{
class InputEventSelectionDialog;
}
class InputEventSelectionDialog : public QDialog
{
Q_OBJECT
public:
2018-07-31 19:00:26 -04:00
explicit InputEventSelectionDialog(QWidget* parent = nullptr);
~InputEventSelectionDialog();
void Setup(const char* text, CInputBindingManager* inputManager, PS2::CControllerInfo::BUTTON button);
2018-10-23 01:40:35 +01:00
#if defined(HAS_LIBEVDEV) || defined(__APPLE__)
void SetupInputDeviceManager(CGamePadDeviceListener* GPDL);
2018-05-23 03:11:24 +03:00
#endif
protected:
2018-04-30 21:01:23 +01:00
void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE;
private:
struct BINDINGINFOEXTENDED : CInputBindingManager::BINDINGINFO
{
int value;
CInputBindingManager::BINDINGTYPE bindtype;
};
2018-04-30 21:01:23 +01:00
void CountDownThreadLoop();
bool setCounter(int);
int click_count = 0;
QString m_bindingtext = QString("Select new binding for\n%1");
QString m_countingtext = QString("Press & Hold Button for %1 Seconds to assign key");
PS2::CControllerInfo::BUTTON m_button;
BINDINGINFOEXTENDED m_key1;
CInputBindingManager::BINDINGINFO m_key2;
CInputBindingManager* m_inputManager;
Ui::InputEventSelectionDialog* ui;
std::chrono::time_point<std::chrono::system_clock> m_countStart = std::chrono::system_clock::now();
2018-04-30 21:01:23 +01:00
std::thread m_thread;
std::atomic<bool> m_running;
std::atomic<bool> m_isCounting;
2018-01-10 15:45:33 +00:00
Q_SIGNALS:
2018-04-30 21:01:23 +01:00
void setSelectedButtonLabelText(QString);
void setCountDownLabelText(QString);
};