@@ -93,7 +93,7 @@ unsigned int HyperXAlloyOriginsCoreController::GetVariant()
9393 if (actual > 0 )
9494 variant = packet[56 ];
9595 else
96- variant = 0x09 ;
96+ variant = 0 ;
9797
9898 LOG_DEBUG (" [HyperX Alloy Origins Core] variant: 0x%02X" , variant);
9999 return variant;
@@ -112,8 +112,7 @@ void HyperXAlloyOriginsCoreController::SetBrightness(unsigned int brightness)
112112 hid_write (dev, packet, 65 );
113113}
114114
115-
116- void HyperXAlloyOriginsCoreController::SetLEDsDirect (std::vector<RGBColor> colors)
115+ void HyperXAlloyOriginsCoreController::SetLEDsDirect (std::vector<led> leds, std::vector<RGBColor> colors)
117116{
118117 /* ------------------------------------------------------------------------------*\
119118 | * Always send 380 bytes to the keyboard and a total of 94 led indexes. |
@@ -132,8 +131,7 @@ void HyperXAlloyOriginsCoreController::SetLEDsDirect(std::vector<RGBColor> color
132131 \*------------------------------------------------------------------------------*/
133132 unsigned int segment = 0 , sector = 0 , sequence = 0 ;
134133 unsigned int total_colors = 0 ;
135- unsigned char buf[380 ];
136- memset (buf, 0x00 , sizeof (buf));
134+ memset (color_buf, 0x00 , sizeof (color_buf));
137135
138136 /* ---------------------------------------------------------------------------*\
139137 | transfer the colors to the buffer. Max 94 colors to avoid buffer overflow. |
@@ -147,22 +145,27 @@ void HyperXAlloyOriginsCoreController::SetLEDsDirect(std::vector<RGBColor> color
147145 total_colors = (unsigned int )colors.size ();
148146 }
149147
150- for (unsigned int color_idx = 0 ; color_idx < total_colors; color_idx++)
148+ unsigned int pos = 0 , color_idx = 0 ;
149+ for (unsigned int i = 0 ; i < total_colors; i++)
151150 {
152- unsigned int pos = 0 ;
153- segment = (color_idx / 12 ) * 48 ;
154- sector = ((color_idx / 6 ) & 1 ) * 8 ;
155- sequence = color_idx % 6 ;
151+ color_idx = leds[i]. value ;
152+ segment = (color_idx / 12 ) * 48 ;
153+ sector = ((color_idx / 6 ) & 1 ) * 8 ;
154+ sequence = color_idx % 6 ;
156155
157- pos = segment + sector + sequence;
156+ pos = segment + sector + sequence;
158157
159- buf [pos ] = RGBGetGValue (colors[color_idx ]);
160- buf [pos + 16 ] = RGBGetRValue (colors[color_idx ]);
161- buf [pos + 32 ] = RGBGetBValue (colors[color_idx ]);
158+ color_buf [pos ] = RGBGetGValue (colors[i ]);
159+ color_buf [pos + 16 ] = RGBGetRValue (colors[i ]);
160+ color_buf [pos + 32 ] = RGBGetBValue (colors[i ]);
162161 }
162+ }
163163
164+
165+ void HyperXAlloyOriginsCoreController::SendRGBToDevice ()
166+ {
164167 unsigned int sentBytes = 0 ;
165- unsigned int bytesToSend = sizeof (buf );
168+ unsigned int bytesToSend = sizeof (color_buf );
166169 unsigned int payloadSize = 60 ;
167170 unsigned int seq = 0 ;
168171
@@ -180,7 +183,7 @@ void HyperXAlloyOriginsCoreController::SetLEDsDirect(std::vector<RGBColor> color
180183 packet[2 ] = seq++;
181184 packet[4 ] = payloadSize;
182185
183- memcpy (&packet[5 ], &buf [sentBytes], payloadSize);
186+ memcpy (&packet[5 ], &color_buf [sentBytes], payloadSize);
184187 hid_write (dev, packet, payloadSize + 5 );
185188
186189 sentBytes += payloadSize;
0 commit comments