2020-01-05 02:46:03 +00:00
|
|
|
#pragma once
|
2022-07-11 13:03:29 +00:00
|
|
|
#include "common/types.h"
|
|
|
|
#include "frontend-common/input_manager.h"
|
2020-01-05 02:46:03 +00:00
|
|
|
#include <QtWidgets/QPushButton>
|
2020-08-29 12:19:28 +00:00
|
|
|
#include <optional>
|
2020-01-05 02:46:03 +00:00
|
|
|
|
|
|
|
class QTimer;
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
class ControllerSettingsDialog;
|
|
|
|
class SettingsInterface;
|
2020-01-05 02:46:03 +00:00
|
|
|
|
2020-02-17 15:06:11 +00:00
|
|
|
class InputBindingWidget : public QPushButton
|
2020-01-05 02:46:03 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-07-11 13:03:29 +00:00
|
|
|
InputBindingWidget(QWidget* parent);
|
|
|
|
InputBindingWidget(QWidget* parent, SettingsInterface* sif, std::string section_name, std::string key_name);
|
2020-02-17 15:06:11 +00:00
|
|
|
~InputBindingWidget();
|
2020-01-05 02:46:03 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
static bool isMouseMappingEnabled();
|
|
|
|
|
|
|
|
void initialize(SettingsInterface* sif, std::string section_name, std::string key_name);
|
2020-03-21 14:50:09 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void clearBinding();
|
2020-04-14 15:44:16 +00:00
|
|
|
void reloadBinding();
|
2020-01-05 02:46:03 +00:00
|
|
|
|
2020-02-17 15:06:11 +00:00
|
|
|
protected Q_SLOTS:
|
2020-04-26 07:23:42 +00:00
|
|
|
void onClicked();
|
2020-01-05 02:46:03 +00:00
|
|
|
void onInputListenTimerTimeout();
|
2022-07-11 13:03:29 +00:00
|
|
|
void inputManagerHookCallback(InputBindingKey key, float value);
|
2020-01-05 02:46:03 +00:00
|
|
|
|
2020-02-17 15:06:11 +00:00
|
|
|
protected:
|
2020-03-21 14:50:09 +00:00
|
|
|
enum : u32
|
|
|
|
{
|
|
|
|
TIMEOUT_FOR_SINGLE_BINDING = 5,
|
|
|
|
TIMEOUT_FOR_ALL_BINDING = 10
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
2020-07-22 16:35:15 +00:00
|
|
|
virtual bool event(QEvent* event) override;
|
2020-03-21 14:50:09 +00:00
|
|
|
virtual void mouseReleaseEvent(QMouseEvent* e) override;
|
|
|
|
|
|
|
|
virtual void startListeningForInput(u32 timeout_in_seconds);
|
2020-02-17 15:06:11 +00:00
|
|
|
virtual void stopListeningForInput();
|
2020-07-22 16:35:15 +00:00
|
|
|
virtual void openDialog();
|
2020-02-17 15:06:11 +00:00
|
|
|
|
2020-01-05 02:46:03 +00:00
|
|
|
bool isListeningForInput() const { return m_input_listen_timer != nullptr; }
|
2020-01-06 05:14:47 +00:00
|
|
|
void setNewBinding();
|
2020-07-22 16:35:15 +00:00
|
|
|
void updateText();
|
2020-01-05 02:46:03 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
void hookInputManager();
|
|
|
|
void unhookInputManager();
|
|
|
|
|
|
|
|
SettingsInterface* m_sif = nullptr;
|
2020-07-21 09:49:04 +00:00
|
|
|
std::string m_section_name;
|
|
|
|
std::string m_key_name;
|
2020-07-22 16:35:15 +00:00
|
|
|
std::vector<std::string> m_bindings;
|
2022-07-11 13:03:29 +00:00
|
|
|
std::vector<InputBindingKey> m_new_bindings;
|
2020-01-05 02:46:03 +00:00
|
|
|
QTimer* m_input_listen_timer = nullptr;
|
|
|
|
u32 m_input_listen_remaining_seconds = 0;
|
2022-07-11 13:03:29 +00:00
|
|
|
QPointF m_input_listen_start_position{};
|
|
|
|
bool m_mouse_mapping_enabled = false;
|
2020-01-05 02:46:03 +00:00
|
|
|
};
|
2020-02-17 15:06:11 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
class InputVibrationBindingWidget : public QPushButton
|
2020-02-17 15:06:11 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-07-11 13:03:29 +00:00
|
|
|
InputVibrationBindingWidget(QWidget* parent);
|
|
|
|
InputVibrationBindingWidget(QWidget* parent, ControllerSettingsDialog* dialog, std::string section_name,
|
|
|
|
std::string key_name);
|
|
|
|
~InputVibrationBindingWidget();
|
2020-02-17 15:06:11 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
void setKey(ControllerSettingsDialog* dialog, std::string section_name, std::string key_name);
|
2020-02-17 15:06:11 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
void clearBinding();
|
2020-02-17 15:06:11 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
protected Q_SLOTS:
|
|
|
|
void onClicked();
|
2020-02-17 15:06:11 +00:00
|
|
|
|
|
|
|
protected:
|
2022-07-11 13:03:29 +00:00
|
|
|
virtual void mouseReleaseEvent(QMouseEvent* e) override;
|
2020-08-29 12:19:28 +00:00
|
|
|
|
|
|
|
private:
|
2022-07-11 13:03:29 +00:00
|
|
|
std::string m_section_name;
|
|
|
|
std::string m_key_name;
|
|
|
|
std::string m_binding;
|
2020-04-14 06:35:04 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
ControllerSettingsDialog* m_dialog;
|
|
|
|
};
|