diff options
| author | 2022-11-13 15:14:08 -0600 | |
|---|---|---|
| committer | 2022-11-13 17:13:43 -0600 | |
| commit | 75e6ec85e107d6e5422d882b97faaa813970d42e (patch) | |
| tree | fede32c546409e0f876c9ba7142da39eb4caf9c1 /src/core | |
| parent | service: am: Fix cabinet applet result (diff) | |
| download | yuzu-75e6ec85e107d6e5422d882b97faaa813970d42e.tar.gz yuzu-75e6ec85e107d6e5422d882b97faaa813970d42e.tar.xz yuzu-75e6ec85e107d6e5422d882b97faaa813970d42e.zip | |
general: Address review comments
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/frontend/applets/cabinet.cpp | 2 | ||||
| -rw-r--r-- | src/core/frontend/applets/cabinet.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applet_cabinet.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applet_cabinet.h | 11 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp_device.cpp | 4 |
5 files changed, 22 insertions, 18 deletions
diff --git a/src/core/frontend/applets/cabinet.cpp b/src/core/frontend/applets/cabinet.cpp index 5ade75de0..26c7fefe3 100644 --- a/src/core/frontend/applets/cabinet.cpp +++ b/src/core/frontend/applets/cabinet.cpp | |||
| @@ -11,7 +11,7 @@ namespace Core::Frontend { | |||
| 11 | CabinetApplet::~CabinetApplet() = default; | 11 | CabinetApplet::~CabinetApplet() = default; |
| 12 | 12 | ||
| 13 | void DefaultCabinetApplet::ShowCabinetApplet( | 13 | void DefaultCabinetApplet::ShowCabinetApplet( |
| 14 | std::function<void(bool, const std::string&)> callback, const CabinetParameters& parameters, | 14 | const CabinetCallback& callback, const CabinetParameters& parameters, |
| 15 | std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const { | 15 | std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const { |
| 16 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 16 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 17 | callback(false, {}); | 17 | callback(false, {}); |
diff --git a/src/core/frontend/applets/cabinet.h b/src/core/frontend/applets/cabinet.h index 1c68bf57d..c28a235c1 100644 --- a/src/core/frontend/applets/cabinet.h +++ b/src/core/frontend/applets/cabinet.h | |||
| @@ -18,18 +18,19 @@ struct CabinetParameters { | |||
| 18 | Service::NFP::CabinetMode mode; | 18 | Service::NFP::CabinetMode mode; |
| 19 | }; | 19 | }; |
| 20 | 20 | ||
| 21 | using CabinetCallback = std::function<void(bool, const std::string&)>; | ||
| 22 | |||
| 21 | class CabinetApplet { | 23 | class CabinetApplet { |
| 22 | public: | 24 | public: |
| 23 | virtual ~CabinetApplet(); | 25 | virtual ~CabinetApplet(); |
| 24 | virtual void ShowCabinetApplet(std::function<void(bool, const std::string&)> callback, | 26 | virtual void ShowCabinetApplet(const CabinetCallback& callback, |
| 25 | const CabinetParameters& parameters, | 27 | const CabinetParameters& parameters, |
| 26 | std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const = 0; | 28 | std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const = 0; |
| 27 | }; | 29 | }; |
| 28 | 30 | ||
| 29 | class DefaultCabinetApplet final : public CabinetApplet { | 31 | class DefaultCabinetApplet final : public CabinetApplet { |
| 30 | public: | 32 | public: |
| 31 | void ShowCabinetApplet(std::function<void(bool, const std::string&)> callback, | 33 | void ShowCabinetApplet(const CabinetCallback& callback, const CabinetParameters& parameters, |
| 32 | const CabinetParameters& parameters, | ||
| 33 | std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override; | 34 | std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override; |
| 34 | }; | 35 | }; |
| 35 | 36 | ||
diff --git a/src/core/hle/service/am/applets/applet_cabinet.cpp b/src/core/hle/service/am/applets/applet_cabinet.cpp index 01f577ab9..d0969b0f1 100644 --- a/src/core/hle/service/am/applets/applet_cabinet.cpp +++ b/src/core/hle/service/am/applets/applet_cabinet.cpp | |||
| @@ -98,7 +98,7 @@ void Cabinet::Execute() { | |||
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_name) { | 101 | void Cabinet::DisplayCompleted(bool apply_changes, std::string_view amiibo_name) { |
| 102 | Service::Mii::MiiManager manager; | 102 | Service::Mii::MiiManager manager; |
| 103 | ReturnValueForAmiiboSettings applet_output{}; | 103 | ReturnValueForAmiiboSettings applet_output{}; |
| 104 | 104 | ||
| @@ -118,7 +118,7 @@ void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_nam | |||
| 118 | switch (applet_input_common.applet_mode) { | 118 | switch (applet_input_common.applet_mode) { |
| 119 | case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: { | 119 | case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: { |
| 120 | Service::NFP::AmiiboName name{}; | 120 | Service::NFP::AmiiboName name{}; |
| 121 | memcpy(name.data(), amiibo_name.data(), std::min(amiibo_name.size(), name.size() - 1)); | 121 | std::memcpy(name.data(), amiibo_name.data(), std::min(amiibo_name.size(), name.size() - 1)); |
| 122 | nfp_device->SetNicknameAndOwner(name); | 122 | nfp_device->SetNicknameAndOwner(name); |
| 123 | break; | 123 | break; |
| 124 | } | 124 | } |
| @@ -142,12 +142,12 @@ void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_nam | |||
| 142 | const auto tag_result = nfp_device->GetTagInfo(applet_output.tag_info); | 142 | const auto tag_result = nfp_device->GetTagInfo(applet_output.tag_info); |
| 143 | nfp_device->Finalize(); | 143 | nfp_device->Finalize(); |
| 144 | 144 | ||
| 145 | if (reg_result.IsSuccess() && tag_result.IsSuccess()) { | 145 | if (reg_result.IsSuccess()) { |
| 146 | applet_output.result = CabinetResult::All; | 146 | applet_output.result |= CabinetResult::RegisterInfo; |
| 147 | } else if (reg_result.IsSuccess()) { | 147 | } |
| 148 | applet_output.result = CabinetResult::RegisterInfo; | 148 | |
| 149 | } else if (tag_result.IsSuccess()) { | 149 | if (tag_result.IsSuccess()) { |
| 150 | applet_output.result = CabinetResult::TagInfo; | 150 | applet_output.result |= CabinetResult::TagInfo; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | std::vector<u8> out_data(sizeof(ReturnValueForAmiiboSettings)); | 153 | std::vector<u8> out_data(sizeof(ReturnValueForAmiiboSettings)); |
diff --git a/src/core/hle/service/am/applets/applet_cabinet.h b/src/core/hle/service/am/applets/applet_cabinet.h index 8466d5997..84197a807 100644 --- a/src/core/hle/service/am/applets/applet_cabinet.h +++ b/src/core/hle/service/am/applets/applet_cabinet.h | |||
| @@ -25,16 +25,17 @@ class NfpDevice; | |||
| 25 | 25 | ||
| 26 | namespace Service::AM::Applets { | 26 | namespace Service::AM::Applets { |
| 27 | 27 | ||
| 28 | enum class CabinetAppletVersion : s32 { | 28 | enum class CabinetAppletVersion : u32 { |
| 29 | Version1 = 0x1, | 29 | Version1 = 0x1, |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | enum class CabinetResult : u8 { | 32 | enum class CabinetResult : u8 { |
| 33 | Cancel, | 33 | Cancel = 0, |
| 34 | TagInfo = 1 << 1, | 34 | TagInfo = 1 << 1, |
| 35 | RegisterInfo = 1 << 2, | 35 | RegisterInfo = 1 << 2, |
| 36 | All = TagInfo | RegisterInfo, | 36 | All = TagInfo | RegisterInfo, |
| 37 | }; | 37 | }; |
| 38 | DECLARE_ENUM_FLAG_OPERATORS(CabinetResult) | ||
| 38 | 39 | ||
| 39 | // This is nn::nfp::AmiiboSettingsStartParam | 40 | // This is nn::nfp::AmiiboSettingsStartParam |
| 40 | struct AmiiboSettingsStartParam { | 41 | struct AmiiboSettingsStartParam { |
| @@ -45,7 +46,7 @@ struct AmiiboSettingsStartParam { | |||
| 45 | static_assert(sizeof(AmiiboSettingsStartParam) == 0x30, | 46 | static_assert(sizeof(AmiiboSettingsStartParam) == 0x30, |
| 46 | "AmiiboSettingsStartParam is an invalid size"); | 47 | "AmiiboSettingsStartParam is an invalid size"); |
| 47 | 48 | ||
| 48 | #pragma pack(1) | 49 | #pragma pack(push, 1) |
| 49 | // This is nn::nfp::StartParamForAmiiboSettings | 50 | // This is nn::nfp::StartParamForAmiiboSettings |
| 50 | struct StartParamForAmiiboSettings { | 51 | struct StartParamForAmiiboSettings { |
| 51 | u8 param_1; | 52 | u8 param_1; |
| @@ -72,7 +73,7 @@ struct ReturnValueForAmiiboSettings { | |||
| 72 | }; | 73 | }; |
| 73 | static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x188, | 74 | static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x188, |
| 74 | "ReturnValueForAmiiboSettings is an invalid size"); | 75 | "ReturnValueForAmiiboSettings is an invalid size"); |
| 75 | #pragma pack() | 76 | #pragma pack(pop) |
| 76 | 77 | ||
| 77 | class Cabinet final : public Applet { | 78 | class Cabinet final : public Applet { |
| 78 | public: | 79 | public: |
| @@ -86,7 +87,7 @@ public: | |||
| 86 | Result GetStatus() const override; | 87 | Result GetStatus() const override; |
| 87 | void ExecuteInteractive() override; | 88 | void ExecuteInteractive() override; |
| 88 | void Execute() override; | 89 | void Execute() override; |
| 89 | void DisplayCompleted(bool apply_changes, const std::string& amiibo_name); | 90 | void DisplayCompleted(bool apply_changes, std::string_view amiibo_name); |
| 90 | void Cancel(); | 91 | void Cancel(); |
| 91 | 92 | ||
| 92 | private: | 93 | private: |
diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp index 2f9dfa9c2..e1bf90d7c 100644 --- a/src/core/hle/service/nfp/nfp_device.cpp +++ b/src/core/hle/service/nfp/nfp_device.cpp | |||
| @@ -148,7 +148,7 @@ void NfpDevice::Finalize() { | |||
| 148 | device_state = DeviceState::Unavailable; | 148 | device_state = DeviceState::Unavailable; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | Result NfpDevice::StartDetection([[maybe_unused]] TagProtocol allowed_protocol) { | 151 | Result NfpDevice::StartDetection(TagProtocol allowed_protocol) { |
| 152 | if (device_state != DeviceState::Initialized && device_state != DeviceState::TagRemoved) { | 152 | if (device_state != DeviceState::Initialized && device_state != DeviceState::TagRemoved) { |
| 153 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); | 153 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); |
| 154 | return WrongDeviceState; | 154 | return WrongDeviceState; |
| @@ -475,6 +475,8 @@ Result NfpDevice::OpenApplicationArea(u32 access_id) { | |||
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | Result NfpDevice::GetApplicationAreaId(u32& application_area_id) const { | 477 | Result NfpDevice::GetApplicationAreaId(u32& application_area_id) const { |
| 478 | application_area_id = {}; | ||
| 479 | |||
| 478 | if (device_state != DeviceState::TagMounted) { | 480 | if (device_state != DeviceState::TagMounted) { |
| 479 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); | 481 | LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); |
| 480 | if (device_state == DeviceState::TagRemoved) { | 482 | if (device_state == DeviceState::TagRemoved) { |