summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2022-11-13 20:59:00 +0100
committergerman77 <juangerman-13@hotmail.com>2022-11-13 21:25:00 +0100
commita253d1557d7d1fb1add6ae923ccb452d423d4547 (patch)
treecfa322a7656f340bb2fe53772bf5fedf309180f3 /src/core/hle/service/am
parentyuzu: Implement cabinet applet frontend (diff)
downloadyuzu-a253d1557d7d1fb1add6ae923ccb452d423d4547.tar
yuzu-a253d1557d7d1fb1add6ae923ccb452d423d4547.tar.gz
yuzu-a253d1557d7d1fb1add6ae923ccb452d423d4547.tar.bz2
yuzu-a253d1557d7d1fb1add6ae923ccb452d423d4547.tar.lz
yuzu-a253d1557d7d1fb1add6ae923ccb452d423d4547.tar.xz
yuzu-a253d1557d7d1fb1add6ae923ccb452d423d4547.tar.zst
yuzu-a253d1557d7d1fb1add6ae923ccb452d423d4547.zip
Diffstat (limited to 'src/core/hle/service/am')
-rw-r--r--src/core/hle/service/am/applets/applet_cabinet.cpp20
-rw-r--r--src/core/hle/service/am/applets/applet_cabinet.h12
2 files changed, 22 insertions, 10 deletions
diff --git a/src/core/hle/service/am/applets/applet_cabinet.cpp b/src/core/hle/service/am/applets/applet_cabinet.cpp
index 1eb5a9f22..01f577ab9 100644
--- a/src/core/hle/service/am/applets/applet_cabinet.cpp
+++ b/src/core/hle/service/am/applets/applet_cabinet.cpp
@@ -32,7 +32,7 @@ void Cabinet::Initialize() {
LOG_INFO(Service_HID, "Initializing Cabinet Applet.");
- LOG_ERROR(Service_HID,
+ LOG_DEBUG(Service_HID,
"Initializing Applet with common_args: arg_version={}, lib_version={}, "
"play_startup_sound={}, size={}, system_tick={}, theme_color={}",
common_args.arguments_version, common_args.library_version,
@@ -111,14 +111,14 @@ void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_nam
Cancel();
}
- if (nfp_device->GetCurrentState() != Service::NFP::DeviceState::TagFound) {
+ if (nfp_device->GetCurrentState() == Service::NFP::DeviceState::TagFound) {
nfp_device->Mount(Service::NFP::MountTarget::All);
}
switch (applet_input_common.applet_mode) {
case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: {
Service::NFP::AmiiboName name{};
- memccpy(name.data(), amiibo_name.data(), 0, name.size());
+ memcpy(name.data(), amiibo_name.data(), std::min(amiibo_name.size(), name.size() - 1));
nfp_device->SetNicknameAndOwner(name);
break;
}
@@ -137,11 +137,19 @@ void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_nam
}
applet_output.device_handle = applet_input_common.device_handle;
- applet_output.result = CabinetResult::Success;
- nfp_device->GetRegisterInfo(applet_output.register_info);
- nfp_device->GetTagInfo(applet_output.tag_info);
+ applet_output.result = CabinetResult::Cancel;
+ const auto reg_result = nfp_device->GetRegisterInfo(applet_output.register_info);
+ const auto tag_result = nfp_device->GetTagInfo(applet_output.tag_info);
nfp_device->Finalize();
+ if (reg_result.IsSuccess() && tag_result.IsSuccess()) {
+ applet_output.result = CabinetResult::All;
+ } else if (reg_result.IsSuccess()) {
+ applet_output.result = CabinetResult::RegisterInfo;
+ } else if (tag_result.IsSuccess()) {
+ applet_output.result = CabinetResult::TagInfo;
+ }
+
std::vector<u8> out_data(sizeof(ReturnValueForAmiiboSettings));
std::memcpy(out_data.data(), &applet_output, 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 2d3f22434..8466d5997 100644
--- a/src/core/hle/service/am/applets/applet_cabinet.h
+++ b/src/core/hle/service/am/applets/applet_cabinet.h
@@ -31,18 +31,21 @@ enum class CabinetAppletVersion : s32 {
enum class CabinetResult : u8 {
Cancel,
- Success,
+ TagInfo = 1 << 1,
+ RegisterInfo = 1 << 2,
+ All = TagInfo | RegisterInfo,
};
// This is nn::nfp::AmiiboSettingsStartParam
struct AmiiboSettingsStartParam {
u64 device_handle;
std::array<u8, 0x20> param_1;
- std::array<u8, 0x1> param_2;
+ u8 param_2;
};
static_assert(sizeof(AmiiboSettingsStartParam) == 0x30,
"AmiiboSettingsStartParam is an invalid size");
+#pragma pack(1)
// This is nn::nfp::StartParamForAmiiboSettings
struct StartParamForAmiiboSettings {
u8 param_1;
@@ -53,7 +56,7 @@ struct StartParamForAmiiboSettings {
Service::NFP::TagInfo tag_info;
Service::NFP::RegisterInfo register_info;
std::array<u8, 0x20> amiibo_settings_3;
- INSERT_PADDING_BYTES(0x20);
+ INSERT_PADDING_BYTES(0x24);
};
static_assert(sizeof(StartParamForAmiiboSettings) == 0x1A8,
"StartParamForAmiiboSettings is an invalid size");
@@ -67,8 +70,9 @@ struct ReturnValueForAmiiboSettings {
Service::NFP::RegisterInfo register_info;
INSERT_PADDING_BYTES(0x24);
};
-static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x190,
+static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x188,
"ReturnValueForAmiiboSettings is an invalid size");
+#pragma pack()
class Cabinet final : public Applet {
public: