input_common: Implement joycon nfc
This commit is contained in:
parent
6e33731f29
commit
6d6b7bdbc3
9 changed files with 544 additions and 13 deletions
61
src/input_common/helpers/joycon_protocol/nfc.h
Normal file
61
src/input_common/helpers/joycon_protocol/nfc.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
// Based on dkms-hid-nintendo implementation, CTCaer joycon toolkit and dekuNukem reverse
|
||||
// engineering https://github.com/nicman23/dkms-hid-nintendo/blob/master/src/hid-nintendo.c
|
||||
// https://github.com/CTCaer/jc_toolkit
|
||||
// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "input_common/helpers/joycon_protocol/common_protocol.h"
|
||||
#include "input_common/helpers/joycon_protocol/joycon_types.h"
|
||||
|
||||
namespace InputCommon::Joycon {
|
||||
|
||||
class NfcProtocol final : private JoyconCommonProtocol {
|
||||
public:
|
||||
NfcProtocol(std::shared_ptr<JoyconHandle> handle);
|
||||
|
||||
DriverResult EnableNfc();
|
||||
|
||||
DriverResult DisableNfc();
|
||||
|
||||
DriverResult StartNFCPollingMode();
|
||||
|
||||
DriverResult ScanAmiibo(std::vector<u8>& data);
|
||||
|
||||
bool HasAmiibo();
|
||||
|
||||
bool IsEnabled();
|
||||
|
||||
private:
|
||||
struct TagFoundData {
|
||||
u8 type;
|
||||
std::vector<u8> uuid;
|
||||
};
|
||||
|
||||
DriverResult WaitUntilNfcIsReady();
|
||||
|
||||
DriverResult StartPolling(TagFoundData& data);
|
||||
|
||||
DriverResult ReadTag(const TagFoundData& data);
|
||||
|
||||
DriverResult GetAmiiboData(std::vector<u8>& data);
|
||||
|
||||
DriverResult SendStartPollingRequest(std::vector<u8>& output);
|
||||
|
||||
DriverResult SendStopPollingRequest(std::vector<u8>& output);
|
||||
|
||||
DriverResult SendStartWaitingRecieveRequest(std::vector<u8>& output);
|
||||
|
||||
DriverResult SendReadAmiiboRequest(std::vector<u8>& output, std::size_t ntag_pages);
|
||||
|
||||
NFCReadBlockCommand GetReadBlockCommand(std::size_t pages) const;
|
||||
|
||||
bool is_enabled{};
|
||||
};
|
||||
|
||||
} // namespace InputCommon::Joycon
|
Loading…
Add table
Add a link
Reference in a new issue