configure_mouse_advanced.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include "core/settings.h"
  9. class QCheckBox;
  10. class QPushButton;
  11. class QTimer;
  12. namespace Ui {
  13. class ConfigureMouseAdvanced;
  14. }
  15. class ConfigureMouseAdvanced : public QDialog {
  16. Q_OBJECT
  17. public:
  18. explicit ConfigureMouseAdvanced(QWidget* parent);
  19. ~ConfigureMouseAdvanced() override;
  20. void ApplyConfiguration();
  21. private:
  22. void changeEvent(QEvent* event) override;
  23. void RetranslateUI();
  24. /// Load configuration settings.
  25. void LoadConfiguration();
  26. /// Restore all buttons to their default values.
  27. void RestoreDefaults();
  28. /// Clear all input configuration
  29. void ClearAll();
  30. /// Update UI to reflect current configuration.
  31. void UpdateButtonLabels();
  32. /// Called when the button was pressed.
  33. void HandleClick(QPushButton* button,
  34. std::function<void(const Common::ParamPackage&)> new_input_setter,
  35. InputCommon::Polling::DeviceType type);
  36. /// Finish polling and configure input using the input_setter
  37. void SetPollingResult(const Common::ParamPackage& params, bool abort);
  38. /// Handle key press events.
  39. void keyPressEvent(QKeyEvent* event) override;
  40. std::unique_ptr<Ui::ConfigureMouseAdvanced> ui;
  41. /// This will be the the setting function when an input is awaiting configuration.
  42. std::optional<std::function<void(const Common::ParamPackage&)>> input_setter;
  43. std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map;
  44. std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param;
  45. std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers;
  46. std::unique_ptr<QTimer> timeout_timer;
  47. std::unique_ptr<QTimer> poll_timer;
  48. /// A flag to indicate if keyboard keys are okay when configuring an input. If this is false,
  49. /// keyboard events are ignored.
  50. bool want_keyboard_keys = false;
  51. };