diff options
author | bunnei <bunneidev@gmail.com> | 2023-01-29 11:43:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-29 11:43:14 +0100 |
commit | 9170387e71d4295477b74666a843a889af62b2a3 (patch) | |
tree | ee08cde9257dc4c77943b7566ee678ed8317eec2 /src/input_common/helpers/joycon_protocol/common_protocol.h | |
parent | Merge pull request #9691 from ameerj/msaa-texcache (diff) | |
parent | input_common: joycon: Replace ReadSPI vector with span (diff) | |
download | yuzu-9170387e71d4295477b74666a843a889af62b2a3.tar yuzu-9170387e71d4295477b74666a843a889af62b2a3.tar.gz yuzu-9170387e71d4295477b74666a843a889af62b2a3.tar.bz2 yuzu-9170387e71d4295477b74666a843a889af62b2a3.tar.lz yuzu-9170387e71d4295477b74666a843a889af62b2a3.tar.xz yuzu-9170387e71d4295477b74666a843a889af62b2a3.tar.zst yuzu-9170387e71d4295477b74666a843a889af62b2a3.zip |
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: /** * Reads the SPI memory stored on the joycon * @param Initial address location - * @param size in bytes to be read * @returns output buffer containing the responce */ - DriverResult ReadSPI(CalAddr addr, u8 size, std::vector<u8>& output); + DriverResult ReadRawSPI(SpiAddress addr, std::span<u8> output); + + /** + * Reads the SPI memory stored on the joycon + * @param Initial address location + * @returns output object containing the responce + */ + template <typename Output> + requires std::is_trivially_copyable_v<Output> DriverResult ReadSPI(SpiAddress addr, + Output& output) { + std::array<u8, sizeof(Output)> buffer; + output = {}; + + const auto result = ReadRawSPI(addr, buffer); + if (result != DriverResult::Success) { + return result; + } + + std::memcpy(&output, buffer.data(), sizeof(Output)); + return DriverResult::Success; + } /** * Enables MCU chip on the joycon |