diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2023-01-28 00:47:47 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2023-01-28 01:45:25 +0100 |
commit | 4e29afefc4afbce77f7ea0d110d7e844ce411eac (patch) | |
tree | 36348693dc5ef55813dfd57420d79bf0e5122c00 /src/input_common/helpers/joycon_protocol/common_protocol.h | |
parent | input_common: joycon: Remove magic numbers from calibration protocol (diff) | |
download | yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar.gz yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar.bz2 yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar.lz yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar.xz yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar.zst yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.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 | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.h b/src/input_common/helpers/joycon_protocol/common_protocol.h index 675eacf68..75d3f20a4 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.h +++ b/src/input_common/helpers/joycon_protocol/common_protocol.h @@ -97,26 +97,26 @@ 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(SpiAddress 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::vector<u8> buffer; + requires std::is_trivially_copyable_v<Output> DriverResult ReadSPI(SpiAddress addr, + Output& output) { + std::array<u8, sizeof(Output)> buffer; output = {}; - const auto result = ReadSPI(addr, sizeof(Output), buffer); + const auto result = ReadRawSPI(addr, buffer); if (result != DriverResult::Success) { return result; } - if (buffer.size() != sizeof(Output)) { - return DriverResult::WrongReply; - } - std::memcpy(&output, buffer.data(), sizeof(Output)); return DriverResult::Success; } |