aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/service/nfp/nfp_device.cpp
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-03-24 10:53:05 -0400
committerGitHub <noreply@github.com>2023-03-24 10:53:05 -0400
commit462c430c8b5e491f4a88cd87c465be7862b1d564 (patch)
tree66fe97f969ed87c5982d17662f0042a15219c72d /src/core/hle/service/nfp/nfp_device.cpp
parent7a8a7545f2e50b04f0b1d3fdb09bc24275cc09d0 (diff)
parent6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8 (diff)
Merge pull request #9981 from german77/nfp_connect
nfc: Initialize device when controller is connected
Diffstat (limited to 'src/core/hle/service/nfp/nfp_device.cpp')
-rw-r--r--src/core/hle/service/nfp/nfp_device.cpp16
1 files changed, 14 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() {
};
void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) {
- if (type == Core::HID::ControllerTriggerType::Connected ||
- type == Core::HID::ControllerTriggerType::Disconnected) {
+ if (!is_initalized) {
+ return;
+ }
+
+ if (type == Core::HID::ControllerTriggerType::Connected) {
+ Initialize();
+ availability_change_event->Signal();
+ return;
+ }
+
+ if (type == Core::HID::ControllerTriggerType::Disconnected) {
+ device_state = DeviceState::Unavailable;
availability_change_event->Signal();
return;
}
@@ -145,6 +155,7 @@ void NfpDevice::Initialize() {
device_state = npad_device->HasNfc() ? DeviceState::Initialized : DeviceState::Unavailable;
encrypted_tag_data = {};
tag_data = {};
+ is_initalized = true;
}
void NfpDevice::Finalize() {
@@ -155,6 +166,7 @@ void NfpDevice::Finalize() {
StopDetection();
}
device_state = DeviceState::Unavailable;
+ is_initalized = false;
}
Result NfpDevice::StartDetection(TagProtocol allowed_protocol) {