From 5ad4cf619e265f5176ec684a078fb0bbd0174a77 Mon Sep 17 00:00:00 2001 From: shinyquagsire23 Date: Fri, 1 Dec 2017 12:37:00 -0700 Subject: [PATCH] Services/NFC: Stub StartTagScanning as it should be for o3DS --- src/core/hle/service/nfc/nfc.cpp | 21 ++++++++++++++++----- src/core/hle/service/nfc/nfc.h | 6 ++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index cb09ed0b7e..56c56fe83c 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "core/hle/ipc.h" +#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/service/nfc/nfc.h" @@ -53,13 +54,23 @@ void StopCommunication(Interface* self) { } void StartTagScanning(Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); + IPC::RequestParser rp(Kernel::GetCommandBuffer(), 5, 1, 0); // 0x00050040 + u16 in_val = rp.Pop(); - nfc_tag_state = TagState::TagInRange; - tag_in_range_event->Signal(); + ResultCode result = RESULT_SUCCESS; - cmd_buff[1] = RESULT_SUCCESS.raw; // No error - LOG_WARNING(Service_NFC, "(STUBBED) called"); + // TODO(shinyquagsire23): Implement NFC tag detection, for now stub result + result = ResultCode(ErrCodes::CommandInvalidForState, ErrorModule::NFC, + ErrorSummary::InvalidState, ErrorLevel::Status); + + if (result == RESULT_SUCCESS) { + nfc_tag_state = TagState::TagInRange; + tag_in_range_event->Signal(); + } + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(result); + LOG_WARNING(Service_NFC, "(STUBBED) called, in_val=%04x", in_val); } void StopTagScanning(Interface* self) { diff --git a/src/core/hle/service/nfc/nfc.h b/src/core/hle/service/nfc/nfc.h index a013bdae7a..57f8d86b22 100644 --- a/src/core/hle/service/nfc/nfc.h +++ b/src/core/hle/service/nfc/nfc.h @@ -12,6 +12,12 @@ class Interface; namespace NFC { +namespace ErrCodes { +enum { + CommandInvalidForState = 512, +}; +} // namespace ErrCodes + enum class TagState : u8 { NotInitialized = 0, NotScanning = 1,