diff options
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/nfc.cpp')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/nfc.cpp | 231 |
1 files changed, 119 insertions, 112 deletions
diff --git a/src/input_common/helpers/joycon_protocol/nfc.cpp b/src/input_common/helpers/joycon_protocol/nfc.cpp index 261f46255..09953394b 100644 --- a/src/input_common/helpers/joycon_protocol/nfc.cpp +++ b/src/input_common/helpers/joycon_protocol/nfc.cpp | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <thread> | 4 | #include "common/input.h" |
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "input_common/helpers/joycon_protocol/nfc.h" | 6 | #include "input_common/helpers/joycon_protocol/nfc.h" |
| 7 | 7 | ||
| @@ -10,21 +10,21 @@ namespace InputCommon::Joycon { | |||
| 10 | NfcProtocol::NfcProtocol(std::shared_ptr<JoyconHandle> handle) | 10 | NfcProtocol::NfcProtocol(std::shared_ptr<JoyconHandle> handle) |
| 11 | : JoyconCommonProtocol(std::move(handle)) {} | 11 | : JoyconCommonProtocol(std::move(handle)) {} |
| 12 | 12 | ||
| 13 | DriverResult NfcProtocol::EnableNfc() { | 13 | Common::Input::DriverResult NfcProtocol::EnableNfc() { |
| 14 | LOG_INFO(Input, "Enable NFC"); | 14 | LOG_INFO(Input, "Enable NFC"); |
| 15 | ScopedSetBlocking sb(this); | 15 | ScopedSetBlocking sb(this); |
| 16 | DriverResult result{DriverResult::Success}; | 16 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 17 | 17 | ||
| 18 | if (result == DriverResult::Success) { | 18 | if (result == Common::Input::DriverResult::Success) { |
| 19 | result = SetReportMode(ReportMode::NFC_IR_MODE_60HZ); | 19 | result = SetReportMode(ReportMode::NFC_IR_MODE_60HZ); |
| 20 | } | 20 | } |
| 21 | if (result == DriverResult::Success) { | 21 | if (result == Common::Input::DriverResult::Success) { |
| 22 | result = EnableMCU(true); | 22 | result = EnableMCU(true); |
| 23 | } | 23 | } |
| 24 | if (result == DriverResult::Success) { | 24 | if (result == Common::Input::DriverResult::Success) { |
| 25 | result = WaitSetMCUMode(ReportMode::NFC_IR_MODE_60HZ, MCUMode::Standby); | 25 | result = WaitSetMCUMode(ReportMode::NFC_IR_MODE_60HZ, MCUMode::Standby); |
| 26 | } | 26 | } |
| 27 | if (result == DriverResult::Success) { | 27 | if (result == Common::Input::DriverResult::Success) { |
| 28 | const MCUConfig config{ | 28 | const MCUConfig config{ |
| 29 | .command = MCUCommand::ConfigureMCU, | 29 | .command = MCUCommand::ConfigureMCU, |
| 30 | .sub_command = MCUSubCommand::SetMCUMode, | 30 | .sub_command = MCUSubCommand::SetMCUMode, |
| @@ -34,32 +34,32 @@ DriverResult NfcProtocol::EnableNfc() { | |||
| 34 | 34 | ||
| 35 | result = ConfigureMCU(config); | 35 | result = ConfigureMCU(config); |
| 36 | } | 36 | } |
| 37 | if (result == DriverResult::Success) { | 37 | if (result == Common::Input::DriverResult::Success) { |
| 38 | result = WaitSetMCUMode(ReportMode::NFC_IR_MODE_60HZ, MCUMode::NFC); | 38 | result = WaitSetMCUMode(ReportMode::NFC_IR_MODE_60HZ, MCUMode::NFC); |
| 39 | } | 39 | } |
| 40 | if (result == DriverResult::Success) { | 40 | if (result == Common::Input::DriverResult::Success) { |
| 41 | result = WaitUntilNfcIs(NFCStatus::Ready); | 41 | result = WaitUntilNfcIs(NFCStatus::Ready); |
| 42 | } | 42 | } |
| 43 | if (result == DriverResult::Success) { | 43 | if (result == Common::Input::DriverResult::Success) { |
| 44 | MCUCommandResponse output{}; | 44 | MCUCommandResponse output{}; |
| 45 | result = SendStopPollingRequest(output); | 45 | result = SendStopPollingRequest(output); |
| 46 | } | 46 | } |
| 47 | if (result == DriverResult::Success) { | 47 | if (result == Common::Input::DriverResult::Success) { |
| 48 | result = WaitUntilNfcIs(NFCStatus::Ready); | 48 | result = WaitUntilNfcIs(NFCStatus::Ready); |
| 49 | } | 49 | } |
| 50 | if (result == DriverResult::Success) { | 50 | if (result == Common::Input::DriverResult::Success) { |
| 51 | is_enabled = true; | 51 | is_enabled = true; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | return result; | 54 | return result; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | DriverResult NfcProtocol::DisableNfc() { | 57 | Common::Input::DriverResult NfcProtocol::DisableNfc() { |
| 58 | LOG_DEBUG(Input, "Disable NFC"); | 58 | LOG_DEBUG(Input, "Disable NFC"); |
| 59 | ScopedSetBlocking sb(this); | 59 | ScopedSetBlocking sb(this); |
| 60 | DriverResult result{DriverResult::Success}; | 60 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 61 | 61 | ||
| 62 | if (result == DriverResult::Success) { | 62 | if (result == Common::Input::DriverResult::Success) { |
| 63 | result = EnableMCU(false); | 63 | result = EnableMCU(false); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| @@ -69,60 +69,60 @@ DriverResult NfcProtocol::DisableNfc() { | |||
| 69 | return result; | 69 | return result; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | DriverResult NfcProtocol::StartNFCPollingMode() { | 72 | Common::Input::DriverResult NfcProtocol::StartNFCPollingMode() { |
| 73 | LOG_DEBUG(Input, "Start NFC polling Mode"); | 73 | LOG_DEBUG(Input, "Start NFC polling Mode"); |
| 74 | ScopedSetBlocking sb(this); | 74 | ScopedSetBlocking sb(this); |
| 75 | DriverResult result{DriverResult::Success}; | 75 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 76 | 76 | ||
| 77 | if (result == DriverResult::Success) { | 77 | if (result == Common::Input::DriverResult::Success) { |
| 78 | MCUCommandResponse output{}; | 78 | MCUCommandResponse output{}; |
| 79 | result = SendStartPollingRequest(output); | 79 | result = SendStartPollingRequest(output); |
| 80 | } | 80 | } |
| 81 | if (result == DriverResult::Success) { | 81 | if (result == Common::Input::DriverResult::Success) { |
| 82 | result = WaitUntilNfcIs(NFCStatus::Polling); | 82 | result = WaitUntilNfcIs(NFCStatus::Polling); |
| 83 | } | 83 | } |
| 84 | if (result == DriverResult::Success) { | 84 | if (result == Common::Input::DriverResult::Success) { |
| 85 | is_polling = true; | 85 | is_polling = true; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | return result; | 88 | return result; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | DriverResult NfcProtocol::StopNFCPollingMode() { | 91 | Common::Input::DriverResult NfcProtocol::StopNFCPollingMode() { |
| 92 | LOG_DEBUG(Input, "Stop NFC polling Mode"); | 92 | LOG_DEBUG(Input, "Stop NFC polling Mode"); |
| 93 | ScopedSetBlocking sb(this); | 93 | ScopedSetBlocking sb(this); |
| 94 | DriverResult result{DriverResult::Success}; | 94 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 95 | 95 | ||
| 96 | if (result == DriverResult::Success) { | 96 | if (result == Common::Input::DriverResult::Success) { |
| 97 | MCUCommandResponse output{}; | 97 | MCUCommandResponse output{}; |
| 98 | result = SendStopPollingRequest(output); | 98 | result = SendStopPollingRequest(output); |
| 99 | } | 99 | } |
| 100 | if (result == DriverResult::Success) { | 100 | if (result == Common::Input::DriverResult::Success) { |
| 101 | result = WaitUntilNfcIs(NFCStatus::WriteReady); | 101 | result = WaitUntilNfcIs(NFCStatus::WriteReady); |
| 102 | } | 102 | } |
| 103 | if (result == DriverResult::Success) { | 103 | if (result == Common::Input::DriverResult::Success) { |
| 104 | is_polling = false; | 104 | is_polling = false; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | return result; | 107 | return result; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | DriverResult NfcProtocol::GetTagInfo(Joycon::TagInfo& tag_info) { | 110 | Common::Input::DriverResult NfcProtocol::GetTagInfo(Joycon::TagInfo& tag_info) { |
| 111 | if (update_counter++ < AMIIBO_UPDATE_DELAY) { | 111 | if (update_counter++ < AMIIBO_UPDATE_DELAY) { |
| 112 | return DriverResult::Delayed; | 112 | return Common::Input::DriverResult::Delayed; |
| 113 | } | 113 | } |
| 114 | update_counter = 0; | 114 | update_counter = 0; |
| 115 | 115 | ||
| 116 | LOG_DEBUG(Input, "Scan for amiibos"); | 116 | LOG_DEBUG(Input, "Scan for amiibos"); |
| 117 | ScopedSetBlocking sb(this); | 117 | ScopedSetBlocking sb(this); |
| 118 | DriverResult result{DriverResult::Success}; | 118 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 119 | TagFoundData tag_data{}; | 119 | TagFoundData tag_data{}; |
| 120 | 120 | ||
| 121 | if (result == DriverResult::Success) { | 121 | if (result == Common::Input::DriverResult::Success) { |
| 122 | result = IsTagInRange(tag_data); | 122 | result = IsTagInRange(tag_data); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | if (result == DriverResult::Success) { | 125 | if (result == Common::Input::DriverResult::Success) { |
| 126 | tag_info = { | 126 | tag_info = { |
| 127 | .uuid_length = tag_data.uuid_size, | 127 | .uuid_length = tag_data.uuid_size, |
| 128 | .protocol = 1, | 128 | .protocol = 1, |
| @@ -147,59 +147,59 @@ DriverResult NfcProtocol::GetTagInfo(Joycon::TagInfo& tag_info) { | |||
| 147 | return result; | 147 | return result; |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | DriverResult NfcProtocol::ReadAmiibo(std::vector<u8>& data) { | 150 | Common::Input::DriverResult NfcProtocol::ReadAmiibo(std::vector<u8>& data) { |
| 151 | LOG_DEBUG(Input, "Scan for amiibos"); | 151 | LOG_DEBUG(Input, "Scan for amiibos"); |
| 152 | ScopedSetBlocking sb(this); | 152 | ScopedSetBlocking sb(this); |
| 153 | DriverResult result{DriverResult::Success}; | 153 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 154 | TagFoundData tag_data{}; | 154 | TagFoundData tag_data{}; |
| 155 | 155 | ||
| 156 | if (result == DriverResult::Success) { | 156 | if (result == Common::Input::DriverResult::Success) { |
| 157 | result = IsTagInRange(tag_data, 7); | 157 | result = IsTagInRange(tag_data, 7); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | if (result == DriverResult::Success) { | 160 | if (result == Common::Input::DriverResult::Success) { |
| 161 | result = GetAmiiboData(data); | 161 | result = GetAmiiboData(data); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | return result; | 164 | return result; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | DriverResult NfcProtocol::WriteAmiibo(std::span<const u8> data) { | 167 | Common::Input::DriverResult NfcProtocol::WriteAmiibo(std::span<const u8> data) { |
| 168 | LOG_DEBUG(Input, "Write amiibo"); | 168 | LOG_DEBUG(Input, "Write amiibo"); |
| 169 | ScopedSetBlocking sb(this); | 169 | ScopedSetBlocking sb(this); |
| 170 | DriverResult result{DriverResult::Success}; | 170 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 171 | TagUUID tag_uuid = GetTagUUID(data); | 171 | TagUUID tag_uuid = GetTagUUID(data); |
| 172 | TagFoundData tag_data{}; | 172 | TagFoundData tag_data{}; |
| 173 | 173 | ||
| 174 | if (result == DriverResult::Success) { | 174 | if (result == Common::Input::DriverResult::Success) { |
| 175 | result = IsTagInRange(tag_data, 7); | 175 | result = IsTagInRange(tag_data, 7); |
| 176 | } | 176 | } |
| 177 | if (result == DriverResult::Success) { | 177 | if (result == Common::Input::DriverResult::Success) { |
| 178 | if (tag_data.uuid != tag_uuid) { | 178 | if (tag_data.uuid != tag_uuid) { |
| 179 | result = DriverResult::InvalidParameters; | 179 | result = Common::Input::DriverResult::InvalidParameters; |
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | if (result == DriverResult::Success) { | 182 | if (result == Common::Input::DriverResult::Success) { |
| 183 | MCUCommandResponse output{}; | 183 | MCUCommandResponse output{}; |
| 184 | result = SendStopPollingRequest(output); | 184 | result = SendStopPollingRequest(output); |
| 185 | } | 185 | } |
| 186 | if (result == DriverResult::Success) { | 186 | if (result == Common::Input::DriverResult::Success) { |
| 187 | result = WaitUntilNfcIs(NFCStatus::Ready); | 187 | result = WaitUntilNfcIs(NFCStatus::Ready); |
| 188 | } | 188 | } |
| 189 | if (result == DriverResult::Success) { | 189 | if (result == Common::Input::DriverResult::Success) { |
| 190 | MCUCommandResponse output{}; | 190 | MCUCommandResponse output{}; |
| 191 | result = SendStartPollingRequest(output, true); | 191 | result = SendStartPollingRequest(output, true); |
| 192 | } | 192 | } |
| 193 | if (result == DriverResult::Success) { | 193 | if (result == Common::Input::DriverResult::Success) { |
| 194 | result = WaitUntilNfcIs(NFCStatus::WriteReady); | 194 | result = WaitUntilNfcIs(NFCStatus::WriteReady); |
| 195 | } | 195 | } |
| 196 | if (result == DriverResult::Success) { | 196 | if (result == Common::Input::DriverResult::Success) { |
| 197 | result = WriteAmiiboData(tag_uuid, data); | 197 | result = WriteAmiiboData(tag_uuid, data); |
| 198 | } | 198 | } |
| 199 | if (result == DriverResult::Success) { | 199 | if (result == Common::Input::DriverResult::Success) { |
| 200 | result = WaitUntilNfcIs(NFCStatus::WriteDone); | 200 | result = WaitUntilNfcIs(NFCStatus::WriteDone); |
| 201 | } | 201 | } |
| 202 | if (result == DriverResult::Success) { | 202 | if (result == Common::Input::DriverResult::Success) { |
| 203 | MCUCommandResponse output{}; | 203 | MCUCommandResponse output{}; |
| 204 | result = SendStopPollingRequest(output); | 204 | result = SendStopPollingRequest(output); |
| 205 | } | 205 | } |
| @@ -207,64 +207,65 @@ DriverResult NfcProtocol::WriteAmiibo(std::span<const u8> data) { | |||
| 207 | return result; | 207 | return result; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | DriverResult NfcProtocol::ReadMifare(std::span<const MifareReadChunk> read_request, | 210 | Common::Input::DriverResult NfcProtocol::ReadMifare(std::span<const MifareReadChunk> read_request, |
| 211 | std::span<MifareReadData> out_data) { | 211 | std::span<MifareReadData> out_data) { |
| 212 | LOG_DEBUG(Input, "Read mifare"); | 212 | LOG_DEBUG(Input, "Read mifare"); |
| 213 | ScopedSetBlocking sb(this); | 213 | ScopedSetBlocking sb(this); |
| 214 | DriverResult result{DriverResult::Success}; | 214 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 215 | TagFoundData tag_data{}; | 215 | TagFoundData tag_data{}; |
| 216 | MifareUUID tag_uuid{}; | 216 | MifareUUID tag_uuid{}; |
| 217 | 217 | ||
| 218 | if (result == DriverResult::Success) { | 218 | if (result == Common::Input::DriverResult::Success) { |
| 219 | result = IsTagInRange(tag_data, 7); | 219 | result = IsTagInRange(tag_data, 7); |
| 220 | } | 220 | } |
| 221 | if (result == DriverResult::Success) { | 221 | if (result == Common::Input::DriverResult::Success) { |
| 222 | memcpy(tag_uuid.data(), tag_data.uuid.data(), sizeof(MifareUUID)); | 222 | memcpy(tag_uuid.data(), tag_data.uuid.data(), sizeof(MifareUUID)); |
| 223 | result = GetMifareData(tag_uuid, read_request, out_data); | 223 | result = GetMifareData(tag_uuid, read_request, out_data); |
| 224 | } | 224 | } |
| 225 | if (result == DriverResult::Success) { | 225 | if (result == Common::Input::DriverResult::Success) { |
| 226 | MCUCommandResponse output{}; | 226 | MCUCommandResponse output{}; |
| 227 | result = SendStopPollingRequest(output); | 227 | result = SendStopPollingRequest(output); |
| 228 | } | 228 | } |
| 229 | if (result == DriverResult::Success) { | 229 | if (result == Common::Input::DriverResult::Success) { |
| 230 | result = WaitUntilNfcIs(NFCStatus::Ready); | 230 | result = WaitUntilNfcIs(NFCStatus::Ready); |
| 231 | } | 231 | } |
| 232 | if (result == DriverResult::Success) { | 232 | if (result == Common::Input::DriverResult::Success) { |
| 233 | MCUCommandResponse output{}; | 233 | MCUCommandResponse output{}; |
| 234 | result = SendStartPollingRequest(output, true); | 234 | result = SendStartPollingRequest(output, true); |
| 235 | } | 235 | } |
| 236 | if (result == DriverResult::Success) { | 236 | if (result == Common::Input::DriverResult::Success) { |
| 237 | result = WaitUntilNfcIs(NFCStatus::WriteReady); | 237 | result = WaitUntilNfcIs(NFCStatus::WriteReady); |
| 238 | } | 238 | } |
| 239 | return result; | 239 | return result; |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | DriverResult NfcProtocol::WriteMifare(std::span<const MifareWriteChunk> write_request) { | 242 | Common::Input::DriverResult NfcProtocol::WriteMifare( |
| 243 | std::span<const MifareWriteChunk> write_request) { | ||
| 243 | LOG_DEBUG(Input, "Write mifare"); | 244 | LOG_DEBUG(Input, "Write mifare"); |
| 244 | ScopedSetBlocking sb(this); | 245 | ScopedSetBlocking sb(this); |
| 245 | DriverResult result{DriverResult::Success}; | 246 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 246 | TagFoundData tag_data{}; | 247 | TagFoundData tag_data{}; |
| 247 | MifareUUID tag_uuid{}; | 248 | MifareUUID tag_uuid{}; |
| 248 | 249 | ||
| 249 | if (result == DriverResult::Success) { | 250 | if (result == Common::Input::DriverResult::Success) { |
| 250 | result = IsTagInRange(tag_data, 7); | 251 | result = IsTagInRange(tag_data, 7); |
| 251 | } | 252 | } |
| 252 | if (result == DriverResult::Success) { | 253 | if (result == Common::Input::DriverResult::Success) { |
| 253 | memcpy(tag_uuid.data(), tag_data.uuid.data(), sizeof(MifareUUID)); | 254 | memcpy(tag_uuid.data(), tag_data.uuid.data(), sizeof(MifareUUID)); |
| 254 | result = WriteMifareData(tag_uuid, write_request); | 255 | result = WriteMifareData(tag_uuid, write_request); |
| 255 | } | 256 | } |
| 256 | if (result == DriverResult::Success) { | 257 | if (result == Common::Input::DriverResult::Success) { |
| 257 | MCUCommandResponse output{}; | 258 | MCUCommandResponse output{}; |
| 258 | result = SendStopPollingRequest(output); | 259 | result = SendStopPollingRequest(output); |
| 259 | } | 260 | } |
| 260 | if (result == DriverResult::Success) { | 261 | if (result == Common::Input::DriverResult::Success) { |
| 261 | result = WaitUntilNfcIs(NFCStatus::Ready); | 262 | result = WaitUntilNfcIs(NFCStatus::Ready); |
| 262 | } | 263 | } |
| 263 | if (result == DriverResult::Success) { | 264 | if (result == Common::Input::DriverResult::Success) { |
| 264 | MCUCommandResponse output{}; | 265 | MCUCommandResponse output{}; |
| 265 | result = SendStartPollingRequest(output, true); | 266 | result = SendStartPollingRequest(output, true); |
| 266 | } | 267 | } |
| 267 | if (result == DriverResult::Success) { | 268 | if (result == Common::Input::DriverResult::Success) { |
| 268 | result = WaitUntilNfcIs(NFCStatus::WriteReady); | 269 | result = WaitUntilNfcIs(NFCStatus::WriteReady); |
| 269 | } | 270 | } |
| 270 | return result; | 271 | return result; |
| @@ -277,17 +278,17 @@ bool NfcProtocol::HasAmiibo() { | |||
| 277 | update_counter = 0; | 278 | update_counter = 0; |
| 278 | 279 | ||
| 279 | ScopedSetBlocking sb(this); | 280 | ScopedSetBlocking sb(this); |
| 280 | DriverResult result{DriverResult::Success}; | 281 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 281 | TagFoundData tag_data{}; | 282 | TagFoundData tag_data{}; |
| 282 | 283 | ||
| 283 | if (result == DriverResult::Success) { | 284 | if (result == Common::Input::DriverResult::Success) { |
| 284 | result = IsTagInRange(tag_data, 7); | 285 | result = IsTagInRange(tag_data, 7); |
| 285 | } | 286 | } |
| 286 | 287 | ||
| 287 | return result == DriverResult::Success; | 288 | return result == Common::Input::DriverResult::Success; |
| 288 | } | 289 | } |
| 289 | 290 | ||
| 290 | DriverResult NfcProtocol::WaitUntilNfcIs(NFCStatus status) { | 291 | Common::Input::DriverResult NfcProtocol::WaitUntilNfcIs(NFCStatus status) { |
| 291 | constexpr std::size_t timeout_limit = 10; | 292 | constexpr std::size_t timeout_limit = 10; |
| 292 | MCUCommandResponse output{}; | 293 | MCUCommandResponse output{}; |
| 293 | std::size_t tries = 0; | 294 | std::size_t tries = 0; |
| @@ -295,30 +296,31 @@ DriverResult NfcProtocol::WaitUntilNfcIs(NFCStatus status) { | |||
| 295 | do { | 296 | do { |
| 296 | auto result = SendNextPackageRequest(output, {}); | 297 | auto result = SendNextPackageRequest(output, {}); |
| 297 | 298 | ||
| 298 | if (result != DriverResult::Success) { | 299 | if (result != Common::Input::DriverResult::Success) { |
| 299 | return result; | 300 | return result; |
| 300 | } | 301 | } |
| 301 | if (tries++ > timeout_limit) { | 302 | if (tries++ > timeout_limit) { |
| 302 | return DriverResult::Timeout; | 303 | return Common::Input::DriverResult::Timeout; |
| 303 | } | 304 | } |
| 304 | } while (output.mcu_report != MCUReport::NFCState || | 305 | } while (output.mcu_report != MCUReport::NFCState || |
| 305 | (output.mcu_data[1] << 8) + output.mcu_data[0] != 0x0500 || | 306 | (output.mcu_data[1] << 8) + output.mcu_data[0] != 0x0500 || |
| 306 | output.mcu_data[5] != 0x31 || output.mcu_data[6] != static_cast<u8>(status)); | 307 | output.mcu_data[5] != 0x31 || output.mcu_data[6] != static_cast<u8>(status)); |
| 307 | 308 | ||
| 308 | return DriverResult::Success; | 309 | return Common::Input::DriverResult::Success; |
| 309 | } | 310 | } |
| 310 | 311 | ||
| 311 | DriverResult NfcProtocol::IsTagInRange(TagFoundData& data, std::size_t timeout_limit) { | 312 | Common::Input::DriverResult NfcProtocol::IsTagInRange(TagFoundData& data, |
| 313 | std::size_t timeout_limit) { | ||
| 312 | MCUCommandResponse output{}; | 314 | MCUCommandResponse output{}; |
| 313 | std::size_t tries = 0; | 315 | std::size_t tries = 0; |
| 314 | 316 | ||
| 315 | do { | 317 | do { |
| 316 | const auto result = SendNextPackageRequest(output, {}); | 318 | const auto result = SendNextPackageRequest(output, {}); |
| 317 | if (result != DriverResult::Success) { | 319 | if (result != Common::Input::DriverResult::Success) { |
| 318 | return result; | 320 | return result; |
| 319 | } | 321 | } |
| 320 | if (tries++ > timeout_limit) { | 322 | if (tries++ > timeout_limit) { |
| 321 | return DriverResult::Timeout; | 323 | return Common::Input::DriverResult::Timeout; |
| 322 | } | 324 | } |
| 323 | } while (output.mcu_report != MCUReport::NFCState || | 325 | } while (output.mcu_report != MCUReport::NFCState || |
| 324 | (output.mcu_data[1] << 8) + output.mcu_data[0] != 0x0500 || | 326 | (output.mcu_data[1] << 8) + output.mcu_data[0] != 0x0500 || |
| @@ -328,10 +330,10 @@ DriverResult NfcProtocol::IsTagInRange(TagFoundData& data, std::size_t timeout_l | |||
| 328 | data.uuid_size = std::min(output.mcu_data[14], static_cast<u8>(sizeof(TagUUID))); | 330 | data.uuid_size = std::min(output.mcu_data[14], static_cast<u8>(sizeof(TagUUID))); |
| 329 | memcpy(data.uuid.data(), output.mcu_data.data() + 15, data.uuid.size()); | 331 | memcpy(data.uuid.data(), output.mcu_data.data() + 15, data.uuid.size()); |
| 330 | 332 | ||
| 331 | return DriverResult::Success; | 333 | return Common::Input::DriverResult::Success; |
| 332 | } | 334 | } |
| 333 | 335 | ||
| 334 | DriverResult NfcProtocol::GetAmiiboData(std::vector<u8>& ntag_data) { | 336 | Common::Input::DriverResult NfcProtocol::GetAmiiboData(std::vector<u8>& ntag_data) { |
| 335 | constexpr std::size_t timeout_limit = 60; | 337 | constexpr std::size_t timeout_limit = 60; |
| 336 | MCUCommandResponse output{}; | 338 | MCUCommandResponse output{}; |
| 337 | std::size_t tries = 0; | 339 | std::size_t tries = 0; |
| @@ -340,7 +342,7 @@ DriverResult NfcProtocol::GetAmiiboData(std::vector<u8>& ntag_data) { | |||
| 340 | std::size_t ntag_buffer_pos = 0; | 342 | std::size_t ntag_buffer_pos = 0; |
| 341 | auto result = SendReadAmiiboRequest(output, NFCPages::Block135); | 343 | auto result = SendReadAmiiboRequest(output, NFCPages::Block135); |
| 342 | 344 | ||
| 343 | if (result != DriverResult::Success) { | 345 | if (result != Common::Input::DriverResult::Success) { |
| 344 | return result; | 346 | return result; |
| 345 | } | 347 | } |
| 346 | 348 | ||
| @@ -349,14 +351,14 @@ DriverResult NfcProtocol::GetAmiiboData(std::vector<u8>& ntag_data) { | |||
| 349 | result = SendNextPackageRequest(output, package_index); | 351 | result = SendNextPackageRequest(output, package_index); |
| 350 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); | 352 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); |
| 351 | 353 | ||
| 352 | if (result != DriverResult::Success) { | 354 | if (result != Common::Input::DriverResult::Success) { |
| 353 | return result; | 355 | return result; |
| 354 | } | 356 | } |
| 355 | 357 | ||
| 356 | if ((output.mcu_report == MCUReport::NFCReadData || | 358 | if ((output.mcu_report == MCUReport::NFCReadData || |
| 357 | output.mcu_report == MCUReport::NFCState) && | 359 | output.mcu_report == MCUReport::NFCState) && |
| 358 | nfc_status == NFCStatus::TagLost) { | 360 | nfc_status == NFCStatus::TagLost) { |
| 359 | return DriverResult::ErrorReadingData; | 361 | return Common::Input::DriverResult::ErrorReadingData; |
| 360 | } | 362 | } |
| 361 | 363 | ||
| 362 | if (output.mcu_report == MCUReport::NFCReadData && output.mcu_data[1] == 0x07) { | 364 | if (output.mcu_report == MCUReport::NFCReadData && output.mcu_data[1] == 0x07) { |
| @@ -375,14 +377,15 @@ DriverResult NfcProtocol::GetAmiiboData(std::vector<u8>& ntag_data) { | |||
| 375 | 377 | ||
| 376 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::LastPackage) { | 378 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::LastPackage) { |
| 377 | LOG_INFO(Input, "Finished reading amiibo"); | 379 | LOG_INFO(Input, "Finished reading amiibo"); |
| 378 | return DriverResult::Success; | 380 | return Common::Input::DriverResult::Success; |
| 379 | } | 381 | } |
| 380 | } | 382 | } |
| 381 | 383 | ||
| 382 | return DriverResult::Timeout; | 384 | return Common::Input::DriverResult::Timeout; |
| 383 | } | 385 | } |
| 384 | 386 | ||
| 385 | DriverResult NfcProtocol::WriteAmiiboData(const TagUUID& tag_uuid, std::span<const u8> data) { | 387 | Common::Input::DriverResult NfcProtocol::WriteAmiiboData(const TagUUID& tag_uuid, |
| 388 | std::span<const u8> data) { | ||
| 386 | constexpr std::size_t timeout_limit = 60; | 389 | constexpr std::size_t timeout_limit = 60; |
| 387 | const auto nfc_data = MakeAmiiboWritePackage(tag_uuid, data); | 390 | const auto nfc_data = MakeAmiiboWritePackage(tag_uuid, data); |
| 388 | const std::vector<u8> nfc_buffer_data = SerializeWritePackage(nfc_data); | 391 | const std::vector<u8> nfc_buffer_data = SerializeWritePackage(nfc_data); |
| @@ -397,7 +400,7 @@ DriverResult NfcProtocol::WriteAmiiboData(const TagUUID& tag_uuid, std::span<con | |||
| 397 | 400 | ||
| 398 | auto result = SendWriteAmiiboRequest(output, tag_uuid); | 401 | auto result = SendWriteAmiiboRequest(output, tag_uuid); |
| 399 | 402 | ||
| 400 | if (result != DriverResult::Success) { | 403 | if (result != Common::Input::DriverResult::Success) { |
| 401 | return result; | 404 | return result; |
| 402 | } | 405 | } |
| 403 | 406 | ||
| @@ -406,14 +409,14 @@ DriverResult NfcProtocol::WriteAmiiboData(const TagUUID& tag_uuid, std::span<con | |||
| 406 | result = SendNextPackageRequest(output, package_index); | 409 | result = SendNextPackageRequest(output, package_index); |
| 407 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); | 410 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); |
| 408 | 411 | ||
| 409 | if (result != DriverResult::Success) { | 412 | if (result != Common::Input::DriverResult::Success) { |
| 410 | return result; | 413 | return result; |
| 411 | } | 414 | } |
| 412 | 415 | ||
| 413 | if ((output.mcu_report == MCUReport::NFCReadData || | 416 | if ((output.mcu_report == MCUReport::NFCReadData || |
| 414 | output.mcu_report == MCUReport::NFCState) && | 417 | output.mcu_report == MCUReport::NFCState) && |
| 415 | nfc_status == NFCStatus::TagLost) { | 418 | nfc_status == NFCStatus::TagLost) { |
| 416 | return DriverResult::ErrorReadingData; | 419 | return Common::Input::DriverResult::ErrorReadingData; |
| 417 | } | 420 | } |
| 418 | 421 | ||
| 419 | if (output.mcu_report == MCUReport::NFCReadData && output.mcu_data[1] == 0x07) { | 422 | if (output.mcu_report == MCUReport::NFCReadData && output.mcu_data[1] == 0x07) { |
| @@ -442,7 +445,7 @@ DriverResult NfcProtocol::WriteAmiiboData(const TagUUID& tag_uuid, std::span<con | |||
| 442 | if ((output.mcu_report == MCUReport::NFCReadData || | 445 | if ((output.mcu_report == MCUReport::NFCReadData || |
| 443 | output.mcu_report == MCUReport::NFCState) && | 446 | output.mcu_report == MCUReport::NFCState) && |
| 444 | nfc_status == NFCStatus::TagLost) { | 447 | nfc_status == NFCStatus::TagLost) { |
| 445 | return DriverResult::ErrorReadingData; | 448 | return Common::Input::DriverResult::ErrorReadingData; |
| 446 | } | 449 | } |
| 447 | 450 | ||
| 448 | // Increase position when data is confirmed by the joycon | 451 | // Increase position when data is confirmed by the joycon |
| @@ -457,14 +460,14 @@ DriverResult NfcProtocol::WriteAmiiboData(const TagUUID& tag_uuid, std::span<con | |||
| 457 | return result; | 460 | return result; |
| 458 | } | 461 | } |
| 459 | 462 | ||
| 460 | DriverResult NfcProtocol::GetMifareData(const MifareUUID& tag_uuid, | 463 | Common::Input::DriverResult NfcProtocol::GetMifareData( |
| 461 | std::span<const MifareReadChunk> read_request, | 464 | const MifareUUID& tag_uuid, std::span<const MifareReadChunk> read_request, |
| 462 | std::span<MifareReadData> out_data) { | 465 | std::span<MifareReadData> out_data) { |
| 463 | constexpr std::size_t timeout_limit = 60; | 466 | constexpr std::size_t timeout_limit = 60; |
| 464 | const auto nfc_data = MakeMifareReadPackage(tag_uuid, read_request); | 467 | const auto nfc_data = MakeMifareReadPackage(tag_uuid, read_request); |
| 465 | const std::vector<u8> nfc_buffer_data = SerializeMifareReadPackage(nfc_data); | 468 | const std::vector<u8> nfc_buffer_data = SerializeMifareReadPackage(nfc_data); |
| 466 | std::span<const u8> buffer(nfc_buffer_data); | 469 | std::span<const u8> buffer(nfc_buffer_data); |
| 467 | DriverResult result = DriverResult::Success; | 470 | Common::Input::DriverResult result = Common::Input::DriverResult::Success; |
| 468 | MCUCommandResponse output{}; | 471 | MCUCommandResponse output{}; |
| 469 | u8 block_id = 1; | 472 | u8 block_id = 1; |
| 470 | u8 package_index = 0; | 473 | u8 package_index = 0; |
| @@ -486,7 +489,7 @@ DriverResult NfcProtocol::GetMifareData(const MifareUUID& tag_uuid, | |||
| 486 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); | 489 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); |
| 487 | 490 | ||
| 488 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { | 491 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { |
| 489 | return DriverResult::ErrorReadingData; | 492 | return Common::Input::DriverResult::ErrorReadingData; |
| 490 | } | 493 | } |
| 491 | 494 | ||
| 492 | // Increase position when data is confirmed by the joycon | 495 | // Increase position when data is confirmed by the joycon |
| @@ -498,7 +501,7 @@ DriverResult NfcProtocol::GetMifareData(const MifareUUID& tag_uuid, | |||
| 498 | } | 501 | } |
| 499 | } | 502 | } |
| 500 | 503 | ||
| 501 | if (result != DriverResult::Success) { | 504 | if (result != Common::Input::DriverResult::Success) { |
| 502 | return result; | 505 | return result; |
| 503 | } | 506 | } |
| 504 | 507 | ||
| @@ -507,12 +510,12 @@ DriverResult NfcProtocol::GetMifareData(const MifareUUID& tag_uuid, | |||
| 507 | result = SendNextPackageRequest(output, package_index); | 510 | result = SendNextPackageRequest(output, package_index); |
| 508 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); | 511 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); |
| 509 | 512 | ||
| 510 | if (result != DriverResult::Success) { | 513 | if (result != Common::Input::DriverResult::Success) { |
| 511 | return result; | 514 | return result; |
| 512 | } | 515 | } |
| 513 | 516 | ||
| 514 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { | 517 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { |
| 515 | return DriverResult::ErrorReadingData; | 518 | return Common::Input::DriverResult::ErrorReadingData; |
| 516 | } | 519 | } |
| 517 | 520 | ||
| 518 | if (output.mcu_report == MCUReport::NFCState && output.mcu_data[1] == 0x10) { | 521 | if (output.mcu_report == MCUReport::NFCState && output.mcu_data[1] == 0x10) { |
| @@ -538,13 +541,13 @@ DriverResult NfcProtocol::GetMifareData(const MifareUUID& tag_uuid, | |||
| 538 | return result; | 541 | return result; |
| 539 | } | 542 | } |
| 540 | 543 | ||
| 541 | DriverResult NfcProtocol::WriteMifareData(const MifareUUID& tag_uuid, | 544 | Common::Input::DriverResult NfcProtocol::WriteMifareData( |
| 542 | std::span<const MifareWriteChunk> write_request) { | 545 | const MifareUUID& tag_uuid, std::span<const MifareWriteChunk> write_request) { |
| 543 | constexpr std::size_t timeout_limit = 60; | 546 | constexpr std::size_t timeout_limit = 60; |
| 544 | const auto nfc_data = MakeMifareWritePackage(tag_uuid, write_request); | 547 | const auto nfc_data = MakeMifareWritePackage(tag_uuid, write_request); |
| 545 | const std::vector<u8> nfc_buffer_data = SerializeMifareWritePackage(nfc_data); | 548 | const std::vector<u8> nfc_buffer_data = SerializeMifareWritePackage(nfc_data); |
| 546 | std::span<const u8> buffer(nfc_buffer_data); | 549 | std::span<const u8> buffer(nfc_buffer_data); |
| 547 | DriverResult result = DriverResult::Success; | 550 | Common::Input::DriverResult result = Common::Input::DriverResult::Success; |
| 548 | MCUCommandResponse output{}; | 551 | MCUCommandResponse output{}; |
| 549 | u8 block_id = 1; | 552 | u8 block_id = 1; |
| 550 | u8 package_index = 0; | 553 | u8 package_index = 0; |
| @@ -566,7 +569,7 @@ DriverResult NfcProtocol::WriteMifareData(const MifareUUID& tag_uuid, | |||
| 566 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); | 569 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); |
| 567 | 570 | ||
| 568 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { | 571 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { |
| 569 | return DriverResult::ErrorReadingData; | 572 | return Common::Input::DriverResult::ErrorReadingData; |
| 570 | } | 573 | } |
| 571 | 574 | ||
| 572 | // Increase position when data is confirmed by the joycon | 575 | // Increase position when data is confirmed by the joycon |
| @@ -578,7 +581,7 @@ DriverResult NfcProtocol::WriteMifareData(const MifareUUID& tag_uuid, | |||
| 578 | } | 581 | } |
| 579 | } | 582 | } |
| 580 | 583 | ||
| 581 | if (result != DriverResult::Success) { | 584 | if (result != Common::Input::DriverResult::Success) { |
| 582 | return result; | 585 | return result; |
| 583 | } | 586 | } |
| 584 | 587 | ||
| @@ -587,12 +590,12 @@ DriverResult NfcProtocol::WriteMifareData(const MifareUUID& tag_uuid, | |||
| 587 | result = SendNextPackageRequest(output, package_index); | 590 | result = SendNextPackageRequest(output, package_index); |
| 588 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); | 591 | const auto nfc_status = static_cast<NFCStatus>(output.mcu_data[6]); |
| 589 | 592 | ||
| 590 | if (result != DriverResult::Success) { | 593 | if (result != Common::Input::DriverResult::Success) { |
| 591 | return result; | 594 | return result; |
| 592 | } | 595 | } |
| 593 | 596 | ||
| 594 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { | 597 | if (output.mcu_report == MCUReport::NFCState && nfc_status == NFCStatus::TagLost) { |
| 595 | return DriverResult::ErrorReadingData; | 598 | return Common::Input::DriverResult::ErrorReadingData; |
| 596 | } | 599 | } |
| 597 | 600 | ||
| 598 | if (output.mcu_report == MCUReport::NFCState && output.mcu_data[1] == 0x10) { | 601 | if (output.mcu_report == MCUReport::NFCState && output.mcu_data[1] == 0x10) { |
| @@ -609,8 +612,8 @@ DriverResult NfcProtocol::WriteMifareData(const MifareUUID& tag_uuid, | |||
| 609 | return result; | 612 | return result; |
| 610 | } | 613 | } |
| 611 | 614 | ||
| 612 | DriverResult NfcProtocol::SendStartPollingRequest(MCUCommandResponse& output, | 615 | Common::Input::DriverResult NfcProtocol::SendStartPollingRequest(MCUCommandResponse& output, |
| 613 | bool is_second_attempt) { | 616 | bool is_second_attempt) { |
| 614 | NFCRequestState request{ | 617 | NFCRequestState request{ |
| 615 | .command_argument = NFCCommand::StartPolling, | 618 | .command_argument = NFCCommand::StartPolling, |
| 616 | .block_id = {}, | 619 | .block_id = {}, |
| @@ -635,7 +638,7 @@ DriverResult NfcProtocol::SendStartPollingRequest(MCUCommandResponse& output, | |||
| 635 | output); | 638 | output); |
| 636 | } | 639 | } |
| 637 | 640 | ||
| 638 | DriverResult NfcProtocol::SendStopPollingRequest(MCUCommandResponse& output) { | 641 | Common::Input::DriverResult NfcProtocol::SendStopPollingRequest(MCUCommandResponse& output) { |
| 639 | NFCRequestState request{ | 642 | NFCRequestState request{ |
| 640 | .command_argument = NFCCommand::StopPolling, | 643 | .command_argument = NFCCommand::StopPolling, |
| 641 | .block_id = {}, | 644 | .block_id = {}, |
| @@ -653,7 +656,8 @@ DriverResult NfcProtocol::SendStopPollingRequest(MCUCommandResponse& output) { | |||
| 653 | output); | 656 | output); |
| 654 | } | 657 | } |
| 655 | 658 | ||
| 656 | DriverResult NfcProtocol::SendNextPackageRequest(MCUCommandResponse& output, u8 packet_id) { | 659 | Common::Input::DriverResult NfcProtocol::SendNextPackageRequest(MCUCommandResponse& output, |
| 660 | u8 packet_id) { | ||
| 657 | NFCRequestState request{ | 661 | NFCRequestState request{ |
| 658 | .command_argument = NFCCommand::StartWaitingRecieve, | 662 | .command_argument = NFCCommand::StartWaitingRecieve, |
| 659 | .block_id = {}, | 663 | .block_id = {}, |
| @@ -671,7 +675,8 @@ DriverResult NfcProtocol::SendNextPackageRequest(MCUCommandResponse& output, u8 | |||
| 671 | output); | 675 | output); |
| 672 | } | 676 | } |
| 673 | 677 | ||
| 674 | DriverResult NfcProtocol::SendReadAmiiboRequest(MCUCommandResponse& output, NFCPages ntag_pages) { | 678 | Common::Input::DriverResult NfcProtocol::SendReadAmiiboRequest(MCUCommandResponse& output, |
| 679 | NFCPages ntag_pages) { | ||
| 675 | NFCRequestState request{ | 680 | NFCRequestState request{ |
| 676 | .command_argument = NFCCommand::ReadNtag, | 681 | .command_argument = NFCCommand::ReadNtag, |
| 677 | .block_id = {}, | 682 | .block_id = {}, |
| @@ -696,8 +701,8 @@ DriverResult NfcProtocol::SendReadAmiiboRequest(MCUCommandResponse& output, NFCP | |||
| 696 | output); | 701 | output); |
| 697 | } | 702 | } |
| 698 | 703 | ||
| 699 | DriverResult NfcProtocol::SendWriteAmiiboRequest(MCUCommandResponse& output, | 704 | Common::Input::DriverResult NfcProtocol::SendWriteAmiiboRequest(MCUCommandResponse& output, |
| 700 | const TagUUID& tag_uuid) { | 705 | const TagUUID& tag_uuid) { |
| 701 | NFCRequestState request{ | 706 | NFCRequestState request{ |
| 702 | .command_argument = NFCCommand::ReadNtag, | 707 | .command_argument = NFCCommand::ReadNtag, |
| 703 | .block_id = {}, | 708 | .block_id = {}, |
| @@ -722,9 +727,10 @@ DriverResult NfcProtocol::SendWriteAmiiboRequest(MCUCommandResponse& output, | |||
| 722 | output); | 727 | output); |
| 723 | } | 728 | } |
| 724 | 729 | ||
| 725 | DriverResult NfcProtocol::SendWriteDataAmiiboRequest(MCUCommandResponse& output, u8 block_id, | 730 | Common::Input::DriverResult NfcProtocol::SendWriteDataAmiiboRequest(MCUCommandResponse& output, |
| 726 | bool is_last_packet, | 731 | u8 block_id, |
| 727 | std::span<const u8> data) { | 732 | bool is_last_packet, |
| 733 | std::span<const u8> data) { | ||
| 728 | const auto data_size = std::min(data.size(), sizeof(NFCRequestState::raw_data)); | 734 | const auto data_size = std::min(data.size(), sizeof(NFCRequestState::raw_data)); |
| 729 | NFCRequestState request{ | 735 | NFCRequestState request{ |
| 730 | .command_argument = NFCCommand::WriteNtag, | 736 | .command_argument = NFCCommand::WriteNtag, |
| @@ -745,8 +751,9 @@ DriverResult NfcProtocol::SendWriteDataAmiiboRequest(MCUCommandResponse& output, | |||
| 745 | output); | 751 | output); |
| 746 | } | 752 | } |
| 747 | 753 | ||
| 748 | DriverResult NfcProtocol::SendReadDataMifareRequest(MCUCommandResponse& output, u8 block_id, | 754 | Common::Input::DriverResult NfcProtocol::SendReadDataMifareRequest(MCUCommandResponse& output, |
| 749 | bool is_last_packet, std::span<const u8> data) { | 755 | u8 block_id, bool is_last_packet, |
| 756 | std::span<const u8> data) { | ||
| 750 | const auto data_size = std::min(data.size(), sizeof(NFCRequestState::raw_data)); | 757 | const auto data_size = std::min(data.size(), sizeof(NFCRequestState::raw_data)); |
| 751 | NFCRequestState request{ | 758 | NFCRequestState request{ |
| 752 | .command_argument = NFCCommand::Mifare, | 759 | .command_argument = NFCCommand::Mifare, |