summaryrefslogtreecommitdiffstats
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-08-10 01:21:23 +0200
committerGitHub <noreply@github.com>2022-08-10 01:21:23 +0200
commit0069b5e118dbc91f2a8b3c30612ea223864c6527 (patch)
tree2103bb82bf7fe9e9669dc4a9992af8621a64cece /src/core/hid/emulated_controller.cpp
parentMerge pull request #8729 from merryhime/cp15-barriers (diff)
parenthid: core: Properly emulate controller color and battery level (diff)
downloadyuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar
yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar.gz
yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar.bz2
yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar.lz
yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar.xz
yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar.zst
yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.zip
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
-rw-r--r--src/core/hid/emulated_controller.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 8c3895937..085ff3fda 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -84,18 +84,19 @@ void EmulatedController::ReloadFromSettings() {
motion_params[index] = Common::ParamPackage(player.motions[index]);
}
+ controller.colors_state.fullkey = {
+ .body = GetNpadColor(player.body_color_left),
+ .button = GetNpadColor(player.button_color_left),
+ };
controller.colors_state.left = {
- .body = player.body_color_left,
- .button = player.button_color_left,
+ .body = GetNpadColor(player.body_color_left),
+ .button = GetNpadColor(player.button_color_left),
};
-
- controller.colors_state.right = {
- .body = player.body_color_right,
- .button = player.button_color_right,
+ controller.colors_state.left = {
+ .body = GetNpadColor(player.body_color_right),
+ .button = GetNpadColor(player.button_color_right),
};
- controller.colors_state.fullkey = controller.colors_state.left;
-
// Other or debug controller should always be a pro controller
if (npad_id_type != NpadIdType::Other) {
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
@@ -1310,6 +1311,15 @@ const CameraState& EmulatedController::GetCamera() const {
return controller.camera_state;
}
+NpadColor EmulatedController::GetNpadColor(u32 color) {
+ return {
+ .r = static_cast<u8>((color >> 16) & 0xFF),
+ .g = static_cast<u8>((color >> 8) & 0xFF),
+ .b = static_cast<u8>(color & 0xFF),
+ .a = 0xff,
+ };
+}
+
void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) {
std::scoped_lock lock{callback_mutex};
for (const auto& poller_pair : callback_list) {