Clean up Corsair Commander Pro code and get effects mode working

This commit is contained in:
Adam Honse
2020-01-17 20:40:40 -06:00
parent 48ba8435b1
commit 90dfa5678b
3 changed files with 517 additions and 180 deletions

View File

@@ -69,171 +69,122 @@ CorsairCmdrProController::~CorsairCmdrProController()
{
}
void CorsairCmdrProController::SendKeepalive()
{
unsigned char usb_apply[] =
{
0x33, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
int actual;
/*-----------------------------------------------------*\
| Send apply packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_apply, 64, &actual, 0);
}
void CorsairCmdrProController::KeepaliveThread()
{
while(1)
{
SendKeepalive();
SendCommit();
Sleep(5000);
}
}
void CorsairCmdrProController::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
void CorsairCmdrProController::SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
)
{
unsigned char usb_start[] =
{
0x38, 0x00, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
unsigned char usb_data[] =
{
0x32, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
unsigned char usb_apply[] =
{
0x33, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
int actual;
/*-----------------------------------------------------*\
| Send Reset packet |
\*-----------------------------------------------------*/
SendReset(channel);
/*-----------------------------------------------------*\
| Set channel in USB packets |
| Send Begin packet |
\*-----------------------------------------------------*/
usb_data[0x01] = channel;
usb_start[0x01] = channel;
SendBegin(channel);
/*-----------------------------------------------------*\
| Send start packet |
| Set Port State packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_start, 64, &actual, 0);
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
/*-----------------------------------------------------*\
| Set Effect Configuration packet |
\*-----------------------------------------------------*/
SendEffectConfig
(
channel,
0,
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
mode,
speed,
direction,
random,
red1,
grn1,
blu1,
red2,
grn2,
blu2,
0,
0,
0,
0,
0,
0
);
/*-----------------------------------------------------*\
| Send Commit packet |
\*-----------------------------------------------------*/
SendCommit();
}
void CorsairCmdrProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char color_data[50];
unsigned char pkt_max;
/*-----------------------------------------------------*\
| Send Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
/*-----------------------------------------------------*\
| Send red channel packet 1 |
\*-----------------------------------------------------*/
std::size_t pkt_max = 50;
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = colors.size();
pkt_max = (unsigned char)colors.size();
}
usb_data[0x02] = 0;
usb_data[0x03] = pkt_max;
usb_data[0x04] = 0x00; //red
for (std::size_t idx = 0; idx < pkt_max; idx++)
for(int idx = 0; idx < pkt_max; idx++)
{
RGBColor color = colors[idx];
usb_data[idx + 5] = RGBGetRValue(color);
color_data[idx] = RGBGetRValue(colors[idx]);
}
libusb_interrupt_transfer(dev, 0x02, usb_data, 64, &actual, 0);
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
/*-----------------------------------------------------*\
| Send red channel packet 2 if necessary |
\*-----------------------------------------------------*/
for(int idx = 4; idx < 64; idx++)
{
usb_data[idx] = 0;
}
pkt_max = 0;
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = colors.size() - 50;
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
usb_data[0x02] = 50;
usb_data[0x03] = pkt_max;
usb_data[0x04] = 0x00; //red
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
RGBColor color = colors[idx + 50];
usb_data[idx + 5] = RGBGetRValue(color);
color_data[idx] = RGBGetRValue(colors[idx+50]);
}
libusb_interrupt_transfer(dev, 0x02, usb_data, 64, &actual, 0);
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
}
/*-----------------------------------------------------*\
| Send green channel packet 1 |
\*-----------------------------------------------------*/
@@ -241,49 +192,34 @@ void CorsairCmdrProController::SetChannelLEDs(unsigned int channel, std::vector<
if(pkt_max > colors.size())
{
pkt_max = colors.size();
pkt_max = (unsigned char)colors.size();
}
usb_data[0x02] = 0;
usb_data[0x03] = pkt_max;
usb_data[0x04] = 0x01; //green
for (std::size_t idx = 0; idx < pkt_max; idx++)
for(int idx = 0; idx < pkt_max; idx++)
{
RGBColor color = colors[idx];
usb_data[idx + 5] = RGBGetGValue(color);
color_data[idx] = RGBGetGValue(colors[idx]);
}
libusb_interrupt_transfer(dev, 0x02, usb_data, 64, &actual, 0);
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
/*-----------------------------------------------------*\
| Send green channel packet 2 if necessary |
\*-----------------------------------------------------*/
for(int idx = 4; idx < 64; idx++)
{
usb_data[idx] = 0;
}
pkt_max = 0;
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = colors.size() - 50;
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
usb_data[0x02] = 50;
usb_data[0x03] = pkt_max;
usb_data[0x04] = 0x01; //green
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
RGBColor color = colors[idx + 50];
usb_data[idx + 5] = RGBGetGValue(color);
color_data[idx] = RGBGetGValue(colors[idx+50]);
}
libusb_interrupt_transfer(dev, 0x02, usb_data, 64, &actual, 0);
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
}
/*-----------------------------------------------------*\
@@ -293,53 +229,275 @@ void CorsairCmdrProController::SetChannelLEDs(unsigned int channel, std::vector<
if(pkt_max > colors.size())
{
pkt_max = colors.size();
pkt_max = (unsigned char)colors.size();
}
usb_data[0x02] = 0;
usb_data[0x03] = pkt_max;
usb_data[0x04] = 0x02; //blue
for (std::size_t idx = 0; idx < pkt_max; idx++)
for(int idx = 0; idx < pkt_max; idx++)
{
RGBColor color = colors[idx];
usb_data[idx + 5] = RGBGetBValue(color);
color_data[idx] = RGBGetBValue(colors[idx]);
}
libusb_interrupt_transfer(dev, 0x02, usb_data, 64, &actual, 0);
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
/*-----------------------------------------------------*\
| Send blue channel packet 2 if necessary |
\*-----------------------------------------------------*/
for(int idx = 4; idx < 64; idx++)
{
usb_data[idx] = 0;
}
pkt_max = 0;
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = colors.size() - 50;
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
usb_data[0x02] = 50;
usb_data[0x03] = pkt_max;
usb_data[0x04] = 0x02; //blue
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
RGBColor color = colors[idx + 50];
usb_data[idx + 5] = RGBGetBValue(color);
color_data[idx] = RGBGetBValue(colors[idx+50]);
}
libusb_interrupt_transfer(dev, 0x02, usb_data, 64, &actual, 0);
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
}
/*-----------------------------------------------------*\
| Send apply packet |
| Send Commit packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_apply, 64, &actual, 0);
SendCommit();
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairCmdrProController::SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
usb_buf[0x04] = color_channel;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], color_data, count);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendCommit()
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendBegin
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count * 10;
usb_buf[0x03] = led_type;
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
usb_buf[0x06] = direction;
usb_buf[0x07] = change_style;
usb_buf[0x08] = 0;
/*-----------------------------------------------------*\
| Set up mode colors |
\*-----------------------------------------------------*/
usb_buf[0x09] = color_0_red;
usb_buf[0x10] = color_0_green;
usb_buf[0x11] = color_0_blue;
usb_buf[0x12] = color_1_red;
usb_buf[0x13] = color_1_green;
usb_buf[0x14] = color_1_blue;
usb_buf[0x15] = color_2_red;
usb_buf[0x16] = color_2_green;
usb_buf[0x17] = color_2_blue;
/*-----------------------------------------------------*\
| Set up temperatures |
\*-----------------------------------------------------*/
usb_buf[0x12] = (temperature_0 >> 8);
usb_buf[0x13] = (temperature_0 & 0xFF);
usb_buf[0x14] = (temperature_1 >> 8);
usb_buf[0x15] = (temperature_1 & 0xFF);
usb_buf[0x16] = (temperature_2 >> 8);
usb_buf[0x17] = (temperature_2 & 0xFF);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendTemperature()
{
}
void CorsairCmdrProController::SendReset
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendPortState
(
unsigned char channel,
unsigned char state
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendBrightness()
{
}
void CorsairCmdrProController::SendLEDCount()
{
}
void CorsairCmdrProController::SendProtocol()
{
}

View File

@@ -12,9 +12,66 @@
enum
{
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02 /* Number of channels */
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
};
enum
{
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
};
enum
{
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
};
enum
{
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
};
enum
{
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
};
enum
{
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x00, /* Slow speed */
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
CORSAIR_CMDR_PRO_SPEED_FAST = 0x02, /* Fast speed */
};
enum
{
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
};
class CorsairCmdrProController
@@ -25,8 +82,21 @@ public:
char* GetLEDString();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors);
void SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors);
void SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SendKeepalive();
unsigned int channel_leds[CORSAIR_CMDR_PRO_NUM_CHANNELS];
@@ -34,4 +104,62 @@ public:
private:
libusb_device_handle* dev;
void SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
);
void SendCommit();
void SendBegin
(
unsigned char channel
);
void SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
);
void SendTemperature();
void SendReset
(
unsigned char channel
);
void SendPortState
(
unsigned char channel,
unsigned char state
);
void SendBrightness();
void SendLEDCount();
void SendProtocol();
};

View File

@@ -18,9 +18,38 @@ RGBController_CorsairCmdrPro::RGBController_CorsairCmdrPro(CorsairCmdrProControl
type = DEVICE_TYPE_LEDSTRIP;
mode led_mode;
led_mode.name = "Custom";
modes.push_back(led_mode);
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Direct);
mode RainbowWave;
RainbowWave.name = "Rainbow Wave";
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
RainbowWave.flags = MODE_FLAG_HAS_SPEED;
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(RainbowWave);
mode ColorShift;
ColorShift.name = "Color Shift";
ColorShift.value = CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT;
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(ColorShift);
mode ColorPulse;
ColorPulse.name = "Color Pulse";
ColorPulse.value = CORSAIR_CMDR_PRO_MODE_COLOR_PULSE;
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(ColorPulse);
/*-------------------------------------------------*\
| Set size of colors array |
@@ -81,9 +110,31 @@ int RGBController_CorsairCmdrPro::GetMode()
return 0;
}
void RGBController_CorsairCmdrPro::SetMode(int /*mode*/)
void RGBController_CorsairCmdrPro::SetMode(int mode)
{
active_mode = mode;
if(modes[active_mode].value == 0xFFFF)
{
UpdateLEDs();
}
else
{
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
{
corsair->SetChannelEffect(channel,
modes[active_mode].value,
modes[active_mode].speed,
0,
modes[active_mode].random,
RGBGetRValue(colors[0]),
RGBGetGValue(colors[0]),
RGBGetBValue(colors[0]),
RGBGetRValue(colors[1]),
RGBGetGValue(colors[1]),
RGBGetBValue(colors[1]));
}
}
}
void RGBController_CorsairCmdrPro::SetCustomMode()
@@ -130,7 +181,7 @@ void RGBController_CorsairCmdrPro::UpdateZoneLEDs(int zone)
if(channel_colors.size() > 0)
{
//corsair->SetChannelLEDs(channel, channel_colors);
corsair->SetChannelLEDs(channel, channel_colors);
}
corsair->SendKeepalive();
}