diff options
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/common_protocol.cpp')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/common_protocol.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.cpp b/src/input_common/helpers/joycon_protocol/common_protocol.cpp index 153a3908c..417d0dcc5 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.cpp +++ b/src/input_common/helpers/joycon_protocol/common_protocol.cpp | |||
| @@ -58,9 +58,8 @@ DriverResult JoyconCommonProtocol::CheckDeviceAccess(SDL_hid_device_info* device | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | DriverResult JoyconCommonProtocol::SetReportMode(ReportMode report_mode) { | 60 | DriverResult JoyconCommonProtocol::SetReportMode(ReportMode report_mode) { |
| 61 | const std::vector<u8> buffer{static_cast<u8>(report_mode)}; | 61 | const std::array<u8, 1> buffer{static_cast<u8>(report_mode)}; |
| 62 | std::vector<u8> output; | 62 | return SendSubCommand(SubCommand::SET_REPORT_MODE, buffer); |
| 63 | return SendSubCommand(SubCommand::SET_REPORT_MODE, buffer, output); | ||
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | DriverResult JoyconCommonProtocol::SendData(std::span<const u8> buffer) { | 65 | DriverResult JoyconCommonProtocol::SendData(std::span<const u8> buffer) { |
| @@ -120,7 +119,12 @@ DriverResult JoyconCommonProtocol::SendSubCommand(SubCommand sc, std::span<const | |||
| 120 | return DriverResult::Success; | 119 | return DriverResult::Success; |
| 121 | } | 120 | } |
| 122 | 121 | ||
| 123 | DriverResult JoyconCommonProtocol::SendMcuCommand(SubCommand sc, std::span<const u8> buffer) { | 122 | DriverResult JoyconCommonProtocol::SendSubCommand(SubCommand sc, std::span<const u8> buffer) { |
| 123 | std::vector<u8> output; | ||
| 124 | return SendSubCommand(sc, buffer, output); | ||
| 125 | } | ||
| 126 | |||
| 127 | DriverResult JoyconCommonProtocol::SendMCUCommand(SubCommand sc, std::span<const u8> buffer) { | ||
| 124 | std::vector<u8> local_buffer(MaxResponseSize); | 128 | std::vector<u8> local_buffer(MaxResponseSize); |
| 125 | 129 | ||
| 126 | local_buffer[0] = static_cast<u8>(OutputReport::MCU_DATA); | 130 | local_buffer[0] = static_cast<u8>(OutputReport::MCU_DATA); |
| @@ -147,7 +151,7 @@ DriverResult JoyconCommonProtocol::SendVibrationReport(std::span<const u8> buffe | |||
| 147 | DriverResult JoyconCommonProtocol::ReadSPI(CalAddr addr, u8 size, std::vector<u8>& output) { | 151 | DriverResult JoyconCommonProtocol::ReadSPI(CalAddr addr, u8 size, std::vector<u8>& output) { |
| 148 | constexpr std::size_t MaxTries = 10; | 152 | constexpr std::size_t MaxTries = 10; |
| 149 | std::size_t tries = 0; | 153 | std::size_t tries = 0; |
| 150 | std::vector<u8> buffer = {0x00, 0x00, 0x00, 0x00, size}; | 154 | std::array<u8, 5> buffer = {0x00, 0x00, 0x00, 0x00, size}; |
| 151 | std::vector<u8> local_buffer(size + 20); | 155 | std::vector<u8> local_buffer(size + 20); |
| 152 | 156 | ||
| 153 | buffer[0] = static_cast<u8>(static_cast<u16>(addr) & 0x00FF); | 157 | buffer[0] = static_cast<u8>(static_cast<u16>(addr) & 0x00FF); |
| @@ -169,10 +173,8 @@ DriverResult JoyconCommonProtocol::ReadSPI(CalAddr addr, u8 size, std::vector<u8 | |||
| 169 | } | 173 | } |
| 170 | 174 | ||
| 171 | DriverResult JoyconCommonProtocol::EnableMCU(bool enable) { | 175 | DriverResult JoyconCommonProtocol::EnableMCU(bool enable) { |
| 172 | std::vector<u8> output; | 176 | const std::array<u8, 1> mcu_state{static_cast<u8>(enable ? 1 : 0)}; |
| 173 | 177 | const auto result = SendSubCommand(SubCommand::SET_MCU_STATE, mcu_state); | |
| 174 | const std::vector<u8> mcu_state{static_cast<u8>(enable ? 1 : 0)}; | ||
| 175 | const auto result = SendSubCommand(SubCommand::SET_MCU_STATE, mcu_state, output); | ||
| 176 | 178 | ||
| 177 | if (result != DriverResult::Success) { | 179 | if (result != DriverResult::Success) { |
| 178 | LOG_ERROR(Input, "SendMCUData failed with error {}", result); | 180 | LOG_ERROR(Input, "SendMCUData failed with error {}", result); |
| @@ -183,13 +185,11 @@ DriverResult JoyconCommonProtocol::EnableMCU(bool enable) { | |||
| 183 | 185 | ||
| 184 | DriverResult JoyconCommonProtocol::ConfigureMCU(const MCUConfig& config) { | 186 | DriverResult JoyconCommonProtocol::ConfigureMCU(const MCUConfig& config) { |
| 185 | LOG_DEBUG(Input, "ConfigureMCU"); | 187 | LOG_DEBUG(Input, "ConfigureMCU"); |
| 186 | std::vector<u8> output; | ||
| 187 | |||
| 188 | std::array<u8, sizeof(MCUConfig)> config_buffer; | 188 | std::array<u8, sizeof(MCUConfig)> config_buffer; |
| 189 | memcpy(config_buffer.data(), &config, sizeof(MCUConfig)); | 189 | memcpy(config_buffer.data(), &config, sizeof(MCUConfig)); |
| 190 | config_buffer[37] = CalculateMCU_CRC8(config_buffer.data() + 1, 36); | 190 | config_buffer[37] = CalculateMCU_CRC8(config_buffer.data() + 1, 36); |
| 191 | 191 | ||
| 192 | const auto result = SendSubCommand(SubCommand::SET_MCU_CONFIG, config_buffer, output); | 192 | const auto result = SendSubCommand(SubCommand::SET_MCU_CONFIG, config_buffer); |
| 193 | 193 | ||
| 194 | if (result != DriverResult::Success) { | 194 | if (result != DriverResult::Success) { |
| 195 | LOG_ERROR(Input, "Set MCU config failed with error {}", result); | 195 | LOG_ERROR(Input, "Set MCU config failed with error {}", result); |