| | |
| | |
| |
|
| | #pragma once |
| |
|
| | #include <map> |
| | #include <QKeySequence> |
| | #include <QString> |
| | #include <QWidget> |
| | #include "hid_core/hid_types.h" |
| |
|
| | class QDialog; |
| | class QSettings; |
| | class QShortcut; |
| | class ControllerShortcut; |
| |
|
| | namespace Core::HID { |
| | enum class ControllerTriggerType; |
| | class EmulatedController; |
| | } |
| |
|
| | 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 std::string& 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: |
| | friend class ConfigureHotkeys; |
| |
|
| | explicit HotkeyRegistry(); |
| | ~HotkeyRegistry(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void LoadHotkeys(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void SaveHotkeys(); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | QShortcut* GetHotkey(const std::string& group, const std::string& action, QWidget* widget); |
| | ControllerShortcut* GetControllerHotkey(const std::string& group, const std::string& action, |
| | Core::HID::EmulatedController* controller); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | QKeySequence GetKeySequence(const std::string& group, const std::string& action); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | Qt::ShortcutContext GetShortcutContext(const std::string& group, const std::string& action); |
| |
|
| | private: |
| | struct Hotkey { |
| | QKeySequence keyseq; |
| | std::string controller_keyseq; |
| | QShortcut* shortcut = nullptr; |
| | ControllerShortcut* controller_shortcut = nullptr; |
| | Qt::ShortcutContext context = Qt::WindowShortcut; |
| | bool repeat; |
| | }; |
| |
|
| | using HotkeyMap = std::map<std::string, Hotkey>; |
| | using HotkeyGroupMap = std::map<std::string, HotkeyMap>; |
| |
|
| | HotkeyGroupMap hotkey_groups; |
| | }; |
| |
|