summaryrefslogtreecommitdiff
path: root/src/input_common/helpers/joycon_protocol/common_protocol.h
diff options
context:
space:
mode:
authorGravatar Narr the Reg2023-01-27 17:47:47 -0600
committerGravatar Narr the Reg2023-01-27 18:45:25 -0600
commit4e29afefc4afbce77f7ea0d110d7e844ce411eac (patch)
tree36348693dc5ef55813dfd57420d79bf0e5122c00 /src/input_common/helpers/joycon_protocol/common_protocol.h
parentinput_common: joycon: Remove magic numbers from calibration protocol (diff)
downloadyuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar.gz
yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.tar.xz
yuzu-4e29afefc4afbce77f7ea0d110d7e844ce411eac.zip
input_common: joycon: Replace ReadSPI vector with span
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/common_protocol.h')
-rw-r--r--src/input_common/helpers/joycon_protocol/common_protocol.h20
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:
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(SpiAddress addr, u8 size, std::vector<u8>& output); 102 DriverResult ReadRawSPI(SpiAddress addr, std::span<u8> output);
104 103
104 /**
105 * Reads the SPI memory stored on the joycon
106 * @param Initial address location
107 * @returns output object containing the responce
108 */
105 template <typename Output> 109 template <typename Output>
106 requires(std::is_trivially_copyable_v<Output>) 110 requires std::is_trivially_copyable_v<Output> DriverResult ReadSPI(SpiAddress addr,
107 DriverResult ReadSPI(SpiAddress addr, Output& output) { 111 Output& output) {
108 std::vector<u8> buffer; 112 std::array<u8, sizeof(Output)> buffer;
109 output = {}; 113 output = {};
110 114
111 const auto result = ReadSPI(addr, sizeof(Output), buffer); 115 const auto result = ReadRawSPI(addr, buffer);
112 if (result != DriverResult::Success) { 116 if (result != DriverResult::Success) {
113 return result; 117 return result;
114 } 118 }
115 119
116 if (buffer.size() != sizeof(Output)) {
117 return DriverResult::WrongReply;
118 }
119
120 std::memcpy(&output, buffer.data(), sizeof(Output)); 120 std::memcpy(&output, buffer.data(), sizeof(Output));
121 return DriverResult::Success; 121 return DriverResult::Success;
122 } 122 }