diff options
author | bunnei <bunneidev@gmail.com> | 2023-05-25 14:07:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-25 14:07:16 -0700 |
commit | ffa1fba7d632d69e564cce302b5e5cf4bf131071 (patch) | |
tree | a601ac622b62f4931202e13a7cf733b6f580390a /src/input_common/helpers/joycon_driver.cpp | |
parent | a596c6e4388ed86af983364c961dcb52ab95e4d3 (diff) | |
parent | fdb2002f77de6af19cc7f526b2e7540c329161c3 (diff) |
Merge pull request #10396 from german77/amiibo_write
input_common: Implement amiibo writing
Diffstat (limited to 'src/input_common/helpers/joycon_driver.cpp')
-rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index 83429a336..95106f16d 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -492,6 +492,26 @@ DriverResult JoyconDriver::SetRingConMode() { return result; } +DriverResult JoyconDriver::WriteNfcData(std::span<const u8> data) { + std::scoped_lock lock{mutex}; + disable_input_thread = true; + + if (!supported_features.nfc) { + return DriverResult::NotSupported; + } + if (!nfc_protocol->IsEnabled()) { + return DriverResult::Disabled; + } + if (!amiibo_detected) { + return DriverResult::ErrorWritingData; + } + + const auto result = nfc_protocol->WriteAmiibo(data); + + disable_input_thread = false; + return result; +} + bool JoyconDriver::IsConnected() const { std::scoped_lock lock{mutex}; return is_connected.load(); |