diff options
author | german77 <juangerman-13@hotmail.com> | 2021-11-15 17:57:41 -0600 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2022-01-06 21:26:05 -0600 |
commit | 72c8a94a6cdb4d3f322fa6d4b06eab824f53dba6 (patch) | |
tree | 1be3b99cfa76a7e7c360fa467d8ea6de69a29dc8 /src/yuzu/hotkeys.h | |
parent | b94e947793dcb53e9e00ef8bf587b2f689d38d41 (diff) |
yuzu: Add controller hotkeys
Diffstat (limited to 'src/yuzu/hotkeys.h')
-rw-r--r-- | src/yuzu/hotkeys.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/yuzu/hotkeys.h b/src/yuzu/hotkeys.h index 248fadaf3..57a7c7da5 100644 --- a/src/yuzu/hotkeys.h +++ b/src/yuzu/hotkeys.h @@ -5,11 +5,53 @@ #pragma once #include <map> +#include "core/hid/hid_types.h" class QDialog; class QKeySequence; class QSettings; class QShortcut; +class ControllerShortcut; + +namespace Core::HID { +enum class ControllerTriggerType; +class EmulatedController; +} // namespace Core::HID + +struct ControllerButtonSequence { + Core::HID::CaptureButtonState capture{}; + Core::HID::HomeButtonState home{}; + Core::HID::NpadButtonState npad{}; +}; + +class ControllerShortcut : public QObject { + Q_OBJECT + +public: + explicit ControllerShortcut(Core::HID::EmulatedController* controller); + ~ControllerShortcut(); + + void SetKey(const ControllerButtonSequence& buttons); + void SetKey(const QString& buttons_shortcut); + + ControllerButtonSequence ButtonSequence() const; + + void SetEnabled(bool enable); + bool IsEnabled() const; + +Q_SIGNALS: + void Activated(); + +private: + void ControllerUpdateEvent(Core::HID::ControllerTriggerType type); + + bool is_enabled{}; + bool active{}; + int callback_key{}; + ControllerButtonSequence button_sequence{}; + std::string name{}; + Core::HID::EmulatedController* emulated_controller = nullptr; +}; class HotkeyRegistry final { public: @@ -46,6 +88,8 @@ public: * QShortcut's parent. */ QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widget); + ControllerShortcut* GetControllerHotkey(const QString& group, const QString& action, + Core::HID::EmulatedController* controller); /** * Returns a QKeySequence object whose signal can be connected to QAction::setShortcut. @@ -68,7 +112,9 @@ public: private: struct Hotkey { QKeySequence keyseq; + QString controller_keyseq; QShortcut* shortcut = nullptr; + ControllerShortcut* controller_shortcut = nullptr; Qt::ShortcutContext context = Qt::WindowShortcut; }; |