mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-12 18:34:21 +01:00
Merge pull request #11965 from german77/color
core: hid: Signal color updates
This commit is contained in:
commit
770d4b0b72
@ -96,18 +96,7 @@ void EmulatedController::ReloadFromSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
controller.color_values = {};
|
controller.color_values = {};
|
||||||
controller.colors_state.fullkey = {
|
ReloadColorsFromSettings();
|
||||||
.body = GetNpadColor(player.body_color_left),
|
|
||||||
.button = GetNpadColor(player.button_color_left),
|
|
||||||
};
|
|
||||||
controller.colors_state.left = {
|
|
||||||
.body = GetNpadColor(player.body_color_left),
|
|
||||||
.button = GetNpadColor(player.button_color_left),
|
|
||||||
};
|
|
||||||
controller.colors_state.right = {
|
|
||||||
.body = GetNpadColor(player.body_color_right),
|
|
||||||
.button = GetNpadColor(player.button_color_right),
|
|
||||||
};
|
|
||||||
|
|
||||||
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
|
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
|
||||||
|
|
||||||
@ -128,6 +117,30 @@ void EmulatedController::ReloadFromSettings() {
|
|||||||
ReloadInput();
|
ReloadInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmulatedController::ReloadColorsFromSettings() {
|
||||||
|
const auto player_index = NpadIdTypeToIndex(npad_id_type);
|
||||||
|
const auto& player = Settings::values.players.GetValue()[player_index];
|
||||||
|
|
||||||
|
// Avoid updating colors if overridden by physical controller
|
||||||
|
if (controller.color_values[LeftIndex].body != 0 &&
|
||||||
|
controller.color_values[RightIndex].body != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.colors_state.fullkey = {
|
||||||
|
.body = GetNpadColor(player.body_color_left),
|
||||||
|
.button = GetNpadColor(player.button_color_left),
|
||||||
|
};
|
||||||
|
controller.colors_state.left = {
|
||||||
|
.body = GetNpadColor(player.body_color_left),
|
||||||
|
.button = GetNpadColor(player.button_color_left),
|
||||||
|
};
|
||||||
|
controller.colors_state.right = {
|
||||||
|
.body = GetNpadColor(player.body_color_right),
|
||||||
|
.button = GetNpadColor(player.button_color_right),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void EmulatedController::LoadDevices() {
|
void EmulatedController::LoadDevices() {
|
||||||
// TODO(german77): Use more buttons to detect the correct device
|
// TODO(german77): Use more buttons to detect the correct device
|
||||||
const auto left_joycon = button_params[Settings::NativeButton::DRight];
|
const auto left_joycon = button_params[Settings::NativeButton::DRight];
|
||||||
|
@ -253,6 +253,9 @@ public:
|
|||||||
/// Overrides current mapped devices with the stored configuration and reloads all input devices
|
/// Overrides current mapped devices with the stored configuration and reloads all input devices
|
||||||
void ReloadFromSettings();
|
void ReloadFromSettings();
|
||||||
|
|
||||||
|
/// Updates current colors with the ones stored in the configuration
|
||||||
|
void ReloadColorsFromSettings();
|
||||||
|
|
||||||
/// Saves the current mapped configuration
|
/// Saves the current mapped configuration
|
||||||
void SaveCurrentConfig();
|
void SaveCurrentConfig();
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
|
|||||||
connect(player_controllers[0], &ConfigureInputPlayer::HandheldStateChanged,
|
connect(player_controllers[0], &ConfigureInputPlayer::HandheldStateChanged,
|
||||||
[this](bool is_handheld) { UpdateDockedState(is_handheld); });
|
[this](bool is_handheld) { UpdateDockedState(is_handheld); });
|
||||||
|
|
||||||
advanced = new ConfigureInputAdvanced(this);
|
advanced = new ConfigureInputAdvanced(hid_core, this);
|
||||||
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
|
ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced));
|
||||||
ui->tabAdvanced->layout()->addWidget(advanced);
|
ui->tabAdvanced->layout()->addWidget(advanced);
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
#include "core/hid/emulated_controller.h"
|
||||||
|
#include "core/hid/hid_core.h"
|
||||||
#include "ui_configure_input_advanced.h"
|
#include "ui_configure_input_advanced.h"
|
||||||
#include "yuzu/configuration/configure_input_advanced.h"
|
#include "yuzu/configuration/configure_input_advanced.h"
|
||||||
|
|
||||||
ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent)
|
ConfigureInputAdvanced::ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QWidget* parent)
|
||||||
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputAdvanced>()) {
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInputAdvanced>()), hid_core{hid_core_} {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
controllers_color_buttons = {{
|
controllers_color_buttons = {{
|
||||||
@ -123,6 +125,8 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
|
|||||||
player.button_color_left = colors[1];
|
player.button_color_left = colors[1];
|
||||||
player.body_color_right = colors[2];
|
player.body_color_right = colors[2];
|
||||||
player.button_color_right = colors[3];
|
player.button_color_right = colors[3];
|
||||||
|
|
||||||
|
hid_core.GetEmulatedControllerByIndex(player_idx)->ReloadColorsFromSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked();
|
Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked();
|
||||||
|
@ -14,11 +14,15 @@ namespace Ui {
|
|||||||
class ConfigureInputAdvanced;
|
class ConfigureInputAdvanced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Core::HID {
|
||||||
|
class HIDCore;
|
||||||
|
} // namespace Core::HID
|
||||||
|
|
||||||
class ConfigureInputAdvanced : public QWidget {
|
class ConfigureInputAdvanced : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConfigureInputAdvanced(QWidget* parent = nullptr);
|
explicit ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QWidget* parent = nullptr);
|
||||||
~ConfigureInputAdvanced() override;
|
~ConfigureInputAdvanced() override;
|
||||||
|
|
||||||
void ApplyConfiguration();
|
void ApplyConfiguration();
|
||||||
@ -44,4 +48,6 @@ private:
|
|||||||
|
|
||||||
std::array<std::array<QColor, 4>, 8> controllers_colors;
|
std::array<std::array<QColor, 4>, 8> controllers_colors;
|
||||||
std::array<std::array<QPushButton*, 4>, 8> controllers_color_buttons;
|
std::array<std::array<QPushButton*, 4>, 8> controllers_color_buttons;
|
||||||
|
|
||||||
|
Core::HID::HIDCore& hid_core;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user