Qt: Add "Clear All" and "Rebind All" to controller bindings

This commit is contained in:
Connor McLaughlin
2020-03-22 00:50:09 +10:00
parent 45050709f2
commit ad6e4cb6e4
5 changed files with 117 additions and 19 deletions

View File

@ -14,21 +14,32 @@ public:
InputBindingWidget(QtHostInterface* host_interface, QString setting_name, QWidget* parent);
~InputBindingWidget();
protected:
virtual bool eventFilter(QObject* watched, QEvent* event) override;
virtual void mouseReleaseEvent(QMouseEvent* e) override;
ALWAYS_INLINE InputBindingWidget* getNextWidget() const { return m_next_widget; }
ALWAYS_INLINE void setNextWidget(InputBindingWidget* widget) { m_next_widget = widget; }
public Q_SLOTS:
void beginRebindAll();
void clearBinding();
protected Q_SLOTS:
void onPressed();
void onInputListenTimerTimeout();
protected:
virtual void startListeningForInput();
enum : u32
{
TIMEOUT_FOR_SINGLE_BINDING = 5,
TIMEOUT_FOR_ALL_BINDING = 10
};
virtual bool eventFilter(QObject* watched, QEvent* event) override;
virtual void mouseReleaseEvent(QMouseEvent* e) override;
virtual void startListeningForInput(u32 timeout_in_seconds);
virtual void stopListeningForInput();
bool isListeningForInput() const { return m_input_listen_timer != nullptr; }
void setNewBinding();
void clearBinding();
QtHostInterface* m_host_interface;
QString m_setting_name;
@ -36,6 +47,9 @@ protected:
QString m_new_binding_value;
QTimer* m_input_listen_timer = nullptr;
u32 m_input_listen_remaining_seconds = 0;
InputBindingWidget* m_next_widget = nullptr;
bool m_is_binding_all = false;
};
class InputButtonBindingWidget : public InputBindingWidget
@ -54,7 +68,7 @@ private Q_SLOTS:
void bindToControllerButton(int controller_index, int button_index);
protected:
void startListeningForInput() override;
void startListeningForInput(u32 timeout_in_seconds) override;
void stopListeningForInput() override;
void hookControllerInput();
void unhookControllerInput();
@ -72,7 +86,7 @@ private Q_SLOTS:
void bindToControllerAxis(int controller_index, int axis_index);
protected:
void startListeningForInput() override;
void startListeningForInput(u32 timeout_in_seconds) override;
void stopListeningForInput() override;
void hookControllerInput();
void unhookControllerInput();