2020-08-21 11:39:24 +00: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>
|
2021-09-03 01:40:55 +00:00
|
|
|
#include "core/core.h"
|
2020-08-21 11:39:24 +00:00
|
|
|
#include "core/frontend/applets/controller.h"
|
|
|
|
|
|
|
|
class GMainWindow;
|
|
|
|
class QCheckBox;
|
|
|
|
class QComboBox;
|
|
|
|
class QDialogButtonBox;
|
|
|
|
class QGroupBox;
|
|
|
|
class QLabel;
|
|
|
|
|
2020-10-26 07:28:03 +00:00
|
|
|
class InputProfiles;
|
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
namespace InputCommon {
|
|
|
|
class InputSubsystem;
|
|
|
|
}
|
|
|
|
|
2020-11-20 16:04:27 +00:00
|
|
|
namespace Settings {
|
|
|
|
enum class ControllerType;
|
|
|
|
}
|
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
namespace Ui {
|
|
|
|
class QtControllerSelectorDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
class QtControllerSelectorDialog final : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit QtControllerSelectorDialog(QWidget* parent,
|
|
|
|
Core::Frontend::ControllerParameters parameters_,
|
2021-09-03 01:40:55 +00:00
|
|
|
InputCommon::InputSubsystem* input_subsystem_,
|
|
|
|
Core::System& system_);
|
2020-08-21 11:39:24 +00:00
|
|
|
~QtControllerSelectorDialog() override;
|
|
|
|
|
2020-09-27 15:18:07 +00:00
|
|
|
int exec() override;
|
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
private:
|
|
|
|
// Applies the current configuration.
|
|
|
|
void ApplyConfiguration();
|
|
|
|
|
2020-08-27 07:52:26 +00:00
|
|
|
// Loads the current input configuration into the frontend applet.
|
|
|
|
void LoadConfiguration();
|
|
|
|
|
2020-10-17 13:38:12 +00:00
|
|
|
// Initializes the "Configure Vibration" Dialog.
|
|
|
|
void CallConfigureVibrationDialog();
|
|
|
|
|
2021-04-13 14:05:07 +00:00
|
|
|
// Initializes the "Configure Motion / Touch" Dialog.
|
|
|
|
void CallConfigureMotionTouchDialog();
|
|
|
|
|
2020-10-26 07:28:03 +00:00
|
|
|
// Initializes the "Create Input Profile" Dialog.
|
|
|
|
void CallConfigureInputProfileDialog();
|
2020-08-21 11:39:24 +00:00
|
|
|
|
2020-09-27 15:18:07 +00:00
|
|
|
// Checks the current configuration against the given parameters.
|
|
|
|
// This sets and returns the value of parameters_met.
|
|
|
|
bool CheckIfParametersMet();
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
// Sets the controller icons for "Supported Controller Types".
|
|
|
|
void SetSupportedControllers();
|
|
|
|
|
2020-11-20 16:04:27 +00:00
|
|
|
// Sets the emulated controllers per player.
|
|
|
|
void SetEmulatedControllers(std::size_t player_index);
|
|
|
|
|
|
|
|
// Gets the Controller Type for a given controller combobox index per player.
|
|
|
|
Settings::ControllerType GetControllerTypeFromIndex(int index, std::size_t player_index) const;
|
|
|
|
|
|
|
|
// Gets the controller combobox index for a given Controller Type per player.
|
|
|
|
int GetIndexFromControllerType(Settings::ControllerType type, std::size_t player_index) const;
|
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
// 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 05:21:48 +00:00
|
|
|
// Sets the "Explain Text" per player.
|
|
|
|
void SetExplainText(std::size_t player_index);
|
|
|
|
|
2020-08-21 11:39:24 +00: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 07:28:03 +00:00
|
|
|
std::unique_ptr<InputProfiles> input_profiles;
|
|
|
|
|
2021-09-03 01:40:55 +00:00
|
|
|
Core::System& system;
|
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
// This is true if and only if all parameters are met. Otherwise, this is false.
|
2020-08-27 05:46:14 +00:00
|
|
|
// This determines whether the "OK" button can be clicked to exit the applet.
|
2020-08-21 11:39:24 +00:00
|
|
|
bool parameters_met{false};
|
|
|
|
|
2020-08-27 05:46:14 +00:00
|
|
|
static constexpr std::size_t NUM_PLAYERS = 8;
|
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
// Widgets encapsulating the groupboxes and comboboxes per player.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QWidget*, NUM_PLAYERS> player_widgets;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
// Groupboxes encapsulating the controller icons and LED patterns per player.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QGroupBox*, NUM_PLAYERS> player_groupboxes;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
// Icons for currently connected controllers/players.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QWidget*, NUM_PLAYERS> connected_controller_icons;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
// Labels that represent the player numbers in place of the controller icons.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QLabel*, NUM_PLAYERS> player_labels;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
// LED patterns for currently connected controllers/players.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<std::array<QCheckBox*, 4>, NUM_PLAYERS> led_patterns_boxes;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
2020-08-27 05:21:48 +00:00
|
|
|
// Labels representing additional information known as "Explain Text" per player.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QLabel*, NUM_PLAYERS> explain_text_labels;
|
2020-08-27 05:21:48 +00:00
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
// Comboboxes with a list of emulated controllers per player.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QComboBox*, NUM_PLAYERS> emulated_controllers;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
2020-11-20 16:04:27 +00:00
|
|
|
/// Pairs of emulated controller index and Controller Type enum per player.
|
|
|
|
std::array<std::vector<std::pair<int, Settings::ControllerType>>, NUM_PLAYERS>
|
|
|
|
index_controller_type_pairs;
|
|
|
|
|
2020-08-21 11:39:24 +00:00
|
|
|
// Labels representing the number of connected controllers
|
|
|
|
// above the "Connected Controllers" checkboxes.
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QLabel*, NUM_PLAYERS> connected_controller_labels;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
// Checkboxes representing the "Connected Controllers".
|
2020-08-27 05:46:14 +00:00
|
|
|
std::array<QCheckBox*, NUM_PLAYERS> connected_controller_checkboxes;
|
2020-08-21 11:39:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class QtControllerSelector final : public QObject, public Core::Frontend::ControllerApplet {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit QtControllerSelector(GMainWindow& parent);
|
|
|
|
~QtControllerSelector() override;
|
|
|
|
|
2020-10-26 23:36:58 +00:00
|
|
|
void ReconfigureControllers(
|
2020-12-05 13:37:13 +00:00
|
|
|
std::function<void()> callback_,
|
2020-10-26 23:36:58 +00:00
|
|
|
const Core::Frontend::ControllerParameters& parameters) const override;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
signals:
|
2020-10-26 23:36:58 +00:00
|
|
|
void MainWindowReconfigureControllers(
|
|
|
|
const Core::Frontend::ControllerParameters& parameters) const;
|
2020-08-21 11:39:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void MainWindowReconfigureFinished();
|
|
|
|
|
|
|
|
mutable std::function<void()> callback;
|
|
|
|
};
|