configure_mouse_advanced.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <optional>
  7. #include <QDialog>
  8. class QCheckBox;
  9. class QPushButton;
  10. class QTimer;
  11. namespace InputCommon {
  12. class InputSubsystem;
  13. }
  14. namespace Ui {
  15. class ConfigureMouseAdvanced;
  16. }
  17. class ConfigureMouseAdvanced : public QDialog {
  18. Q_OBJECT
  19. public:
  20. explicit ConfigureMouseAdvanced(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_);
  21. ~ConfigureMouseAdvanced() override;
  22. void ApplyConfiguration();
  23. private:
  24. void changeEvent(QEvent* event) override;
  25. void RetranslateUI();
  26. /// Load configuration settings.
  27. void LoadConfiguration();
  28. /// Restore all buttons to their default values.
  29. void RestoreDefaults();
  30. /// Clear all input configuration
  31. void ClearAll();
  32. /// Update UI to reflect current configuration.
  33. void UpdateButtonLabels();
  34. /// Called when the button was pressed.
  35. void HandleClick(QPushButton* button,
  36. std::function<void(const Common::ParamPackage&)> new_input_setter,
  37. InputCommon::Polling::DeviceType type);
  38. /// Finish polling and configure input using the input_setter
  39. void SetPollingResult(const Common::ParamPackage& params, bool abort);
  40. /// Handle mouse button press events.
  41. void mousePressEvent(QMouseEvent* event) override;
  42. /// Handle key press events.
  43. void keyPressEvent(QKeyEvent* event) override;
  44. std::unique_ptr<Ui::ConfigureMouseAdvanced> ui;
  45. InputCommon::InputSubsystem* input_subsystem;
  46. /// This will be the the setting function when an input is awaiting configuration.
  47. std::optional<std::function<void(const Common::ParamPackage&)>> input_setter;
  48. std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map;
  49. std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param;
  50. std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
  51. std::unique_ptr<QTimer> timeout_timer;
  52. std::unique_ptr<QTimer> poll_timer;
  53. /// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
  54. /// keyboard events are ignored.
  55. bool want_keyboard_mouse = false;
  56. };