From 4e29afefc4afbce77f7ea0d110d7e844ce411eac Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Fri, 27 Jan 2023 17:47:47 -0600 Subject: input_common: joycon: Replace ReadSPI vector with span --- .../helpers/joycon_protocol/common_protocol.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/input_common/helpers/joycon_protocol/common_protocol.h') 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& output); + DriverResult ReadRawSPI(SpiAddress addr, std::span output); + /** + * Reads the SPI memory stored on the joycon + * @param Initial address location + * @returns output object containing the responce + */ template - requires(std::is_trivially_copyable_v) - DriverResult ReadSPI(SpiAddress addr, Output& output) { - std::vector buffer; + requires std::is_trivially_copyable_v DriverResult ReadSPI(SpiAddress addr, + Output& output) { + std::array 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; } -- cgit v1.2.3