summaryrefslogtreecommitdiff
path: root/src/core/hle/service/nfp
diff options
context:
space:
mode:
authorGravatar Narr the Reg2023-03-21 20:04:01 -0600
committerGravatar Narr the Reg2023-03-21 20:09:36 -0600
commit6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8 (patch)
tree3aec9d001317af55a6610ea8ca28da7758492c35 /src/core/hle/service/nfp
parentMerge pull request #9966 from bunnei/bounded-polyfill (diff)
downloadyuzu-6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8.tar.gz
yuzu-6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8.tar.xz
yuzu-6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8.zip
nfc: Initialize device when controller is connected
Diffstat (limited to 'src/core/hle/service/nfp')
-rw-r--r--src/core/hle/service/nfp/nfp_device.cpp16
-rw-r--r--src/core/hle/service/nfp/nfp_device.h1
2 files changed, 15 insertions, 2 deletions
diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp
index 268337d2e..5990e1473 100644
--- a/src/core/hle/service/nfp/nfp_device.cpp
+++ b/src/core/hle/service/nfp/nfp_device.cpp
@@ -66,8 +66,18 @@ NfpDevice::~NfpDevice() {
66}; 66};
67 67
68void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { 68void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
69 if (type == Core::HID::ControllerTriggerType::Connected || 69 if (!is_initalized) {
70 type == Core::HID::ControllerTriggerType::Disconnected) { 70 return;
71 }
72
73 if (type == Core::HID::ControllerTriggerType::Connected) {
74 Initialize();
75 availability_change_event->Signal();
76 return;
77 }
78
79 if (type == Core::HID::ControllerTriggerType::Disconnected) {
80 device_state = DeviceState::Unavailable;
71 availability_change_event->Signal(); 81 availability_change_event->Signal();
72 return; 82 return;
73 } 83 }
@@ -145,6 +155,7 @@ void NfpDevice::Initialize() {
145 device_state = npad_device->HasNfc() ? DeviceState::Initialized : DeviceState::Unavailable; 155 device_state = npad_device->HasNfc() ? DeviceState::Initialized : DeviceState::Unavailable;
146 encrypted_tag_data = {}; 156 encrypted_tag_data = {};
147 tag_data = {}; 157 tag_data = {};
158 is_initalized = true;
148} 159}
149 160
150void NfpDevice::Finalize() { 161void NfpDevice::Finalize() {
@@ -155,6 +166,7 @@ void NfpDevice::Finalize() {
155 StopDetection(); 166 StopDetection();
156 } 167 }
157 device_state = DeviceState::Unavailable; 168 device_state = DeviceState::Unavailable;
169 is_initalized = false;
158} 170}
159 171
160Result NfpDevice::StartDetection(TagProtocol allowed_protocol) { 172Result NfpDevice::StartDetection(TagProtocol allowed_protocol) {
diff --git a/src/core/hle/service/nfp/nfp_device.h b/src/core/hle/service/nfp/nfp_device.h
index 8813df998..27122e86e 100644
--- a/src/core/hle/service/nfp/nfp_device.h
+++ b/src/core/hle/service/nfp/nfp_device.h
@@ -92,6 +92,7 @@ private:
92 Kernel::KEvent* deactivate_event = nullptr; 92 Kernel::KEvent* deactivate_event = nullptr;
93 Kernel::KEvent* availability_change_event = nullptr; 93 Kernel::KEvent* availability_change_event = nullptr;
94 94
95 bool is_initalized{};
95 bool is_data_moddified{}; 96 bool is_data_moddified{};
96 bool is_app_area_open{}; 97 bool is_app_area_open{};
97 TagProtocol allowed_protocols{}; 98 TagProtocol allowed_protocols{};