mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-13 22:17:59 -05:00
Project Mjölnir: Part 1
Co-authored-by: James Rowe <jroweboy@gmail.com> Co-authored-by: Its-Rei <kupfel@gmail.com>
This commit is contained in:
@ -5,38 +5,86 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <QColorDialog>
|
||||
#include <QGridLayout>
|
||||
#include <QInputDialog>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include "common/assert.h"
|
||||
#include "common/param_package.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/hid/controllers/npad.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
#include "input_common/main.h"
|
||||
#include "ui_configure_input_player.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
#include "yuzu/configuration/configure_input_player.h"
|
||||
|
||||
constexpr std::size_t HANDHELD_INDEX = 8;
|
||||
|
||||
const std::array<std::string, ConfigureInputPlayer::ANALOG_SUB_BUTTONS_NUM>
|
||||
ConfigureInputPlayer::analog_sub_buttons{{
|
||||
"up",
|
||||
"down",
|
||||
"left",
|
||||
"right",
|
||||
"modifier",
|
||||
}};
|
||||
|
||||
static void LayerGridElements(QGridLayout* grid, QWidget* item, QWidget* onTopOf) {
|
||||
const int index1 = grid->indexOf(item);
|
||||
const int index2 = grid->indexOf(onTopOf);
|
||||
int row, column, rowSpan, columnSpan;
|
||||
grid->getItemPosition(index2, &row, &column, &rowSpan, &columnSpan);
|
||||
grid->takeAt(index1);
|
||||
grid->addWidget(item, row, column, rowSpan, columnSpan);
|
||||
namespace {
|
||||
|
||||
void UpdateController(Settings::ControllerType controller_type, std::size_t npad_index,
|
||||
bool connected) {
|
||||
Core::System& system{Core::System::GetInstance()};
|
||||
if (!system.IsPoweredOn()) {
|
||||
return;
|
||||
}
|
||||
Service::SM::ServiceManager& sm = system.ServiceManager();
|
||||
|
||||
auto& npad =
|
||||
sm.GetService<Service::HID::Hid>("hid")
|
||||
->GetAppletResource()
|
||||
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad);
|
||||
|
||||
npad.UpdateControllerAt(npad.MapSettingsTypeToNPad(controller_type), npad_index, connected);
|
||||
}
|
||||
|
||||
static QString GetKeyName(int key_code) {
|
||||
/// Maps the controller type combobox index to Controller Type enum
|
||||
constexpr Settings::ControllerType GetControllerTypeFromIndex(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
default:
|
||||
return Settings::ControllerType::ProController;
|
||||
case 1:
|
||||
return Settings::ControllerType::DualJoyconDetached;
|
||||
case 2:
|
||||
return Settings::ControllerType::LeftJoycon;
|
||||
case 3:
|
||||
return Settings::ControllerType::RightJoycon;
|
||||
case 4:
|
||||
return Settings::ControllerType::Handheld;
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps the Controller Type enum to controller type combobox index
|
||||
constexpr int GetIndexFromControllerType(Settings::ControllerType type) {
|
||||
switch (type) {
|
||||
case Settings::ControllerType::ProController:
|
||||
default:
|
||||
return 0;
|
||||
case Settings::ControllerType::DualJoyconDetached:
|
||||
return 1;
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
return 2;
|
||||
case Settings::ControllerType::RightJoycon:
|
||||
return 3;
|
||||
case Settings::ControllerType::Handheld:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
QString GetKeyName(int key_code) {
|
||||
switch (key_code) {
|
||||
case Qt::Key_Shift:
|
||||
return QObject::tr("Shift");
|
||||
@ -51,9 +99,16 @@ static QString GetKeyName(int key_code) {
|
||||
}
|
||||
}
|
||||
|
||||
static void SetAnalogButton(const Common::ParamPackage& input_param,
|
||||
Common::ParamPackage& analog_param, const std::string& button_name) {
|
||||
if (analog_param.Get("engine", "") != "analog_from_button") {
|
||||
void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param,
|
||||
const std::string& button_name) {
|
||||
// The poller returned a complete axis, so set all the buttons
|
||||
if (input_param.Has("axis_x") && input_param.Has("axis_y")) {
|
||||
analog_param = input_param;
|
||||
return;
|
||||
}
|
||||
// Check if the current configuration has either no engine or an axis binding.
|
||||
// Clears out the old binding and adds one with analog_from_button.
|
||||
if (!analog_param.Has("engine") || analog_param.Has("axis_x") || analog_param.Has("axis_y")) {
|
||||
analog_param = {
|
||||
{"engine", "analog_from_button"},
|
||||
};
|
||||
@ -61,7 +116,7 @@ static void SetAnalogButton(const Common::ParamPackage& input_param,
|
||||
analog_param.Set(button_name, input_param.Serialize());
|
||||
}
|
||||
|
||||
static QString ButtonToText(const Common::ParamPackage& param) {
|
||||
QString ButtonToText(const Common::ParamPackage& param) {
|
||||
if (!param.Has("engine")) {
|
||||
return QObject::tr("[not set]");
|
||||
}
|
||||
@ -111,7 +166,7 @@ static QString ButtonToText(const Common::ParamPackage& param) {
|
||||
return QObject::tr("[unknown]");
|
||||
}
|
||||
|
||||
static QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) {
|
||||
QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) {
|
||||
if (!param.Has("engine")) {
|
||||
return QObject::tr("[not set]");
|
||||
}
|
||||
@ -161,22 +216,24 @@ static QString AnalogToText(const Common::ParamPackage& param, const std::string
|
||||
}
|
||||
return QObject::tr("[unknown]");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index, bool debug)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureInputPlayer>()), player_index(player_index),
|
||||
ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index,
|
||||
QWidget* bottom_row, bool debug)
|
||||
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPlayer>()), player_index(player_index),
|
||||
debug(debug), timeout_timer(std::make_unique<QTimer>()),
|
||||
poll_timer(std::make_unique<QTimer>()) {
|
||||
poll_timer(std::make_unique<QTimer>()), bottom_row(bottom_row) {
|
||||
ui->setupUi(this);
|
||||
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
button_map = {
|
||||
ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY,
|
||||
ui->buttonLStick, ui->buttonRStick, ui->buttonL, ui->buttonR,
|
||||
ui->buttonZL, ui->buttonZR, ui->buttonPlus, ui->buttonMinus,
|
||||
ui->buttonDpadLeft, ui->buttonDpadUp, ui->buttonDpadRight, ui->buttonDpadDown,
|
||||
ui->buttonLStickLeft, ui->buttonLStickUp, ui->buttonLStickRight, ui->buttonLStickDown,
|
||||
ui->buttonRStickLeft, ui->buttonRStickUp, ui->buttonRStickRight, ui->buttonRStickDown,
|
||||
ui->buttonSL, ui->buttonSR, ui->buttonHome, ui->buttonScreenshot,
|
||||
ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY,
|
||||
ui->buttonLStick, ui->buttonRStick, ui->buttonL, ui->buttonR,
|
||||
ui->buttonZL, ui->buttonZR, ui->buttonPlus, ui->buttonMinus,
|
||||
ui->buttonDpadLeft, ui->buttonDpadUp, ui->buttonDpadRight, ui->buttonDpadDown,
|
||||
ui->buttonSL, ui->buttonSR, ui->buttonHome, ui->buttonScreenshot,
|
||||
ui->buttonLStickMod, ui->buttonRStickMod,
|
||||
};
|
||||
|
||||
analog_map_buttons = {{
|
||||
@ -185,208 +242,159 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
||||
ui->buttonLStickDown,
|
||||
ui->buttonLStickLeft,
|
||||
ui->buttonLStickRight,
|
||||
ui->buttonLStickMod,
|
||||
},
|
||||
{
|
||||
ui->buttonRStickUp,
|
||||
ui->buttonRStickDown,
|
||||
ui->buttonRStickLeft,
|
||||
ui->buttonRStickRight,
|
||||
ui->buttonRStickMod,
|
||||
},
|
||||
}};
|
||||
|
||||
debug_hidden = {
|
||||
ui->buttonSL, ui->labelSL,
|
||||
ui->buttonSR, ui->labelSR,
|
||||
ui->buttonLStick, ui->labelLStickPressed,
|
||||
ui->buttonRStick, ui->labelRStickPressed,
|
||||
ui->buttonHome, ui->labelHome,
|
||||
ui->buttonScreenshot, ui->labelScreenshot,
|
||||
analog_map_deadzone_label = {ui->labelLStickDeadzone, ui->labelRStickDeadzone};
|
||||
analog_map_deadzone_slider = {ui->sliderLStickDeadzone, ui->sliderRStickDeadzone};
|
||||
analog_map_modifier_groupbox = {ui->buttonLStickModGroup, ui->buttonRStickModGroup};
|
||||
analog_map_modifier_button = {ui->buttonLStickMod, ui->buttonRStickMod};
|
||||
analog_map_modifier_label = {ui->labelLStickModifierRange, ui->labelRStickModifierRange};
|
||||
analog_map_modifier_slider = {ui->sliderLStickModifierRange, ui->sliderRStickModifierRange};
|
||||
analog_map_range_groupbox = {ui->buttonLStickRangeGroup, ui->buttonRStickRangeGroup};
|
||||
analog_map_range_spinbox = {ui->spinboxLStickRange, ui->spinboxRStickRange};
|
||||
|
||||
const auto ConfigureButtonClick = [&](QPushButton* button, Common::ParamPackage* param,
|
||||
int default_val) {
|
||||
connect(button, &QPushButton::clicked, [=, this] {
|
||||
HandleClick(
|
||||
button,
|
||||
[=, this](Common::ParamPackage params) {
|
||||
// Workaround for ZL & ZR for analog triggers like on XBOX
|
||||
// controllers. Analog triggers (from controllers like the XBOX
|
||||
// controller) would not work due to a different range of their
|
||||
// signals (from 0 to 255 on analog triggers instead of -32768 to
|
||||
// 32768 on analog joysticks). The SDL driver misinterprets analog
|
||||
// triggers as analog joysticks.
|
||||
// TODO: reinterpret the signal range for analog triggers to map the
|
||||
// values correctly. This is required for the correct emulation of
|
||||
// the analog triggers of the GameCube controller.
|
||||
if (button == ui->buttonZL || button == ui->buttonZR) {
|
||||
params.Set("direction", "+");
|
||||
params.Set("threshold", "0.5");
|
||||
}
|
||||
(*param) = std::move(params);
|
||||
},
|
||||
InputCommon::Polling::DeviceType::Button);
|
||||
});
|
||||
};
|
||||
|
||||
auto layout = Settings::values.players[player_index].type;
|
||||
if (debug)
|
||||
layout = Settings::ControllerType::DualJoycon;
|
||||
|
||||
switch (layout) {
|
||||
case Settings::ControllerType::ProController:
|
||||
case Settings::ControllerType::DualJoycon:
|
||||
layout_hidden = {
|
||||
ui->buttonSL,
|
||||
ui->labelSL,
|
||||
ui->buttonSR,
|
||||
ui->labelSR,
|
||||
};
|
||||
break;
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
layout_hidden = {
|
||||
ui->right_body_button,
|
||||
ui->right_buttons_button,
|
||||
ui->right_body_label,
|
||||
ui->right_buttons_label,
|
||||
ui->buttonR,
|
||||
ui->labelR,
|
||||
ui->buttonZR,
|
||||
ui->labelZR,
|
||||
ui->labelHome,
|
||||
ui->buttonHome,
|
||||
ui->buttonPlus,
|
||||
ui->labelPlus,
|
||||
ui->RStick,
|
||||
ui->faceButtons,
|
||||
};
|
||||
break;
|
||||
case Settings::ControllerType::RightJoycon:
|
||||
layout_hidden = {
|
||||
ui->left_body_button, ui->left_buttons_button,
|
||||
ui->left_body_label, ui->left_buttons_label,
|
||||
ui->buttonL, ui->labelL,
|
||||
ui->buttonZL, ui->labelZL,
|
||||
ui->labelScreenshot, ui->buttonScreenshot,
|
||||
ui->buttonMinus, ui->labelMinus,
|
||||
ui->LStick, ui->Dpad,
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
if (debug || layout == Settings::ControllerType::ProController) {
|
||||
ui->controller_color->hide();
|
||||
} else {
|
||||
if (layout == Settings::ControllerType::LeftJoycon ||
|
||||
layout == Settings::ControllerType::RightJoycon) {
|
||||
ui->horizontalSpacer_4->setGeometry({0, 0, 0, 0});
|
||||
|
||||
LayerGridElements(ui->buttons, ui->shoulderButtons, ui->Dpad);
|
||||
LayerGridElements(ui->buttons, ui->misc, ui->RStick);
|
||||
LayerGridElements(ui->buttons, ui->Dpad, ui->faceButtons);
|
||||
LayerGridElements(ui->buttons, ui->RStick, ui->LStick);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* widget : layout_hidden)
|
||||
widget->setVisible(false);
|
||||
|
||||
analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog};
|
||||
analog_map_deadzone_and_modifier_slider = {ui->sliderLStickDeadzoneAndModifier,
|
||||
ui->sliderRStickDeadzoneAndModifier};
|
||||
analog_map_deadzone_and_modifier_slider_label = {ui->labelLStickDeadzoneAndModifier,
|
||||
ui->labelRStickDeadzoneAndModifier};
|
||||
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
|
||||
auto* const button = button_map[button_id];
|
||||
if (button == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
button->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(button, &QPushButton::clicked, [=, this] {
|
||||
HandleClick(
|
||||
button_map[button_id],
|
||||
[=, this](Common::ParamPackage params) {
|
||||
// Workaround for ZL & ZR for analog triggers like on XBOX controllors.
|
||||
// Analog triggers (from controllers like the XBOX controller) would not
|
||||
// work due to a different range of their signals (from 0 to 255 on
|
||||
// analog triggers instead of -32768 to 32768 on analog joysticks). The
|
||||
// SDL driver misinterprets analog triggers as analog joysticks.
|
||||
// TODO: reinterpret the signal range for analog triggers to map the
|
||||
// values correctly. This is required for the correct emulation of the
|
||||
// analog triggers of the GameCube controller.
|
||||
if (button_id == Settings::NativeButton::ZL ||
|
||||
button_id == Settings::NativeButton::ZR) {
|
||||
params.Set("direction", "+");
|
||||
params.Set("threshold", "0.5");
|
||||
}
|
||||
buttons_param[button_id] = std::move(params);
|
||||
},
|
||||
InputCommon::Polling::DeviceType::Button);
|
||||
});
|
||||
connect(button, &QPushButton::customContextMenuRequested,
|
||||
[=, this](const QPoint& menu_location) {
|
||||
QMenu context_menu;
|
||||
context_menu.addAction(tr("Clear"), [&] {
|
||||
buttons_param[button_id].Clear();
|
||||
button_map[button_id]->setText(tr("[not set]"));
|
||||
});
|
||||
context_menu.addAction(tr("Restore Default"), [&] {
|
||||
buttons_param[button_id] = Common::ParamPackage{
|
||||
InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
|
||||
button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
|
||||
});
|
||||
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
|
||||
});
|
||||
ConfigureButtonClick(button_map[button_id], &buttons_param[button_id],
|
||||
Config::default_buttons[button_id]);
|
||||
}
|
||||
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
|
||||
// Handle clicks for the modifier buttons as well.
|
||||
ConfigureButtonClick(ui->buttonLStickMod, &lstick_mod, Config::default_lstick_mod);
|
||||
ConfigureButtonClick(ui->buttonRStickMod, &rstick_mod, Config::default_rstick_mod);
|
||||
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
|
||||
auto* const analog_button = analog_map_buttons[analog_id][sub_button_id];
|
||||
|
||||
if (analog_button == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
analog_button->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(analog_button, &QPushButton::clicked, [=, this] {
|
||||
HandleClick(
|
||||
analog_map_buttons[analog_id][sub_button_id],
|
||||
[=, this](const Common::ParamPackage& params) {
|
||||
SetAnalogButton(params, analogs_param[analog_id],
|
||||
analog_sub_buttons[sub_button_id]);
|
||||
SetAnalogParam(params, analogs_param[analog_id],
|
||||
analog_sub_buttons[sub_button_id]);
|
||||
},
|
||||
InputCommon::Polling::DeviceType::Button);
|
||||
InputCommon::Polling::DeviceType::AnalogPreferred);
|
||||
});
|
||||
connect(analog_button, &QPushButton::customContextMenuRequested,
|
||||
[=, this](const QPoint& menu_location) {
|
||||
QMenu context_menu;
|
||||
context_menu.addAction(tr("Clear"), [&] {
|
||||
analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
|
||||
analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
|
||||
});
|
||||
context_menu.addAction(tr("Restore Default"), [&] {
|
||||
Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
|
||||
Config::default_analogs[analog_id][sub_button_id])};
|
||||
SetAnalogButton(params, analogs_param[analog_id],
|
||||
analog_sub_buttons[sub_button_id]);
|
||||
analog_map_buttons[analog_id][sub_button_id]->setText(AnalogToText(
|
||||
analogs_param[analog_id], analog_sub_buttons[sub_button_id]));
|
||||
});
|
||||
context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
|
||||
menu_location));
|
||||
});
|
||||
}
|
||||
connect(analog_map_stick[analog_id], &QPushButton::clicked, [=, this] {
|
||||
if (QMessageBox::information(
|
||||
this, tr("Information"),
|
||||
tr("After pressing OK, first move your joystick horizontally, "
|
||||
"and then vertically."),
|
||||
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
|
||||
HandleClick(
|
||||
analog_map_stick[analog_id],
|
||||
[=, this](const Common::ParamPackage& params) {
|
||||
analogs_param[analog_id] = params;
|
||||
},
|
||||
InputCommon::Polling::DeviceType::Analog);
|
||||
}
|
||||
|
||||
connect(analog_map_modifier_button[analog_id], &QPushButton::clicked, [=, this] {
|
||||
HandleClick(
|
||||
analog_map_modifier_button[analog_id],
|
||||
[=, this](const Common::ParamPackage& params) {
|
||||
SetAnalogParam(params, analogs_param[analog_id], "modifier");
|
||||
},
|
||||
InputCommon::Polling::DeviceType::AnalogPreferred);
|
||||
});
|
||||
|
||||
connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged,
|
||||
connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged),
|
||||
[=, this] {
|
||||
const float slider_value =
|
||||
analog_map_deadzone_and_modifier_slider[analog_id]->value();
|
||||
if (analogs_param[analog_id].Get("engine", "") == "sdl" ||
|
||||
analogs_param[analog_id].Get("engine", "") == "gcpad") {
|
||||
analog_map_deadzone_and_modifier_slider_label[analog_id]->setText(
|
||||
tr("Deadzone: %1%").arg(slider_value));
|
||||
analogs_param[analog_id].Set("deadzone", slider_value / 100.0f);
|
||||
} else {
|
||||
analog_map_deadzone_and_modifier_slider_label[analog_id]->setText(
|
||||
tr("Modifier Scale: %1%").arg(slider_value));
|
||||
analogs_param[analog_id].Set("modifier_scale", slider_value / 100.0f);
|
||||
}
|
||||
const auto spinbox_value = analog_map_range_spinbox[analog_id]->value();
|
||||
analogs_param[analog_id].Set("range", spinbox_value / 100.0f);
|
||||
});
|
||||
|
||||
connect(analog_map_deadzone_slider[analog_id], &QSlider::valueChanged, [=, this] {
|
||||
const auto slider_value = analog_map_deadzone_slider[analog_id]->value();
|
||||
analog_map_deadzone_label[analog_id]->setText(tr("Deadzone: %1%").arg(slider_value));
|
||||
analogs_param[analog_id].Set("deadzone", slider_value / 100.0f);
|
||||
});
|
||||
|
||||
connect(analog_map_modifier_slider[analog_id], &QSlider::valueChanged, [=, this] {
|
||||
const auto slider_value = analog_map_modifier_slider[analog_id]->value();
|
||||
analog_map_modifier_label[analog_id]->setText(
|
||||
tr("Modifier Range: %1%").arg(slider_value));
|
||||
analogs_param[analog_id].Set("modifier_scale", slider_value / 100.0f);
|
||||
});
|
||||
}
|
||||
|
||||
// Player Connected checkbox
|
||||
connect(ui->groupConnectedController, &QGroupBox::toggled,
|
||||
[&](bool checked) { emit Connected(checked); });
|
||||
|
||||
// Set up controller type. Only Player 1 can choose Handheld.
|
||||
ui->comboControllerType->clear();
|
||||
|
||||
QStringList controller_types = {
|
||||
QStringLiteral("Pro Controller"),
|
||||
QStringLiteral("Dual Joycons"),
|
||||
QStringLiteral("Left Joycon"),
|
||||
QStringLiteral("Right Joycon"),
|
||||
};
|
||||
|
||||
if (player_index == 0) {
|
||||
controller_types.append(QStringLiteral("Handheld"));
|
||||
connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
[&](int index) {
|
||||
emit HandheldStateChanged(GetControllerTypeFromIndex(index) ==
|
||||
Settings::ControllerType::Handheld);
|
||||
});
|
||||
}
|
||||
|
||||
connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); });
|
||||
connect(ui->buttonRestoreDefaults, &QPushButton::clicked, [this] { RestoreDefaults(); });
|
||||
// The Debug Controller can only choose the Pro Controller.
|
||||
if (debug) {
|
||||
ui->buttonScreenshot->setEnabled(false);
|
||||
ui->buttonHome->setEnabled(false);
|
||||
ui->groupConnectedController->setCheckable(false);
|
||||
QStringList debug_controller_types = {
|
||||
QStringLiteral("Pro Controller"),
|
||||
};
|
||||
ui->comboControllerType->addItems(debug_controller_types);
|
||||
} else {
|
||||
ui->comboControllerType->addItems(controller_types);
|
||||
}
|
||||
|
||||
UpdateControllerIcon();
|
||||
UpdateControllerAvailableButtons();
|
||||
connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [&](int) {
|
||||
UpdateControllerIcon();
|
||||
UpdateControllerAvailableButtons();
|
||||
});
|
||||
|
||||
connect(ui->comboDevices, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
[&] { UpdateMappingWithDefaults(); });
|
||||
|
||||
ui->buttonRefreshDevices->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
|
||||
UpdateInputDevices();
|
||||
connect(ui->buttonRefreshDevices, &QPushButton::clicked, [&] { emit RefreshInputDevices(); });
|
||||
|
||||
timeout_timer->setSingleShot(true);
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
|
||||
@ -416,20 +424,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
||||
}
|
||||
});
|
||||
|
||||
controller_color_buttons = {
|
||||
ui->left_body_button,
|
||||
ui->left_buttons_button,
|
||||
ui->right_body_button,
|
||||
ui->right_buttons_button,
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < controller_color_buttons.size(); ++i) {
|
||||
connect(controller_color_buttons[i], &QPushButton::clicked, this,
|
||||
[this, i] { OnControllerButtonClick(static_cast<int>(i)); });
|
||||
}
|
||||
|
||||
LoadConfiguration();
|
||||
resize(0, 0);
|
||||
|
||||
// TODO(wwylele): enable this when we actually emulate it
|
||||
ui->buttonHome->setEnabled(false);
|
||||
@ -438,27 +433,43 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
||||
ConfigureInputPlayer::~ConfigureInputPlayer() = default;
|
||||
|
||||
void ConfigureInputPlayer::ApplyConfiguration() {
|
||||
auto& buttons =
|
||||
debug ? Settings::values.debug_pad_buttons : Settings::values.players[player_index].buttons;
|
||||
auto& analogs =
|
||||
debug ? Settings::values.debug_pad_analogs : Settings::values.players[player_index].analogs;
|
||||
auto& player = Settings::values.players[player_index];
|
||||
auto& buttons = debug ? Settings::values.debug_pad_buttons : player.buttons;
|
||||
auto& analogs = debug ? Settings::values.debug_pad_analogs : player.analogs;
|
||||
|
||||
std::transform(buttons_param.begin(), buttons_param.end(), buttons.begin(),
|
||||
[](const Common::ParamPackage& param) { return param.Serialize(); });
|
||||
std::transform(analogs_param.begin(), analogs_param.end(), analogs.begin(),
|
||||
[](const Common::ParamPackage& param) { return param.Serialize(); });
|
||||
|
||||
if (debug)
|
||||
if (debug) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::array<u32, 4> colors{};
|
||||
std::transform(controller_colors.begin(), controller_colors.end(), colors.begin(),
|
||||
[](QColor color) { return color.rgb(); });
|
||||
player.controller_type =
|
||||
static_cast<Settings::ControllerType>(ui->comboControllerType->currentIndex());
|
||||
player.connected = ui->groupConnectedController->isChecked();
|
||||
|
||||
Settings::values.players[player_index].body_color_left = colors[0];
|
||||
Settings::values.players[player_index].button_color_left = colors[1];
|
||||
Settings::values.players[player_index].body_color_right = colors[2];
|
||||
Settings::values.players[player_index].button_color_right = colors[3];
|
||||
// Player 2-8
|
||||
if (player_index != 0) {
|
||||
UpdateController(player.controller_type, player_index, player.connected);
|
||||
return;
|
||||
}
|
||||
|
||||
// Player 1 and Handheld
|
||||
auto& handheld = Settings::values.players[HANDHELD_INDEX];
|
||||
// If Handheld is selected, copy all the settings from Player 1 to Handheld.
|
||||
if (player.controller_type == Settings::ControllerType::Handheld) {
|
||||
handheld = player;
|
||||
handheld.connected = ui->groupConnectedController->isChecked();
|
||||
player.connected = false; // Disconnect Player 1
|
||||
} else {
|
||||
player.connected = ui->groupConnectedController->isChecked();
|
||||
handheld.connected = false; // Disconnect Handheld
|
||||
}
|
||||
|
||||
UpdateController(player.controller_type, player_index, player.connected);
|
||||
UpdateController(Settings::ControllerType::Handheld, HANDHELD_INDEX, handheld.connected);
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::changeEvent(QEvent* event) {
|
||||
@ -466,24 +477,16 @@ void ConfigureInputPlayer::changeEvent(QEvent* event) {
|
||||
RetranslateUI();
|
||||
}
|
||||
|
||||
QDialog::changeEvent(event);
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::RetranslateUI() {
|
||||
ui->retranslateUi(this);
|
||||
UpdateButtonLabels();
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::OnControllerButtonClick(int i) {
|
||||
const QColor new_bg_color = QColorDialog::getColor(controller_colors[i]);
|
||||
if (!new_bg_color.isValid())
|
||||
return;
|
||||
controller_colors[i] = new_bg_color;
|
||||
controller_color_buttons[i]->setStyleSheet(
|
||||
QStringLiteral("QPushButton { background-color: %1 }").arg(controller_colors[i].name()));
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::LoadConfiguration() {
|
||||
auto& player = Settings::values.players[player_index];
|
||||
if (debug) {
|
||||
std::transform(Settings::values.debug_pad_buttons.begin(),
|
||||
Settings::values.debug_pad_buttons.end(), buttons_param.begin(),
|
||||
@ -492,56 +495,53 @@ void ConfigureInputPlayer::LoadConfiguration() {
|
||||
Settings::values.debug_pad_analogs.end(), analogs_param.begin(),
|
||||
[](const std::string& str) { return Common::ParamPackage(str); });
|
||||
} else {
|
||||
std::transform(Settings::values.players[player_index].buttons.begin(),
|
||||
Settings::values.players[player_index].buttons.end(), buttons_param.begin(),
|
||||
std::transform(player.buttons.begin(), player.buttons.end(), buttons_param.begin(),
|
||||
[](const std::string& str) { return Common::ParamPackage(str); });
|
||||
std::transform(Settings::values.players[player_index].analogs.begin(),
|
||||
Settings::values.players[player_index].analogs.end(), analogs_param.begin(),
|
||||
std::transform(player.analogs.begin(), player.analogs.end(), analogs_param.begin(),
|
||||
[](const std::string& str) { return Common::ParamPackage(str); });
|
||||
}
|
||||
|
||||
UpdateButtonLabels();
|
||||
UpdateUI();
|
||||
|
||||
if (debug)
|
||||
if (debug) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::array<u32, 4> colors = {
|
||||
Settings::values.players[player_index].body_color_left,
|
||||
Settings::values.players[player_index].button_color_left,
|
||||
Settings::values.players[player_index].body_color_right,
|
||||
Settings::values.players[player_index].button_color_right,
|
||||
};
|
||||
ui->comboControllerType->setCurrentIndex(static_cast<int>(player.controller_type));
|
||||
ui->groupConnectedController->setChecked(
|
||||
player.connected ||
|
||||
(player_index == 0 && Settings::values.players[HANDHELD_INDEX].connected));
|
||||
}
|
||||
|
||||
std::transform(colors.begin(), colors.end(), controller_colors.begin(),
|
||||
[](u32 rgb) { return QColor::fromRgb(rgb); });
|
||||
|
||||
for (std::size_t i = 0; i < colors.size(); ++i) {
|
||||
controller_color_buttons[i]->setStyleSheet(
|
||||
QStringLiteral("QPushButton { background-color: %1 }")
|
||||
.arg(controller_colors[i].name()));
|
||||
void ConfigureInputPlayer::UpdateInputDevices() {
|
||||
input_devices = InputCommon::GetInputDevices();
|
||||
ui->comboDevices->clear();
|
||||
for (auto device : input_devices) {
|
||||
ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {});
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::RestoreDefaults() {
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
||||
// Reset Buttons
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
|
||||
buttons_param[button_id] = Common::ParamPackage{
|
||||
InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
|
||||
}
|
||||
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
|
||||
// Reset Analogs
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
|
||||
Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
|
||||
Config::default_analogs[analog_id][sub_button_id])};
|
||||
SetAnalogButton(params, analogs_param[analog_id], analog_sub_buttons[sub_button_id]);
|
||||
SetAnalogParam(params, analogs_param[analog_id], analog_sub_buttons[sub_button_id]);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateButtonLabels();
|
||||
ApplyConfiguration();
|
||||
UpdateUI();
|
||||
UpdateInputDevices();
|
||||
ui->comboControllerType->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::ClearAll() {
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) {
|
||||
const auto* const button = button_map[button_id];
|
||||
if (button == nullptr || !button->isEnabled()) {
|
||||
continue;
|
||||
@ -550,8 +550,8 @@ void ConfigureInputPlayer::ClearAll() {
|
||||
buttons_param[button_id].Clear();
|
||||
}
|
||||
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
|
||||
const auto* const analog_button = analog_map_buttons[analog_id][sub_button_id];
|
||||
if (analog_button == nullptr || !analog_button->isEnabled()) {
|
||||
continue;
|
||||
@ -561,17 +561,17 @@ void ConfigureInputPlayer::ClearAll() {
|
||||
}
|
||||
}
|
||||
|
||||
UpdateButtonLabels();
|
||||
ApplyConfiguration();
|
||||
UpdateUI();
|
||||
UpdateInputDevices();
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::UpdateButtonLabels() {
|
||||
for (int button = 0; button < Settings::NativeButton::NumButtons; button++) {
|
||||
void ConfigureInputPlayer::UpdateUI() {
|
||||
for (int button = 0; button < Settings::NativeButton::NumButtons; ++button) {
|
||||
button_map[button]->setText(ButtonToText(buttons_param[button]));
|
||||
}
|
||||
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
|
||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
|
||||
auto* const analog_button = analog_map_buttons[analog_id][sub_button_id];
|
||||
|
||||
if (analog_button == nullptr) {
|
||||
@ -581,52 +581,75 @@ void ConfigureInputPlayer::UpdateButtonLabels() {
|
||||
analog_button->setText(
|
||||
AnalogToText(analogs_param[analog_id], analog_sub_buttons[sub_button_id]));
|
||||
}
|
||||
analog_map_stick[analog_id]->setText(tr("Set Analog Stick"));
|
||||
|
||||
const auto deadzone_label = analog_map_deadzone_label[analog_id];
|
||||
const auto deadzone_slider = analog_map_deadzone_slider[analog_id];
|
||||
const auto modifier_groupbox = analog_map_modifier_groupbox[analog_id];
|
||||
const auto modifier_label = analog_map_modifier_label[analog_id];
|
||||
const auto modifier_slider = analog_map_modifier_slider[analog_id];
|
||||
const auto range_groupbox = analog_map_range_groupbox[analog_id];
|
||||
const auto range_spinbox = analog_map_range_spinbox[analog_id];
|
||||
|
||||
int slider_value;
|
||||
auto& param = analogs_param[analog_id];
|
||||
auto* const analog_stick_slider = analog_map_deadzone_and_modifier_slider[analog_id];
|
||||
auto* const analog_stick_slider_label =
|
||||
analog_map_deadzone_and_modifier_slider_label[analog_id];
|
||||
const bool is_controller =
|
||||
param.Get("engine", "") == "sdl" || param.Get("engine", "") == "gcpad";
|
||||
|
||||
if (param.Has("engine")) {
|
||||
if (param.Get("engine", "") == "sdl" || param.Get("engine", "") == "gcpad") {
|
||||
if (!param.Has("deadzone")) {
|
||||
param.Set("deadzone", 0.1f);
|
||||
}
|
||||
|
||||
analog_stick_slider->setValue(static_cast<int>(param.Get("deadzone", 0.1f) * 100));
|
||||
if (analog_stick_slider->value() == 0) {
|
||||
analog_stick_slider_label->setText(tr("Deadzone: 0%"));
|
||||
}
|
||||
} else {
|
||||
if (!param.Has("modifier_scale")) {
|
||||
param.Set("modifier_scale", 0.5f);
|
||||
}
|
||||
|
||||
analog_stick_slider->setValue(
|
||||
static_cast<int>(param.Get("modifier_scale", 0.5f) * 100));
|
||||
if (analog_stick_slider->value() == 0) {
|
||||
analog_stick_slider_label->setText(tr("Modifier Scale: 0%"));
|
||||
}
|
||||
if (is_controller) {
|
||||
if (!param.Has("deadzone")) {
|
||||
param.Set("deadzone", 0.1f);
|
||||
}
|
||||
slider_value = static_cast<int>(param.Get("deadzone", 0.1f) * 100);
|
||||
deadzone_label->setText(tr("Deadzone: %1%").arg(slider_value));
|
||||
deadzone_slider->setValue(slider_value);
|
||||
if (!param.Has("range")) {
|
||||
param.Set("range", 1.0f);
|
||||
}
|
||||
range_spinbox->setValue(static_cast<int>(param.Get("range", 1.0f) * 100));
|
||||
} else {
|
||||
if (!param.Has("modifier_scale")) {
|
||||
param.Set("modifier_scale", 0.5f);
|
||||
}
|
||||
slider_value = static_cast<int>(param.Get("modifier_scale", 0.5f) * 100);
|
||||
modifier_label->setText(tr("Modifier Range: %1%").arg(slider_value));
|
||||
modifier_slider->setValue(slider_value);
|
||||
}
|
||||
|
||||
deadzone_label->setVisible(is_controller);
|
||||
deadzone_slider->setVisible(is_controller);
|
||||
modifier_groupbox->setVisible(!is_controller);
|
||||
modifier_label->setVisible(!is_controller);
|
||||
modifier_slider->setVisible(!is_controller);
|
||||
range_groupbox->setVisible(is_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::UpdateMappingWithDefaults() {
|
||||
if (ui->comboDevices->currentIndex() < 2) {
|
||||
return;
|
||||
}
|
||||
const auto& device = input_devices[ui->comboDevices->currentIndex()];
|
||||
auto button_mapping = InputCommon::GetButtonMappingForDevice(device);
|
||||
auto analog_mapping = InputCommon::GetAnalogMappingForDevice(device);
|
||||
for (int i = 0; i < buttons_param.size(); ++i) {
|
||||
buttons_param[i] = button_mapping[static_cast<Settings::NativeButton::Values>(i)];
|
||||
}
|
||||
for (int i = 0; i < analogs_param.size(); ++i) {
|
||||
analogs_param[i] = analog_mapping[static_cast<Settings::NativeAnalog::Values>(i)];
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::HandleClick(
|
||||
QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||
InputCommon::Polling::DeviceType type) {
|
||||
button->setText(tr("[press key]"));
|
||||
button->setText(tr("[waiting]"));
|
||||
button->setFocus();
|
||||
|
||||
// Keyboard keys can only be used as button devices
|
||||
want_keyboard_keys = type == InputCommon::Polling::DeviceType::Button;
|
||||
if (want_keyboard_keys) {
|
||||
const auto iter = std::find(button_map.begin(), button_map.end(), button);
|
||||
ASSERT(iter != button_map.end());
|
||||
const auto index = std::distance(button_map.begin(), iter);
|
||||
ASSERT(index < Settings::NativeButton::NumButtons && index >= 0);
|
||||
}
|
||||
// The first two input devices are always Any and Keyboard. If the user filtered to a
|
||||
// controller, then they don't want keyboard input
|
||||
want_keyboard_keys = ui->comboDevices->currentIndex() < 2;
|
||||
|
||||
input_setter = new_input_setter;
|
||||
|
||||
@ -636,20 +659,17 @@ void ConfigureInputPlayer::HandleClick(
|
||||
poller->Start();
|
||||
}
|
||||
|
||||
grabKeyboard();
|
||||
grabMouse();
|
||||
if (type == InputCommon::Polling::DeviceType::Button) {
|
||||
InputCommon::GetGCButtons()->BeginConfiguration();
|
||||
} else {
|
||||
InputCommon::GetGCAnalogs()->BeginConfiguration();
|
||||
}
|
||||
timeout_timer->start(5000); // Cancel after 5 seconds
|
||||
poll_timer->start(200); // Check for new inputs every 200ms
|
||||
|
||||
timeout_timer->start(2500); // Cancel after 2.5 seconds
|
||||
poll_timer->start(50); // Check for new inputs every 50ms
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params, bool abort) {
|
||||
releaseKeyboard();
|
||||
releaseMouse();
|
||||
timeout_timer->stop();
|
||||
poll_timer->stop();
|
||||
for (auto& poller : device_pollers) {
|
||||
@ -663,7 +683,7 @@ void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params,
|
||||
(*input_setter)(params);
|
||||
}
|
||||
|
||||
UpdateButtonLabels();
|
||||
UpdateUI();
|
||||
input_setter = std::nullopt;
|
||||
}
|
||||
|
||||
@ -683,3 +703,114 @@ void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
|
||||
}
|
||||
SetPollingResult({}, true);
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::UpdateControllerIcon() {
|
||||
// We aren't using Qt's built in theme support here since we aren't drawing an icon (and its
|
||||
// "nonstandard" to use an image through the icon support)
|
||||
QString stylesheet{};
|
||||
switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) {
|
||||
case Settings::ControllerType::ProController:
|
||||
stylesheet = QStringLiteral("image: url(:/controller/pro_controller%0)");
|
||||
break;
|
||||
case Settings::ControllerType::DualJoyconDetached:
|
||||
stylesheet = QStringLiteral("image: url(:/controller/dual_joycon%0)");
|
||||
break;
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
stylesheet = QStringLiteral("image: url(:/controller/single_joycon_left_vertical%0)");
|
||||
break;
|
||||
case Settings::ControllerType::RightJoycon:
|
||||
stylesheet = QStringLiteral("image: url(:/controller/single_joycon_right_vertical%0)");
|
||||
break;
|
||||
case Settings::ControllerType::Handheld:
|
||||
stylesheet = QStringLiteral("image: url(:/controller/handheld%0)");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const QString theme = [this] {
|
||||
if (QIcon::themeName().contains(QStringLiteral("dark"))) {
|
||||
return QStringLiteral("_dark");
|
||||
} else if (QIcon::themeName().contains(QStringLiteral("midnight"))) {
|
||||
return QStringLiteral("_midnight");
|
||||
} else {
|
||||
return QString{};
|
||||
}
|
||||
}();
|
||||
|
||||
ui->controllerFrame->setStyleSheet(stylesheet.arg(theme));
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
|
||||
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
|
||||
if (debug) {
|
||||
layout = Settings::ControllerType::DualJoyconDetached;
|
||||
}
|
||||
|
||||
// List of all the widgets that will be hidden by any of the following layouts that need
|
||||
// "unhidden" after the controller type changes
|
||||
const std::vector<QWidget*> layout_show = {
|
||||
ui->buttonShoulderButtonsSLSR,
|
||||
ui->horizontalSpacerShoulderButtonsWidget,
|
||||
ui->horizontalSpacerShoulderButtonsWidget2,
|
||||
ui->buttonShoulderButtonsLeft,
|
||||
ui->buttonMiscButtonsMinusScreenshot,
|
||||
ui->bottomLeft,
|
||||
ui->buttonShoulderButtonsRight,
|
||||
ui->buttonMiscButtonsPlusHome,
|
||||
ui->bottomRight,
|
||||
};
|
||||
|
||||
for (auto* widget : layout_show) {
|
||||
widget->show();
|
||||
}
|
||||
|
||||
std::vector<QWidget*> layout_hidden;
|
||||
switch (layout) {
|
||||
case Settings::ControllerType::ProController:
|
||||
layout_hidden = {
|
||||
ui->buttonShoulderButtonsSLSR,
|
||||
ui->horizontalSpacerShoulderButtonsWidget2,
|
||||
};
|
||||
break;
|
||||
case Settings::ControllerType::DualJoyconDetached:
|
||||
case Settings::ControllerType::Handheld:
|
||||
layout_hidden = {
|
||||
ui->buttonShoulderButtonsSLSR,
|
||||
ui->horizontalSpacerShoulderButtonsWidget2,
|
||||
};
|
||||
break;
|
||||
case Settings::ControllerType::LeftJoycon:
|
||||
layout_hidden = {
|
||||
ui->horizontalSpacerShoulderButtonsWidget2,
|
||||
ui->buttonShoulderButtonsRight,
|
||||
ui->buttonMiscButtonsPlusHome,
|
||||
ui->bottomRight,
|
||||
};
|
||||
break;
|
||||
case Settings::ControllerType::RightJoycon:
|
||||
layout_hidden = {
|
||||
ui->horizontalSpacerShoulderButtonsWidget,
|
||||
ui->buttonShoulderButtonsLeft,
|
||||
ui->buttonMiscButtonsMinusScreenshot,
|
||||
ui->bottomLeft,
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto* widget : layout_hidden) {
|
||||
widget->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::showEvent(QShowEvent* event) {
|
||||
if (bottom_row == nullptr) {
|
||||
return;
|
||||
}
|
||||
QWidget::showEvent(event);
|
||||
ui->main->addWidget(bottom_row);
|
||||
}
|
||||
|
||||
void ConfigureInputPlayer::ConnectPlayer(bool connected) {
|
||||
ui->groupConnectedController->setChecked(connected);
|
||||
}
|
||||
|
Reference in New Issue
Block a user