controller.h 1.4 KB

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