controller.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2015 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <QWidget>
  6. class QAction;
  7. class QHideEvent;
  8. class QShowEvent;
  9. class PlayerControlPreview;
  10. namespace InputCommon {
  11. class InputSubsystem;
  12. }
  13. namespace Core::HID {
  14. class HIDCore;
  15. class EmulatedController;
  16. enum class ControllerTriggerType;
  17. } // namespace Core::HID
  18. class ControllerDialog : public QWidget {
  19. Q_OBJECT
  20. public:
  21. explicit ControllerDialog(Core::HID::HIDCore& hid_core_,
  22. std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_,
  23. QWidget* parent = nullptr);
  24. /// Returns a QAction that can be used to toggle visibility of this dialog.
  25. QAction* toggleViewAction();
  26. /// Reloads the widget to apply any changes in the configuration
  27. void refreshConfiguration();
  28. /// Disables events from the emulated controller
  29. void UnloadController();
  30. protected:
  31. void showEvent(QShowEvent* ev) override;
  32. void hideEvent(QHideEvent* ev) override;
  33. private:
  34. /// Redirects input from the widget to the TAS driver
  35. void ControllerUpdate(Core::HID::ControllerTriggerType type);
  36. int callback_key;
  37. bool is_controller_set{};
  38. Core::HID::EmulatedController* controller;
  39. QAction* toggle_view_action = nullptr;
  40. PlayerControlPreview* widget;
  41. Core::HID::HIDCore& hid_core;
  42. std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
  43. };