diff options
| author | 2023-07-05 09:23:47 -0400 | |
|---|---|---|
| committer | 2023-07-05 09:23:47 -0400 | |
| commit | ef7d44e24313d531f035026510fb9f156002edff (patch) | |
| tree | b422a9ec97d2feb275dd0de3419f8ab2ed9734cb /src/core/hle | |
| parent | Merge pull request #11012 from gidoly/metroid-fix (diff) | |
| parent | android: Reintroduce launch mode as single top (diff) | |
| download | yuzu-ef7d44e24313d531f035026510fb9f156002edff.tar.gz yuzu-ef7d44e24313d531f035026510fb9f156002edff.tar.xz yuzu-ef7d44e24313d531f035026510fb9f156002edff.zip | |
Merge pull request #11006 from german77/nfc_nfc
service: nfc: Ensure controller is in the correct mode
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/nfc/common/device.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index 5bf289818..2d633b03f 100644 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp | |||
| @@ -66,10 +66,6 @@ NfcDevice::~NfcDevice() { | |||
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { | 68 | void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { |
| 69 | if (!is_initalized) { | ||
| 70 | return; | ||
| 71 | } | ||
| 72 | |||
| 73 | if (type == Core::HID::ControllerTriggerType::Connected) { | 69 | if (type == Core::HID::ControllerTriggerType::Connected) { |
| 74 | Initialize(); | 70 | Initialize(); |
| 75 | availability_change_event->Signal(); | 71 | availability_change_event->Signal(); |
| @@ -77,12 +73,12 @@ void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { | |||
| 77 | } | 73 | } |
| 78 | 74 | ||
| 79 | if (type == Core::HID::ControllerTriggerType::Disconnected) { | 75 | if (type == Core::HID::ControllerTriggerType::Disconnected) { |
| 80 | device_state = DeviceState::Unavailable; | 76 | Finalize(); |
| 81 | availability_change_event->Signal(); | 77 | availability_change_event->Signal(); |
| 82 | return; | 78 | return; |
| 83 | } | 79 | } |
| 84 | 80 | ||
| 85 | if (type != Core::HID::ControllerTriggerType::Nfc) { | 81 | if (!is_initalized) { |
| 86 | return; | 82 | return; |
| 87 | } | 83 | } |
| 88 | 84 | ||
| @@ -90,6 +86,17 @@ void NfcDevice::NpadUpdate(Core::HID::ControllerTriggerType type) { | |||
| 90 | return; | 86 | return; |
| 91 | } | 87 | } |
| 92 | 88 | ||
| 89 | // Ensure nfc mode is always active | ||
| 90 | if (npad_device->GetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex) == | ||
| 91 | Common::Input::PollingMode::Active) { | ||
| 92 | npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, | ||
| 93 | Common::Input::PollingMode::NFC); | ||
| 94 | } | ||
| 95 | |||
| 96 | if (type != Core::HID::ControllerTriggerType::Nfc) { | ||
| 97 | return; | ||
| 98 | } | ||
| 99 | |||
| 93 | const auto nfc_status = npad_device->GetNfc(); | 100 | const auto nfc_status = npad_device->GetNfc(); |
| 94 | switch (nfc_status.state) { | 101 | switch (nfc_status.state) { |
| 95 | case Common::Input::NfcState::NewAmiibo: | 102 | case Common::Input::NfcState::NewAmiibo: |
| @@ -207,11 +214,14 @@ void NfcDevice::Initialize() { | |||
| 207 | } | 214 | } |
| 208 | 215 | ||
| 209 | void NfcDevice::Finalize() { | 216 | void NfcDevice::Finalize() { |
| 210 | if (device_state == DeviceState::TagMounted) { | 217 | if (npad_device->IsConnected()) { |
| 211 | Unmount(); | 218 | if (device_state == DeviceState::TagMounted) { |
| 212 | } | 219 | Unmount(); |
| 213 | if (device_state == DeviceState::SearchingForTag || device_state == DeviceState::TagRemoved) { | 220 | } |
| 214 | StopDetection(); | 221 | if (device_state == DeviceState::SearchingForTag || |
| 222 | device_state == DeviceState::TagRemoved) { | ||
| 223 | StopDetection(); | ||
| 224 | } | ||
| 215 | } | 225 | } |
| 216 | 226 | ||
| 217 | if (device_state != DeviceState::Unavailable) { | 227 | if (device_state != DeviceState::Unavailable) { |