diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2023-01-28 05:30:44 +0100 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-01-30 03:12:58 +0100 |
commit | c318a4c80b4b6eef9f8020f452573ef5c80f6716 (patch) | |
tree | ea031039eb63ef385ceeb0a5c0694baa9e8da8be /src/input_common/helpers/joycon_protocol/common_protocol.h | |
parent | input_common: joycon: Fill missing enum data (diff) | |
download | yuzu-c318a4c80b4b6eef9f8020f452573ef5c80f6716.tar yuzu-c318a4c80b4b6eef9f8020f452573ef5c80f6716.tar.gz yuzu-c318a4c80b4b6eef9f8020f452573ef5c80f6716.tar.bz2 yuzu-c318a4c80b4b6eef9f8020f452573ef5c80f6716.tar.lz yuzu-c318a4c80b4b6eef9f8020f452573ef5c80f6716.tar.xz yuzu-c318a4c80b4b6eef9f8020f452573ef5c80f6716.tar.zst yuzu-c318a4c80b4b6eef9f8020f452573ef5c80f6716.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 | 31 |
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: * Sends data to the joycon device * @param buffer data to be send */ - DriverResult SendData(std::span<const u8> buffer); + DriverResult SendRawData(std::span<const u8> buffer); + + template <typename Output> + requires std::is_trivially_copyable_v<Output> + DriverResult SendData(const Output& output) { + std::array<u8, sizeof(Output)> buffer; + std::memcpy(buffer.data(), &output, sizeof(Output)); + return SendRawData(buffer); + } /** * Waits for incoming data of the joycon device that matchs the subcommand * @param sub_command type of data to be returned - * @returns a buffer containing the responce + * @returns a buffer containing the response */ - DriverResult GetSubCommandResponse(SubCommand sub_command, std::vector<u8>& output); + DriverResult GetSubCommandResponse(SubCommand sub_command, SubCommandResponse& output); /** * Sends a sub command to the device and waits for it's reply * @param sc sub command to be send * @param buffer data to be send - * @returns output buffer containing the responce + * @returns output buffer containing the response */ - DriverResult SendSubCommand(SubCommand sc, std::span<const u8> buffer, std::vector<u8>& output); + DriverResult SendSubCommand(SubCommand sc, std::span<const u8> buffer, + SubCommandResponse& output); /** * Sends a sub command to the device and waits for it's reply and ignores the output @@ -97,14 +106,14 @@ public: /** * Reads the SPI memory stored on the joycon * @param Initial address location - * @returns output buffer containing the responce + * @returns output buffer containing the response */ 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 + * @returns output object containing the response */ template <typename Output> requires std::is_trivially_copyable_v<Output> @@ -136,19 +145,19 @@ public: /** * Waits until there's MCU data available. On timeout returns error * @param report mode of the expected reply - * @returns a buffer containing the responce + * @returns a buffer containing the response */ - DriverResult GetMCUDataResponse(ReportMode report_mode_, std::vector<u8>& output); + DriverResult GetMCUDataResponse(ReportMode report_mode_, MCUCommandResponse& output); /** * Sends data to the MCU chip and waits for it's reply * @param report mode of the expected reply * @param sub command to be send * @param buffer data to be send - * @returns output buffer containing the responce + * @returns output buffer containing the response */ DriverResult SendMCUData(ReportMode report_mode, SubCommand sc, std::span<const u8> buffer, - std::vector<u8>& output); + MCUCommandResponse& output); /** * Wait's until the MCU chip is on the specified mode |