configure_input.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // SPDX-FileCopyrightText: 2016 Citra Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include <memory>
  6. #include <QKeyEvent>
  7. #include <QList>
  8. #include <QWidget>
  9. namespace Core {
  10. class System;
  11. }
  12. class QCheckBox;
  13. class QString;
  14. class QTimer;
  15. class ConfigureInputAdvanced;
  16. class ConfigureInputPlayer;
  17. class InputProfiles;
  18. namespace InputCommon {
  19. class InputSubsystem;
  20. }
  21. namespace Ui {
  22. class ConfigureInput;
  23. }
  24. void OnDockedModeChanged(bool last_state, bool new_state, Core::System& system);
  25. class ConfigureInput : public QWidget {
  26. Q_OBJECT
  27. public:
  28. explicit ConfigureInput(Core::System& system_, QWidget* parent = nullptr);
  29. ~ConfigureInput() override;
  30. /// Initializes the input dialog with the given input subsystem.
  31. void Initialize(InputCommon::InputSubsystem* input_subsystem_, std::size_t max_players = 8);
  32. /// Save all button configurations to settings file.
  33. void ApplyConfiguration();
  34. QList<QWidget*> GetSubTabs() const;
  35. private:
  36. void changeEvent(QEvent* event) override;
  37. void RetranslateUI();
  38. void ClearAll();
  39. void UpdateDockedState(bool is_handheld);
  40. void UpdateAllInputDevices();
  41. void UpdateAllInputProfiles(std::size_t player_index);
  42. // Enable preceding controllers or disable following ones
  43. void PropagatePlayerNumberChanged(size_t player_index, bool checked,
  44. bool reconnect_current = false);
  45. /// Load configuration settings.
  46. void LoadConfiguration();
  47. void LoadPlayerControllerIndices();
  48. /// Restore all buttons to their default values.
  49. void RestoreDefaults();
  50. std::unique_ptr<Ui::ConfigureInput> ui;
  51. std::unique_ptr<InputProfiles> profiles;
  52. std::array<ConfigureInputPlayer*, 8> player_controllers;
  53. std::array<QWidget*, 8> player_tabs;
  54. // Checkboxes representing the "Connected Controllers".
  55. std::array<QCheckBox*, 8> connected_controller_checkboxes;
  56. ConfigureInputAdvanced* advanced;
  57. Core::System& system;
  58. };