2020-08-21 13:39:24 +02:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2020-10-26 08:28:03 +01:00
|
|
|
class InputProfiles;
|
|
|
|
|
2020-08-21 13:39:24 +02:00
|
|
|
namespace InputCommon {
|
|
|
|
class InputSubsystem;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class QtControllerSelectorDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
class QtControllerSelectorDialog final : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit QtControllerSelectorDialog(QWidget* parent,
|
|
|
|
Core::Frontend::ControllerParameters parameters_,
|
|
|
|
InputCommon::InputSubsystem* input_subsystem_);
|
|
|
|
~QtControllerSelectorDialog() override;
|
|
|
|
|
2020-09-27 17:18:07 +02:00
|
|
|
int exec() override;
|
|
|
|
|
2020-08-21 13:39:24 +02:00
|
|
|
private:
|
|
|
|
// Applies the current configuration.
|
|
|
|
void ApplyConfiguration();
|
|
|
|
|
2020-08-27 09:52:26 +02:00
|
|
|
// Loads the current input configuration into the frontend applet.
|
|
|
|
void LoadConfiguration();
|
|
|
|
|
2020-10-17 15:38:12 +02:00
|
|
|
// Initializes the "Configure Vibration" Dialog.
|
|
|
|
void CallConfigureVibrationDialog();
|
|
|
|
|
2020-10-26 08:28:03 +01:00
|
|
|
// Initializes the "Create Input Profile" Dialog.
|
|
|
|
void CallConfigureInputProfileDialog();
|
2020-08-21 13:39:24 +02:00
|
|
|
|
2020-09-27 17:18:07 +02:00
|
|
|
// Checks the current configuration against the given parameters.
|
|
|
|
// This sets and returns the value of parameters_met.
|
|
|
|
bool CheckIfParametersMet();
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
// Sets the controller icons for "Supported Controller Types".
|
|
|
|
void SetSupportedControllers();
|
|
|
|
|
|
|
|
// Updates the controller icons per player.
|
|
|
|
void UpdateControllerIcon(std::size_t player_index);
|
|
|
|
|
|
|
|
// Updates the controller state (type and connection status) per player.
|
|
|
|
void UpdateControllerState(std::size_t player_index);
|
|
|
|
|
|
|
|
// Updates the LED pattern per player.
|
|
|
|
void UpdateLEDPattern(std::size_t player_index);
|
|
|
|
|
|
|
|
// Updates the border color per player.
|
|
|
|
void UpdateBorderColor(std::size_t player_index);
|
|
|
|
|
2020-08-27 07:21:48 +02:00
|
|
|
// Sets the "Explain Text" per player.
|
|
|
|
void SetExplainText(std::size_t player_index);
|
|
|
|
|
2020-08-21 13:39:24 +02:00
|
|
|
// Updates the console mode.
|
|
|
|
void UpdateDockedState(bool is_handheld);
|
|
|
|
|
|
|
|
// Disables and disconnects unsupported players based on the given parameters.
|
|
|
|
void DisableUnsupportedPlayers();
|
|
|
|
|
|
|
|
std::unique_ptr<Ui::QtControllerSelectorDialog> ui;
|
|
|
|
|
|
|
|
// Parameters sent in from the backend HLE applet.
|
|
|
|
Core::Frontend::ControllerParameters parameters;
|
|
|
|
|
|
|
|
InputCommon::InputSubsystem* input_subsystem;
|
|
|
|
|
2020-10-26 08:28:03 +01:00
|
|
|
std::unique_ptr<InputProfiles> input_profiles;
|
|
|
|
|
2020-08-21 13:39:24 +02:00
|
|
|
// This is true if and only if all parameters are met. Otherwise, this is false.
|
2020-08-27 07:46:14 +02:00
|
|
|
// This determines whether the "OK" button can be clicked to exit the applet.
|
2020-08-21 13:39:24 +02:00
|
|
|
bool parameters_met{false};
|
|
|
|
|
2020-08-27 07:46:14 +02:00
|
|
|
static constexpr std::size_t NUM_PLAYERS = 8;
|
|
|
|
|
2020-08-21 13:39:24 +02:00
|
|
|
// Widgets encapsulating the groupboxes and comboboxes per player.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QWidget*, NUM_PLAYERS> player_widgets;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
// Groupboxes encapsulating the controller icons and LED patterns per player.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QGroupBox*, NUM_PLAYERS> player_groupboxes;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
// Icons for currently connected controllers/players.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QWidget*, NUM_PLAYERS> connected_controller_icons;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
// Labels that represent the player numbers in place of the controller icons.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QLabel*, NUM_PLAYERS> player_labels;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
// LED patterns for currently connected controllers/players.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<std::array<QCheckBox*, 4>, NUM_PLAYERS> led_patterns_boxes;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
2020-08-27 07:21:48 +02:00
|
|
|
// Labels representing additional information known as "Explain Text" per player.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QLabel*, NUM_PLAYERS> explain_text_labels;
|
2020-08-27 07:21:48 +02:00
|
|
|
|
2020-08-21 13:39:24 +02:00
|
|
|
// Comboboxes with a list of emulated controllers per player.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QComboBox*, NUM_PLAYERS> emulated_controllers;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
// Labels representing the number of connected controllers
|
|
|
|
// above the "Connected Controllers" checkboxes.
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QLabel*, NUM_PLAYERS> connected_controller_labels;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
// Checkboxes representing the "Connected Controllers".
|
2020-08-27 07:46:14 +02:00
|
|
|
std::array<QCheckBox*, NUM_PLAYERS> connected_controller_checkboxes;
|
2020-08-21 13:39:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class QtControllerSelector final : public QObject, public Core::Frontend::ControllerApplet {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit QtControllerSelector(GMainWindow& parent);
|
|
|
|
~QtControllerSelector() override;
|
|
|
|
|
2020-10-27 00:36:58 +01:00
|
|
|
void ReconfigureControllers(
|
|
|
|
std::function<void()> callback,
|
|
|
|
const Core::Frontend::ControllerParameters& parameters) const override;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
signals:
|
2020-10-27 00:36:58 +01:00
|
|
|
void MainWindowReconfigureControllers(
|
|
|
|
const Core::Frontend::ControllerParameters& parameters) const;
|
2020-08-21 13:39:24 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void MainWindowReconfigureFinished();
|
|
|
|
|
|
|
|
mutable std::function<void()> callback;
|
|
|
|
};
|