summaryrefslogtreecommitdiff
path: root/src/input_common/helpers/joycon_protocol/common_protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/common_protocol.h')
-rw-r--r--src/input_common/helpers/joycon_protocol/common_protocol.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.h b/src/input_common/helpers/joycon_protocol/common_protocol.h
index 188f6ecfa..f44f73ba4 100644
--- a/src/input_common/helpers/joycon_protocol/common_protocol.h
+++ b/src/input_common/helpers/joycon_protocol/common_protocol.h
@@ -57,22 +57,31 @@ public:
57 * Sends data to the joycon device 57 * Sends data to the joycon device
58 * @param buffer data to be send 58 * @param buffer data to be send
59 */ 59 */
60 DriverResult SendData(std::span<const u8> buffer); 60 DriverResult SendRawData(std::span<const u8> buffer);
61
62 template <typename Output>
63 requires std::is_trivially_copyable_v<Output>
64 DriverResult SendData(const Output& output) {
65 std::array<u8, sizeof(Output)> buffer;
66 std::memcpy(buffer.data(), &output, sizeof(Output));
67 return SendRawData(buffer);
68 }
61 69
62 /** 70 /**
63 * Waits for incoming data of the joycon device that matchs the subcommand 71 * Waits for incoming data of the joycon device that matchs the subcommand
64 * @param sub_command type of data to be returned 72 * @param sub_command type of data to be returned
65 * @returns a buffer containing the responce 73 * @returns a buffer containing the response
66 */ 74 */
67 DriverResult GetSubCommandResponse(SubCommand sub_command, std::vector<u8>& output); 75 DriverResult GetSubCommandResponse(SubCommand sub_command, SubCommandResponse& output);
68 76
69 /** 77 /**
70 * Sends a sub command to the device and waits for it's reply 78 * Sends a sub command to the device and waits for it's reply
71 * @param sc sub command to be send 79 * @param sc sub command to be send
72 * @param buffer data to be send 80 * @param buffer data to be send
73 * @returns output buffer containing the responce 81 * @returns output buffer containing the response
74 */ 82 */
75 DriverResult SendSubCommand(SubCommand sc, std::span<const u8> buffer, std::vector<u8>& output); 83 DriverResult SendSubCommand(SubCommand sc, std::span<const u8> buffer,
84 SubCommandResponse& output);
76 85
77 /** 86 /**
78 * Sends a sub command to the device and waits for it's reply and ignores the output 87 * Sends a sub command to the device and waits for it's reply and ignores the output
@@ -97,14 +106,14 @@ public:
97 /** 106 /**
98 * Reads the SPI memory stored on the joycon 107 * Reads the SPI memory stored on the joycon
99 * @param Initial address location 108 * @param Initial address location
100 * @returns output buffer containing the responce 109 * @returns output buffer containing the response
101 */ 110 */
102 DriverResult ReadRawSPI(SpiAddress addr, std::span<u8> output); 111 DriverResult ReadRawSPI(SpiAddress addr, std::span<u8> output);
103 112
104 /** 113 /**
105 * Reads the SPI memory stored on the joycon 114 * Reads the SPI memory stored on the joycon
106 * @param Initial address location 115 * @param Initial address location
107 * @returns output object containing the responce 116 * @returns output object containing the response
108 */ 117 */
109 template <typename Output> 118 template <typename Output>
110 requires std::is_trivially_copyable_v<Output> 119 requires std::is_trivially_copyable_v<Output>
@@ -136,19 +145,19 @@ public:
136 /** 145 /**
137 * Waits until there's MCU data available. On timeout returns error 146 * Waits until there's MCU data available. On timeout returns error
138 * @param report mode of the expected reply 147 * @param report mode of the expected reply
139 * @returns a buffer containing the responce 148 * @returns a buffer containing the response
140 */ 149 */
141 DriverResult GetMCUDataResponse(ReportMode report_mode_, std::vector<u8>& output); 150 DriverResult GetMCUDataResponse(ReportMode report_mode_, MCUCommandResponse& output);
142 151
143 /** 152 /**
144 * Sends data to the MCU chip and waits for it's reply 153 * Sends data to the MCU chip and waits for it's reply
145 * @param report mode of the expected reply 154 * @param report mode of the expected reply
146 * @param sub command to be send 155 * @param sub command to be send
147 * @param buffer data to be send 156 * @param buffer data to be send
148 * @returns output buffer containing the responce 157 * @returns output buffer containing the response
149 */ 158 */
150 DriverResult SendMCUData(ReportMode report_mode, SubCommand sc, std::span<const u8> buffer, 159 DriverResult SendMCUData(ReportMode report_mode, SubCommand sc, std::span<const u8> buffer,
151 std::vector<u8>& output); 160 MCUCommandResponse& output);
152 161
153 /** 162 /**
154 * Wait's until the MCU chip is on the specified mode 163 * Wait's until the MCU chip is on the specified mode