service: am: Fix cabinet applet result
This commit is contained in:
parent
9afadca5dc
commit
a253d1557d
|
@ -32,7 +32,7 @@ void Cabinet::Initialize() {
|
||||||
|
|
||||||
LOG_INFO(Service_HID, "Initializing Cabinet Applet.");
|
LOG_INFO(Service_HID, "Initializing Cabinet Applet.");
|
||||||
|
|
||||||
LOG_ERROR(Service_HID,
|
LOG_DEBUG(Service_HID,
|
||||||
"Initializing Applet with common_args: arg_version={}, lib_version={}, "
|
"Initializing Applet with common_args: arg_version={}, lib_version={}, "
|
||||||
"play_startup_sound={}, size={}, system_tick={}, theme_color={}",
|
"play_startup_sound={}, size={}, system_tick={}, theme_color={}",
|
||||||
common_args.arguments_version, common_args.library_version,
|
common_args.arguments_version, common_args.library_version,
|
||||||
|
@ -111,14 +111,14 @@ void Cabinet::DisplayCompleted(bool apply_changes, const std::string& amiibo_nam
|
||||||
Cancel();
|
Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nfp_device->GetCurrentState() != Service::NFP::DeviceState::TagFound) {
|
if (nfp_device->GetCurrentState() == Service::NFP::DeviceState::TagFound) {
|
||||||
nfp_device->Mount(Service::NFP::MountTarget::All);
|
nfp_device->Mount(Service::NFP::MountTarget::All);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (applet_input_common.applet_mode) {
|
switch (applet_input_common.applet_mode) {
|
||||||
case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: {
|
case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: {
|
||||||
Service::NFP::AmiiboName name{};
|
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);
|
nfp_device->SetNicknameAndOwner(name);
|
||||||
break;
|
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.device_handle = applet_input_common.device_handle;
|
||||||
applet_output.result = CabinetResult::Success;
|
applet_output.result = CabinetResult::Cancel;
|
||||||
nfp_device->GetRegisterInfo(applet_output.register_info);
|
const auto reg_result = nfp_device->GetRegisterInfo(applet_output.register_info);
|
||||||
nfp_device->GetTagInfo(applet_output.tag_info);
|
const auto tag_result = nfp_device->GetTagInfo(applet_output.tag_info);
|
||||||
nfp_device->Finalize();
|
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::vector<u8> out_data(sizeof(ReturnValueForAmiiboSettings));
|
||||||
std::memcpy(out_data.data(), &applet_output, sizeof(ReturnValueForAmiiboSettings));
|
std::memcpy(out_data.data(), &applet_output, sizeof(ReturnValueForAmiiboSettings));
|
||||||
|
|
||||||
|
|
|
@ -31,18 +31,21 @@ enum class CabinetAppletVersion : s32 {
|
||||||
|
|
||||||
enum class CabinetResult : u8 {
|
enum class CabinetResult : u8 {
|
||||||
Cancel,
|
Cancel,
|
||||||
Success,
|
TagInfo = 1 << 1,
|
||||||
|
RegisterInfo = 1 << 2,
|
||||||
|
All = TagInfo | RegisterInfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is nn::nfp::AmiiboSettingsStartParam
|
// This is nn::nfp::AmiiboSettingsStartParam
|
||||||
struct AmiiboSettingsStartParam {
|
struct AmiiboSettingsStartParam {
|
||||||
u64 device_handle;
|
u64 device_handle;
|
||||||
std::array<u8, 0x20> param_1;
|
std::array<u8, 0x20> param_1;
|
||||||
std::array<u8, 0x1> param_2;
|
u8 param_2;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(AmiiboSettingsStartParam) == 0x30,
|
static_assert(sizeof(AmiiboSettingsStartParam) == 0x30,
|
||||||
"AmiiboSettingsStartParam is an invalid size");
|
"AmiiboSettingsStartParam is an invalid size");
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
// This is nn::nfp::StartParamForAmiiboSettings
|
// This is nn::nfp::StartParamForAmiiboSettings
|
||||||
struct StartParamForAmiiboSettings {
|
struct StartParamForAmiiboSettings {
|
||||||
u8 param_1;
|
u8 param_1;
|
||||||
|
@ -53,7 +56,7 @@ struct StartParamForAmiiboSettings {
|
||||||
Service::NFP::TagInfo tag_info;
|
Service::NFP::TagInfo tag_info;
|
||||||
Service::NFP::RegisterInfo register_info;
|
Service::NFP::RegisterInfo register_info;
|
||||||
std::array<u8, 0x20> amiibo_settings_3;
|
std::array<u8, 0x20> amiibo_settings_3;
|
||||||
INSERT_PADDING_BYTES(0x20);
|
INSERT_PADDING_BYTES(0x24);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(StartParamForAmiiboSettings) == 0x1A8,
|
static_assert(sizeof(StartParamForAmiiboSettings) == 0x1A8,
|
||||||
"StartParamForAmiiboSettings is an invalid size");
|
"StartParamForAmiiboSettings is an invalid size");
|
||||||
|
@ -67,8 +70,9 @@ struct ReturnValueForAmiiboSettings {
|
||||||
Service::NFP::RegisterInfo register_info;
|
Service::NFP::RegisterInfo register_info;
|
||||||
INSERT_PADDING_BYTES(0x24);
|
INSERT_PADDING_BYTES(0x24);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x190,
|
static_assert(sizeof(ReturnValueForAmiiboSettings) == 0x188,
|
||||||
"ReturnValueForAmiiboSettings is an invalid size");
|
"ReturnValueForAmiiboSettings is an invalid size");
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
class Cabinet final : public Applet {
|
class Cabinet final : public Applet {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue