-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathRazerChroma.cpp
612 lines (532 loc) · 22.5 KB
/
RazerChroma.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
/*---------------------------------------------------------*\
| Processing Code for Razer Chroma SDK Interface |
| |
| Adam Honse ([email protected]), 12/11/2016 |
\*---------------------------------------------------------*/
#include "RazerChroma.h"
#include <iostream>
//Index lists for BlackWidow
int BlackWidowXIndex[22];
int BlackWidowYIndex[6];
int BlackWidowAvgCnt[6];
int BlackWidowAvgIndex[6*3];
//Index lists for BlackWidow TE
int BlackWidowTEXIndex[18];
int BlackWidowTEYIndex[6];
int BlackWidowTEAvgCnt[6];
int BlackWidowTEAvgIndex[6*3];
//Index lists for Blade Stealth
int BladeStealthXIndex[16];
int BladeStealthYIndex[6];
int BlackStealthAvgCnt[6];
int BlackStealthAvgIndex[6*3];
//Index list for Firefly
int FireflyIndex[15];
//Index list for mice (Mamba TE, DeathAdder)
int MouseXIndex[9][7];
int MouseYIndex[9][7];
//Index list for Razer Core
int CoreXIndex[8];
//Index list for DeathStalker
static int DeathStalkerXLEDIndex[] = { 1, 4, 8, 12, 15, 18 };
int DeathStalkerXIndex[6];
//Index lists for Orbweaver
int OrbweaverXIndex[5];
int OrbweaverYIndex[4];
//Index list for ChromaLink
int ChromaLinkXIndex[ChromaSDK::ChromaLink::MAX_LEDS];
//Index list for Chroma HDK Matrix (Chroma Box)
int ChromaBoxXIndex[16];
int ChromaBoxYIndex[4];
//Index list for individual strips bar graph Chroma HDK
int ChromaBox1BarXIndex[4][16];
//Index list for 2 strips bar graph Chroma HDK
int ChromaBox2BarXIndex[4][16];
//Index list for 4 strips bar graph Chroma HDK
int ChromaBox4BarXIndex[4][16];
RazerChroma::RazerChroma()
{
}
RazerChroma::~RazerChroma()
{
if (hModule)
{
UNINIT UnInit = (UNINIT)GetProcAddress(hModule, "UnInit");
if (UnInit)
{
UnInit();
}
}
}
static void SetupKeyboardGrid(int x_count, int y_count, int * x_idx_list, int * y_idx_list)
{
for (int x = 0; x < x_count; x++)
{
if (x_count < 10)
{
x_idx_list[x] = (int)((x * (SPECTROGRAPH_COLS / (x_count))) + (0.5f * (SPECTROGRAPH_COLS / (x_count))));
}
else if (x < ((x_count) / 2))
{
x_idx_list[x] = (int)((x * (SPECTROGRAPH_COLS / (x_count - 1))) + (0.5f * (SPECTROGRAPH_COLS / (x_count - 1))));
}
else
{
x_idx_list[x] = (int)((x * (SPECTROGRAPH_COLS / (x_count - 1))) - (0.5f * (SPECTROGRAPH_COLS / (x_count - 1))));
}
}
for (int y = 0; y < y_count; y++)
{
y_idx_list[y] = (int)(ROW_IDX_SPECTROGRAPH_TOP + (y * (SPECTROGRAPH_ROWS / y_count)) + (0.5f * (SPECTROGRAPH_ROWS / y_count)));
}
}
void FillCustomGrid(int x_count, int y_count, int * x_idx_list, int * y_idx_list, ChromaSDK::CUSTOM_EFFECT_TYPE * effect, COLORREF pixels[64][256])
{
for (int x = 0; x < x_count; x++)
{
for (int y = 0; y < y_count; y++)
{
effect->Color[y][x] = (pixels[y_idx_list[y]][x_idx_list[x]] & 0x00FFFFFF);
}
}
}
void FillKeyboardGrid(int x_count, int y_count, int * x_idx_list, int * y_idx_list, ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE * effect, COLORREF pixels[64][256])
{
for (int x = 0; x < x_count; x++)
{
for (int y = 0; y < y_count; y++)
{
effect->Color[y][x] = (pixels[y_idx_list[y]][x_idx_list[x]] & 0x00FFFFFF);
}
}
}
void FillKeyboardGridAvg(int x_count, int y_count, int *tmpColumnCount, int *tmpColumnColor, ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE * effect, COLORREF pixels[64][256])
{
//defines how many pixels will get averaged out per row/column
float pxCntCol = ((float)SPECTROGRAPH_COLS / (float)x_count);
float pxCntRow = ((float)SPECTROGRAPH_ROWS / (float)y_count);
//reset added up colors for next column
memset(tmpColumnCount, 0, y_count * sizeof(int));
memset(tmpColumnColor, 0, y_count * 3 * sizeof(int));
//variables for current keyboard row and column
int cRow = 0, cColumn = 0;
//temporary color storage
int cCol[3];
cCol[0] = 0; cCol[1] = 0; cCol[2] = 0;
//used to determine if keyboard row/column is done
int cRowMulti = 1; int cColumnMulti = 1;
for (int cColumnTotal = 0; cColumnTotal < SPECTROGRAPH_COLS; cColumnTotal++)
{
if (cColumnTotal >= (cColumnMulti*pxCntCol)) //one column done
{
for (int k = 0; k < y_count; k++) //iterate through rows
{
effect->Color[k][cColumn] =
RGB((((tmpColumnColor[(k * 3) + 0]) / tmpColumnCount[k]) & 0xFF),
(((tmpColumnColor[(k * 3) + 1]) / tmpColumnCount[k]) & 0xFF),
(((tmpColumnColor[(k * 3) + 2]) / tmpColumnCount[k]) & 0xFF));
}
//reset added up colors for next column
memset(tmpColumnCount, 0, y_count * sizeof(int));
memset(tmpColumnColor, 0, y_count * 3 * sizeof(int));
//increase column count
cColumnMulti++;
cColumn++;
//done handling columns
if (cColumn >= x_count)
break;
}
for (int cRowsTotal = 0; cRowsTotal < SPECTROGRAPH_ROWS; cRowsTotal++) //rows
{
if (cRowsTotal >= (cRowMulti*pxCntRow)) //one row in current column done
{
tmpColumnColor[(cRow * 3)+0] += cCol[0];
tmpColumnColor[(cRow * 3)+1] += cCol[1];
tmpColumnColor[(cRow * 3)+2] += cCol[2];
//clear colors
cCol[0] = 0; cCol[1] = 0; cCol[2] = 0;
//increase row count
cRowMulti++;
cRow++;
//done handling rows
if (cRow >= y_count)
break;
}
cCol[0] += GetRValue(pixels[ROW_IDX_SPECTROGRAPH_TOP + cRowsTotal][cColumnTotal]);
cCol[1] += GetGValue(pixels[ROW_IDX_SPECTROGRAPH_TOP + cRowsTotal][cColumnTotal]);
cCol[2] += GetBValue(pixels[ROW_IDX_SPECTROGRAPH_TOP + cRowsTotal][cColumnTotal]);
//increase total colors added for this row/column for division later
tmpColumnCount[cRow]++;
}
if (cRow < y_count) //last row was not set yet
{
//add last row
tmpColumnColor[(cRow * 3)+0] += cCol[0];
tmpColumnColor[(cRow * 3)+1] += cCol[1];
tmpColumnColor[(cRow * 3)+2] += cCol[2];
}
//clear colors
cCol[0] = 0; cCol[1] = 0; cCol[2] = 0;
//reset row count
cRowMulti = 1;
cRow = 0;
}
if (cColumn < x_count) //last column was not set yet
{
for (int k = 0; k < y_count; k++) //iterate through rows
{
effect->Color[k][cColumn] =
RGB(((tmpColumnColor[(k * 3) + 0]) / tmpColumnCount[k]),
((tmpColumnColor[(k * 3) + 1]) / tmpColumnCount[k]),
((tmpColumnColor[(k * 3) + 2]) / tmpColumnCount[k]));
}
//no color reset needed here, will be done on next call
}
}
void FillKeypadGrid(int x_count, int y_count, int * x_idx_list, int * y_idx_list, ChromaSDK::Keypad::CUSTOM_EFFECT_TYPE * effect, COLORREF pixels[64][256])
{
for (int x = 0; x < x_count; x++)
{
for (int y = 0; y < y_count; y++)
{
effect->Color[y][x] = (pixels[y_idx_list[y]][x_idx_list[x]] & 0x00FFFFFF);
}
}
}
void RazerChroma::Initialize()
{
// Initialize variables
use_keyboard_generic_effect = false;
use_headset_custom_effect = false;
use_chromalink_single_color = false;
use_keyboard_nearest_filter = false;
disable_chromalink = false;
chroma_box_mode = 1;
// Dynamically loads the Chroma SDK library.
hModule = LoadLibrary(CHROMASDKDLL);
if (hModule)
{
INIT Init = (INIT)GetProcAddress(hModule, "Init");
if (Init)
{
//Initialize the SDK
Init();
//Build index list for BlackWidow
SetupKeyboardGrid(22, 6, BlackWidowXIndex, BlackWidowYIndex);
//Build index list for BlackWidow TE
SetupKeyboardGrid(18, 6, BlackWidowTEXIndex, BlackWidowTEYIndex);
//Build index list for Blade Stealth
SetupKeyboardGrid(16, 6, BladeStealthXIndex, BladeStealthYIndex);
//Build index list for Chroma Box
SetupKeyboardGrid(16, 4, ChromaBoxXIndex, ChromaBoxYIndex);
//Build index list for OrbWeaver
SetupKeyboardGrid(5, 4, OrbweaverXIndex, OrbweaverYIndex);
//Build index list for Firefly
for (int x = 0; x < 15; x++)
{
if (x == 7)
{
FireflyIndex[x] = 128;
}
else if (x < 8)
{
FireflyIndex[x] = 7 + ((x+1) * 16);
}
else
{
FireflyIndex[x] = 8 + (x * 16);
}
}
//Build index list for mice
for (int x = 0; x < 7; x++)
{
for (int y = 0; y < 9; y++)
{
//Set scroll wheel LED
if ((x == 3) && (y == 2))
{
MouseXIndex[y][x] = 0;
MouseYIndex[y][x] = ROW_IDX_SINGLE_COLOR;
}
//Set logo LED
else if ((x == 3) && (y == 7))
{
MouseXIndex[y][x] = 14 * 5;
MouseYIndex[y][x] = ROW_IDX_SINGLE_COLOR;
}
//Set keypad LED
else if ((x == 3) && (y == 4))
{
MouseXIndex[y][x] = 14 * 5;
MouseYIndex[y][x] = ROW_IDX_SINGLE_COLOR;
}
//Set side LEDs
else if (((x == 0) || (x == 6)) && (y > 0) && (y < 8))
{
MouseXIndex[y][x] = 14 * ( y );
MouseYIndex[y][x] = ROW_IDX_BAR_GRAPH;
}
//Set bottom LEDs
else if ((y == 8) && (x > 0) && (x < 6))
{
if ((x == 1) || (x == 5))
{
MouseXIndex[y][x] = 14 * (y);
MouseYIndex[y][x] = ROW_IDX_BAR_GRAPH;
}
else if ((x == 2) || (x == 4))
{
MouseXIndex[y][x] = 14 * (y + 1);
MouseYIndex[y][x] = ROW_IDX_BAR_GRAPH;
}
else if (x == 3)
{
MouseXIndex[y][x] = 14 * (y + 2);
MouseYIndex[y][x] = ROW_IDX_BAR_GRAPH;
}
}
}
}
//Build index list for Core
for (int x = 0; x < 8; x++)
{
CoreXIndex[x] = (x * (256 / 8)) + (256 / 16);
}
//Build index list for DeathStalker
for (int x = 0; x < 6; x++)
{
DeathStalkerXIndex[x] = 128 + (x * (256 / 12) + (256 / 24));
}
//Build index list for ChromaLink Matrix
for (int x = 0; x < ChromaSDK::ChromaLink::MAX_LEDS; x++)
{
ChromaLinkXIndex[x] = (x * (256 / ChromaSDK::ChromaLink::MAX_LEDS)) + (256 / (ChromaSDK::ChromaLink::MAX_LEDS * 2));
}
//Build index list for ChromaLink 1 Strip Bar Graph
for (int y = 0; y < 4; y++)
{
for (int x = 0; x < 16; x++)
{
ChromaBox1BarXIndex[y][x] = (x * (256 / 16)) + (256 / 32);
}
}
//Build index list for ChromaLink 2 Strip Bar Graph
for (int y = 0; y < 4; y += 2)
{
for (int x = 0; x < 32; x++)
{
if (x < 16)
{
ChromaBox2BarXIndex[y][x] = (x * (256 / 32)) + (256 / 64);
}
else
{
ChromaBox2BarXIndex[y+1][x-16] = (x * (256 / 32)) + (256 / 64);
}
}
}
//Build index list for ChromaLink 4 Strip Bar Graph
for (int x = 0; x < 64; x++)
{
if (x < 16)
{
ChromaBox4BarXIndex[0][15-x] = (x * (256 / 64)) + (256 / 128);
}
else if (x < 32)
{
ChromaBox4BarXIndex[1][15-(x-16)] = (x * (256 / 64)) + (256 / 128);
}
else if (x < 48)
{
ChromaBox4BarXIndex[2][x-32] = (x * (256 / 64)) + (256 / 128);
}
else
{
ChromaBox4BarXIndex[3][x-48] = (x * (256 / 64)) + (256 / 128);
}
}
}
}
}
bool RazerChroma::SetLEDs(COLORREF pixels[64][256])
{
CreateEffect = (CREATEEFFECT)GetProcAddress(hModule, "CreateEffect");
CreateKeyboardEffect = (CREATEKEYBOARDEFFECT)GetProcAddress(hModule, "CreateKeyboardEffect");
CreateMouseEffect = (CREATEMOUSEEFFECT)GetProcAddress(hModule, "CreateMouseEffect");
CreateMousepadEffect = (CREATEMOUSEPADEFFECT)GetProcAddress(hModule, "CreateMousepadEffect");
CreateHeadsetEffect = (CREATEHEADSETEFFECT)GetProcAddress(hModule, "CreateHeadsetEffect");
CreateChromaLinkEffect = (CREATECHROMALINKEFFECT)GetProcAddress(hModule, "CreateChromaLinkEffect");
if (CreateEffect == NULL || pixels == NULL)
{
return FALSE;
}
else
{
//The use_generic_keyboard option uses the generic keyboard effect to apply the same pattern
//to all Chroma SDK supported keyboards. This effect is a workaround for missing Blade Stealth
//Kaby Lake support in the SDK, as the generic effect seems to be the only working way to
//support this product
if (use_keyboard_generic_effect)
{
//Keyboard Effect
ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE KeyboardEffect;
if(use_keyboard_nearest_filter)
FillKeyboardGrid(22, 6, BlackWidowXIndex, BlackWidowYIndex, &KeyboardEffect, pixels);
else
FillKeyboardGridAvg(22, 6, BlackWidowAvgCnt, BlackWidowAvgIndex, &KeyboardEffect, pixels);
//Set Razer "Three Headed Snake" logo to the background color of the 11th column
KeyboardEffect.Color[0][20] = pixels[ROW_IDX_SINGLE_COLOR][11 * (256 / 22)];
CreateKeyboardEffect(ChromaSDK::Keyboard::CHROMA_CUSTOM, &KeyboardEffect, NULL);
}
else
{
//Blackwidow Chroma
ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE BlackWidowEffect;
if (use_keyboard_nearest_filter)
FillKeyboardGrid(22, 6, BlackWidowXIndex, BlackWidowYIndex, &BlackWidowEffect, pixels);
else
FillKeyboardGridAvg(22, 6, BlackWidowAvgCnt, BlackWidowAvgIndex, &BlackWidowEffect, pixels);
//Set Razer "Three Headed Snake" logo to the background color of the 11th column
BlackWidowEffect.Color[0][20] = pixels[ROW_IDX_SINGLE_COLOR][11 * (256 / 22)];
CreateEffect(ChromaSDK::BLACKWIDOW_CHROMA, ChromaSDK::CHROMA_CUSTOM, &BlackWidowEffect, NULL);
CreateEffect(ChromaSDK::BLACKWIDOW_X_CHROMA, ChromaSDK::CHROMA_CUSTOM, &BlackWidowEffect, NULL);
CreateEffect(ChromaSDK::BLACKWIDOW_X_TE_CHROMA, ChromaSDK::CHROMA_CUSTOM, &BlackWidowEffect, NULL);
CreateEffect(ChromaSDK::OVERWATCH_KEYBOARD, ChromaSDK::CHROMA_CUSTOM, &BlackWidowEffect, NULL);
CreateEffect(ChromaSDK::ORNATA_CHROMA, ChromaSDK::CHROMA_CUSTOM, &BlackWidowEffect, NULL);
//Blackwidow Chroma Tournament Edition
ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE BlackWidowTEEffect;
if (use_keyboard_nearest_filter)
FillKeyboardGrid(18, 6, BlackWidowTEXIndex, BlackWidowTEYIndex, &BlackWidowTEEffect, pixels);
else
FillKeyboardGridAvg(18, 6, BlackWidowTEAvgCnt, BlackWidowTEAvgIndex, &BlackWidowTEEffect, pixels);
//Set Razer "Three Headed Snake" logo to the background color of the 11th column
BlackWidowTEEffect.Color[0][20] = pixels[ROW_IDX_SINGLE_COLOR][11 * (256 / 22)];
CreateEffect(ChromaSDK::BLACKWIDOW_CHROMA_TE, ChromaSDK::CHROMA_CUSTOM, &BlackWidowTEEffect, NULL);
//Blade Stealth and Blade 14
ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE BladeStealthEffect;
if (use_keyboard_nearest_filter)
FillKeyboardGrid(16, 6, BladeStealthXIndex, BladeStealthYIndex, &BladeStealthEffect, pixels);
else
FillKeyboardGridAvg(16, 6, BlackStealthAvgCnt, BlackStealthAvgIndex, &BladeStealthEffect, pixels);
CreateEffect(ChromaSDK::BLADE_STEALTH, ChromaSDK::CHROMA_CUSTOM, &BladeStealthEffect, NULL);
CreateEffect(ChromaSDK::BLADE, ChromaSDK::CHROMA_CUSTOM, &BladeStealthEffect, NULL);
//DeathStalker Chroma
ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE DeathStalkerEffect;
for (int x = 0; x < 6; x++)
{
DeathStalkerEffect.Color[1][DeathStalkerXLEDIndex[x]] = (pixels[ROW_IDX_BAR_GRAPH][DeathStalkerXIndex[x]] & 0x00FFFFFF);
}
CreateEffect(ChromaSDK::DEATHSTALKER_CHROMA, ChromaSDK::CHROMA_CUSTOM, &DeathStalkerEffect, NULL);
}
//Orbweaver Chroma
ChromaSDK::Keypad::CUSTOM_EFFECT_TYPE OrbweaverEffect;
FillKeypadGrid(5, 4, OrbweaverXIndex, OrbweaverYIndex, &OrbweaverEffect, pixels);
CreateEffect(ChromaSDK::ORBWEAVER_CHROMA, ChromaSDK::CHROMA_CUSTOM, &OrbweaverEffect, NULL);
//Tartarus Chroma
ChromaSDK::Keypad::CUSTOM_EFFECT_TYPE TartarusEffect;
TartarusEffect.Color[0][0] = pixels[ROW_IDX_SINGLE_COLOR][0];
CreateEffect(ChromaSDK::TARTARUS_CHROMA, ChromaSDK::CHROMA_CUSTOM, &TartarusEffect, NULL);
//Firefly Chroma
ChromaSDK::Mousepad::CUSTOM_EFFECT_TYPE FireflyEffect = {};
for (int x = 0; x < 15; x++)
{
FireflyEffect.Color[x] = pixels[ROW_IDX_BAR_GRAPH][FireflyIndex[x]];
}
CreateMousepadEffect(ChromaSDK::Mousepad::CHROMA_CUSTOM, &FireflyEffect, NULL);
//Razer Core
ChromaSDK::Mousepad::CUSTOM_EFFECT_TYPE CoreEffect = {};
for (int x = 0; x < 8; x++)
{
CoreEffect.Color[x+3] = pixels[ROW_IDX_BAR_GRAPH][CoreXIndex[x]];
}
//Razer Core internal LEDs are a single color zone
CoreEffect.Color[2] = pixels[ROW_IDX_SINGLE_COLOR][0];
CreateEffect(ChromaSDK::CORE_CHROMA, ChromaSDK::CHROMA_CUSTOM, &CoreEffect, NULL);
//Mamba Chroma Tournament Edition
ChromaSDK::Mouse::CUSTOM_EFFECT_TYPE2 MouseEffect = {};
for (int x = 0; x < 7; x++)
{
for (int y = 0; y < 9; y++)
{
MouseEffect.Color[y][x] = pixels[MouseYIndex[y][x]][MouseXIndex[y][x]];
}
}
CreateEffect(ChromaSDK::OROCHI_CHROMA, ChromaSDK::CHROMA_NONE, NULL, NULL); // Quick-fix for "lazy" Orochi Chroma color transition effect, see https://gfycat.com/DiscreteDisfiguredBluetickcoonhound
CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM2, &MouseEffect, NULL);
//The Kraken 7.1 Chroma v1 headset (as well as possibly others) does not support custom effects.
//To work around this, I set a NONE effect followed by a STATIC effect, which instantly updates
//the color at the expense of a slight flicker.
//The Kraken 7.1 Chroma v2 does support custom effects, but using them means the v1 gets no
//pattern at all. Until the SDK is updated to break these two devices into separate IDs,
//I'm adding a workaround to select whether to use custom or static effects.
if (use_headset_custom_effect)
{
//Kraken Chroma V2
ChromaSDK::Headset::STATIC_EFFECT_TYPE KrakenEffect;
KrakenEffect.Color = pixels[ROW_IDX_SINGLE_COLOR][0];
CreateHeadsetEffect(ChromaSDK::Headset::CHROMA_CUSTOM, &KrakenEffect, NULL);
}
else
{
//Kraken Chroma V1
ChromaSDK::Headset::STATIC_EFFECT_TYPE KrakenEffect;
KrakenEffect.Color = pixels[ROW_IDX_SINGLE_COLOR][0];
CreateHeadsetEffect(ChromaSDK::Headset::CHROMA_NONE, &KrakenEffect, NULL);
CreateHeadsetEffect(ChromaSDK::Headset::CHROMA_STATIC, &KrakenEffect, NULL);
}
if (!disable_chromalink)
{
//Chroma Link SDK
ChromaSDK::ChromaLink::CUSTOM_EFFECT_TYPE ChromaLinkEffect = {};
for (int x = 0; x < ChromaSDK::ChromaLink::MAX_LEDS; x++)
{
if (use_chromalink_single_color)
{
ChromaLinkEffect.Color[x] = pixels[ROW_IDX_SINGLE_COLOR][ChromaLinkXIndex[x]];
}
else
{
ChromaLinkEffect.Color[x] = pixels[ROW_IDX_BAR_GRAPH][ChromaLinkXIndex[x]];
}
}
CreateChromaLinkEffect(ChromaSDK::ChromaLink::CHROMA_CUSTOM, &ChromaLinkEffect, NULL);
}
ChromaSDK::CUSTOM_EFFECT_TYPE ChromaBoxEffect;
switch (chroma_box_mode)
{
case 0:
FillCustomGrid(16, 4, ChromaBoxXIndex, ChromaBoxYIndex, &ChromaBoxEffect, pixels);
break;
default:
case 1:
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 4; y++)
{
ChromaBoxEffect.Color[y][x] = pixels[ROW_IDX_BAR_GRAPH][ChromaBox1BarXIndex[y][x]];
}
}
break;
case 2:
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 4; y++)
{
ChromaBoxEffect.Color[y][x] = pixels[ROW_IDX_BAR_GRAPH][ChromaBox2BarXIndex[y][x]];
}
}
break;
case 3:
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 4; y++)
{
ChromaBoxEffect.Color[y][x] = pixels[ROW_IDX_BAR_GRAPH][ChromaBox4BarXIndex[y][x]];
}
}
break;
}
CreateEffect(ChromaSDK::CHROMABOX, ChromaSDK::CHROMA_CUSTOM, &ChromaBoxEffect, NULL);
return TRUE;
}
};