From 94151097b9abadf35c55ea06a31925c9848f4c62 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Wed, 19 Apr 2023 19:01:23 -0600 Subject: service: nfc: Merge device interfaces and create the device manager --- src/core/hle/service/nfc/nfc_interface.h | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/core/hle/service/nfc/nfc_interface.h') diff --git a/src/core/hle/service/nfc/nfc_interface.h b/src/core/hle/service/nfc/nfc_interface.h index 8c1bf5a59..08be174d8 100644 --- a/src/core/hle/service/nfc/nfc_interface.h +++ b/src/core/hle/service/nfc/nfc_interface.h @@ -3,20 +3,17 @@ #pragma once -#include -#include -#include - #include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/nfc/nfc_types.h" #include "core/hle/service/service.h" namespace Service::NFC { -class NfcDevice; +class DeviceManager; -class Interface : public ServiceFramework { +class NfcInterface : public ServiceFramework { public: - explicit Interface(Core::System& system_, const char* name); - ~Interface(); + explicit NfcInterface(Core::System& system_, const char* name, BackendType service_backend); + ~NfcInterface(); void Initialize(HLERequestContext& ctx); void Finalize(HLERequestContext& ctx); @@ -31,22 +28,22 @@ public: void GetTagInfo(HLERequestContext& ctx); void AttachActivateEvent(HLERequestContext& ctx); void AttachDeactivateEvent(HLERequestContext& ctx); + void ReadMifare(HLERequestContext& ctx); + void WriteMifare(HLERequestContext& ctx); void SendCommandByPassThrough(HLERequestContext& ctx); -private: - enum class State : u32 { - NonInitialized, - Initialized, - }; - - std::optional> GetNfcDevice(u64 handle); +protected: + std::shared_ptr GetManager(); + BackendType GetBackendType() const; + Result TranslateResultToServiceError(Result result) const; + Result TranslateResultToNfp(Result result) const; + Result TranslateResultToMifare(Result result) const; KernelHelpers::ServiceContext service_context; - std::array, 10> devices{}; - + BackendType backend_type; State state{State::NonInitialized}; - Kernel::KEvent* availability_change_event; + std::shared_ptr device_manager = nullptr; }; } // namespace Service::NFC -- cgit v1.2.3