diff options
| author | 2023-03-21 20:04:01 -0600 | |
|---|---|---|
| committer | 2023-03-21 20:09:36 -0600 | |
| commit | 6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8 (patch) | |
| tree | 3aec9d001317af55a6610ea8ca28da7758492c35 /src/core/hle/service/nfc | |
| parent | Merge pull request #9966 from bunnei/bounded-polyfill (diff) | |
| download | yuzu-6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8.tar.gz yuzu-6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8.tar.xz yuzu-6ff4bf9b1c48f4cd148cbebc9f0f21bcc74cdac8.zip | |
nfc: Initialize device when controller is connected
Diffstat (limited to 'src/core/hle/service/nfc')
| -rw-r--r-- | src/core/hle/service/nfc/nfc_device.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/nfc/nfc_device.h | 1 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/core/hle/service/nfc/nfc_device.cpp b/src/core/hle/service/nfc/nfc_device.cpp index 3f17d0c7a..c7db74d14 100644 --- a/src/core/hle/service/nfc/nfc_device.cpp +++ b/src/core/hle/service/nfc/nfc_device.cpp | |||
| @@ -42,8 +42,18 @@ NfcDevice::~NfcDevice() { | |||
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { | 44 | void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { |
| 45 | if (type == Core::HID::ControllerTriggerType::Connected || | 45 | if (!is_initalized) { |
| 46 | type == Core::HID::ControllerTriggerType::Disconnected) { | 46 | return; |
| 47 | } | ||
| 48 | |||
| 49 | if (type == Core::HID::ControllerTriggerType::Connected) { | ||
| 50 | Initialize(); | ||
| 51 | availability_change_event->Signal(); | ||
| 52 | return; | ||
| 53 | } | ||
| 54 | |||
| 55 | if (type == Core::HID::ControllerTriggerType::Disconnected) { | ||
| 56 | device_state = NFP::DeviceState::Unavailable; | ||
| 47 | availability_change_event->Signal(); | 57 | availability_change_event->Signal(); |
| 48 | return; | 58 | return; |
| 49 | } | 59 | } |
| @@ -113,6 +123,7 @@ void NfcDevice::Initialize() { | |||
| 113 | device_state = | 123 | device_state = |
| 114 | npad_device->HasNfc() ? NFP::DeviceState::Initialized : NFP::DeviceState::Unavailable; | 124 | npad_device->HasNfc() ? NFP::DeviceState::Initialized : NFP::DeviceState::Unavailable; |
| 115 | encrypted_tag_data = {}; | 125 | encrypted_tag_data = {}; |
| 126 | is_initalized = true; | ||
| 116 | } | 127 | } |
| 117 | 128 | ||
| 118 | void NfcDevice::Finalize() { | 129 | void NfcDevice::Finalize() { |
| @@ -121,6 +132,7 @@ void NfcDevice::Finalize() { | |||
| 121 | StopDetection(); | 132 | StopDetection(); |
| 122 | } | 133 | } |
| 123 | device_state = NFP::DeviceState::Unavailable; | 134 | device_state = NFP::DeviceState::Unavailable; |
| 135 | is_initalized = false; | ||
| 124 | } | 136 | } |
| 125 | 137 | ||
| 126 | Result NfcDevice::StartDetection(NFP::TagProtocol allowed_protocol) { | 138 | Result NfcDevice::StartDetection(NFP::TagProtocol allowed_protocol) { |
diff --git a/src/core/hle/service/nfc/nfc_device.h b/src/core/hle/service/nfc/nfc_device.h index a6e114d36..ea63f0537 100644 --- a/src/core/hle/service/nfc/nfc_device.h +++ b/src/core/hle/service/nfc/nfc_device.h | |||
| @@ -67,6 +67,7 @@ private: | |||
| 67 | Kernel::KEvent* deactivate_event = nullptr; | 67 | Kernel::KEvent* deactivate_event = nullptr; |
| 68 | Kernel::KEvent* availability_change_event = nullptr; | 68 | Kernel::KEvent* availability_change_event = nullptr; |
| 69 | 69 | ||
| 70 | bool is_initalized{}; | ||
| 70 | NFP::TagProtocol allowed_protocols{}; | 71 | NFP::TagProtocol allowed_protocols{}; |
| 71 | NFP::DeviceState device_state{NFP::DeviceState::Unavailable}; | 72 | NFP::DeviceState device_state{NFP::DeviceState::Unavailable}; |
| 72 | 73 | ||