diff options
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/common_protocol.h')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/common_protocol.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.h b/src/input_common/helpers/joycon_protocol/common_protocol.h index 903bcf402..75d3f20a4 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.h +++ b/src/input_common/helpers/joycon_protocol/common_protocol.h | |||
| @@ -97,10 +97,29 @@ public: | |||
| 97 | /** | 97 | /** |
| 98 | * Reads the SPI memory stored on the joycon | 98 | * Reads the SPI memory stored on the joycon |
| 99 | * @param Initial address location | 99 | * @param Initial address location |
| 100 | * @param size in bytes to be read | ||
| 101 | * @returns output buffer containing the responce | 100 | * @returns output buffer containing the responce |
| 102 | */ | 101 | */ |
| 103 | DriverResult ReadSPI(CalAddr addr, u8 size, std::vector<u8>& output); | 102 | DriverResult ReadRawSPI(SpiAddress addr, std::span<u8> output); |
| 103 | |||
| 104 | /** | ||
| 105 | * Reads the SPI memory stored on the joycon | ||
| 106 | * @param Initial address location | ||
| 107 | * @returns output object containing the responce | ||
| 108 | */ | ||
| 109 | template <typename Output> | ||
| 110 | requires std::is_trivially_copyable_v<Output> DriverResult ReadSPI(SpiAddress addr, | ||
| 111 | Output& output) { | ||
| 112 | std::array<u8, sizeof(Output)> buffer; | ||
| 113 | output = {}; | ||
| 114 | |||
| 115 | const auto result = ReadRawSPI(addr, buffer); | ||
| 116 | if (result != DriverResult::Success) { | ||
| 117 | return result; | ||
| 118 | } | ||
| 119 | |||
| 120 | std::memcpy(&output, buffer.data(), sizeof(Output)); | ||
| 121 | return DriverResult::Success; | ||
| 122 | } | ||
| 104 | 123 | ||
| 105 | /** | 124 | /** |
| 106 | * Enables MCU chip on the joycon | 125 | * Enables MCU chip on the joycon |