diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2022-11-20 16:31:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-20 16:31:20 +0100 |
commit | db7bcd51ae09c4ef25e08096de563903f61e2380 (patch) | |
tree | 5ae9977b48e1aff118fae3ebffb215b0b4afa887 /src/core/hle/service/nfp/nfp_device.cpp | |
parent | service: nfc: Implement nfc user (diff) | |
parent | Merge pull request #9238 from german77/cabinet_applet (diff) | |
download | yuzu-db7bcd51ae09c4ef25e08096de563903f61e2380.tar yuzu-db7bcd51ae09c4ef25e08096de563903f61e2380.tar.gz yuzu-db7bcd51ae09c4ef25e08096de563903f61e2380.tar.bz2 yuzu-db7bcd51ae09c4ef25e08096de563903f61e2380.tar.lz yuzu-db7bcd51ae09c4ef25e08096de563903f61e2380.tar.xz yuzu-db7bcd51ae09c4ef25e08096de563903f61e2380.tar.zst yuzu-db7bcd51ae09c4ef25e08096de563903f61e2380.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/nfp/nfp_device.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp index 296603764..c860fd1a1 100644 --- a/src/core/hle/service/nfp/nfp_device.cpp +++ b/src/core/hle/service/nfp/nfp_device.cpp @@ -75,6 +75,9 @@ void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { LoadAmiibo(nfc_status.data); break; case Common::Input::NfcState::AmiiboRemoved: + if (device_state == DeviceState::Initialized || device_state == DeviceState::TagRemoved) { + break; + } if (device_state != DeviceState::SearchingForTag) { CloseAmiibo(); } @@ -95,6 +98,8 @@ bool NfpDevice::LoadAmiibo(std::span<const u8> data) { return false; } + // TODO: Filter by allowed_protocols here + memcpy(&encrypted_tag_data, data.data(), sizeof(EncryptedNTAG215File)); device_state = DeviceState::TagFound; @@ -141,7 +146,7 @@ void NfpDevice::Finalize() { device_state = DeviceState::Unavailable; } -Result NfpDevice::StartDetection(s32 protocol_) { +Result NfpDevice::StartDetection(TagProtocol allowed_protocol) { if (device_state != DeviceState::Initialized && device_state != DeviceState::TagRemoved) { LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); return WrongDeviceState; @@ -153,7 +158,7 @@ Result NfpDevice::StartDetection(s32 protocol_) { } device_state = DeviceState::SearchingForTag; - protocol = protocol_; + allowed_protocols = allowed_protocol; return ResultSuccess; } @@ -467,6 +472,32 @@ Result NfpDevice::OpenApplicationArea(u32 access_id) { return ResultSuccess; } +Result NfpDevice::GetApplicationAreaId(u32& application_area_id) const { + application_area_id = {}; + + if (device_state != DeviceState::TagMounted) { + LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); + if (device_state == DeviceState::TagRemoved) { + return TagRemoved; + } + return WrongDeviceState; + } + + if (mount_target == MountTarget::None || mount_target == MountTarget::Rom) { + LOG_ERROR(Service_NFP, "Amiibo is read only", device_state); + return WrongDeviceState; + } + + if (tag_data.settings.settings.appdata_initialized.Value() == 0) { + LOG_WARNING(Service_NFP, "Application area is not initialized"); + return ApplicationAreaIsNotInitialized; + } + + application_area_id = tag_data.application_area_id; + + return ResultSuccess; +} + Result NfpDevice::GetApplicationArea(std::vector<u8>& data) const { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); |