summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2023-03-22 18:09:12 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:48 +0200
commitca4be4283d8eec9624019f4bca88f7d1aa467f01 (patch)
tree6fc3424bb97d17315b1e63335020efc57a65b912 /src/input_common
parentandroid: vulkan_device: Disable VK_EXT_custom_border_color on Adreno. (diff)
downloadyuzu-ca4be4283d8eec9624019f4bca88f7d1aa467f01.tar
yuzu-ca4be4283d8eec9624019f4bca88f7d1aa467f01.tar.gz
yuzu-ca4be4283d8eec9624019f4bca88f7d1aa467f01.tar.bz2
yuzu-ca4be4283d8eec9624019f4bca88f7d1aa467f01.tar.lz
yuzu-ca4be4283d8eec9624019f4bca88f7d1aa467f01.tar.xz
yuzu-ca4be4283d8eec9624019f4bca88f7d1aa467f01.tar.zst
yuzu-ca4be4283d8eec9624019f4bca88f7d1aa467f01.zip
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/virtual_amiibo.cpp26
-rw-r--r--src/input_common/drivers/virtual_amiibo.h2
2 files changed, 24 insertions, 4 deletions
diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp
index 304f4c70b..9505179c6 100644
--- a/src/input_common/drivers/virtual_amiibo.cpp
+++ b/src/input_common/drivers/virtual_amiibo.cpp
@@ -73,10 +73,7 @@ VirtualAmiibo::State VirtualAmiibo::GetCurrentState() const {
VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(const std::string& filename) {
const Common::FS::IOFile nfc_file{filename, Common::FS::FileAccessMode::Read,
Common::FS::FileType::BinaryFile};
-
- if (state != State::WaitingForAmiibo) {
- return Info::WrongDeviceState;
- }
+ std::vector<u8> data{};
if (!nfc_file.IsOpen()) {
return Info::UnableToLoad;
@@ -101,7 +98,28 @@ VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(const std::string& filename) {
}
file_path = filename;
+ return LoadAmiibo(data);
+}
+
+VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(std::span<u8> data) {
+ if (state != State::WaitingForAmiibo) {
+ return Info::WrongDeviceState;
+ }
+
+ switch (data.size_bytes()) {
+ case AmiiboSize:
+ case AmiiboSizeWithoutPassword:
+ nfc_data.resize(AmiiboSize);
+ break;
+ case MifareSize:
+ nfc_data.resize(MifareSize);
+ break;
+ default:
+ return Info::NotAnAmiibo;
+ }
+
state = State::AmiiboIsOpen;
+ memcpy(nfc_data.data(),data.data(),data.size_bytes());
SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, nfc_data});
return Info::Success;
}
diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h
index 488d00b31..34e97cd91 100644
--- a/src/input_common/drivers/virtual_amiibo.h
+++ b/src/input_common/drivers/virtual_amiibo.h
@@ -4,6 +4,7 @@
#pragma once
#include <array>
+#include <span>
#include <string>
#include <vector>
@@ -47,6 +48,7 @@ public:
State GetCurrentState() const;
Info LoadAmiibo(const std::string& amiibo_file);
+ Info LoadAmiibo(std::span<u8> data);
Info ReloadAmiibo();
Info CloseAmiibo();