From fdb2002f77de6af19cc7f526b2e7540c329161c3 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Wed, 17 May 2023 22:17:16 -0600 Subject: input_common: Implement amiibo writting --- src/core/hid/emulated_controller.cpp | 9 +++++++-- src/core/hle/service/nfc/common/device.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 366880711..bbfea7117 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -1283,9 +1283,14 @@ bool EmulatedController::HasNfc() const { } bool EmulatedController::WriteNfc(const std::vector& data) { - auto& nfc_output_device = output_devices[3]; + auto& nfc_output_device = output_devices[static_cast(DeviceIndex::Right)]; + auto& nfc_virtual_output_device = output_devices[3]; + + if (nfc_output_device->SupportsNfc() != Common::Input::NfcState::NotSupported) { + return nfc_output_device->WriteNfcData(data) == Common::Input::NfcState::Success; + } - return nfc_output_device->WriteNfcData(data) == Common::Input::NfcState::Success; + return nfc_virtual_output_device->WriteNfcData(data) == Common::Input::NfcState::Success; } void EmulatedController::SetLedPattern() { diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index 322bde2ed..8a7e9edac 100644 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp @@ -421,11 +421,11 @@ Result NfcDevice::Flush() { tag_data.write_counter++; - FlushWithBreak(NFP::BreakType::Normal); + const auto result = FlushWithBreak(NFP::BreakType::Normal); is_data_moddified = false; - return ResultSuccess; + return result; } Result NfcDevice::FlushDebug() { @@ -444,11 +444,11 @@ Result NfcDevice::FlushDebug() { tag_data.write_counter++; - FlushWithBreak(NFP::BreakType::Normal); + const auto result = FlushWithBreak(NFP::BreakType::Normal); is_data_moddified = false; - return ResultSuccess; + return result; } Result NfcDevice::FlushWithBreak(NFP::BreakType break_type) { -- cgit v1.2.3