diff options
| author | 2022-08-09 16:21:23 -0700 | |
|---|---|---|
| committer | 2022-08-09 16:21:23 -0700 | |
| commit | 0069b5e118dbc91f2a8b3c30612ea223864c6527 (patch) | |
| tree | 2103bb82bf7fe9e9669dc4a9992af8621a64cece /src/core/hid/emulated_controller.cpp | |
| parent | Merge pull request #8729 from merryhime/cp15-barriers (diff) | |
| parent | hid: core: Properly emulate controller color and battery level (diff) | |
| download | yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar.gz yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.tar.xz yuzu-0069b5e118dbc91f2a8b3c30612ea223864c6527.zip | |
Merge pull request #8724 from german77/no_alpha
hid: core: Properly emulate controller color and battery level
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 26 |
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() { | |||
| 84 | motion_params[index] = Common::ParamPackage(player.motions[index]); | 84 | motion_params[index] = Common::ParamPackage(player.motions[index]); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | controller.colors_state.fullkey = { | ||
| 88 | .body = GetNpadColor(player.body_color_left), | ||
| 89 | .button = GetNpadColor(player.button_color_left), | ||
| 90 | }; | ||
| 87 | controller.colors_state.left = { | 91 | controller.colors_state.left = { |
| 88 | .body = player.body_color_left, | 92 | .body = GetNpadColor(player.body_color_left), |
| 89 | .button = player.button_color_left, | 93 | .button = GetNpadColor(player.button_color_left), |
| 90 | }; | 94 | }; |
| 91 | 95 | controller.colors_state.left = { | |
| 92 | controller.colors_state.right = { | 96 | .body = GetNpadColor(player.body_color_right), |
| 93 | .body = player.body_color_right, | 97 | .button = GetNpadColor(player.button_color_right), |
| 94 | .button = player.button_color_right, | ||
| 95 | }; | 98 | }; |
| 96 | 99 | ||
| 97 | controller.colors_state.fullkey = controller.colors_state.left; | ||
| 98 | |||
| 99 | // Other or debug controller should always be a pro controller | 100 | // Other or debug controller should always be a pro controller |
| 100 | if (npad_id_type != NpadIdType::Other) { | 101 | if (npad_id_type != NpadIdType::Other) { |
| 101 | SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); | 102 | SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); |
| @@ -1310,6 +1311,15 @@ const CameraState& EmulatedController::GetCamera() const { | |||
| 1310 | return controller.camera_state; | 1311 | return controller.camera_state; |
| 1311 | } | 1312 | } |
| 1312 | 1313 | ||
| 1314 | NpadColor EmulatedController::GetNpadColor(u32 color) { | ||
| 1315 | return { | ||
| 1316 | .r = static_cast<u8>((color >> 16) & 0xFF), | ||
| 1317 | .g = static_cast<u8>((color >> 8) & 0xFF), | ||
| 1318 | .b = static_cast<u8>(color & 0xFF), | ||
| 1319 | .a = 0xff, | ||
| 1320 | }; | ||
| 1321 | } | ||
| 1322 | |||
| 1313 | void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) { | 1323 | void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) { |
| 1314 | std::scoped_lock lock{callback_mutex}; | 1324 | std::scoped_lock lock{callback_mutex}; |
| 1315 | for (const auto& poller_pair : callback_list) { | 1325 | for (const auto& poller_pair : callback_list) { |