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 | |
| 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')
| -rw-r--r-- | src/core/hle/service/nfc/nfc_device.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/nfc/nfc_device.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp_device.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp_device.h | 1 |
4 files changed, 30 insertions, 4 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 | ||
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 | ||
| 68 | void NfpDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { | 68 | void 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 | ||
| 150 | void NfpDevice::Finalize() { | 161 | void 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 | ||
| 160 | Result NfpDevice::StartDetection(TagProtocol allowed_protocol) { | 172 | Result 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{}; |