Skip to content

Commit e21d29f

Browse files
Nikola JurkovicCalcProgrammer1
authored andcommitted
Commander Core XT
1 parent febdd2a commit e21d29f

4 files changed

Lines changed: 123 additions & 49 deletions

File tree

Controllers/CorsairCommanderCoreController/CorsairCommanderCoreController.cpp

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,19 @@ CorsairCommanderCoreController::CorsairCommanderCoreController(hid_device* dev_h
3030
this->pid = pid;
3131
guard_manager_ptr = new DeviceGuardManager(new CorsairDeviceGuard());
3232

33-
if(pid == 0x0C32)
33+
if(pid == CORSAIR_COMMANDER_CORE2_PID)
3434
{
3535
packet_size = CORSAIR_COMMANDER_CORE_PACKET_SIZE_V3;
3636
command_res_size = packet_size - 4;
3737
}
38+
else if(pid == CORSAIR_COMMANDER_CORE_XT_PID)
39+
{
40+
/*-----------------------------------------------------*\
41+
| Commander Core XT |
42+
\*-----------------------------------------------------*/
43+
packet_size = CORSAIR_COMMANDER_CORE_XT_PACKET_SIZE;
44+
command_res_size = packet_size - 4;
45+
}
3846

3947
/*-----------------------------------------------------*\
4048
| Initialize controller |
@@ -84,7 +92,7 @@ void CorsairCommanderCoreController::InitController()
8492
version[2] = res[2];
8593
delete[] res;
8694

87-
if(pid == 0x0C1C && version[0] == 1)
95+
if(pid == CORSAIR_COMMANDER_CORE_PID && version[0] == 1)
8896
{
8997
packet_size = CORSAIR_COMMANDER_CORE_PACKET_SIZE_V1;
9098
command_res_size = packet_size - 4;
@@ -116,6 +124,11 @@ std::string CorsairCommanderCoreController::GetNameString()
116124
return(name);
117125
}
118126

127+
int CorsairCommanderCoreController::GetPidInt()
128+
{
129+
return(this->pid);
130+
}
131+
119132
std::vector<unsigned short int> CorsairCommanderCoreController::GetLedCounts()
120133
{
121134
/*-----------------------------------------------------*\
@@ -336,9 +349,14 @@ void CorsairCommanderCoreController::SetDirectColor
336349
int packet_offset = 0;
337350
int led_idx = 0;
338351
int channel_idx = 0;
339-
unsigned char* usb_buf = new unsigned char[CORSAIR_COMMANDER_CORE_RGB_DATA_LENGTH];
352+
int packet_len = CORSAIR_COMMANDER_CORE_RGB_DATA_LENGTH;
340353

341-
memset(usb_buf, 0, CORSAIR_COMMANDER_CORE_RGB_DATA_LENGTH);
354+
if(pid == CORSAIR_COMMANDER_CORE_XT_PID)
355+
{
356+
packet_len = CORSAIR_COMMANDER_CORE_XT_RGB_DATA_LENGTH;
357+
}
358+
359+
unsigned char* usb_buf = new unsigned char[packet_len];
342360

343361
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
344362
{
@@ -355,10 +373,6 @@ void CorsairCommanderCoreController::SetDirectColor
355373

356374
led_idx = led_idx + zones[zone_idx].leds_count;
357375

358-
359-
/*-------------------------------------------------*\
360-
| Move offset for fans with less than 34 LEDs |
361-
\*-------------------------------------------------*/
362376
if(zone_idx != 0)
363377
{
364378
packet_offset += 3 * (34 - zones[zone_idx].leds_count);
@@ -382,31 +396,71 @@ void CorsairCommanderCoreController::SetDirectColor
382396

383397
void CorsairCommanderCoreController::SetFanMode()
384398
{
399+
controller_ready = 0;
400+
DeviceGuardLock _ = guard_manager_ptr->AwaitExclusiveAccess();
401+
385402
/*--------------------------------------------------------------------------------------------------*\
386403
| Force controller to 6 QL fan mode to expose maximum number of LEDs per rgb port (34 LEDs per port) |
387404
\*--------------------------------------------------------------------------------------------------*/
405+
unsigned char endpoint[2] = {0x1E, 0x00};
406+
unsigned char data_type[2] = {0x0D, 0x00};
388407

389-
unsigned char endpoint[2] = {0x1E, 0x00};
390-
unsigned char data_type[2] = {0x0D, 0x00};
391408
unsigned char buf[15];
392409

393410
/*-----------------------------------------------------*\
394-
| Set AIO mode |
411+
| Zero out buffer |
395412
\*-----------------------------------------------------*/
396-
buf[0] = 0x07;
397-
buf[1] = 0x01;
398-
buf[2] = 0x08;
413+
memset(buf, 0x00, 15);
414+
415+
buf[0] = 0x07;
416+
if(pid == CORSAIR_COMMANDER_CORE_XT_PID)
417+
{
418+
/*-----------------------------------------------------*\
419+
| Commander Core XT external RGB port |
420+
\*-----------------------------------------------------*/
421+
buf[1] = 0x01;
422+
buf[2] = 0x01;
423+
}
424+
else
425+
{
426+
/*-----------------------------------------------------*\
427+
| Commander Core, Set AIO mode |
428+
\*-----------------------------------------------------*/
429+
buf[1] = 0x01;
430+
buf[2] = 0x08;
431+
}
399432

400433
/*-----------------------------------------------------*\
401434
| SET fan modes |
402435
\*-----------------------------------------------------*/
403436
for(unsigned int i = 3; i < 15; i = i + 2)
404437
{
405-
buf[i] = 0x01;
406-
buf[i + 1] = 0x06;
438+
buf[i] = 0x01;
439+
buf[i + 1] = 0x06;
407440
}
408441

409442
WriteData(endpoint, data_type, buf, 15);
443+
controller_ready = 1;
444+
}
445+
446+
void CorsairCommanderCoreController::SetLedAmount(int led_amount)
447+
{
448+
controller_ready = 0;
449+
DeviceGuardLock _ = guard_manager_ptr->AwaitExclusiveAccess();
450+
451+
unsigned char buf[15];
410452

453+
/*-----------------------------------------------------*\
454+
| Zero out buffer |
455+
\*-----------------------------------------------------*/
456+
memset(buf, 0x00, 15);
457+
458+
unsigned char endpoint[2] = {0x1D, 0x00};
459+
unsigned char data_type[2] = {0x0C, 0x00};
460+
461+
buf[0] = 0x07;
462+
buf[1] = led_amount;
463+
464+
WriteData(endpoint, data_type, buf, 15);
411465
controller_ready = 1;
412466
}

Controllers/CorsairCommanderCoreController/CorsairCommanderCoreController.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,27 @@
1818
#include "RGBController.h"
1919
#include "DeviceGuardManager.h"
2020

21-
#define CORSAIR_COMMANDER_CORE_PACKET_SIZE_V1 1025 // First bit is the report bit
22-
#define CORSAIR_COMMANDER_CORE_PACKET_SIZE_V2 97 // First bit is the report bit
23-
#define CORSAIR_COMMANDER_CORE_PACKET_SIZE_V3 65 // First bit is the report bit
21+
/*-----------------------------------------------------*\
22+
| Packet size per device |
23+
\*-----------------------------------------------------*/
24+
#define CORSAIR_COMMANDER_CORE_PACKET_SIZE_V1 1025
25+
#define CORSAIR_COMMANDER_CORE_PACKET_SIZE_V2 97
26+
#define CORSAIR_COMMANDER_CORE_PACKET_SIZE_V3 65
27+
#define CORSAIR_COMMANDER_CORE_XT_PACKET_SIZE 385
2428

25-
#define CORSAIR_COMMANDER_CORE_RGB_DATA_LENGTH 699
26-
#define CORSAIR_QL_FAN_ZONE_OFFSET 102
27-
#define CORSAIR_COMMANDER_CORE_NUM_CHANNELS 6
29+
#define CORSAIR_COMMANDER_CORE_RGB_DATA_LENGTH 699
30+
#define CORSAIR_COMMANDER_CORE_XT_RGB_DATA_LENGTH 1224
31+
32+
#define CORSAIR_QL_FAN_ZONE_OFFSET 102
33+
#define CORSAIR_COMMANDER_CORE_NUM_CHANNELS 6
34+
35+
#define CORSAIR_COMMANDER_CORE_PID 0x0C1C
36+
#define CORSAIR_COMMANDER_CORE2_PID 0x0C32
37+
#define CORSAIR_COMMANDER_CORE3_PID 0x0C1D
38+
#define CORSAIR_COMMANDER_CORE4_PID 0x0C3C
39+
#define CORSAIR_COMMANDER_CORE5_PID 0x0C3D
40+
#define CORSAIR_COMMANDER_CORE6_PID 0x0C3E
41+
#define CORSAIR_COMMANDER_CORE_XT_PID 0x0C2A
2842

2943
enum
3044
{
@@ -41,6 +55,7 @@ class CorsairCommanderCoreController
4155
std::vector<unsigned short int> GetLedCounts();
4256
std::string GetLocationString();
4357
std::string GetNameString();
58+
int GetPidInt();
4459

4560
void SetDirectColor
4661
(
@@ -50,6 +65,7 @@ class CorsairCommanderCoreController
5065

5166
void KeepaliveThread();
5267
void SetFanMode();
68+
void SetLedAmount(int led_amount);
5369

5470
private:
5571
hid_device* dev;

Controllers/CorsairCommanderCoreController/CorsairCommanderCoreControllerDetect.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@
1919
\*-----------------------------------------------------*/
2020
#define CORSAIR_VID 0x1B1C
2121

22-
/*-----------------------------------------------------*\
23-
| Commander Core product IDs |
24-
\*-----------------------------------------------------*/
25-
#define CORSAIR_COMMANDER_CORE_PID 0x0C1C
26-
#define CORSAIR_COMMANDER_CORE2_PID 0x0C32
27-
#define CORSAIR_COMMANDER_CORE3_PID 0x0C1D
28-
#define CORSAIR_COMMANDER_CORE4_PID 0x0C3C
29-
#define CORSAIR_COMMANDER_CORE5_PID 0x0C3D
30-
#define CORSAIR_COMMANDER_CORE6_PID 0x0C3E
31-
3222
/******************************************************************************************\
3323
* *
3424
* DetectCorsairCommanderCoreControllers *
@@ -56,3 +46,4 @@ REGISTER_HID_DETECTOR_IPU("Corsair Commander Core", DetectCorsairCommanderCoreCo
5646
REGISTER_HID_DETECTOR_IPU("Corsair Commander Core", DetectCorsairCommanderCoreControllers, CORSAIR_VID, CORSAIR_COMMANDER_CORE4_PID, 0x00, 0xFF42, 0x01);
5747
REGISTER_HID_DETECTOR_IPU("Corsair Commander Core", DetectCorsairCommanderCoreControllers, CORSAIR_VID, CORSAIR_COMMANDER_CORE5_PID, 0x00, 0xFF42, 0x01);
5848
REGISTER_HID_DETECTOR_IPU("Corsair Commander Core", DetectCorsairCommanderCoreControllers, CORSAIR_VID, CORSAIR_COMMANDER_CORE6_PID, 0x00, 0xFF42, 0x01);
49+
REGISTER_HID_DETECTOR_IPU("Corsair Commander Core XT", DetectCorsairCommanderCoreControllers, CORSAIR_VID, CORSAIR_COMMANDER_CORE_XT_PID, 0x00, 0xFF42, 0x01);

Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ RGBController_CorsairCommanderCore::RGBController_CorsairCommanderCore(CorsairCo
5555

5656
name = controller->GetNameString();
5757
vendor = "Corsair";
58-
description = "Corsair Commander Core";
58+
description = "Corsair Commander Core Device";
5959
version = controller->GetFirmwareString();
6060
type = DEVICE_TYPE_COOLER;
6161
location = controller->GetLocationString();
62-
6362
SetupZones();
6463

6564
mode Direct;
@@ -87,23 +86,34 @@ void RGBController_CorsairCommanderCore::SetupZones()
8786

8887
std::vector<unsigned short int> led_count = controller->GetLedCounts();
8988
zones.resize(7);
90-
zones[0].name = "Pump";
91-
zones[0].type = ZONE_TYPE_MATRIX;
92-
zones[0].leds_min = led_count.at(0);
93-
zones[0].leds_max = led_count.at(0);
94-
zones[0].leds_count = led_count.at(0);
95-
zones[0].matrix_map = new matrix_map_type;
96-
if(led_count.at(0) == 24)
89+
if(controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID)
9790
{
98-
zones[0].matrix_map->height = 11;
99-
zones[0].matrix_map->width = 11;
100-
zones[0].matrix_map->map = (unsigned int *)&matrix_map24;
91+
zones[0].name = "External RGB Port";
92+
zones[0].type = ZONE_TYPE_LINEAR;
93+
zones[0].leds_min = zones[0].leds_min;
94+
zones[0].leds_max = 204;
95+
zones[0].leds_count = zones[0].leds_count;
10196
}
10297
else
10398
{
104-
zones[0].matrix_map->height = 7;
105-
zones[0].matrix_map->width = 7;
106-
zones[0].matrix_map->map = (unsigned int *)&matrix_map29;
99+
zones[0].name = "Pump";
100+
zones[0].type = ZONE_TYPE_MATRIX;
101+
zones[0].leds_min = led_count.at(0);
102+
zones[0].leds_max = led_count.at(0);
103+
zones[0].leds_count = led_count.at(0);
104+
zones[0].matrix_map = new matrix_map_type;
105+
if(led_count.at(0) == 24)
106+
{
107+
zones[0].matrix_map->height = 11;
108+
zones[0].matrix_map->width = 11;
109+
zones[0].matrix_map->map = (unsigned int *)&matrix_map24;
110+
}
111+
else
112+
{
113+
zones[0].matrix_map->height = 7;
114+
zones[0].matrix_map->width = 7;
115+
zones[0].matrix_map->map = (unsigned int *)&matrix_map29;
116+
}
107117
}
108118

109119
for(unsigned int i = 1; i < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); i++)
@@ -124,7 +134,7 @@ void RGBController_CorsairCommanderCore::SetupZones()
124134

125135
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
126136
{
127-
for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
137+
for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
128138
{
129139
led new_led;
130140
new_led.name = zones[zone_idx].name + " LED " + std::to_string(led_idx+1);
@@ -146,7 +156,10 @@ void RGBController_CorsairCommanderCore::ResizeZone(int zone, int new_size)
146156
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
147157
{
148158
zones[zone].leds_count = new_size;
149-
159+
if(zone == 0 && controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID)
160+
{
161+
controller->SetLedAmount(new_size);
162+
}
150163
SetupZones();
151164
}
152165
}

0 commit comments

Comments
 (0)