summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-11-05 04:26:24 +0100
committerGitHub <noreply@github.com>2023-11-05 04:26:24 +0100
commit770d4b0b721be88bea327c8164b1f62ffbcc1d90 (patch)
treef45c4f1525d92af472806507bbbe778f03da18a8 /src/core
parentMerge pull request #11963 from Kelebek1/eol_lf (diff)
parentcore: hid: Signal color updates (diff)
downloadyuzu-770d4b0b721be88bea327c8164b1f62ffbcc1d90.tar
yuzu-770d4b0b721be88bea327c8164b1f62ffbcc1d90.tar.gz
yuzu-770d4b0b721be88bea327c8164b1f62ffbcc1d90.tar.bz2
yuzu-770d4b0b721be88bea327c8164b1f62ffbcc1d90.tar.lz
yuzu-770d4b0b721be88bea327c8164b1f62ffbcc1d90.tar.xz
yuzu-770d4b0b721be88bea327c8164b1f62ffbcc1d90.tar.zst
yuzu-770d4b0b721be88bea327c8164b1f62ffbcc1d90.zip
Diffstat (limited to '')
-rw-r--r--src/core/hid/emulated_controller.cpp37
-rw-r--r--src/core/hid/emulated_controller.h3
2 files changed, 28 insertions, 12 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 8e2894449..b08a71446 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -96,18 +96,7 @@ void EmulatedController::ReloadFromSettings() {
}
controller.color_values = {};
- 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),
- };
+ ReloadColorsFromSettings();
ring_params[0] = Common::ParamPackage(Settings::values.ringcon_analogs);
@@ -128,6 +117,30 @@ void EmulatedController::ReloadFromSettings() {
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() {
// TODO(german77): Use more buttons to detect the correct device
const auto left_joycon = button_params[Settings::NativeButton::DRight];
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index d4500583e..ea18c2343 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -253,6 +253,9 @@ public:
/// Overrides current mapped devices with the stored configuration and reloads all input devices
void ReloadFromSettings();
+ /// Updates current colors with the ones stored in the configuration
+ void ReloadColorsFromSettings();
+
/// Saves the current mapped configuration
void SaveCurrentConfig();