From c318a4c80b4b6eef9f8020f452573ef5c80f6716 Mon Sep 17 00:00:00 2001
From: Narr the Reg <juangerman-13@hotmail.com>
Date: Fri, 27 Jan 2023 22:30:44 -0600
Subject: input_common: joycon: Remove Magic numbers from common protocol

---
 src/input_common/helpers/joycon_protocol/irs.cpp | 13 +++++++------
 1 file changed, 7 insertions(+), 6 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 09e17bc5b6..731fd59810 100644
--- a/src/input_common/helpers/joycon_protocol/irs.cpp
+++ b/src/input_common/helpers/joycon_protocol/irs.cpp
@@ -132,7 +132,7 @@ DriverResult IrsProtocol::RequestImage(std::span<u8> buffer) {
 DriverResult IrsProtocol::ConfigureIrs() {
     LOG_DEBUG(Input, "Configure IRS");
     constexpr std::size_t max_tries = 28;
-    std::vector<u8> output;
+    SubCommandResponse output{};
     std::size_t tries = 0;
 
     const IrsConfigure irs_configuration{
@@ -158,7 +158,7 @@ DriverResult IrsProtocol::ConfigureIrs() {
         if (tries++ >= max_tries) {
             return DriverResult::WrongReply;
         }
-    } while (output[15] != 0x0b);
+    } while (output.command_data[0] != 0x0b);
 
     return DriverResult::Success;
 }
@@ -167,7 +167,7 @@ DriverResult IrsProtocol::WriteRegistersStep1() {
     LOG_DEBUG(Input, "WriteRegistersStep1");
     DriverResult result{DriverResult::Success};
     constexpr std::size_t max_tries = 28;
-    std::vector<u8> output;
+    SubCommandResponse output{};
     std::size_t tries = 0;
 
     const IrsWriteRegisters irs_registers{
@@ -218,7 +218,8 @@ DriverResult IrsProtocol::WriteRegistersStep1() {
         if (tries++ >= max_tries) {
             return DriverResult::WrongReply;
         }
-    } while (!(output[15] == 0x13 && output[17] == 0x07) && output[15] != 0x23);
+    } while (!(output.command_data[0] == 0x13 && output.command_data[2] == 0x07) &&
+             output.command_data[0] != 0x23);
 
     return DriverResult::Success;
 }
@@ -226,7 +227,7 @@ DriverResult IrsProtocol::WriteRegistersStep1() {
 DriverResult IrsProtocol::WriteRegistersStep2() {
     LOG_DEBUG(Input, "WriteRegistersStep2");
     constexpr std::size_t max_tries = 28;
-    std::vector<u8> output;
+    SubCommandResponse output{};
     std::size_t tries = 0;
 
     const IrsWriteRegisters irs_registers{
@@ -260,7 +261,7 @@ DriverResult IrsProtocol::WriteRegistersStep2() {
         if (tries++ >= max_tries) {
             return DriverResult::WrongReply;
         }
-    } while (output[15] != 0x13 && output[15] != 0x23);
+    } while (output.command_data[0] != 0x13 && output.command_data[0] != 0x23);
 
     return DriverResult::Success;
 }
-- 
cgit v1.2.3-70-g09d2