2024-03-06 05:26:38 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
2022-09-25 00:46:49 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
2023-03-22 17:09:12 +00:00
|
|
|
#include <span>
|
2022-09-25 00:46:49 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "input_common/input_engine.h"
|
|
|
|
|
|
|
|
namespace Common::FS {
|
|
|
|
class IOFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace InputCommon {
|
|
|
|
|
|
|
|
class VirtualAmiibo final : public InputEngine {
|
|
|
|
public:
|
|
|
|
enum class State {
|
2023-06-17 03:57:21 +00:00
|
|
|
Disabled,
|
2022-09-25 00:46:49 +00:00
|
|
|
Initialized,
|
|
|
|
WaitingForAmiibo,
|
2023-06-17 03:57:21 +00:00
|
|
|
TagNearby,
|
2022-09-25 00:46:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class Info {
|
|
|
|
Success,
|
|
|
|
UnableToLoad,
|
|
|
|
NotAnAmiibo,
|
|
|
|
WrongDeviceState,
|
|
|
|
Unknown,
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit VirtualAmiibo(std::string input_engine_);
|
|
|
|
~VirtualAmiibo() override;
|
|
|
|
|
|
|
|
// Sets polling mode to a controller
|
2022-12-26 17:11:01 +00:00
|
|
|
Common::Input::DriverResult SetPollingMode(
|
2022-09-25 00:46:49 +00:00
|
|
|
const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override;
|
|
|
|
|
2022-09-25 03:52:33 +00:00
|
|
|
Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
|
2023-06-17 03:57:21 +00:00
|
|
|
Common::Input::NfcState StartNfcPolling(const PadIdentifier& identifier_) override;
|
|
|
|
Common::Input::NfcState StopNfcPolling(const PadIdentifier& identifier_) override;
|
|
|
|
Common::Input::NfcState ReadAmiiboData(const PadIdentifier& identifier_,
|
|
|
|
std::vector<u8>& out_data) override;
|
2022-09-25 00:46:49 +00:00
|
|
|
Common::Input::NfcState WriteNfcData(const PadIdentifier& identifier_,
|
|
|
|
const std::vector<u8>& data) override;
|
2023-06-17 03:57:21 +00:00
|
|
|
Common::Input::NfcState ReadMifareData(const PadIdentifier& identifier_,
|
|
|
|
const Common::Input::MifareRequest& data,
|
|
|
|
Common::Input::MifareRequest& out_data) override;
|
|
|
|
Common::Input::NfcState WriteMifareData(const PadIdentifier& identifier_,
|
|
|
|
const Common::Input::MifareRequest& data) override;
|
2022-09-25 00:46:49 +00:00
|
|
|
|
|
|
|
State GetCurrentState() const;
|
|
|
|
|
|
|
|
Info LoadAmiibo(const std::string& amiibo_file);
|
2023-03-22 17:09:12 +00:00
|
|
|
Info LoadAmiibo(std::span<u8> data);
|
2022-11-13 16:56:01 +00:00
|
|
|
Info ReloadAmiibo();
|
2022-09-25 00:46:49 +00:00
|
|
|
Info CloseAmiibo();
|
|
|
|
|
2022-11-13 21:14:08 +00:00
|
|
|
std::string GetLastFilePath() const;
|
2022-11-13 16:56:01 +00:00
|
|
|
|
2022-09-25 00:46:49 +00:00
|
|
|
private:
|
2022-12-02 01:42:39 +00:00
|
|
|
static constexpr std::size_t AmiiboSize = 0x21C;
|
|
|
|
static constexpr std::size_t AmiiboSizeWithoutPassword = AmiiboSize - 0x8;
|
2023-06-15 23:39:01 +00:00
|
|
|
static constexpr std::size_t AmiiboSizeWithSignature = AmiiboSize + 0x20;
|
2022-12-02 01:42:39 +00:00
|
|
|
static constexpr std::size_t MifareSize = 0x400;
|
2022-09-25 00:46:49 +00:00
|
|
|
|
|
|
|
std::string file_path{};
|
2023-06-17 03:57:21 +00:00
|
|
|
State state{State::Disabled};
|
2022-12-02 01:42:39 +00:00
|
|
|
std::vector<u8> nfc_data;
|
2023-06-17 03:57:21 +00:00
|
|
|
Common::Input::NfcStatus status;
|
2023-03-08 02:15:46 +00:00
|
|
|
Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Passive};
|
2022-09-25 00:46:49 +00:00
|
|
|
};
|
|
|
|
} // namespace InputCommon
|