diff options
| author | 2020-08-27 01:21:48 -0400 | |
|---|---|---|
| committer | 2020-09-04 12:23:25 -0400 | |
| commit | 5ce3015945e327751a053f7a5a1331a33f07819e (patch) | |
| tree | d12f57a8b573e466c2b5a18bf0a40a019782219a /src/core | |
| parent | Project Mjölnir: Part 2 - Controller Applet (diff) | |
| download | yuzu-5ce3015945e327751a053f7a5a1331a33f07819e.tar.gz yuzu-5ce3015945e327751a053f7a5a1331a33f07819e.tar.xz yuzu-5ce3015945e327751a053f7a5a1331a33f07819e.zip | |
applets/controller: Implement "Explain Text"
"Explain Text" is additional text that is shown for each player in the controller applet.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/frontend/applets/controller.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/controller.cpp | 37 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/controller.h | 5 |
3 files changed, 29 insertions, 16 deletions
diff --git a/src/core/frontend/applets/controller.h b/src/core/frontend/applets/controller.h index 0908f2b69..a227f15cd 100644 --- a/src/core/frontend/applets/controller.h +++ b/src/core/frontend/applets/controller.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | namespace Core::Frontend { | 11 | namespace Core::Frontend { |
| 12 | 12 | ||
| 13 | using BorderColor = std::array<u8, 4>; | 13 | using BorderColor = std::array<u8, 4>; |
| 14 | using ExplainText = std::array<char, 0x81>; | ||
| 14 | 15 | ||
| 15 | struct ControllerParameters { | 16 | struct ControllerParameters { |
| 16 | s8 min_players{}; | 17 | s8 min_players{}; |
| @@ -19,6 +20,8 @@ struct ControllerParameters { | |||
| 19 | bool enable_single_mode{}; | 20 | bool enable_single_mode{}; |
| 20 | bool enable_border_color{}; | 21 | bool enable_border_color{}; |
| 21 | std::vector<BorderColor> border_colors{}; | 22 | std::vector<BorderColor> border_colors{}; |
| 23 | bool enable_explain_text{}; | ||
| 24 | std::vector<ExplainText> explain_text{}; | ||
| 22 | bool allow_pro_controller{}; | 25 | bool allow_pro_controller{}; |
| 23 | bool allow_handheld{}; | 26 | bool allow_handheld{}; |
| 24 | bool allow_dual_joycons{}; | 27 | bool allow_dual_joycons{}; |
diff --git a/src/core/hle/service/am/applets/controller.cpp b/src/core/hle/service/am/applets/controller.cpp index 2a45a388f..63c85256d 100644 --- a/src/core/hle/service/am/applets/controller.cpp +++ b/src/core/hle/service/am/applets/controller.cpp | |||
| @@ -19,8 +19,8 @@ namespace Service::AM::Applets { | |||
| 19 | [[maybe_unused]] constexpr ResultCode ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102}; | 19 | [[maybe_unused]] constexpr ResultCode ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102}; |
| 20 | 20 | ||
| 21 | static Core::Frontend::ControllerParameters ConvertToFrontendParameters( | 21 | static Core::Frontend::ControllerParameters ConvertToFrontendParameters( |
| 22 | ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, | 22 | ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text, |
| 23 | std::vector<IdentificationColor> identification_colors) { | 23 | std::vector<IdentificationColor> identification_colors, std::vector<ExplainText> text) { |
| 24 | HID::Controller_NPad::NPadType npad_style_set; | 24 | HID::Controller_NPad::NPadType npad_style_set; |
| 25 | npad_style_set.raw = private_arg.style_set; | 25 | npad_style_set.raw = private_arg.style_set; |
| 26 | 26 | ||
| @@ -31,6 +31,8 @@ static Core::Frontend::ControllerParameters ConvertToFrontendParameters( | |||
| 31 | .enable_single_mode = header.enable_single_mode, | 31 | .enable_single_mode = header.enable_single_mode, |
| 32 | .enable_border_color = header.enable_identification_color, | 32 | .enable_border_color = header.enable_identification_color, |
| 33 | .border_colors = identification_colors, | 33 | .border_colors = identification_colors, |
| 34 | .enable_explain_text = enable_text, | ||
| 35 | .explain_text = text, | ||
| 34 | .allow_pro_controller = npad_style_set.pro_controller == 1, | 36 | .allow_pro_controller = npad_style_set.pro_controller == 1, |
| 35 | .allow_handheld = npad_style_set.handheld == 1, | 37 | .allow_handheld = npad_style_set.handheld == 1, |
| 36 | .allow_dual_joycons = npad_style_set.joycon_dual == 1, | 38 | .allow_dual_joycons = npad_style_set.joycon_dual == 1, |
| @@ -126,31 +128,38 @@ void Controller::Execute() { | |||
| 126 | case LibraryAppletVersion::Version5: | 128 | case LibraryAppletVersion::Version5: |
| 127 | return ConvertToFrontendParameters( | 129 | return ConvertToFrontendParameters( |
| 128 | controller_private_arg, controller_user_arg_old.header, | 130 | controller_private_arg, controller_user_arg_old.header, |
| 131 | controller_user_arg_old.enable_explain_text, | ||
| 129 | std::vector<IdentificationColor>( | 132 | std::vector<IdentificationColor>( |
| 130 | controller_user_arg_old.identification_colors.begin(), | 133 | controller_user_arg_old.identification_colors.begin(), |
| 131 | controller_user_arg_old.identification_colors.end())); | 134 | controller_user_arg_old.identification_colors.end()), |
| 135 | std::vector<ExplainText>(controller_user_arg_old.explain_text.begin(), | ||
| 136 | controller_user_arg_old.explain_text.end())); | ||
| 132 | case LibraryAppletVersion::Version7: | 137 | case LibraryAppletVersion::Version7: |
| 133 | default: | 138 | default: |
| 134 | return ConvertToFrontendParameters( | 139 | return ConvertToFrontendParameters( |
| 135 | controller_private_arg, controller_user_arg_new.header, | 140 | controller_private_arg, controller_user_arg_new.header, |
| 141 | controller_user_arg_new.enable_explain_text, | ||
| 136 | std::vector<IdentificationColor>( | 142 | std::vector<IdentificationColor>( |
| 137 | controller_user_arg_new.identification_colors.begin(), | 143 | controller_user_arg_new.identification_colors.begin(), |
| 138 | controller_user_arg_new.identification_colors.end())); | 144 | controller_user_arg_new.identification_colors.end()), |
| 145 | std::vector<ExplainText>(controller_user_arg_new.explain_text.begin(), | ||
| 146 | controller_user_arg_new.explain_text.end())); | ||
| 139 | } | 147 | } |
| 140 | }(); | 148 | }(); |
| 141 | 149 | ||
| 142 | is_single_mode = parameters.enable_single_mode; | 150 | is_single_mode = parameters.enable_single_mode; |
| 143 | 151 | ||
| 144 | LOG_DEBUG( | 152 | LOG_DEBUG(Service_HID, |
| 145 | Service_HID, | 153 | "Controller Parameters: min_players={}, max_players={}, " |
| 146 | "Controller Parameters: min_players={}, max_players={}, keep_controllers_connected={}, " | 154 | "keep_controllers_connected={}, enable_single_mode={}, enable_border_color={}, " |
| 147 | "enable_single_mode={}, enable_border_color={}, allow_pro_controller={}, " | 155 | "enable_explain_text={}, allow_pro_controller={}, allow_handheld={}, " |
| 148 | "allow_handheld={}, allow_dual_joycons={}, allow_left_joycon={}, allow_right_joycon={}", | 156 | "allow_dual_joycons={}, allow_left_joycon={}, allow_right_joycon={}", |
| 149 | parameters.min_players, parameters.max_players, parameters.keep_controllers_connected, | 157 | parameters.min_players, parameters.max_players, |
| 150 | parameters.enable_single_mode, parameters.enable_border_color, | 158 | parameters.keep_controllers_connected, parameters.enable_single_mode, |
| 151 | parameters.allow_pro_controller, parameters.allow_handheld, | 159 | parameters.enable_border_color, parameters.enable_explain_text, |
| 152 | parameters.allow_dual_joycons, parameters.allow_left_joycon, | 160 | parameters.allow_pro_controller, parameters.allow_handheld, |
| 153 | parameters.allow_right_joycon); | 161 | parameters.allow_dual_joycons, parameters.allow_left_joycon, |
| 162 | parameters.allow_right_joycon); | ||
| 154 | 163 | ||
| 155 | frontend.ReconfigureControllers([this] { ConfigurationComplete(); }, parameters); | 164 | frontend.ReconfigureControllers([this] { ConfigurationComplete(); }, parameters); |
| 156 | break; | 165 | break; |
diff --git a/src/core/hle/service/am/applets/controller.h b/src/core/hle/service/am/applets/controller.h index 90a78d508..31ba2af4f 100644 --- a/src/core/hle/service/am/applets/controller.h +++ b/src/core/hle/service/am/applets/controller.h | |||
| @@ -16,6 +16,7 @@ class System; | |||
| 16 | namespace Service::AM::Applets { | 16 | namespace Service::AM::Applets { |
| 17 | 17 | ||
| 18 | using IdentificationColor = std::array<u8, 4>; | 18 | using IdentificationColor = std::array<u8, 4>; |
| 19 | using ExplainText = std::array<char, 0x81>; | ||
| 19 | 20 | ||
| 20 | enum class LibraryAppletVersion : u32_le { | 21 | enum class LibraryAppletVersion : u32_le { |
| 21 | Version3 = 0x3, // 1.0.0 - 2.3.0 | 22 | Version3 = 0x3, // 1.0.0 - 2.3.0 |
| @@ -65,7 +66,7 @@ struct ControllerSupportArgOld { | |||
| 65 | ControllerSupportArgHeader header{}; | 66 | ControllerSupportArgHeader header{}; |
| 66 | std::array<IdentificationColor, 4> identification_colors{}; | 67 | std::array<IdentificationColor, 4> identification_colors{}; |
| 67 | bool enable_explain_text{}; | 68 | bool enable_explain_text{}; |
| 68 | std::array<std::array<char, 0x81>, 4> explain_text{}; | 69 | std::array<ExplainText, 4> explain_text{}; |
| 69 | }; | 70 | }; |
| 70 | static_assert(sizeof(ControllerSupportArgOld) == 0x21C, | 71 | static_assert(sizeof(ControllerSupportArgOld) == 0x21C, |
| 71 | "ControllerSupportArgOld has incorrect size."); | 72 | "ControllerSupportArgOld has incorrect size."); |
| @@ -75,7 +76,7 @@ struct ControllerSupportArgNew { | |||
| 75 | ControllerSupportArgHeader header{}; | 76 | ControllerSupportArgHeader header{}; |
| 76 | std::array<IdentificationColor, 8> identification_colors{}; | 77 | std::array<IdentificationColor, 8> identification_colors{}; |
| 77 | bool enable_explain_text{}; | 78 | bool enable_explain_text{}; |
| 78 | std::array<std::array<char, 0x81>, 8> explain_text{}; | 79 | std::array<ExplainText, 8> explain_text{}; |
| 79 | }; | 80 | }; |
| 80 | static_assert(sizeof(ControllerSupportArgNew) == 0x430, | 81 | static_assert(sizeof(ControllerSupportArgNew) == 0x430, |
| 81 | "ControllerSupportArgNew has incorrect size."); | 82 | "ControllerSupportArgNew has incorrect size."); |