summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Narr the Reg2024-02-23 12:38:43 -0600
committerGravatar Narr the Reg2024-02-23 18:58:50 -0600
commit015d666a4d1b38a0f4b9f66e55613881c0908f37 (patch)
tree094038539bef5bc7f1d02a6fa60a145e3e5580b0 /src
parentservice: npns: Add ListenTo and GetReceiveEvent for QLaunch (diff)
downloadyuzu-015d666a4d1b38a0f4b9f66e55613881c0908f37.tar.gz
yuzu-015d666a4d1b38a0f4b9f66e55613881c0908f37.tar.xz
yuzu-015d666a4d1b38a0f4b9f66e55613881c0908f37.zip
service: nfc: Implement SetNfcEnabled
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nfc/common/device_manager.cpp8
-rw-r--r--src/core/hle/service/nfc/common/device_manager.h5
-rw-r--r--src/core/hle/service/nfc/nfc.cpp4
-rw-r--r--src/core/hle/service/nfc/nfc_interface.cpp24
-rw-r--r--src/core/hle/service/nfc/nfc_interface.h6
5 files changed, 39 insertions, 8 deletions
diff --git a/src/core/hle/service/nfc/common/device_manager.cpp b/src/core/hle/service/nfc/common/device_manager.cpp
index 94a8243b5..2dd3e9f89 100644
--- a/src/core/hle/service/nfc/common/device_manager.cpp
+++ b/src/core/hle/service/nfc/common/device_manager.cpp
@@ -13,6 +13,7 @@
13#include "core/hle/service/nfc/nfc_result.h" 13#include "core/hle/service/nfc/nfc_result.h"
14#include "core/hle/service/psc/time/steady_clock.h" 14#include "core/hle/service/psc/time/steady_clock.h"
15#include "core/hle/service/service.h" 15#include "core/hle/service/service.h"
16#include "core/hle/service/set/system_settings_server.h"
16#include "core/hle/service/sm/sm.h" 17#include "core/hle/service/sm/sm.h"
17#include "hid_core/hid_types.h" 18#include "hid_core/hid_types.h"
18#include "hid_core/hid_util.h" 19#include "hid_core/hid_util.h"
@@ -32,6 +33,9 @@ DeviceManager::DeviceManager(Core::System& system_, KernelHelpers::ServiceContex
32 } 33 }
33 34
34 is_initialized = false; 35 is_initialized = false;
36
37 m_set_sys =
38 system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
35} 39}
36 40
37DeviceManager ::~DeviceManager() { 41DeviceManager ::~DeviceManager() {
@@ -774,8 +778,8 @@ Result DeviceManager::CheckDeviceState(std::shared_ptr<NfcDevice> device) const
774} 778}
775 779
776Result DeviceManager::IsNfcEnabled() const { 780Result DeviceManager::IsNfcEnabled() const {
777 // TODO: This calls nn::settings::detail::GetNfcEnableFlag 781 bool is_enabled{};
778 const bool is_enabled = true; 782 R_TRY(m_set_sys->GetNfcEnableFlag(&is_enabled));
779 if (!is_enabled) { 783 if (!is_enabled) {
780 return ResultNfcDisabled; 784 return ResultNfcDisabled;
781 } 785 }
diff --git a/src/core/hle/service/nfc/common/device_manager.h b/src/core/hle/service/nfc/common/device_manager.h
index c56a2fbda..6c0e6b255 100644
--- a/src/core/hle/service/nfc/common/device_manager.h
+++ b/src/core/hle/service/nfc/common/device_manager.h
@@ -15,6 +15,10 @@
15#include "core/hle/service/service.h" 15#include "core/hle/service/service.h"
16#include "hid_core/hid_types.h" 16#include "hid_core/hid_types.h"
17 17
18namespace Service::Set {
19class ISystemSettingsServer;
20}
21
18namespace Service::NFC { 22namespace Service::NFC {
19class NfcDevice; 23class NfcDevice;
20 24
@@ -98,6 +102,7 @@ private:
98 Core::System& system; 102 Core::System& system;
99 KernelHelpers::ServiceContext service_context; 103 KernelHelpers::ServiceContext service_context;
100 Kernel::KEvent* availability_change_event; 104 Kernel::KEvent* availability_change_event;
105 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
101}; 106};
102 107
103} // namespace Service::NFC 108} // namespace Service::NFC
diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp
index 30ae989b9..9d4808dbe 100644
--- a/src/core/hle/service/nfc/nfc.cpp
+++ b/src/core/hle/service/nfc/nfc.cpp
@@ -57,7 +57,7 @@ public:
57 {1, &NfcInterface::Finalize, "FinalizeOld"}, 57 {1, &NfcInterface::Finalize, "FinalizeOld"},
58 {2, &NfcInterface::GetState, "GetStateOld"}, 58 {2, &NfcInterface::GetState, "GetStateOld"},
59 {3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"}, 59 {3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"},
60 {100, nullptr, "SetNfcEnabledOld"}, 60 {100, &NfcInterface::SetNfcEnabled, "SetNfcEnabledOld"},
61 {400, &NfcInterface::Initialize, "Initialize"}, 61 {400, &NfcInterface::Initialize, "Initialize"},
62 {401, &NfcInterface::Finalize, "Finalize"}, 62 {401, &NfcInterface::Finalize, "Finalize"},
63 {402, &NfcInterface::GetState, "GetState"}, 63 {402, &NfcInterface::GetState, "GetState"},
@@ -71,7 +71,7 @@ public:
71 {410, &NfcInterface::GetTagInfo, "GetTagInfo"}, 71 {410, &NfcInterface::GetTagInfo, "GetTagInfo"},
72 {411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"}, 72 {411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"},
73 {412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"}, 73 {412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"},
74 {500, nullptr, "SetNfcEnabled"}, 74 {500, &NfcInterface::SetNfcEnabled, "SetNfcEnabled"},
75 {510, nullptr, "OutputTestWave"}, 75 {510, nullptr, "OutputTestWave"},
76 {1000, &NfcInterface::ReadMifare, "ReadMifare"}, 76 {1000, &NfcInterface::ReadMifare, "ReadMifare"},
77 {1001, &NfcInterface::WriteMifare, "WriteMifare"}, 77 {1001, &NfcInterface::WriteMifare, "WriteMifare"},
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 @@
13#include "core/hle/service/nfc/nfc_result.h" 13#include "core/hle/service/nfc/nfc_result.h"
14#include "core/hle/service/nfc/nfc_types.h" 14#include "core/hle/service/nfc/nfc_types.h"
15#include "core/hle/service/nfp/nfp_result.h" 15#include "core/hle/service/nfp/nfp_result.h"
16#include "core/hle/service/set/system_settings_server.h"
17#include "core/hle/service/sm/sm.h"
16#include "hid_core/hid_types.h" 18#include "hid_core/hid_types.h"
17 19
18namespace Service::NFC { 20namespace Service::NFC {
19 21
20NfcInterface::NfcInterface(Core::System& system_, const char* name, BackendType service_backend) 22NfcInterface::NfcInterface(Core::System& system_, const char* name, BackendType service_backend)
21 : ServiceFramework{system_, name}, service_context{system_, service_name}, 23 : ServiceFramework{system_, name}, service_context{system_, service_name},
22 backend_type{service_backend} {} 24 backend_type{service_backend} {
25 m_set_sys =
26 system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
27}
23 28
24NfcInterface ::~NfcInterface() = default; 29NfcInterface ::~NfcInterface() = default;
25 30
@@ -65,11 +70,11 @@ void NfcInterface::GetState(HLERequestContext& ctx) {
65void NfcInterface::IsNfcEnabled(HLERequestContext& ctx) { 70void NfcInterface::IsNfcEnabled(HLERequestContext& ctx) {
66 LOG_DEBUG(Service_NFC, "called"); 71 LOG_DEBUG(Service_NFC, "called");
67 72
68 // TODO: This calls nn::settings::detail::GetNfcEnableFlag 73 bool is_enabled{};
69 const bool is_enabled = true; 74 const auto result = m_set_sys->GetNfcEnableFlag(&is_enabled);
70 75
71 IPC::ResponseBuilder rb{ctx, 3}; 76 IPC::ResponseBuilder rb{ctx, 3};
72 rb.Push(ResultSuccess); 77 rb.Push(result);
73 rb.Push(is_enabled); 78 rb.Push(is_enabled);
74} 79}
75 80
@@ -212,6 +217,17 @@ void NfcInterface::AttachDeactivateEvent(HLERequestContext& ctx) {
212 rb.PushCopyObjects(out_event); 217 rb.PushCopyObjects(out_event);
213} 218}
214 219
220void NfcInterface::SetNfcEnabled(HLERequestContext& ctx) {
221 IPC::RequestParser rp{ctx};
222 const auto is_enabled{rp.Pop<bool>()};
223 LOG_DEBUG(Service_NFC, "called, is_enabled={}", is_enabled);
224
225 const auto result = m_set_sys->SetNfcEnableFlag(is_enabled);
226
227 IPC::ResponseBuilder rb{ctx, 2};
228 rb.Push(result);
229}
230
215void NfcInterface::ReadMifare(HLERequestContext& ctx) { 231void NfcInterface::ReadMifare(HLERequestContext& ctx) {
216 IPC::RequestParser rp{ctx}; 232 IPC::RequestParser rp{ctx};
217 const auto device_handle{rp.Pop<u64>()}; 233 const auto device_handle{rp.Pop<u64>()};
diff --git a/src/core/hle/service/nfc/nfc_interface.h b/src/core/hle/service/nfc/nfc_interface.h
index 08be174d8..5cc0d8ec0 100644
--- a/src/core/hle/service/nfc/nfc_interface.h
+++ b/src/core/hle/service/nfc/nfc_interface.h
@@ -7,6 +7,10 @@
7#include "core/hle/service/nfc/nfc_types.h" 7#include "core/hle/service/nfc/nfc_types.h"
8#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
9 9
10namespace Service::Set {
11class ISystemSettingsServer;
12}
13
10namespace Service::NFC { 14namespace Service::NFC {
11class DeviceManager; 15class DeviceManager;
12 16
@@ -29,6 +33,7 @@ public:
29 void AttachActivateEvent(HLERequestContext& ctx); 33 void AttachActivateEvent(HLERequestContext& ctx);
30 void AttachDeactivateEvent(HLERequestContext& ctx); 34 void AttachDeactivateEvent(HLERequestContext& ctx);
31 void ReadMifare(HLERequestContext& ctx); 35 void ReadMifare(HLERequestContext& ctx);
36 void SetNfcEnabled(HLERequestContext& ctx);
32 void WriteMifare(HLERequestContext& ctx); 37 void WriteMifare(HLERequestContext& ctx);
33 void SendCommandByPassThrough(HLERequestContext& ctx); 38 void SendCommandByPassThrough(HLERequestContext& ctx);
34 39
@@ -44,6 +49,7 @@ protected:
44 BackendType backend_type; 49 BackendType backend_type;
45 State state{State::NonInitialized}; 50 State state{State::NonInitialized};
46 std::shared_ptr<DeviceManager> device_manager = nullptr; 51 std::shared_ptr<DeviceManager> device_manager = nullptr;
52 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
47}; 53};
48 54
49} // namespace Service::NFC 55} // namespace Service::NFC