From 340f15d1fa79594dbe12a6e19140ba012751b533 Mon Sep 17 00:00:00 2001 From: german77 Date: Fri, 13 Jan 2023 23:29:05 -0600 Subject: input_common: Address byte review --- src/input_common/helpers/joycon_protocol/irs.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/input_common/helpers/joycon_protocol/irs.cpp') diff --git a/src/input_common/helpers/joycon_protocol/irs.cpp b/src/input_common/helpers/joycon_protocol/irs.cpp index 9dfa503c2..09e17bc5b 100644 --- a/src/input_common/helpers/joycon_protocol/irs.cpp +++ b/src/input_common/helpers/joycon_protocol/irs.cpp @@ -12,8 +12,8 @@ IrsProtocol::IrsProtocol(std::shared_ptr handle) DriverResult IrsProtocol::EnableIrs() { LOG_INFO(Input, "Enable IRS"); + ScopedSetBlocking sb(this); DriverResult result{DriverResult::Success}; - SetBlocking(); if (result == DriverResult::Success) { result = SetReportMode(ReportMode::NFC_IR_MODE_60HZ); @@ -49,14 +49,13 @@ DriverResult IrsProtocol::EnableIrs() { is_enabled = true; - SetNonBlocking(); return result; } DriverResult IrsProtocol::DisableIrs() { LOG_DEBUG(Input, "Disable IRS"); + ScopedSetBlocking sb(this); DriverResult result{DriverResult::Success}; - SetBlocking(); if (result == DriverResult::Success) { result = EnableMCU(false); @@ -64,7 +63,6 @@ DriverResult IrsProtocol::DisableIrs() { is_enabled = false; - SetNonBlocking(); return result; } @@ -148,7 +146,7 @@ DriverResult IrsProtocol::ConfigureIrs() { }; buf_image.resize((static_cast(fragments) + 1) * 300); - std::vector request_data(sizeof(IrsConfigure)); + std::array request_data{}; memcpy(request_data.data(), &irs_configuration, sizeof(IrsConfigure)); request_data[37] = CalculateMCU_CRC8(request_data.data() + 1, 36); do { @@ -191,7 +189,7 @@ DriverResult IrsProtocol::WriteRegistersStep1() { .crc = {}, }; - std::vector request_data(sizeof(IrsWriteRegisters)); + std::array request_data{}; memcpy(request_data.data(), &irs_registers, sizeof(IrsWriteRegisters)); request_data[37] = CalculateMCU_CRC8(request_data.data() + 1, 36); @@ -208,7 +206,7 @@ DriverResult IrsProtocol::WriteRegistersStep1() { // First time we need to set the report mode if (result == DriverResult::Success && tries == 0) { - result = SendMcuCommand(SubCommand::SET_REPORT_MODE, mcu_request); + result = SendMCUCommand(SubCommand::SET_REPORT_MODE, mcu_request); } if (result == DriverResult::Success && tries == 0) { GetSubCommandResponse(SubCommand::SET_MCU_CONFIG, output); @@ -250,7 +248,7 @@ DriverResult IrsProtocol::WriteRegistersStep2() { .crc = {}, }; - std::vector request_data(sizeof(IrsWriteRegisters)); + std::array request_data{}; memcpy(request_data.data(), &irs_registers, sizeof(IrsWriteRegisters)); request_data[37] = CalculateMCU_CRC8(request_data.data() + 1, 36); do { @@ -272,7 +270,7 @@ DriverResult IrsProtocol::RequestFrame(u8 frame) { mcu_request[3] = frame; mcu_request[36] = CalculateMCU_CRC8(mcu_request.data(), 36); mcu_request[37] = 0xFF; - return SendMcuCommand(SubCommand::SET_REPORT_MODE, mcu_request); + return SendMCUCommand(SubCommand::SET_REPORT_MODE, mcu_request); } DriverResult IrsProtocol::ResendFrame(u8 frame) { @@ -282,7 +280,7 @@ DriverResult IrsProtocol::ResendFrame(u8 frame) { mcu_request[3] = 0x0; mcu_request[36] = CalculateMCU_CRC8(mcu_request.data(), 36); mcu_request[37] = 0xFF; - return SendMcuCommand(SubCommand::SET_REPORT_MODE, mcu_request); + return SendMCUCommand(SubCommand::SET_REPORT_MODE, mcu_request); } std::vector IrsProtocol::GetImage() const { -- cgit v1.2.3