diff options
| author | 2023-01-24 09:29:37 -0500 | |
|---|---|---|
| committer | 2023-01-24 09:29:37 -0500 | |
| commit | a68af583ea378b48e2ed5a19f519a815ba89e40f (patch) | |
| tree | 2983c14a7d4bc2797259c7d97462a439bec629f3 /src/input_common/helpers/joycon_protocol/nfc.h | |
| parent | Merge pull request #9555 from abouvier/catch2-update (diff) | |
| parent | core: hid: Make use of SCOPE_EXIT and SCOPE_GUARD where applicable (diff) | |
| download | yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.gz yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.xz yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.zip | |
Merge pull request #9492 from german77/joycon_release
Input_common: Implement custom joycon driver v2
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/nfc.h')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/nfc.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/input_common/helpers/joycon_protocol/nfc.h b/src/input_common/helpers/joycon_protocol/nfc.h new file mode 100644 index 000000000..e63665aa9 --- /dev/null +++ b/src/input_common/helpers/joycon_protocol/nfc.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | // Based on dkms-hid-nintendo implementation, CTCaer joycon toolkit and dekuNukem reverse | ||
| 5 | // engineering https://github.com/nicman23/dkms-hid-nintendo/blob/master/src/hid-nintendo.c | ||
| 6 | // https://github.com/CTCaer/jc_toolkit | ||
| 7 | // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include <vector> | ||
| 12 | |||
| 13 | #include "input_common/helpers/joycon_protocol/common_protocol.h" | ||
| 14 | #include "input_common/helpers/joycon_protocol/joycon_types.h" | ||
| 15 | |||
| 16 | namespace InputCommon::Joycon { | ||
| 17 | |||
| 18 | class NfcProtocol final : private JoyconCommonProtocol { | ||
| 19 | public: | ||
| 20 | explicit NfcProtocol(std::shared_ptr<JoyconHandle> handle); | ||
| 21 | |||
| 22 | DriverResult EnableNfc(); | ||
| 23 | |||
| 24 | DriverResult DisableNfc(); | ||
| 25 | |||
| 26 | DriverResult StartNFCPollingMode(); | ||
| 27 | |||
| 28 | DriverResult ScanAmiibo(std::vector<u8>& data); | ||
| 29 | |||
| 30 | bool HasAmiibo(); | ||
| 31 | |||
| 32 | bool IsEnabled() const; | ||
| 33 | |||
| 34 | private: | ||
| 35 | struct TagFoundData { | ||
| 36 | u8 type; | ||
| 37 | std::vector<u8> uuid; | ||
| 38 | }; | ||
| 39 | |||
| 40 | DriverResult WaitUntilNfcIsReady(); | ||
| 41 | |||
| 42 | DriverResult StartPolling(TagFoundData& data); | ||
| 43 | |||
| 44 | DriverResult ReadTag(const TagFoundData& data); | ||
| 45 | |||
| 46 | DriverResult GetAmiiboData(std::vector<u8>& data); | ||
| 47 | |||
| 48 | DriverResult SendStartPollingRequest(std::vector<u8>& output); | ||
| 49 | |||
| 50 | DriverResult SendStopPollingRequest(std::vector<u8>& output); | ||
| 51 | |||
| 52 | DriverResult SendStartWaitingRecieveRequest(std::vector<u8>& output); | ||
| 53 | |||
| 54 | DriverResult SendReadAmiiboRequest(std::vector<u8>& output, NFCPages ntag_pages); | ||
| 55 | |||
| 56 | NFCReadBlockCommand GetReadBlockCommand(NFCPages pages) const; | ||
| 57 | |||
| 58 | bool is_enabled{}; | ||
| 59 | }; | ||
| 60 | |||
| 61 | } // namespace InputCommon::Joycon | ||