| |
| |
|
|
| #pragma once |
|
|
| #include <array> |
| #include <memory> |
| #include <QDialog> |
| #include "core/frontend/applets/controller.h" |
|
|
| class GMainWindow; |
| class QCheckBox; |
| class QComboBox; |
| class QDialogButtonBox; |
| class QGroupBox; |
| class QLabel; |
|
|
| class InputProfiles; |
|
|
| namespace InputCommon { |
| class InputSubsystem; |
| } |
|
|
| namespace Ui { |
| class QtControllerSelectorDialog; |
| } |
|
|
| namespace Core { |
| class System; |
| } |
|
|
| namespace Core::HID { |
| class HIDCore; |
| enum class NpadStyleIndex : u8; |
| } |
|
|
| class ControllerNavigation; |
|
|
| class QtControllerSelectorDialog final : public QDialog { |
| Q_OBJECT |
|
|
| public: |
| explicit QtControllerSelectorDialog(QWidget* parent, |
| Core::Frontend::ControllerParameters parameters_, |
| InputCommon::InputSubsystem* input_subsystem_, |
| Core::System& system_); |
| ~QtControllerSelectorDialog() override; |
|
|
| int exec() override; |
|
|
| void keyPressEvent(QKeyEvent* evt) override; |
|
|
| private: |
| |
| void ApplyConfiguration(); |
|
|
| |
| void LoadConfiguration(); |
|
|
| |
| void CallConfigureVibrationDialog(); |
|
|
| |
| void CallConfigureMotionTouchDialog(); |
|
|
| |
| void CallConfigureInputProfileDialog(); |
|
|
| |
| |
| bool CheckIfParametersMet(); |
|
|
| |
| void SetSupportedControllers(); |
|
|
| |
| void SetEmulatedControllers(std::size_t player_index); |
|
|
| |
| Core::HID::NpadStyleIndex GetControllerTypeFromIndex(int index, std::size_t player_index) const; |
|
|
| |
| int GetIndexFromControllerType(Core::HID::NpadStyleIndex type, std::size_t player_index) const; |
|
|
| |
| void UpdateControllerIcon(std::size_t player_index); |
|
|
| |
| void UpdateControllerState(std::size_t player_index); |
|
|
| |
| void UpdateLEDPattern(std::size_t player_index); |
|
|
| |
| void UpdateBorderColor(std::size_t player_index); |
|
|
| |
| void SetExplainText(std::size_t player_index); |
|
|
| |
| void UpdateDockedState(bool is_handheld); |
|
|
| |
| void PropagatePlayerNumberChanged(size_t player_index, bool checked, |
| bool reconnect_current = false); |
|
|
| |
| void DisableUnsupportedPlayers(); |
|
|
| std::unique_ptr<Ui::QtControllerSelectorDialog> ui; |
|
|
| |
| Core::Frontend::ControllerParameters parameters; |
|
|
| InputCommon::InputSubsystem* input_subsystem; |
|
|
| std::unique_ptr<InputProfiles> input_profiles; |
|
|
| Core::System& system; |
|
|
| ControllerNavigation* controller_navigation = nullptr; |
|
|
| |
| |
| bool parameters_met{false}; |
|
|
| static constexpr std::size_t NUM_PLAYERS = 8; |
|
|
| |
| std::array<QWidget*, NUM_PLAYERS> player_widgets; |
|
|
| |
| std::array<QGroupBox*, NUM_PLAYERS> player_groupboxes; |
|
|
| |
| std::array<QWidget*, NUM_PLAYERS> connected_controller_icons; |
|
|
| |
| std::array<QLabel*, NUM_PLAYERS> player_labels; |
|
|
| |
| std::array<std::array<QCheckBox*, 4>, NUM_PLAYERS> led_patterns_boxes; |
|
|
| |
| std::array<QLabel*, NUM_PLAYERS> explain_text_labels; |
|
|
| |
| std::array<QComboBox*, NUM_PLAYERS> emulated_controllers; |
|
|
| |
| std::array<std::vector<std::pair<int, Core::HID::NpadStyleIndex>>, NUM_PLAYERS> |
| index_controller_type_pairs; |
|
|
| |
| |
| std::array<QLabel*, NUM_PLAYERS> connected_controller_labels; |
|
|
| |
| std::array<QCheckBox*, NUM_PLAYERS> connected_controller_checkboxes; |
| }; |
|
|
| class QtControllerSelector final : public QObject, public Core::Frontend::ControllerApplet { |
| Q_OBJECT |
|
|
| public: |
| explicit QtControllerSelector(GMainWindow& parent); |
| ~QtControllerSelector() override; |
|
|
| void Close() const override; |
| void ReconfigureControllers( |
| ReconfigureCallback callback_, |
| const Core::Frontend::ControllerParameters& parameters) const override; |
|
|
| signals: |
| void MainWindowReconfigureControllers( |
| const Core::Frontend::ControllerParameters& parameters) const; |
| void MainWindowRequestExit() const; |
|
|
| private: |
| void MainWindowReconfigureFinished(bool is_success); |
|
|
| mutable ReconfigureCallback callback; |
| }; |
|
|