mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-23 02:15:47 +01:00
Address feedback
This commit is contained in:
parent
fc505110f1
commit
efa0b7a056
@ -118,37 +118,38 @@ std::vector<Common::ParamPackage> GetInputDevices() {
|
|||||||
|
|
||||||
std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> GetButtonMappingForDevice(
|
std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> GetButtonMappingForDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> mappings{};
|
std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> mappings;
|
||||||
if (!params.Has("class") || params.Get("class", "") == "any") {
|
if (!params.Has("class") || params.Get("class", "") == "any") {
|
||||||
return mappings;
|
return {};
|
||||||
}
|
}
|
||||||
if (params.Get("class", "") == "key") {
|
if (params.Get("class", "") == "key") {
|
||||||
// TODO consider returning the SDL key codes for the default keybindings
|
// TODO consider returning the SDL key codes for the default keybindings
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
if (params.Get("class", "") == "sdl") {
|
if (params.Get("class", "") == "sdl") {
|
||||||
return sdl->GetButtonMappingForDevice(params);
|
return sdl->GetButtonMappingForDevice(params);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return mappings;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> GetAnalogMappingForDevice(
|
std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> GetAnalogMappingForDevice(
|
||||||
const Common::ParamPackage& params) {
|
const Common::ParamPackage& params) {
|
||||||
std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> mappings{};
|
std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> mappings;
|
||||||
if (!params.Has("class") || params.Get("class", "") == "any") {
|
if (!params.Has("class") || params.Get("class", "") == "any") {
|
||||||
return mappings;
|
return {};
|
||||||
}
|
}
|
||||||
if (params.Get("class", "") == "key") {
|
if (params.Get("class", "") == "key") {
|
||||||
// TODO consider returning the SDL key codes for the default keybindings
|
// TODO consider returning the SDL key codes for the default keybindings
|
||||||
return mappings;
|
return {};
|
||||||
}
|
}
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
if (params.Get("class", "") == "sdl") {
|
if (params.Get("class", "") == "sdl") {
|
||||||
return sdl->GetAnalogMappingForDevice(params);
|
return sdl->GetAnalogMappingForDevice(params);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return mappings;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Polling {
|
namespace Polling {
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
/// Setup and start polling for inputs, should be called before GetNextInput
|
/// Setup and start polling for inputs, should be called before GetNextInput
|
||||||
/// If a device_id is provided, events should be filtered to only include events from this
|
/// If a device_id is provided, events should be filtered to only include events from this
|
||||||
/// device id
|
/// device id
|
||||||
virtual void Start(std::string device_id = "") = 0;
|
virtual void Start(const std::string& device_id = "") = 0;
|
||||||
/// Stop polling
|
/// Stop polling
|
||||||
virtual void Stop() = 0;
|
virtual void Stop() = 0;
|
||||||
/**
|
/**
|
||||||
|
@ -545,17 +545,16 @@ SDLState::~SDLState() {
|
|||||||
|
|
||||||
std::vector<Common::ParamPackage> SDLState::GetInputDevices() {
|
std::vector<Common::ParamPackage> SDLState::GetInputDevices() {
|
||||||
std::scoped_lock lock(joystick_map_mutex);
|
std::scoped_lock lock(joystick_map_mutex);
|
||||||
std::vector<Common::ParamPackage> devices = {};
|
std::vector<Common::ParamPackage> devices;
|
||||||
for (const auto& [key, value] : joystick_map) {
|
for (const auto& [key, value] : joystick_map) {
|
||||||
for (const auto& joystick : value) {
|
for (const auto& joystick : value) {
|
||||||
auto controller = joystick->GetSDLGameController();
|
|
||||||
auto joy = joystick->GetSDLJoystick();
|
auto joy = joystick->GetSDLJoystick();
|
||||||
if (controller) {
|
if (auto controller = joystick->GetSDLGameController()) {
|
||||||
std::string name =
|
std::string name =
|
||||||
fmt::format("{} {}", SDL_GameControllerName(controller), joystick->GetPort());
|
fmt::format("{} {}", SDL_GameControllerName(controller), joystick->GetPort());
|
||||||
devices.emplace_back(Common::ParamPackage{
|
devices.emplace_back(Common::ParamPackage{
|
||||||
{"class", "sdl"},
|
{"class", "sdl"},
|
||||||
{"display", name},
|
{"display", std::move(name)},
|
||||||
{"guid", joystick->GetGUID()},
|
{"guid", joystick->GetGUID()},
|
||||||
{"port", std::to_string(joystick->GetPort())},
|
{"port", std::to_string(joystick->GetPort())},
|
||||||
});
|
});
|
||||||
@ -563,7 +562,7 @@ std::vector<Common::ParamPackage> SDLState::GetInputDevices() {
|
|||||||
std::string name = fmt::format("{} {}", SDL_JoystickName(joy), joystick->GetPort());
|
std::string name = fmt::format("{} {}", SDL_JoystickName(joy), joystick->GetPort());
|
||||||
devices.emplace_back(Common::ParamPackage{
|
devices.emplace_back(Common::ParamPackage{
|
||||||
{"class", "sdl"},
|
{"class", "sdl"},
|
||||||
{"display", name},
|
{"display", std::move(name)},
|
||||||
{"guid", joystick->GetGUID()},
|
{"guid", joystick->GetGUID()},
|
||||||
{"port", std::to_string(joystick->GetPort())},
|
{"port", std::to_string(joystick->GetPort())},
|
||||||
});
|
});
|
||||||
@ -624,54 +623,43 @@ Common::ParamPackage BuildHatParamPackageForButton(int port, std::string guid, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
Common::ParamPackage SDLEventToButtonParamPackage(SDLState& state, const SDL_Event& event) {
|
Common::ParamPackage SDLEventToButtonParamPackage(SDLState& state, const SDL_Event& event) {
|
||||||
Common::ParamPackage params{};
|
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_JOYAXISMOTION: {
|
case SDL_JOYAXISMOTION: {
|
||||||
const auto joystick = state.GetSDLJoystickBySDLID(event.jaxis.which);
|
const auto joystick = state.GetSDLJoystickBySDLID(event.jaxis.which);
|
||||||
params = BuildAnalogParamPackageForButton(joystick->GetPort(), joystick->GetGUID(),
|
return BuildAnalogParamPackageForButton(joystick->GetPort(), joystick->GetGUID(),
|
||||||
event.jaxis.axis, event.jaxis.value);
|
event.jaxis.axis, event.jaxis.value);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SDL_JOYBUTTONUP: {
|
case SDL_JOYBUTTONUP: {
|
||||||
const auto joystick = state.GetSDLJoystickBySDLID(event.jbutton.which);
|
const auto joystick = state.GetSDLJoystickBySDLID(event.jbutton.which);
|
||||||
params = BuildButtonParamPackageForButton(joystick->GetPort(), joystick->GetGUID(),
|
return BuildButtonParamPackageForButton(joystick->GetPort(), joystick->GetGUID(),
|
||||||
event.jbutton.button);
|
event.jbutton.button);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SDL_JOYHATMOTION: {
|
case SDL_JOYHATMOTION: {
|
||||||
const auto joystick = state.GetSDLJoystickBySDLID(event.jhat.which);
|
const auto joystick = state.GetSDLJoystickBySDLID(event.jhat.which);
|
||||||
params = BuildHatParamPackageForButton(joystick->GetPort(), joystick->GetGUID(),
|
return BuildHatParamPackageForButton(joystick->GetPort(), joystick->GetGUID(),
|
||||||
event.jhat.hat, event.jhat.value);
|
event.jhat.hat, event.jhat.value);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return params;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ParamPackage BuildParamPackageForBinding(int port, const std::string& guid,
|
Common::ParamPackage BuildParamPackageForBinding(int port, const std::string& guid,
|
||||||
const SDL_GameControllerButtonBind& binding) {
|
const SDL_GameControllerButtonBind& binding) {
|
||||||
Common::ParamPackage out{};
|
|
||||||
switch (binding.bindType) {
|
switch (binding.bindType) {
|
||||||
case SDL_CONTROLLER_BINDTYPE_AXIS:
|
case SDL_CONTROLLER_BINDTYPE_AXIS:
|
||||||
out = BuildAnalogParamPackageForButton(port, guid, binding.value.axis);
|
return BuildAnalogParamPackageForButton(port, guid, binding.value.axis);
|
||||||
break;
|
|
||||||
case SDL_CONTROLLER_BINDTYPE_BUTTON:
|
case SDL_CONTROLLER_BINDTYPE_BUTTON:
|
||||||
out = BuildButtonParamPackageForButton(port, guid, binding.value.button);
|
return BuildButtonParamPackageForButton(port, guid, binding.value.button);
|
||||||
break;
|
|
||||||
case SDL_CONTROLLER_BINDTYPE_HAT:
|
case SDL_CONTROLLER_BINDTYPE_HAT:
|
||||||
out = BuildHatParamPackageForButton(port, guid, binding.value.hat.hat,
|
return BuildHatParamPackageForButton(port, guid, binding.value.hat.hat,
|
||||||
binding.value.hat.hat_mask);
|
binding.value.hat.hat_mask);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return out;
|
return {};
|
||||||
};
|
}
|
||||||
|
|
||||||
Common::ParamPackage BuildParamPackageForAnalog(int port, const std::string& guid, int axis_x,
|
Common::ParamPackage BuildParamPackageForAnalog(int port, const std::string& guid, int axis_x,
|
||||||
int axis_y) {
|
int axis_y) {
|
||||||
Common::ParamPackage params{};
|
Common::ParamPackage params;
|
||||||
params.Set("engine", "sdl");
|
params.Set("engine", "sdl");
|
||||||
params.Set("port", port);
|
params.Set("port", port);
|
||||||
params.Set("guid", guid);
|
params.Set("guid", guid);
|
||||||
@ -769,7 +757,7 @@ class SDLPoller : public InputCommon::Polling::DevicePoller {
|
|||||||
public:
|
public:
|
||||||
explicit SDLPoller(SDLState& state_) : state(state_) {}
|
explicit SDLPoller(SDLState& state_) : state(state_) {}
|
||||||
|
|
||||||
void Start(std::string device_id) override {
|
void Start(const std::string& device_id) override {
|
||||||
state.event_queue.Clear();
|
state.event_queue.Clear();
|
||||||
state.polling = true;
|
state.polling = true;
|
||||||
}
|
}
|
||||||
@ -821,7 +809,7 @@ public:
|
|||||||
explicit SDLAnalogPreferredPoller(SDLState& state_)
|
explicit SDLAnalogPreferredPoller(SDLState& state_)
|
||||||
: SDLPoller(state_), button_poller(state_) {}
|
: SDLPoller(state_), button_poller(state_) {}
|
||||||
|
|
||||||
void Start(std::string device_id) override {
|
void Start(const std::string& device_id) override {
|
||||||
SDLPoller::Start(device_id);
|
SDLPoller::Start(device_id);
|
||||||
// Load the game controller
|
// Load the game controller
|
||||||
// Reset stored axes
|
// Reset stored axes
|
||||||
|
@ -89,10 +89,9 @@ State::~State() {
|
|||||||
Input::UnregisterFactory<Input::MotionDevice>("cemuhookudp");
|
Input::UnregisterFactory<Input::MotionDevice>("cemuhookudp");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Common::ParamPackage> State::GetInputDevices() {
|
std::vector<Common::ParamPackage> State::GetInputDevices() const {
|
||||||
std::vector<Common::ParamPackage> devices = {};
|
|
||||||
// TODO support binding udp devices
|
// TODO support binding udp devices
|
||||||
return devices;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void State::ReloadUDPClient() {
|
void State::ReloadUDPClient() {
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
State();
|
State();
|
||||||
~State();
|
~State();
|
||||||
void ReloadUDPClient();
|
void ReloadUDPClient();
|
||||||
std::vector<Common::ParamPackage> GetInputDevices();
|
std::vector<Common::ParamPackage> GetInputDevices() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Client> client;
|
std::unique_ptr<Client> client;
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
#include "yuzu/configuration/configure_debug_controller.h"
|
#include "yuzu/configuration/configure_debug_controller.h"
|
||||||
|
|
||||||
ConfigureDebugController::ConfigureDebugController(QWidget* parent)
|
ConfigureDebugController::ConfigureDebugController(QWidget* parent)
|
||||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigureDebugController>()) {
|
: QDialog(parent), ui(std::make_unique<Ui::ConfigureDebugController>()),
|
||||||
|
debug_controller(new ConfigureInputPlayer(this, 9, nullptr, true)) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
debug_controller = new ConfigureInputPlayer(this, 9, nullptr, true);
|
|
||||||
ui->controllerLayout->addWidget(debug_controller);
|
ui->controllerLayout->addWidget(debug_controller);
|
||||||
|
|
||||||
connect(ui->clear_all_button, &QPushButton::clicked, this,
|
connect(ui->clear_all_button, &QPushButton::clicked, this,
|
||||||
|
@ -27,7 +27,7 @@ private:
|
|||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
|
|
||||||
ConfigureInputPlayer* debug_controller;
|
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureDebugController> ui;
|
std::unique_ptr<Ui::ConfigureDebugController> ui;
|
||||||
|
|
||||||
|
ConfigureInputPlayer* debug_controller;
|
||||||
};
|
};
|
||||||
|
@ -103,13 +103,14 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputDevices,
|
connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputDevices,
|
||||||
[&] { UpdateAllInputDevices(); });
|
[this] { UpdateAllInputDevices(); });
|
||||||
connect(player_connected[i], &QCheckBox::stateChanged,
|
connect(player_connected[i], &QCheckBox::stateChanged, [this, i](int state) {
|
||||||
[&, i](int state) { player_controllers[i]->ConnectPlayer(state == Qt::Checked); });
|
player_controllers[i]->ConnectPlayer(state == Qt::Checked);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Only the first player can choose handheld mode so connect the signal just to player 1
|
// Only the first player can choose handheld mode so connect the signal just to player 1
|
||||||
connect(player_controllers[0], &ConfigureInputPlayer::HandheldStateChanged,
|
connect(player_controllers[0], &ConfigureInputPlayer::HandheldStateChanged,
|
||||||
[&](bool is_handheld) { UpdateDockedState(is_handheld); });
|
[this](bool is_handheld) { UpdateDockedState(is_handheld); });
|
||||||
|
|
||||||
advanced = new ConfigureInputAdvanced(this);
|
advanced = new ConfigureInputAdvanced(this);
|
||||||
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
|
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
|
||||||
@ -182,14 +183,14 @@ void ConfigureInput::LoadPlayerControllerIndices() {
|
|||||||
void ConfigureInput::ClearAll() {
|
void ConfigureInput::ClearAll() {
|
||||||
// We don't have a good way to know what tab is active, but we can find out by getting the
|
// We don't have a good way to know what tab is active, but we can find out by getting the
|
||||||
// parent of the consoleInputSettings
|
// parent of the consoleInputSettings
|
||||||
auto player_tab = static_cast<ConfigureInputPlayer*>(ui->consoleInputSettings->parent());
|
auto* player_tab = static_cast<ConfigureInputPlayer*>(ui->consoleInputSettings->parent());
|
||||||
player_tab->ClearAll();
|
player_tab->ClearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureInput::RestoreDefaults() {
|
void ConfigureInput::RestoreDefaults() {
|
||||||
// We don't have a good way to know what tab is active, but we can find out by getting the
|
// We don't have a good way to know what tab is active, but we can find out by getting the
|
||||||
// parent of the consoleInputSettings
|
// parent of the consoleInputSettings
|
||||||
auto player_tab = static_cast<ConfigureInputPlayer*>(ui->consoleInputSettings->parent());
|
auto* player_tab = static_cast<ConfigureInputPlayer*>(ui->consoleInputSettings->parent());
|
||||||
player_tab->RestoreDefaults();
|
player_tab->RestoreDefaults();
|
||||||
|
|
||||||
ui->radioDocked->setChecked(true);
|
ui->radioDocked->setChecked(true);
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
#include "ui_configure_input.h"
|
#include "ui_configure_input.h"
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
class QString;
|
class QString;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class QCheckBox;
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureInput;
|
class ConfigureInput;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "yuzu/configuration/configure_input_advanced.h"
|
#include "yuzu/configuration/configure_input_advanced.h"
|
||||||
|
|
||||||
ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent)
|
ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent)
|
||||||
: QWidget(parent), ui(new Ui::ConfigureInputAdvanced) {
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputAdvanced>()) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
controllers_color_buttons = {{
|
controllers_color_buttons = {{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
@ -348,22 +348,22 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
|
|
||||||
// Player Connected checkbox
|
// Player Connected checkbox
|
||||||
connect(ui->groupConnectedController, &QGroupBox::toggled,
|
connect(ui->groupConnectedController, &QGroupBox::toggled,
|
||||||
[&](bool checked) { emit Connected(checked); });
|
[this](bool checked) { emit Connected(checked); });
|
||||||
|
|
||||||
// Set up controller type. Only Player 1 can choose Handheld.
|
// Set up controller type. Only Player 1 can choose Handheld.
|
||||||
ui->comboControllerType->clear();
|
ui->comboControllerType->clear();
|
||||||
|
|
||||||
QStringList controller_types = {
|
QStringList controller_types = {
|
||||||
QStringLiteral("Pro Controller"),
|
tr("Pro Controller"),
|
||||||
QStringLiteral("Dual Joycons"),
|
tr("Dual Joycons"),
|
||||||
QStringLiteral("Left Joycon"),
|
tr("Left Joycon"),
|
||||||
QStringLiteral("Right Joycon"),
|
tr("Right Joycon"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (player_index == 0) {
|
if (player_index == 0) {
|
||||||
controller_types.append(QStringLiteral("Handheld"));
|
controller_types.append(tr("Handheld"));
|
||||||
connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged),
|
connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||||
[&](int index) {
|
[this](int index) {
|
||||||
emit HandheldStateChanged(GetControllerTypeFromIndex(index) ==
|
emit HandheldStateChanged(GetControllerTypeFromIndex(index) ==
|
||||||
Settings::ControllerType::Handheld);
|
Settings::ControllerType::Handheld);
|
||||||
});
|
});
|
||||||
@ -375,7 +375,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
ui->buttonHome->setEnabled(false);
|
ui->buttonHome->setEnabled(false);
|
||||||
ui->groupConnectedController->setCheckable(false);
|
ui->groupConnectedController->setCheckable(false);
|
||||||
QStringList debug_controller_types = {
|
QStringList debug_controller_types = {
|
||||||
QStringLiteral("Pro Controller"),
|
tr("Pro Controller"),
|
||||||
};
|
};
|
||||||
ui->comboControllerType->addItems(debug_controller_types);
|
ui->comboControllerType->addItems(debug_controller_types);
|
||||||
} else {
|
} else {
|
||||||
@ -384,17 +384,18 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
|
|||||||
|
|
||||||
UpdateControllerIcon();
|
UpdateControllerIcon();
|
||||||
UpdateControllerAvailableButtons();
|
UpdateControllerAvailableButtons();
|
||||||
connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [&](int) {
|
connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [this](int) {
|
||||||
UpdateControllerIcon();
|
UpdateControllerIcon();
|
||||||
UpdateControllerAvailableButtons();
|
UpdateControllerAvailableButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->comboDevices, qOverload<int>(&QComboBox::currentIndexChanged),
|
connect(ui->comboDevices, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||||
[&] { UpdateMappingWithDefaults(); });
|
&ConfigureInputPlayer::UpdateMappingWithDefaults);
|
||||||
|
|
||||||
ui->buttonRefreshDevices->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
|
ui->buttonRefreshDevices->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
|
||||||
UpdateInputDevices();
|
UpdateInputDevices();
|
||||||
connect(ui->buttonRefreshDevices, &QPushButton::clicked, [&] { emit RefreshInputDevices(); });
|
connect(ui->buttonRefreshDevices, &QPushButton::clicked,
|
||||||
|
[this] { emit RefreshInputDevices(); });
|
||||||
|
|
||||||
timeout_timer->setSingleShot(true);
|
timeout_timer->setSingleShot(true);
|
||||||
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
|
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
|
||||||
@ -707,26 +708,22 @@ void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
|
|||||||
void ConfigureInputPlayer::UpdateControllerIcon() {
|
void ConfigureInputPlayer::UpdateControllerIcon() {
|
||||||
// We aren't using Qt's built in theme support here since we aren't drawing an icon (and its
|
// 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)
|
// "nonstandard" to use an image through the icon support)
|
||||||
QString stylesheet{};
|
const QString stylesheet = [this] {
|
||||||
switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) {
|
switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) {
|
||||||
case Settings::ControllerType::ProController:
|
case Settings::ControllerType::ProController:
|
||||||
stylesheet = QStringLiteral("image: url(:/controller/pro_controller%0)");
|
return QStringLiteral("image: url(:/controller/pro_controller%0)");
|
||||||
break;
|
case Settings::ControllerType::DualJoyconDetached:
|
||||||
case Settings::ControllerType::DualJoyconDetached:
|
return QStringLiteral("image: url(:/controller/dual_joycon%0)");
|
||||||
stylesheet = QStringLiteral("image: url(:/controller/dual_joycon%0)");
|
case Settings::ControllerType::LeftJoycon:
|
||||||
break;
|
return QStringLiteral("image: url(:/controller/single_joycon_left_vertical%0)");
|
||||||
case Settings::ControllerType::LeftJoycon:
|
case Settings::ControllerType::RightJoycon:
|
||||||
stylesheet = QStringLiteral("image: url(:/controller/single_joycon_left_vertical%0)");
|
return QStringLiteral("image: url(:/controller/single_joycon_right_vertical%0)");
|
||||||
break;
|
case Settings::ControllerType::Handheld:
|
||||||
case Settings::ControllerType::RightJoycon:
|
return QStringLiteral("image: url(:/controller/handheld%0)");
|
||||||
stylesheet = QStringLiteral("image: url(:/controller/single_joycon_right_vertical%0)");
|
default:
|
||||||
break;
|
return QString{};
|
||||||
case Settings::ControllerType::Handheld:
|
}
|
||||||
stylesheet = QStringLiteral("image: url(:/controller/handheld%0)");
|
}();
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString theme = [this] {
|
const QString theme = [this] {
|
||||||
if (QIcon::themeName().contains(QStringLiteral("dark"))) {
|
if (QIcon::themeName().contains(QStringLiteral("dark"))) {
|
||||||
@ -744,12 +741,12 @@ void ConfigureInputPlayer::UpdateControllerIcon() {
|
|||||||
void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
|
void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
|
||||||
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
|
auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
|
||||||
if (debug) {
|
if (debug) {
|
||||||
layout = Settings::ControllerType::DualJoyconDetached;
|
layout = Settings::ControllerType::ProController;
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of all the widgets that will be hidden by any of the following layouts that need
|
// List of all the widgets that will be hidden by any of the following layouts that need
|
||||||
// "unhidden" after the controller type changes
|
// "unhidden" after the controller type changes
|
||||||
const std::vector<QWidget*> layout_show = {
|
const std::array<QWidget*, 9> layout_show = {
|
||||||
ui->buttonShoulderButtonsSLSR,
|
ui->buttonShoulderButtonsSLSR,
|
||||||
ui->horizontalSpacerShoulderButtonsWidget,
|
ui->horizontalSpacerShoulderButtonsWidget,
|
||||||
ui->horizontalSpacerShoulderButtonsWidget2,
|
ui->horizontalSpacerShoulderButtonsWidget2,
|
||||||
@ -768,11 +765,6 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() {
|
|||||||
std::vector<QWidget*> layout_hidden;
|
std::vector<QWidget*> layout_hidden;
|
||||||
switch (layout) {
|
switch (layout) {
|
||||||
case Settings::ControllerType::ProController:
|
case Settings::ControllerType::ProController:
|
||||||
layout_hidden = {
|
|
||||||
ui->buttonShoulderButtonsSLSR,
|
|
||||||
ui->horizontalSpacerShoulderButtonsWidget2,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case Settings::ControllerType::DualJoyconDetached:
|
case Settings::ControllerType::DualJoyconDetached:
|
||||||
case Settings::ControllerType::Handheld:
|
case Settings::ControllerType::Handheld:
|
||||||
layout_hidden = {
|
layout_hidden = {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/settings.h"
|
|
||||||
|
|
||||||
namespace UISettings {
|
namespace UISettings {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user