From 015d666a4d1b38a0f4b9f66e55613881c0908f37 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Fri, 23 Feb 2024 12:38:43 -0600 Subject: service: nfc: Implement SetNfcEnabled --- src/core/hle/service/nfc/nfc_interface.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/core/hle/service/nfc/nfc_interface.cpp') diff --git a/src/core/hle/service/nfc/nfc_interface.cpp b/src/core/hle/service/nfc/nfc_interface.cpp index 3e2c7deab..c28e55431 100644 --- a/src/core/hle/service/nfc/nfc_interface.cpp +++ b/src/core/hle/service/nfc/nfc_interface.cpp @@ -13,13 +13,18 @@ #include "core/hle/service/nfc/nfc_result.h" #include "core/hle/service/nfc/nfc_types.h" #include "core/hle/service/nfp/nfp_result.h" +#include "core/hle/service/set/system_settings_server.h" +#include "core/hle/service/sm/sm.h" #include "hid_core/hid_types.h" namespace Service::NFC { NfcInterface::NfcInterface(Core::System& system_, const char* name, BackendType service_backend) : ServiceFramework{system_, name}, service_context{system_, service_name}, - backend_type{service_backend} {} + backend_type{service_backend} { + m_set_sys = + system.ServiceManager().GetService("set:sys", true); +} NfcInterface ::~NfcInterface() = default; @@ -65,11 +70,11 @@ void NfcInterface::GetState(HLERequestContext& ctx) { void NfcInterface::IsNfcEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); - // TODO: This calls nn::settings::detail::GetNfcEnableFlag - const bool is_enabled = true; + bool is_enabled{}; + const auto result = m_set_sys->GetNfcEnableFlag(&is_enabled); IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); + rb.Push(result); rb.Push(is_enabled); } @@ -212,6 +217,17 @@ void NfcInterface::AttachDeactivateEvent(HLERequestContext& ctx) { rb.PushCopyObjects(out_event); } +void NfcInterface::SetNfcEnabled(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto is_enabled{rp.Pop()}; + LOG_DEBUG(Service_NFC, "called, is_enabled={}", is_enabled); + + const auto result = m_set_sys->SetNfcEnableFlag(is_enabled); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result); +} + void NfcInterface::ReadMifare(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; -- cgit v1.2.3