summaryrefslogtreecommitdiff
path: root/src/yuzu/util/controller_navigation.h
diff options
context:
space:
mode:
authorFeng Chen <VonChenPlus@gmail.com>2021-12-18 13:57:14 +0800
committerGitHub <noreply@github.com>2021-12-18 13:57:14 +0800
commite49184e6069a9d791d2df3c1958f5c4b1187e124 (patch)
treeb776caf722e0be0e680f67b0ad0842628162ef1c /src/yuzu/util/controller_navigation.h
parent4dd85f86a89338ff84d05a3981c14f6de1be4606 (diff)
parent77d06d5df02d18da381bcd572ce11fee790d9edf (diff)
Merge branch 'yuzu-emu:master' into convert_legacy
Diffstat (limited to 'src/yuzu/util/controller_navigation.h')
-rw-r--r--src/yuzu/util/controller_navigation.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/yuzu/util/controller_navigation.h b/src/yuzu/util/controller_navigation.h
new file mode 100644
index 000000000..7c616a088
--- /dev/null
+++ b/src/yuzu/util/controller_navigation.h
@@ -0,0 +1,51 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included
+
+#pragma once
+
+#include <QKeyEvent>
+#include <QObject>
+
+#include "common/input.h"
+#include "common/settings_input.h"
+
+namespace Core::HID {
+using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>;
+using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>;
+enum class ControllerTriggerType;
+class EmulatedController;
+class HIDCore;
+} // namespace Core::HID
+
+class ControllerNavigation : public QObject {
+ Q_OBJECT
+
+public:
+ explicit ControllerNavigation(Core::HID::HIDCore& hid_core, QWidget* parent = nullptr);
+ ~ControllerNavigation();
+
+ /// Disables events from the emulated controller
+ void UnloadController();
+
+signals:
+ void TriggerKeyboardEvent(Qt::Key key);
+
+private:
+ void TriggerButton(Settings::NativeButton::Values native_button, Qt::Key key);
+ void ControllerUpdateEvent(Core::HID::ControllerTriggerType type);
+
+ void ControllerUpdateButton();
+
+ void ControllerUpdateStick();
+
+ Core::HID::ButtonValues button_values{};
+ Core::HID::SticksValues stick_values{};
+
+ int player1_callback_key{};
+ int handheld_callback_key{};
+ bool is_controller_set{};
+ mutable std::mutex mutex;
+ Core::HID::EmulatedController* player1_controller;
+ Core::HID::EmulatedController* handheld_controller;
+};