Compare commits
100
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
133d1f1ccb | ||
|
|
45b25d21ab | ||
|
|
ee57491eee | ||
|
|
fab4052bbd | ||
|
|
0703fb8c68 | ||
|
|
8d0915de6e | ||
|
|
ef33d7e2c4 | ||
|
|
bba88eb1f2 | ||
|
|
7b35cf72f7 | ||
|
|
9603489f4a | ||
|
|
d4cd2a6853 | ||
|
|
c4d2f72df1 | ||
|
|
1a07aee7a6 | ||
|
|
415d79a3ef | ||
|
|
fd59f83556 | ||
|
|
7adcfa77fa | ||
|
|
b338fbca3c | ||
|
|
aba3a3fd23 | ||
|
|
cb680508a5 | ||
|
|
2104c975be | ||
|
|
339e1e14c2 | ||
|
|
dca3b0d733 | ||
|
|
c52eb528ea | ||
|
|
3948e74711 | ||
|
|
4672d4a686 | ||
|
|
befa9baf20 | ||
|
|
077cda545e | ||
|
|
e934ce2c23 | ||
|
|
b10ff42df2 | ||
|
|
afb6ff6a74 | ||
|
|
6828335dc5 | ||
|
|
966297710b | ||
|
|
443d558ac2 | ||
|
|
2cd0b64251 | ||
|
|
7ad3c18e3f | ||
|
|
fc11427019 | ||
|
|
2f00fb9186 | ||
|
|
ea1f21106c | ||
|
|
47ca068628 | ||
|
|
f07cc134bb | ||
|
|
1d98ce063c | ||
|
|
9ddb9f04ce | ||
|
|
8aee3c427b | ||
|
|
6a6ad0dda6 | ||
|
|
12116c70ee | ||
|
|
7d6699cf9c | ||
|
|
48b9be3f76 | ||
|
|
760c57c29c | ||
|
|
c6cc88ba7b | ||
|
|
779471e3e4 | ||
|
|
adb9a6e59f | ||
|
|
d48bcec5ba | ||
|
|
80d2282313 | ||
|
|
a4474602d8 | ||
|
|
d28be0640e | ||
|
|
5b17833c6e | ||
|
|
e8e9a1e7e5 | ||
|
|
d7740c2d28 | ||
|
|
f110589f91 | ||
|
|
b3c1cdf63d | ||
|
|
6b789be1e1 | ||
|
|
12f307228b | ||
|
|
848ea8b064 | ||
|
|
438c3840a7 | ||
|
|
fef6f4cba3 | ||
|
|
d38543a820 | ||
|
|
2a76201ca4 | ||
|
|
2e84e9808c | ||
|
|
ee492632ac | ||
|
|
fd16bc3053 | ||
|
|
64f11b42f4 | ||
|
|
7ba610df77 | ||
|
|
a76bd7b974 | ||
|
|
7999620db2 | ||
|
|
585eb8a5a3 | ||
|
|
f1523adcdf | ||
|
|
1113c7874f | ||
|
|
ab03311717 | ||
|
|
d13971b7ce | ||
|
|
5bc94fd677 | ||
|
|
90dfa5678b | ||
|
|
48ba8435b1 | ||
|
|
cf2c2d6b93 | ||
|
|
4b8668e0ef | ||
|
|
0bc5982970 | ||
|
|
2ae74c1e7f | ||
|
|
abd4c87b1e | ||
|
|
fb3103e458 | ||
|
|
c70943da18 | ||
|
|
2efd0dc81d | ||
|
|
8b8012a431 | ||
|
|
0716f55880 | ||
|
|
bcc95abe53 | ||
|
|
bb7852a3e4 | ||
|
|
d79c7e9c04 | ||
|
|
fa4d9ebbf6 | ||
|
|
ec8cdf1e26 | ||
|
|
1d6e0cf6a4 | ||
|
|
b06d56bb2d | ||
|
|
50c9f7b84b |
@@ -0,0 +1 @@
|
||||
*.pro.user*
|
||||
@@ -1,3 +1,6 @@
|
||||
[submodule "dependencies/libe131"]
|
||||
path = dependencies/libe131
|
||||
url = https://github.com/CalcProgrammer1/libe131
|
||||
[submodule "razer-drivers-win32"]
|
||||
path = razer-drivers-win32
|
||||
url = https://github.com/rsandoz/razer-drivers-win32
|
||||
|
||||
@@ -18,9 +18,19 @@ AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_han
|
||||
|
||||
strcpy(device_name, "AMD Wraith Prism");
|
||||
|
||||
current_fan_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
|
||||
current_fan_speed = 0xFF;
|
||||
current_fan_random_color = false;
|
||||
|
||||
current_logo_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
|
||||
current_logo_speed = 0xFF;
|
||||
current_logo_random_color = false;
|
||||
|
||||
current_ring_mode = AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC;
|
||||
current_ring_speed = 0xFF;
|
||||
current_ring_direction = false;
|
||||
|
||||
SendEnableCommand();
|
||||
SetRingEffectChannel(0x00);
|
||||
SendApplyCommand();
|
||||
}
|
||||
|
||||
AMDWraithPrismController::~AMDWraithPrismController()
|
||||
@@ -116,133 +126,83 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
|
||||
return(ret_string);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetFanMode(unsigned char mode, unsigned char speed, bool random_color)
|
||||
{
|
||||
current_fan_mode = mode;
|
||||
current_fan_speed = speed_values_fan_logo[mode][speed];
|
||||
current_fan_random_color = random_color;
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetFanColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x06, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
SendEffectChannelUpdate
|
||||
(
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED,
|
||||
current_fan_speed,
|
||||
false,
|
||||
current_fan_random_color,
|
||||
current_fan_mode,
|
||||
max_brightness_fan_logo[current_fan_mode],
|
||||
red,
|
||||
green,
|
||||
blue
|
||||
);
|
||||
}
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
void AMDWraithPrismController::SetLogoMode(unsigned char mode, unsigned char speed, bool random_color)
|
||||
{
|
||||
current_logo_mode = mode;
|
||||
current_logo_speed = speed_values_fan_logo[mode][speed];
|
||||
current_logo_random_color = random_color;
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetLogoColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x05, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
SendEffectChannelUpdate
|
||||
(
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED,
|
||||
current_logo_speed,
|
||||
false,
|
||||
current_logo_random_color,
|
||||
current_logo_mode,
|
||||
max_brightness_fan_logo[current_logo_mode],
|
||||
red,
|
||||
green,
|
||||
blue
|
||||
);
|
||||
}
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
void AMDWraithPrismController::SetRingMode(unsigned char mode, unsigned char speed, bool direction, bool random_color)
|
||||
{
|
||||
current_ring_mode = mode;
|
||||
current_ring_speed = speed_values_ring[mode][speed];
|
||||
current_ring_direction = direction;
|
||||
current_ring_random_color = random_color;
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetRingColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x00, 0xFF, 0x00, 0xFF,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
SetRingEffectChannel(current_ring_mode);
|
||||
|
||||
int actual;
|
||||
SendEffectChannelUpdate
|
||||
(
|
||||
current_ring_mode,
|
||||
current_ring_speed,
|
||||
current_ring_direction,
|
||||
current_ring_random_color,
|
||||
mode_value_ring[current_ring_mode],
|
||||
max_brightness_ring[current_ring_mode],
|
||||
red,
|
||||
green,
|
||||
blue
|
||||
);
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
SendApplyCommand();
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetRingEffectChannel(unsigned char channel)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0xA0, 0x01, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00,
|
||||
0x05, 0x06, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 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;
|
||||
|
||||
for(int led = 0x0A; led <= 0x18; led++)
|
||||
{
|
||||
usb_buf[led] = channel;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
SendChannelRemap(channel, AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED, AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEnableCommand()
|
||||
@@ -301,7 +261,18 @@ void AMDWraithPrismController::SendApplyCommand()
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEffectCommand()
|
||||
void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
(
|
||||
unsigned char effect_channel,
|
||||
unsigned char speed,
|
||||
bool direction,
|
||||
bool random_color,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
@@ -325,6 +296,53 @@ void AMDWraithPrismController::SendEffectCommand()
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x04] = effect_channel;
|
||||
usb_buf[0x05] = speed;
|
||||
usb_buf[0x06] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
|
||||
usb_buf[0x07] = mode;
|
||||
|
||||
usb_buf[0x09] = brightness;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0xA0, 0x01, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00,
|
||||
0x05, 0x06, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 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;
|
||||
|
||||
usb_buf[0x08] = logo_channel;
|
||||
usb_buf[0x09] = fan_channel;
|
||||
|
||||
for(int led = 0x0A; led <= 0x18; led++)
|
||||
{
|
||||
usb_buf[led] = ring_channel;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,100 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
static const unsigned char max_brightness_fan_logo[] =
|
||||
{
|
||||
0x00,
|
||||
0xFF,
|
||||
0x7F,
|
||||
0xFF
|
||||
};
|
||||
|
||||
static const unsigned char speed_values_fan_logo[][5] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
|
||||
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
|
||||
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
|
||||
};
|
||||
|
||||
static const unsigned char max_brightness_ring[] =
|
||||
{
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x7F,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF
|
||||
};
|
||||
|
||||
static const unsigned char mode_value_ring[] =
|
||||
{
|
||||
0xFF,
|
||||
0x03,
|
||||
0xFF,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x05,
|
||||
0xFF,
|
||||
0xC3,
|
||||
0x4A,
|
||||
0x05
|
||||
};
|
||||
|
||||
static const unsigned char speed_values_ring[][5] =
|
||||
{
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
|
||||
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
|
||||
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x72, 0x68, 0x64, 0x62, 0x61 }, /* Rainbow */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Bounce */
|
||||
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Chase */
|
||||
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Swirl */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Morse Code */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC = 0x01, /* Fan/Logo Static Mode */
|
||||
AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE = 0x02, /* Fan/Logo Color Cycle Mode */
|
||||
AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING = 0x03, /* Fan/Logo Breathing Mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC = 0x00, /* Static effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING = 0x01, /* Breathing effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE = 0x02, /* Color cycle effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED = 0x05, /* Logo LED effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED = 0x06, /* Fan LED effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW = 0x07, /* Rainbow effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE = 0x08, /* Bounce effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE = 0x09, /* Chase effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL = 0x0A, /* Swirl effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_MORSE = 0x0B, /* Morse code effect channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AMD_WRAITH_PRISM_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
AMD_WRAITH_PRISM_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
AMD_WRAITH_PRISM_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
AMD_WRAITH_PRISM_SPEED_FAST = 0x03, /* Fast speed */
|
||||
AMD_WRAITH_PRISM_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class AMDWraithPrismController
|
||||
{
|
||||
public:
|
||||
@@ -25,15 +119,48 @@ public:
|
||||
|
||||
void SetRingEffectChannel(unsigned char channel);
|
||||
|
||||
void SetFanMode(unsigned char mode, unsigned char speed, bool random_color);
|
||||
void SetFanColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void SendEnableCommand();
|
||||
void SendApplyCommand();
|
||||
void SendEffectCommand();
|
||||
void SetLogoMode(unsigned char mode, unsigned char speed, bool random_color);
|
||||
void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void SetRingMode(unsigned char mode, unsigned char speed, bool direction, bool random_color);
|
||||
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
libusb_device_handle* dev;
|
||||
|
||||
unsigned char current_fan_mode;
|
||||
unsigned char current_fan_speed;
|
||||
bool current_fan_random_color;
|
||||
|
||||
unsigned char current_logo_mode;
|
||||
unsigned char current_logo_speed;
|
||||
bool current_logo_random_color;
|
||||
|
||||
unsigned char current_ring_mode;
|
||||
unsigned char current_ring_speed;
|
||||
bool current_ring_direction;
|
||||
bool current_ring_random_color;
|
||||
|
||||
void SendEnableCommand();
|
||||
|
||||
void SendApplyCommand();
|
||||
|
||||
void SendEffectChannelUpdate
|
||||
(
|
||||
unsigned char effect_channel,
|
||||
unsigned char speed,
|
||||
bool direction,
|
||||
bool random_color,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel);
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ static void Sleep(unsigned int milliseconds)
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura RAM |
|
||||
\*----------------------------------------------------------------------*/
|
||||
#define AURA_RAM_ADDRESS_COUNT 17
|
||||
#define AURA_RAM_ADDRESS_COUNT 21
|
||||
|
||||
static const unsigned char aura_ram_addresses[] =
|
||||
{
|
||||
@@ -40,7 +40,11 @@ static const unsigned char aura_ram_addresses[] =
|
||||
0x7F,
|
||||
0x4F,
|
||||
0x66,
|
||||
0x67
|
||||
0x67,
|
||||
0x39,
|
||||
0x3B,
|
||||
0x3C,
|
||||
0x3D
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------------*\
|
||||
|
||||
@@ -0,0 +1,507 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for Corsair Commander Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/16/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "CorsairCmdrProController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
//Include thread libraries for Windows or Linux
|
||||
#ifdef WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include "pthread.h"
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
//Thread functions have different types in Windows and Linux
|
||||
#ifdef WIN32
|
||||
#define THREAD static void
|
||||
#define THREADRETURN
|
||||
#else
|
||||
#define THREAD static void*
|
||||
#define THREADRETURN return(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
CorsairCmdrProController* corsair = static_cast<CorsairCmdrProController*>(param);
|
||||
corsair->KeepaliveThread();
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
CorsairCmdrProController::CorsairCmdrProController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
channel_leds[0] = 60;
|
||||
channel_leds[1] = 60;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The Corsair Lighting Node Pro requires a packet within|
|
||||
| 20 seconds of sending the lighting change in order |
|
||||
| to not revert back into rainbow mode. Start a thread |
|
||||
| to continuously send a keepalive packet every 5s |
|
||||
\*-----------------------------------------------------*/
|
||||
#ifdef WIN32
|
||||
_beginthread(keepalive_thread, 0, this);
|
||||
#else
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, &keepalive_thread, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
CorsairCmdrProController::~CorsairCmdrProController()
|
||||
{
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::KeepaliveThread()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
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 red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendReset(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendBegin(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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,
|
||||
red3,
|
||||
grn3,
|
||||
blu3,
|
||||
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 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Commander Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/16/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
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_FAST = 0x00, /* Fast speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow 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
|
||||
{
|
||||
public:
|
||||
CorsairCmdrProController(libusb_device_handle* dev_handle);
|
||||
~CorsairCmdrProController();
|
||||
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
|
||||
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,
|
||||
unsigned char red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
unsigned int channel_leds[CORSAIR_CMDR_PRO_NUM_CHANNELS];
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
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();
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "CorsairCmdrProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairCmdrPro.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define CORSAIR_COMMANDER_PRO_VID 0x1B1C
|
||||
#define CORSAIR_COMMANDER_PRO_PID 0x0C10
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairCmdrProControllers *
|
||||
* *
|
||||
* Detect devices supported by the Corsair Commander Pro driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for Corsair Commander Pro
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_COMMANDER_PRO_VID, CORSAIR_COMMANDER_PRO_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairCmdrProController* controller = new CorsairCmdrProController(dev);
|
||||
|
||||
RGBController_CorsairCmdrPro* rgb_controller = new RGBController_CorsairCmdrPro(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectCorsairCmdrProControllers() */
|
||||
@@ -104,6 +104,22 @@ void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::ve
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5E
|
||||
if (TestForCorsairController(busses[bus], 0x5E))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5E);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5F
|
||||
if (TestForCorsairController(busses[bus], 0x5F))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5F);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairControllers() */
|
||||
@@ -0,0 +1,253 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Corsair RGB keyboard lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairKeyboardController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
|
||||
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
|
||||
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
|
||||
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
|
||||
136, 137, 139, 140, 141};
|
||||
|
||||
static void send_usb_msg(hid_device* dev, char * data_pkt)
|
||||
{
|
||||
char usb_pkt[65];
|
||||
usb_pkt[0] = 0x00;
|
||||
for(int i = 1; i < 65; i++)
|
||||
{
|
||||
usb_pkt[i] = data_pkt[i-1];
|
||||
}
|
||||
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
|
||||
bytes++;
|
||||
}
|
||||
|
||||
static void get_usb_msg(hid_device* dev, char* data_pkt)
|
||||
{
|
||||
char usb_pkt[65];
|
||||
usb_pkt[0] = 0x00;
|
||||
for(int i = 1; i < 65; i++)
|
||||
{
|
||||
usb_pkt[i] = data_pkt[i-1];
|
||||
}
|
||||
int bytes = hid_get_feature_report(dev, (unsigned char*)data_pkt, 64);
|
||||
bytes++;
|
||||
}
|
||||
|
||||
CorsairKeyboardController::CorsairKeyboardController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
char data_pkt[64] = { 0 };
|
||||
|
||||
LightingControl();
|
||||
}
|
||||
|
||||
CorsairKeyboardController::~CorsairKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char data_pkt[216];
|
||||
unsigned char red_val[144];
|
||||
unsigned char grn_val[144];
|
||||
unsigned char blu_val[144];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffers |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(data_pkt, 0x00, sizeof( data_pkt ));
|
||||
memset(red_val, 0x00, sizeof( red_val ));
|
||||
memset(grn_val, 0x00, sizeof( grn_val ));
|
||||
memset(blu_val, 0x00, sizeof( blu_val ));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Scale color values to 9-bit |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
RGBColor color = colors[color_idx];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if( red > 7 ) red = 7;
|
||||
if( grn > 7 ) grn = 7;
|
||||
if( blu > 7 ) blu = 7;
|
||||
|
||||
red = 7 - red;
|
||||
grn = 7 - grn;
|
||||
blu = 7 - blu;
|
||||
|
||||
red_val[keys[color_idx]] = red;
|
||||
grn_val[keys[color_idx]] = grn;
|
||||
blu_val[keys[color_idx]] = blu;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Pack the color values, 2 values per byte |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int red_idx = 0; red_idx < 72; red_idx++)
|
||||
{
|
||||
data_pkt[red_idx] = red_val[(red_idx * 2) + 1] << 4 | red_val[red_idx * 2];
|
||||
}
|
||||
|
||||
for(int grn_idx = 0; grn_idx < 72; grn_idx++)
|
||||
{
|
||||
data_pkt[grn_idx + 72] = grn_val[(grn_idx * 2) + 1] << 4 | grn_val[grn_idx * 2];
|
||||
}
|
||||
|
||||
for(int blu_idx = 0; blu_idx < 72; blu_idx++)
|
||||
{
|
||||
data_pkt[blu_idx + 144] = blu_val[(blu_idx * 2) + 1] << 4 | blu_val[blu_idx * 2];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the packets |
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &data_pkt[0]);
|
||||
StreamPacket(2, 60, &data_pkt[60]);
|
||||
StreamPacket(3, 60, &data_pkt[120]);
|
||||
StreamPacket(4, 36, &data_pkt[180]);
|
||||
|
||||
SubmitLimitedColors(216);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairKeyboardController::LightingControl()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
|
||||
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
|
||||
usb_buf[0x04] = 0x03;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::ReadFirmwareInfo()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Read Firmware Info packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_READ;
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
get_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::StreamPacket
|
||||
(
|
||||
unsigned char packet_id,
|
||||
unsigned char data_sz,
|
||||
unsigned char* data_ptr
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Stream packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
|
||||
usb_buf[0x01] = packet_id;
|
||||
usb_buf[0x02] = data_sz;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x04], data_ptr, data_sz);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::SubmitColors()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Submit Keyboard 24-Bit Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::SubmitLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Submit Keyboard 9-Bit Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
|
||||
usb_buf[0x04] = byte_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairKeyboardController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair RGB |
|
||||
| keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_COMMAND_WRITE = 0x07,
|
||||
CORSAIR_COMMAND_READ = 0x0E,
|
||||
CORSAIR_COMMAND_STREAM = 0x7F
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PROPERTY_FIRMWARE_INFO = 0x01,
|
||||
CORSAIR_PROPERTY_RESET = 0x02,
|
||||
CORSAIR_PROPERTY_SPECIAL_FUNCTION = 0x04,
|
||||
CORSAIR_PROPERTY_LIGHTING_CONTROL = 0x05,
|
||||
CORSAIR_PROPERTY_HARDWARE_PROFILE = 0x13,
|
||||
CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR = 0x22,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9 = 0x27,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24 = 0x28,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_CONTROL_HARDWARE = 0x01,
|
||||
CORSAIR_LIGHTING_CONTROL_SOFTWARE = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_COLOR_CHANNEL_RED = 0x01,
|
||||
CORSAIR_COLOR_CHANNEL_GREEN = 0x02,
|
||||
CORSAIR_COLOR_CHANNEL_BLUE = 0x03
|
||||
};
|
||||
|
||||
class CorsairKeyboardController
|
||||
{
|
||||
public:
|
||||
CorsairKeyboardController(hid_device* dev_handle);
|
||||
~CorsairKeyboardController();
|
||||
|
||||
void SetLEDsDirect(std::vector<RGBColor> colors);
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
void LightingControl();
|
||||
|
||||
void ReadFirmwareInfo();
|
||||
|
||||
void StreamPacket
|
||||
(
|
||||
unsigned char packet_id,
|
||||
unsigned char data_sz,
|
||||
unsigned char* data_ptr
|
||||
);
|
||||
|
||||
void SubmitColors();
|
||||
|
||||
void SubmitLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "CorsairKeyboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairKeyboard.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define CORSAIR_RGB_KEYBOARD_VID 0x1B1C
|
||||
#define CORSAIR_RGB_KEYBOARD_K70_PID 0x1B13
|
||||
#define CORSAIR_RGB_KEYBOARD_K95_PID 0x1B11
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairKeyboardControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev = NULL;
|
||||
|
||||
hid_init();
|
||||
|
||||
info = hid_enumerate(CORSAIR_RGB_KEYBOARD_VID, CORSAIR_RGB_KEYBOARD_K70_PID);
|
||||
|
||||
//Look for Corsair RGB Keyboard, interface 1
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == CORSAIR_RGB_KEYBOARD_VID)
|
||||
&&(info->product_id == CORSAIR_RGB_KEYBOARD_K70_PID)
|
||||
&&(info->interface_number == 1))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
CorsairKeyboardController* controller = new CorsairKeyboardController(dev);
|
||||
|
||||
RGBController_CorsairKeyboard* rgb_controller = new RGBController_CorsairKeyboard(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,507 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for Corsair Lighting Node Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/12/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "CorsairNodeProController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
//Include thread libraries for Windows or Linux
|
||||
#ifdef WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include "pthread.h"
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
//Thread functions have different types in Windows and Linux
|
||||
#ifdef WIN32
|
||||
#define THREAD static void
|
||||
#define THREADRETURN
|
||||
#else
|
||||
#define THREAD static void*
|
||||
#define THREADRETURN return(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
CorsairNodeProController* corsair = static_cast<CorsairNodeProController*>(param);
|
||||
corsair->KeepaliveThread();
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
CorsairNodeProController::CorsairNodeProController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
channel_leds[0] = 60;
|
||||
channel_leds[1] = 60;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The Corsair Lighting Node Pro requires a packet within|
|
||||
| 20 seconds of sending the lighting change in order |
|
||||
| to not revert back into rainbow mode. Start a thread |
|
||||
| to continuously send a keepalive packet every 5s |
|
||||
\*-----------------------------------------------------*/
|
||||
#ifdef WIN32
|
||||
_beginthread(keepalive_thread, 0, this);
|
||||
#else
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, &keepalive_thread, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
CorsairNodeProController::~CorsairNodeProController()
|
||||
{
|
||||
}
|
||||
|
||||
void CorsairNodeProController::KeepaliveThread()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairNodeProController::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 red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendReset(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendBegin(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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,
|
||||
red3,
|
||||
grn3,
|
||||
blu3,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void CorsairNodeProController::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 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairNodeProController::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, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::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, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::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, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::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, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendTemperature()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairNodeProController::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, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::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, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendBrightness()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendLEDCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendProtocol()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Lighting Node Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/12/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
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_FAST = 0x00, /* Fast speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow 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 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_NODE_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
CORSAIR_NODE_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
|
||||
CORSAIR_NODE_PRO_NUM_CHANNELS = 0x02 /* Number of channels */
|
||||
};
|
||||
|
||||
class CorsairNodeProController
|
||||
{
|
||||
public:
|
||||
CorsairNodeProController(libusb_device_handle* dev_handle);
|
||||
~CorsairNodeProController();
|
||||
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
|
||||
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,
|
||||
unsigned char red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
unsigned int channel_leds[CORSAIR_NODE_PRO_NUM_CHANNELS];
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
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();
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "CorsairNodeProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairNodePro.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define CORSAIR_LIGHTING_NODE_PRO_VID 0x1B1C
|
||||
#define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairNodeProControllers *
|
||||
* *
|
||||
* Detect devices supported by the Corsair Lighting Node Pro driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for Corsair Lighting Node Pro
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_LIGHTING_NODE_PRO_VID, CORSAIR_LIGHTING_NODE_PRO_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairNodeProController* controller = new CorsairNodeProController(dev);
|
||||
|
||||
RGBController_CorsairNodePro* rgb_controller = new RGBController_CorsairNodePro(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectCorsairNodeProControllers() */
|
||||
@@ -29,6 +29,8 @@ CorsairProController::CorsairProController(i2c_smbus_interface* bus, corsair_dev
|
||||
strcpy(device_name, "Corsair Vengeance Pro RGB");
|
||||
led_count = CORSAIR_PRO_LED_COUNT;
|
||||
|
||||
effect_mode = CORSAIR_PRO_MODE_STATIC;
|
||||
|
||||
for (unsigned int i = 0; i < led_count; i++)
|
||||
{
|
||||
led_red[i] = 0;
|
||||
@@ -62,6 +64,11 @@ unsigned int CorsairProController::GetLEDCount()
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char CorsairProController::GetEffect()
|
||||
{
|
||||
return(effect_mode);
|
||||
}
|
||||
|
||||
void CorsairProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
for (unsigned int i = 0; i < led_count; i++)
|
||||
@@ -97,24 +104,47 @@ void CorsairProController::ApplyColors()
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
|
||||
}
|
||||
|
||||
void CorsairProController::SetEffect(unsigned char mode)
|
||||
void CorsairProController::SetEffect(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
|
||||
)
|
||||
{
|
||||
effect_mode = mode;
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
|
||||
Sleep(1);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, mode); //Mode
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_SPEED_MEDIUM); //Speed
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_EFFECT_RANDOM_COLORS); //Custom color
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_DIRECTION_UP); //Direction
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 blue
|
||||
unsigned char random_byte;
|
||||
|
||||
if(random)
|
||||
{
|
||||
random_byte = CORSAIR_PRO_EFFECT_RANDOM_COLORS;
|
||||
}
|
||||
else
|
||||
{
|
||||
random_byte = CORSAIR_PRO_EFFECT_CUSTOM_COLORS;
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, effect_mode); //Mode
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, speed); //Speed
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, random_byte); //Custom color
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, direction); //Direction
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, red1); // Custom color 1 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, grn1); // Custom color 1 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, blu1); // Custom color 1 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, red2); // Custom color 2 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, grn2); // Custom color 2 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, blu2); // Custom color 2 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
@@ -129,11 +159,6 @@ void CorsairProController::SetEffect(unsigned char mode)
|
||||
WaitReady();
|
||||
}
|
||||
|
||||
void CorsairProController::SetCustom()
|
||||
{
|
||||
SetEffect(CORSAIR_PRO_MODE_STATIC);
|
||||
}
|
||||
|
||||
bool CorsairProController::WaitReady()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -69,8 +69,18 @@ public:
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void SetEffect(unsigned char mode);
|
||||
void SetCustom();
|
||||
unsigned char GetEffect();
|
||||
void SetEffect(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 SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
@@ -80,7 +90,7 @@ public:
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
|
||||
unsigned char effect_mode;
|
||||
unsigned char led_red[CORSAIR_PRO_LED_COUNT];
|
||||
unsigned char led_green[CORSAIR_PRO_LED_COUNT];
|
||||
unsigned char led_blue[CORSAIR_PRO_LED_COUNT];
|
||||
|
||||
@@ -6,6 +6,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairProController *
|
||||
@@ -24,20 +35,6 @@ bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address
|
||||
{
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x24);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x25);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if (res != 0x1C)
|
||||
@@ -53,6 +50,8 @@ bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairProController() */
|
||||
@@ -122,6 +121,22 @@ void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std:
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5E
|
||||
if (TestForCorsairProController(busses[bus], 0x5E))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5E);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5F
|
||||
if (TestForCorsairProController(busses[bus], 0x5F))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5F);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairProControllers() */
|
||||
@@ -0,0 +1,133 @@
|
||||
/*-----------------------------------------*\
|
||||
| CrucialController.cpp |
|
||||
| |
|
||||
| Driver for Crucial Ballistix RGB lighting|
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CrucialController.h"
|
||||
#include <cstring>
|
||||
|
||||
CrucialController::CrucialController(i2c_smbus_interface* bus, crucial_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
}
|
||||
|
||||
CrucialController::~CrucialController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CrucialController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string CrucialController::GetDeviceLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
char addr[5];
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
unsigned int CrucialController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void CrucialController::SetMode(unsigned char mode)
|
||||
{
|
||||
SendEffectMode(mode, 0x10);
|
||||
}
|
||||
|
||||
void CrucialController::SetAllColorsDirect(RGBColor* colors)
|
||||
{
|
||||
SendDirectColors(colors);
|
||||
}
|
||||
|
||||
void CrucialController::SendEffectColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
CrucialRegisterWrite(0x82E9, 0xFF);
|
||||
CrucialRegisterWrite(0x82EA, 0x00);
|
||||
CrucialRegisterWrite(0x82EB, 0x00);
|
||||
CrucialRegisterWrite(0x82EC, 0x00);
|
||||
CrucialRegisterWrite(0x82ED, red);
|
||||
CrucialRegisterWrite(0x82EE, green);
|
||||
CrucialRegisterWrite(0x82EF, blue);
|
||||
CrucialRegisterWrite(0x82F0, 0x01);
|
||||
}
|
||||
|
||||
void CrucialController::SendBrightness(unsigned char brightness)
|
||||
{
|
||||
CrucialRegisterWrite(0x82EE, 0xFF);
|
||||
CrucialRegisterWrite(0x82EF, brightness);
|
||||
CrucialRegisterWrite(0x82F0, 0x83);
|
||||
}
|
||||
|
||||
void CrucialController::SendEffectMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
CrucialRegisterWrite(0x820F, mode);
|
||||
CrucialRegisterWrite(0x82EE, 0x00);
|
||||
CrucialRegisterWrite(0x82EF, speed);
|
||||
CrucialRegisterWrite(0x82F0, 0x84);
|
||||
}
|
||||
|
||||
void CrucialController::SendDirectColors(RGBColor* color_buf)
|
||||
{
|
||||
//Red Channels
|
||||
CrucialRegisterWrite(0x8300, RGBGetRValue(color_buf[0]));
|
||||
CrucialRegisterWrite(0x8301, RGBGetRValue(color_buf[1]));
|
||||
CrucialRegisterWrite(0x8302, RGBGetRValue(color_buf[2]));
|
||||
CrucialRegisterWrite(0x8303, RGBGetRValue(color_buf[3]));
|
||||
CrucialRegisterWrite(0x8304, RGBGetRValue(color_buf[4]));
|
||||
CrucialRegisterWrite(0x8305, RGBGetRValue(color_buf[5]));
|
||||
CrucialRegisterWrite(0x8306, RGBGetRValue(color_buf[6]));
|
||||
CrucialRegisterWrite(0x8307, RGBGetRValue(color_buf[7]));
|
||||
|
||||
//Green Channels
|
||||
CrucialRegisterWrite(0x8340, RGBGetGValue(color_buf[0]));
|
||||
CrucialRegisterWrite(0x8341, RGBGetGValue(color_buf[1]));
|
||||
CrucialRegisterWrite(0x8342, RGBGetGValue(color_buf[2]));
|
||||
CrucialRegisterWrite(0x8343, RGBGetGValue(color_buf[3]));
|
||||
CrucialRegisterWrite(0x8344, RGBGetGValue(color_buf[4]));
|
||||
CrucialRegisterWrite(0x8345, RGBGetGValue(color_buf[5]));
|
||||
CrucialRegisterWrite(0x8346, RGBGetGValue(color_buf[6]));
|
||||
CrucialRegisterWrite(0x8347, RGBGetGValue(color_buf[7]));
|
||||
|
||||
//Blue Channels
|
||||
CrucialRegisterWrite(0x8380, RGBGetBValue(color_buf[0]));
|
||||
CrucialRegisterWrite(0x8381, RGBGetBValue(color_buf[1]));
|
||||
CrucialRegisterWrite(0x8382, RGBGetBValue(color_buf[2]));
|
||||
CrucialRegisterWrite(0x8383, RGBGetBValue(color_buf[3]));
|
||||
CrucialRegisterWrite(0x8384, RGBGetBValue(color_buf[4]));
|
||||
CrucialRegisterWrite(0x8385, RGBGetBValue(color_buf[5]));
|
||||
CrucialRegisterWrite(0x8386, RGBGetBValue(color_buf[6]));
|
||||
CrucialRegisterWrite(0x8387, RGBGetBValue(color_buf[7]));
|
||||
}
|
||||
|
||||
unsigned char CrucialController::CrucialRegisterRead(crucial_register reg)
|
||||
{
|
||||
//Write Crucial register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Read Crucial value
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
|
||||
}
|
||||
|
||||
void CrucialController::CrucialRegisterWrite(crucial_register reg, unsigned char val)
|
||||
{
|
||||
//Write Crucial register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Crucial value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*-----------------------------------------*\
|
||||
| CrucialController.h |
|
||||
| |
|
||||
| Definitions and types for Crucial |
|
||||
| Ballistix RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char crucial_dev_id;
|
||||
typedef unsigned short crucial_register;
|
||||
|
||||
enum
|
||||
{
|
||||
CRUCIAL_MODE_SHIFT = 0x1F, /* Shift effect mode */
|
||||
CRUCIAL_MODE_GRADIENT_SHIFT = 0x2F, /* Gradient shift mode */
|
||||
CRUCIAL_MODE_FILL = 0x3F, /* Fill effect mode */
|
||||
CRUCIAL_MODE_STACK = 0x4F, /* Stack effect mode */
|
||||
CRUCIAL_MODE_DOUBLE_STACK = 0x5F, /* Double stack effect mode */
|
||||
CRUCIAL_MODE_BREATHING = 0x6F, /* Breathing effect mode */
|
||||
CRUCIAL_MODE_MOTION_POINT = 0x7F, /* Motion point effect mode */
|
||||
CRUCIAL_MODE_INSIDE_OUT = 0x8F, /* Inside out effect mode */
|
||||
CRUCIAL_MODE_COLOR_STEP = 0x9F, /* Color step effect mode */
|
||||
CRUCIAL_MODE_WATER_WAVE = 0xAF, /* Water wave effect mode */
|
||||
CRUCIAL_MODE_FLASHING = 0xBF, /* Flashing effect mode */
|
||||
CRUCIAL_MODE_STATIC = 0xCF, /* Static effect mode */
|
||||
};
|
||||
|
||||
class CrucialController
|
||||
{
|
||||
public:
|
||||
CrucialController(i2c_smbus_interface* bus, crucial_dev_id dev);
|
||||
~CrucialController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void SetAllColorsDirect(RGBColor* colors);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
unsigned char CrucialRegisterRead(crucial_register reg);
|
||||
void CrucialRegisterWrite(crucial_register reg, unsigned char val);
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
unsigned char channel_cfg;
|
||||
i2c_smbus_interface * bus;
|
||||
crucial_dev_id dev;
|
||||
|
||||
void SendDirectColors(RGBColor* color_buf);
|
||||
void SendEffectColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SendBrightness(unsigned char brightness);
|
||||
void SendEffectMode(unsigned char mode, unsigned char speed);
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "CrucialController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Crucial.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for Crucial RAM |
|
||||
\*----------------------------------------------------------------------*/
|
||||
#define CRUCIAL_ADDRESS_COUNT 4
|
||||
|
||||
static const unsigned char crucial_addresses[] =
|
||||
{
|
||||
0x20,
|
||||
0x21,
|
||||
0x22,
|
||||
0x23
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCrucialController *
|
||||
* *
|
||||
* Tests the given address to see if an Crucial controller exists there. First does a*
|
||||
* quick write to test for a response, and if so does a simple read at 0xA0 to test *
|
||||
* for incrementing values 0...F which was observed at this location during data dump *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCrucialController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != (i - 0xA0))
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCrucialController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCrucialControllers *
|
||||
* *
|
||||
* Detect Crucial controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CrucialController* new_crucial;
|
||||
RGBController_Crucial* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Add Crucial controllers
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < CRUCIAL_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx]))
|
||||
{
|
||||
new_crucial = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Crucial(new_crucial);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCrucialControllers() */
|
||||
@@ -19,6 +19,9 @@ Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle)
|
||||
|
||||
Hue2Controller::~Hue2Controller()
|
||||
{
|
||||
current_mode = HUE_2_MODE_FIXED;
|
||||
current_speed = HUE_2_SPEED_NORMAL;
|
||||
current_direction = false;
|
||||
}
|
||||
|
||||
unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
@@ -60,12 +63,20 @@ unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
case 0x01: //Hue 1 strip
|
||||
num_leds_on_channel += 10;
|
||||
break;
|
||||
|
||||
|
||||
case 0x02: //Aer 1 fan
|
||||
num_leds_on_channel += 8;
|
||||
break;
|
||||
|
||||
case 0x04: //Hue 2 strip
|
||||
num_leds_on_channel += 10;
|
||||
break;
|
||||
|
||||
case 0x0B: //Aer 2 fan
|
||||
case 0x0B: //Aer 2 fan (120mm)
|
||||
num_leds_on_channel += 8;
|
||||
break;
|
||||
|
||||
case 0x0C: //Aer 2 fan (140mm)
|
||||
num_leds_on_channel += 8;
|
||||
break;
|
||||
|
||||
@@ -78,7 +89,14 @@ unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors)
|
||||
void Hue2Controller::SetMode(unsigned char mode, unsigned char speed, bool direction)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_direction = direction;
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
@@ -109,8 +127,18 @@ void Hue2Controller::SetChannelEffect(unsigned int channel, unsigned int mode, s
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x04] = mode;
|
||||
usb_buf[0x04] = current_mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set speed in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x05] = current_speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set direction in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x06] = current_direction ? 0x01 : 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set color count in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -130,110 +158,4 @@ void Hue2Controller::SetChannelEffect(unsigned int channel, unsigned int mode, s
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x22, 0x10, 0x01, 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[] =
|
||||
{
|
||||
0x22, 0xA0, 0x01, 0x00,
|
||||
0x01, 0x00, 0x00, 0x28,
|
||||
0x00, 0x00, 0x80, 0x00,
|
||||
0x32, 0x00, 0x00, 0x01,
|
||||
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;
|
||||
|
||||
std::size_t pkt_max = 20;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in USB packets |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x02] = 1 << channel;
|
||||
usb_apply[0x02] = 1 << channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send first packet for first 20 LEDs |
|
||||
\*-----------------------------------------------------*/
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = colors.size();
|
||||
}
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx];
|
||||
usb_buf[pixel_idx + 4] = RGBGetGValue(color);
|
||||
usb_buf[pixel_idx + 5] = RGBGetRValue(color);
|
||||
usb_buf[pixel_idx + 6] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send second packet for second 20 LEDs if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int idx = 4; idx < 64; idx++)
|
||||
{
|
||||
usb_buf[idx] = 0;
|
||||
}
|
||||
|
||||
usb_buf[0x01] = 0x11;
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 20)
|
||||
{
|
||||
pkt_max = colors.size() - 20;
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx + 20];
|
||||
usb_buf[pixel_idx + 4] = RGBGetGValue(color);
|
||||
usb_buf[pixel_idx + 5] = RGBGetRValue(color);
|
||||
usb_buf[pixel_idx + 6] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send apply packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_apply, 64, &actual, 0);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,15 @@ enum
|
||||
HUE_2_CHANNEL_4_IDX = 0x01, /* Channel 4 array index */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_2_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
HUE_2_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
HUE_2_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
HUE_2_SPEED_FAST = 0x03, /* Fast speed */
|
||||
HUE_2_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_2_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
@@ -46,14 +55,17 @@ class Hue2Controller
|
||||
public:
|
||||
Hue2Controller(libusb_device_handle* dev_handle);
|
||||
~Hue2Controller();
|
||||
|
||||
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 SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed, bool direction);
|
||||
|
||||
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
bool current_direction;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#define NZXT_HUE_2_VID 0x1E71
|
||||
#define NZXT_HUE_2_PID 0x2001
|
||||
#define NZXT_SMART_DEVICE_V2_PID 0x2006
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -21,14 +22,29 @@ void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers)
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for NZXT Hue 2
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_HUE_2_PID);
|
||||
libusb_device_handle * hue_2_dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_HUE_2_PID);
|
||||
|
||||
if( dev )
|
||||
if( hue_2_dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
libusb_detach_kernel_driver(hue_2_dev, 0);
|
||||
libusb_claim_interface(hue_2_dev, 0);
|
||||
|
||||
Hue2Controller* controller = new Hue2Controller(dev);
|
||||
Hue2Controller* controller = new Hue2Controller(hue_2_dev);
|
||||
|
||||
RGBController_Hue2* rgb_controller = new RGBController_Hue2(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
//Look for NZXT Smart Device V2
|
||||
libusb_device_handle * smart_dev_2_dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_SMART_DEVICE_V2_PID);
|
||||
|
||||
if( smart_dev_2_dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(smart_dev_2_dev, 0);
|
||||
libusb_claim_interface(smart_dev_2_dev, 0);
|
||||
|
||||
Hue2Controller* controller = new Hue2Controller(smart_dev_2_dev);
|
||||
|
||||
RGBController_Hue2* rgb_controller = new RGBController_Hue2(controller);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
@@ -24,29 +24,31 @@ static void Sleep(unsigned int milliseconds)
|
||||
|
||||
HuePlusController::HuePlusController()
|
||||
{
|
||||
|
||||
current_mode = HUE_PLUS_MODE_FIXED;
|
||||
current_speed = HUE_PLUS_SPEED_NORMAL;
|
||||
current_direction = false;
|
||||
}
|
||||
|
||||
HuePlusController::~HuePlusController()
|
||||
{
|
||||
}
|
||||
|
||||
void HuePlusController::Initialize(char* port_name)
|
||||
void HuePlusController::Initialize(char* port)
|
||||
{
|
||||
strcpy(led_string, port_name);
|
||||
strcpy(port_name, port);
|
||||
|
||||
serialport = new serial_port(port_name, HUE_PLUS_BAUD);
|
||||
|
||||
channel_leds[HUE_PLUS_CHANNEL_1_IDX] = GetStripsOnChannel(HUE_PLUS_CHANNEL_1) * 10;
|
||||
channel_leds[HUE_PLUS_CHANNEL_2_IDX] = GetStripsOnChannel(HUE_PLUS_CHANNEL_2) * 10;
|
||||
channel_leds[HUE_PLUS_CHANNEL_1_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_1);
|
||||
channel_leds[HUE_PLUS_CHANNEL_2_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_2);
|
||||
}
|
||||
|
||||
char* HuePlusController::GetLEDString()
|
||||
char* HuePlusController::GetLocation()
|
||||
{
|
||||
return(led_string);
|
||||
return(port_name);
|
||||
}
|
||||
|
||||
unsigned int HuePlusController::GetStripsOnChannel(unsigned int channel)
|
||||
unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
|
||||
{
|
||||
unsigned char serial_buf[] =
|
||||
{
|
||||
@@ -70,49 +72,95 @@ unsigned int HuePlusController::GetStripsOnChannel(unsigned int channel)
|
||||
|
||||
if(bytes_read == 5)
|
||||
{
|
||||
ret_val = serial_buf[4];
|
||||
if(serial_buf[3] == 0x01)
|
||||
{
|
||||
ret_val = serial_buf[4] * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_val += serial_buf[4] * 10;
|
||||
}
|
||||
}
|
||||
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors)
|
||||
void HuePlusController::SetMode(unsigned char mode, unsigned char speed, bool direction)
|
||||
{
|
||||
unsigned char serial_buf[] =
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_direction = direction;
|
||||
}
|
||||
|
||||
void HuePlusController::SetModeColors(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char serial_buf[125];
|
||||
|
||||
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
0x4B, 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,
|
||||
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
|
||||
};
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0x00, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up main packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x00] = 0x4B;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x02] = current_mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set options bitfield in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x03] = 0;
|
||||
serial_buf[0x03] |= current_direction ? ( 1 << 4 ) : 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set color index and speed in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x04] = ( color_idx << 5 ) | current_speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for (std::size_t idx = 0; idx < 40; idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[color_idx];
|
||||
serial_buf[pixel_idx + 0x05] = RGBGetGValue(color);
|
||||
serial_buf[pixel_idx + 0x06] = RGBGetRValue(color);
|
||||
serial_buf[pixel_idx + 0x07] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char serial_buf[125];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0x00, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up main packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x00] = 0x4B;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in serial packet |
|
||||
@@ -122,7 +170,18 @@ void HuePlusController::SetChannelEffect(unsigned int channel, unsigned int mode
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x02] = mode;
|
||||
serial_buf[0x02] = current_mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set options bitfield in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x03] = 0;
|
||||
serial_buf[0x03] |= current_direction ? ( 1 << 4 ) : 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set speed in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x04] = current_speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
@@ -141,69 +200,3 @@ void HuePlusController::SetChannelEffect(unsigned int channel, unsigned int mode
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char serial_buf[] =
|
||||
{
|
||||
0x4B, 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,
|
||||
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
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x02] = HUE_PLUS_MODE_FIXED;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for (unsigned int idx = 0; idx < (colors.size() * 3); idx += 3)
|
||||
{
|
||||
int pixel_idx = idx / 3;
|
||||
RGBColor color = colors[pixel_idx];
|
||||
serial_buf[idx + 5] = RGBGetGValue(color);
|
||||
serial_buf[idx + 6] = RGBGetRValue(color);
|
||||
serial_buf[idx + 7] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
@@ -41,10 +41,27 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_PLUS_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
HUE_PLUS_MODE_FADING = 0x01, /* Fading mode */
|
||||
HUE_PLUS_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
|
||||
HUE_PLUS_NUM_MODES /* Number of Hue Plus modes */
|
||||
HUE_PLUS_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
HUE_PLUS_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
HUE_PLUS_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
HUE_PLUS_SPEED_FAST = 0x03, /* Fast speed */
|
||||
HUE_PLUS_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_PLUS_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
HUE_PLUS_MODE_FADING = 0x01, /* Fading mode */
|
||||
HUE_PLUS_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
|
||||
HUE_PLUS_MODE_MARQUEE = 0x03, /* Marquee mode */
|
||||
HUE_PLUS_MODE_COVER_MARQUEE = 0x04, /* Cover marquee mode */
|
||||
HUE_PLUS_MODE_ALTERNATING = 0x05, /* Alternating mode */
|
||||
HUE_PLUS_MODE_PULSING = 0x06, /* Pulsing mode */
|
||||
HUE_PLUS_MODE_BREATHING = 0x07, /* Breathing mode */
|
||||
HUE_PLUS_MODE_ALERT = 0x08, /* Alert mode */
|
||||
HUE_PLUS_MODE_CANDLELIGHT = 0x09, /* Candlelight mode */
|
||||
HUE_PLUS_MODE_WINGS = 0x0C, /* Wings mode */
|
||||
HUE_PLUS_MODE_WAVE = 0x0D, /* Wave mode */
|
||||
};
|
||||
|
||||
class HuePlusController
|
||||
@@ -53,18 +70,22 @@ public:
|
||||
HuePlusController();
|
||||
~HuePlusController();
|
||||
|
||||
void Initialize(char* port_name);
|
||||
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 Initialize(char* port);
|
||||
char* GetLocation();
|
||||
unsigned int GetLEDsOnChannel(unsigned int channel);
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed, bool direction);
|
||||
void SetModeColors(unsigned char channel, std::vector<RGBColor> colors);
|
||||
|
||||
unsigned int channel_leds[HUE_PLUS_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
char led_string[1024];
|
||||
char port_name[128];
|
||||
serial_port *serialport;
|
||||
char port_name[128];
|
||||
serial_port *serialport;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
bool current_direction;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* DetectHuePlusControllers *
|
||||
* *
|
||||
* Detect devices supported by the HuePlus driver *
|
||||
* * *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
|
||||
@@ -109,7 +109,7 @@ void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsi
|
||||
|
||||
if(mode == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE3, HYPERX_MODE3_DIRECT);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_INDEPENDENT, HYPERX_MODE3_DIRECT);
|
||||
}
|
||||
|
||||
for(int led = 0; led < 5; led++)
|
||||
@@ -194,48 +194,91 @@ void HyperXController::SetLEDColor(unsigned int slot, unsigned int led, unsigned
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
}
|
||||
|
||||
void HyperXController::SetMode(unsigned char new_mode)
|
||||
void HyperXController::SetMode(unsigned char new_mode, bool random, unsigned short new_speed)
|
||||
{
|
||||
mode = new_mode;
|
||||
mode = new_mode;
|
||||
speed = new_speed;
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Determine which mode register to use. |
|
||||
| If set to random color mode, use Mode1. |
|
||||
| If set to fixed color mode, use Mode2. |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned char mode_reg;
|
||||
|
||||
if(random)
|
||||
{
|
||||
mode_reg = HYPERX_REG_MODE_RANDOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_reg = HYPERX_REG_MODE_CUSTOM;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case HYPERX_MODE_DIRECT:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE3, HYPERX_MODE3_DIRECT);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_INDEPENDENT, HYPERX_MODE3_DIRECT);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_STATIC:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_STATIC);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_CUSTOM, HYPERX_MODE2_STATIC);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_RAINBOW:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE1, HYPERX_MODE1_RAINBOW);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_RANDOM, HYPERX_MODE1_RAINBOW);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_COMET:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_COMET);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_COMET);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_HEARTBEAT:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_HEARTBEAT);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_HEARTBEAT);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_DELAY_TIME_MSB, 0x03);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_DELAY_TIME_LSB, 0xE8);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_CYCLE:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE1, HYPERX_MODE1_CYCLE);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_RANDOM, HYPERX_MODE1_CYCLE);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_CHANGE_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_CHANGE_TIME_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BREATHING:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BREATHING);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BREATHING);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_IN_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_IN_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_OUT_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_OUT_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, 0x00);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BOUNCE:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BOUNCE);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BOUNCE);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BLINK:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BLINK);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BLINK);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, 0x07);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, 0xD4);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,25 @@ enum
|
||||
HYPERX_REG_SLOT3_LED3_BRIGHTNESS = 0xBA, /* Brightness for LED 3, Slot 3 (0-100) */
|
||||
HYPERX_REG_SLOT3_LED4_BRIGHTNESS = 0xBD, /* Brightness for LED 4, Slot 3 (0-100) */
|
||||
|
||||
HYPERX_REG_TIMER_MSB = 0xD1, /* Timer MSB */
|
||||
HYPERX_REG_TIMER_LSB = 0xD2, /* Timer LSB */
|
||||
HYPERX_REG_ON_TIME_MSB = 0xD3, /* Effect on time MSB */
|
||||
HYPERX_REG_ON_TIME_LSB = 0xD4, /* Effect on time LSB */
|
||||
HYPERX_REG_CHANGE_TIME_MSB = 0xD5, /* Change time MSB */
|
||||
HYPERX_REG_CHANGE_TIME_LSB = 0xD6, /* Change time LSB */
|
||||
HYPERX_REG_FADE_IN_TIME_MSB = 0xD7, /* Fade in time MSB */
|
||||
HYPERX_REG_FADE_IN_TIME_LSB = 0xD8, /* Fade in time LSB */
|
||||
HYPERX_REG_FADE_OUT_TIME_MSB = 0xD9, /* Fade out time MSB */
|
||||
HYPERX_REG_FADE_OUT_TIME_LSB = 0xDA, /* Fade out time LSB */
|
||||
HYPERX_REG_OFF_TIME_MSB = 0xDB, /* Effect off time MSB */
|
||||
HYPERX_REG_OFF_TIME_LSB = 0xDC, /* Effect off time LSB */
|
||||
HYPERX_REG_EFFECT_BRIGHTNESS = 0xDD, /* Brightness for effects (0-100) */
|
||||
HYPERX_REG_APPLY = 0xE1, /* Apply changes register */
|
||||
HYPERX_REG_MODE1 = 0xE3, /* Mode control register 1 */
|
||||
HYPERX_REG_MODE2 = 0xE4, /* Mode control register 2 */
|
||||
HYPERX_REG_MODE3 = 0xE5, /* Mode control register 3 */
|
||||
HYPERX_REG_MODE_RANDOM = 0xE3, /* Mode control register, random colors */
|
||||
HYPERX_REG_MODE_CUSTOM = 0xE4, /* Mode control register, custom colors */
|
||||
HYPERX_REG_MODE_INDEPENDENT = 0xE5, /* Mode control register, independent */
|
||||
HYPERX_REG_DELAY_TIME_MSB = 0xEA, /* Delay time MSB */
|
||||
HYPERX_REG_DELAY_TIME_LSB = 0xEB, /* Delay time LSB */
|
||||
HYPERX_REG_EFFECT_RED = 0xEC, /* Red color register for effects */
|
||||
HYPERX_REG_EFFECT_GREEN = 0xED, /* Green color register for effects */
|
||||
HYPERX_REG_EFFECT_BLUE = 0xEE, /* Blue color register for effects */
|
||||
@@ -146,6 +160,31 @@ enum
|
||||
HYPERX_NUMBER_MODES /* Number of HyperX modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_SPEED_BOUNCE_SLOW = 0x07D0, /* Slowest speed for bounce mode */
|
||||
HYPERX_SPEED_BOUNCE_NORMAL = 0x07D0, /* Normal speed for bounce mode */
|
||||
HYPERX_SPEED_BOUNCE_FAST = 0x0064, /* Fastest speed for bounce mode */
|
||||
HYPERX_SPEED_BREATHING_SLOW = 0x07D0, /* Slowest speed for breathing mode */
|
||||
HYPERX_SPEED_BREATHING_NORMAL = 0x07D0, /* Normal speed for breathing mode */
|
||||
HYPERX_SPEED_BREATHING_FAST = 0x0064, /* Fastest speed for breathing mode */
|
||||
HYPERX_SPEED_CYCLE_SLOW = 0x05DC, /* Slowest speed for cycle mode */
|
||||
HYPERX_SPEED_CYCLE_NORMAL = 0x05DC, /* Normal speed for cycle mode */
|
||||
HYPERX_SPEED_CYCLE_FAST = 0x00FA, /* Fastest speed for cycle mode */
|
||||
HYPERX_SPEED_RAINBOW_SLOW = 0x07D0, /* Slowest speed for rainbow mode */
|
||||
HYPERX_SPEED_RAINBOW_NORMAL = 0x07D0, /* Normal speed for rainbow mode */
|
||||
HYPERX_SPEED_RAINBOW_FAST = 0x0064, /* Fastest speed for rainbow mode */
|
||||
HYPERX_SPEED_BLINK_SLOW = 0x07D0, /* Slowest speed for blink mode */
|
||||
HYPERX_SPEED_BLINK_NORMAL = 0x07D0, /* Normal speed for blink mode */
|
||||
HYPERX_SPEED_BLINK_FAST = 0x01F4, /* Fastest speed for blink mode */
|
||||
HYPERX_SPEED_HEARTBEAT_SLOW = 0x07D0, /* Slowest speed for heartbeat mode */
|
||||
HYPERX_SPEED_HEARTBEAT_NORMAL = 0x07D0, /* Normal speed for heartbeat mode */
|
||||
HYPERX_SPEED_HEARTBEAT_FAST = 0x01F4, /* Fastest speed for heartbeat mode */
|
||||
HYPERX_SPEED_COMET_SLOW = 0x07D0, /* Slowest speed for comet mode */
|
||||
HYPERX_SPEED_COMET_NORMAL = 0x07D0, /* Normal speed for comet mode */
|
||||
HYPERX_SPEED_COMET_FAST = 0x0064, /* Fastest speed for comet mode */
|
||||
};
|
||||
|
||||
static const unsigned char slot_base[4] =
|
||||
{
|
||||
HYPERX_REG_SLOT0_LED0_RED, /* SPD 0x50 maps to slot 0 */
|
||||
@@ -165,7 +204,7 @@ public:
|
||||
unsigned int GetLEDCount();
|
||||
unsigned int GetSlotCount();
|
||||
unsigned int GetMode();
|
||||
void SetMode(unsigned char new_mode);
|
||||
void SetMode(unsigned char new_mode, bool random, unsigned short new_speed);
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetEffectColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
@@ -179,4 +218,5 @@ private:
|
||||
i2c_smbus_interface* bus;
|
||||
hyperx_dev_id dev;
|
||||
unsigned int mode;
|
||||
unsigned short speed;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,483 @@
|
||||
/*-----------------------------------------*\
|
||||
| HyperXKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for HyperX RGB Keyboard lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "HyperXKeyboardController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
|
||||
0x15, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x20, 0x21, 0x22, 0x23, 0x24,
|
||||
0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32,
|
||||
0x33, 0x34, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x41, 0x44, 0x45,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x51, 0x54, 0x55, 0x58, 0x59,
|
||||
0x5A, 0x5B, 0x5C, 0x5E, 0x5F, 0x61, 0x64, 0x65, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
|
||||
0x6E, 0x6F, 0x74, 0x75, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x81,
|
||||
0x84, 0x85, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x91, 0x94, 0x95 };
|
||||
|
||||
static unsigned int extended_red[] = {0x08, 0x48, 0x88, 0x09, 0x89, 0x0A, 0x8A, 0x0B, 0x8B, 0x0C, 0x8C, 0x0D, 0x8D, 0x0E, 0x8F, 0x8E, 0x0F, 0x4F, 0x92, 0x13, 0x93, 0x12 };
|
||||
static unsigned int extended_grn[] = {0x29, 0x28, 0x78, 0x19, 0x79, 0x1A, 0x7A, 0x1B, 0x7B, 0x1C, 0x7C, 0x1D, 0x7D, 0x1E, 0x6E, 0x7E, 0x1F, 0x6F, 0x82, 0x23, 0x83, 0x22 };
|
||||
static unsigned int extended_blu[] = {0x39, 0x38, 0x68, 0x3A, 0x69, 0x2A, 0x6A, 0x2B, 0x6B, 0x2C, 0x6C, 0x2D, 0x6D, 0x2E, 0x5E, 0x5D, 0x2F, 0x5F, 0x72, 0x33, 0x73, 0x32 };
|
||||
|
||||
HyperXKeyboardController::HyperXKeyboardController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
HyperXKeyboardController::~HyperXKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char direction,
|
||||
unsigned char speed,
|
||||
std::vector<RGBColor> colors
|
||||
)
|
||||
{
|
||||
unsigned char color_mode;
|
||||
unsigned char mode_colors[9];
|
||||
|
||||
active_mode = mode;
|
||||
active_direction = direction;
|
||||
active_speed = speed;
|
||||
|
||||
memset(mode_colors, 0x00, sizeof(mode_colors));
|
||||
|
||||
switch(colors.size())
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
color_mode = HYPERX_COLOR_MODE_SPECTRUM;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
color_mode = HYPERX_COLOR_MODE_SINGLE;
|
||||
mode_colors[0] = RGBGetRValue(colors[0]);
|
||||
mode_colors[1] = RGBGetGValue(colors[0]);
|
||||
mode_colors[2] = RGBGetBValue(colors[0]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
color_mode = HYPERX_COLOR_MODE_DUAL;
|
||||
mode_colors[3] = RGBGetRValue(colors[0]);
|
||||
mode_colors[4] = RGBGetGValue(colors[0]);
|
||||
mode_colors[5] = RGBGetBValue(colors[0]);
|
||||
mode_colors[6] = RGBGetRValue(colors[1]);
|
||||
mode_colors[7] = RGBGetGValue(colors[1]);
|
||||
mode_colors[8] = RGBGetBValue(colors[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
SendEffect
|
||||
(
|
||||
0x01,
|
||||
active_mode,
|
||||
active_direction,
|
||||
HYPERX_REACTIVE_MODE_NONE,
|
||||
active_speed,
|
||||
color_mode,
|
||||
mode_colors[0],
|
||||
mode_colors[1],
|
||||
mode_colors[2],
|
||||
mode_colors[3],
|
||||
mode_colors[4],
|
||||
mode_colors[5],
|
||||
mode_colors[6],
|
||||
mode_colors[7],
|
||||
mode_colors[8]
|
||||
);
|
||||
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[104];
|
||||
unsigned char grn_color_data[104];
|
||||
unsigned char blu_color_data[104];
|
||||
unsigned char ext_color_data[150];
|
||||
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
{
|
||||
red_color_data[i] = RGBGetRValue(colors[i]);
|
||||
grn_color_data[i] = RGBGetGValue(colors[i]);
|
||||
blu_color_data[i] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
for(std::size_t i = 0; i < 22; i++)
|
||||
{
|
||||
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 104]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 104]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 104]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_COLOR_CHANNEL_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(2);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_COLOR_CHANNEL_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(2);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_COLOR_CHANNEL_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(2);
|
||||
|
||||
SendDirectExtended
|
||||
(
|
||||
ext_color_data
|
||||
);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[104];
|
||||
unsigned char grn_color_data[104];
|
||||
unsigned char blu_color_data[104];
|
||||
unsigned char ext_color_data[150];
|
||||
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
{
|
||||
red_color_data[i] = RGBGetRValue(colors[i]);
|
||||
grn_color_data[i] = RGBGetGValue(colors[i]);
|
||||
blu_color_data[i] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
for(std::size_t i = 0; i < 22; i++)
|
||||
{
|
||||
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 104]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 104]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 104]);
|
||||
}
|
||||
|
||||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_COLOR_CHANNEL_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_COLOR_CHANNEL_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_COLOR_CHANNEL_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
SendExtendedColor
|
||||
(
|
||||
0x01,
|
||||
ext_color_data
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HyperXKeyboardController::SelectProfile
|
||||
(
|
||||
unsigned char profile
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Select Profile packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = 0x01;
|
||||
buf[0x02] = profile;
|
||||
|
||||
buf[0x06] = 0x03;
|
||||
buf[0x07] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendEffect
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char mode,
|
||||
unsigned char direction,
|
||||
unsigned char reactive_mode,
|
||||
unsigned char speed,
|
||||
unsigned char color_mode,
|
||||
unsigned char red_single,
|
||||
unsigned char grn_single,
|
||||
unsigned char blu_single,
|
||||
unsigned char red_dual_1,
|
||||
unsigned char grn_dual_1,
|
||||
unsigned char blu_dual_1,
|
||||
unsigned char red_dual_2,
|
||||
unsigned char grn_dual_2,
|
||||
unsigned char blu_dual_2
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Effect packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_SET_EFFECT;
|
||||
buf[0x02] = profile;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x09] = 0x01;
|
||||
buf[0x0A] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set direction |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x0D] = direction;
|
||||
buf[0x0E] = direction;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set reactive mode |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x1B] = reactive_mode;
|
||||
buf[0x1C] = reactive_mode;
|
||||
buf[0x1D] = reactive_mode;
|
||||
buf[0x1E] = reactive_mode;
|
||||
buf[0x1F] = reactive_mode;
|
||||
buf[0x20] = reactive_mode;
|
||||
buf[0x21] = reactive_mode;
|
||||
buf[0x22] = reactive_mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode-specific colors |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x29] = red_single;
|
||||
buf[0x41] = grn_single;
|
||||
buf[0x59] = blu_single;
|
||||
buf[0x2A] = red_dual_1;
|
||||
buf[0x42] = grn_dual_1;
|
||||
buf[0x5A] = blu_dual_1;
|
||||
buf[0x2B] = red_dual_2;
|
||||
buf[0x43] = grn_dual_2;
|
||||
buf[0x5B] = blu_dual_2;
|
||||
|
||||
buf[0x6B] = 0x09;
|
||||
buf[0x6C] = 0x09;
|
||||
buf[0x6D] = 0x05;
|
||||
buf[0x6E] = 0x05;
|
||||
buf[0x6F] = 0x06;
|
||||
buf[0x70] = 0x05;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set speed |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x71] = speed;
|
||||
|
||||
buf[0x72] = 0x09;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set color mode |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x73] = color_mode;
|
||||
buf[0x74] = color_mode;
|
||||
buf[0x75] = color_mode;
|
||||
buf[0x76] = color_mode;
|
||||
buf[0x77] = color_mode;
|
||||
buf[0x78] = color_mode;
|
||||
buf[0x79] = color_mode;
|
||||
buf[0x7A] = color_mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendColor
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Color packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile;
|
||||
buf[0x03] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 104; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendExtendedColor
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Color packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile;
|
||||
buf[0x03] = HYPERX_COLOR_CHANNEL_EXTENDED;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0x08; i <= 0x93; i++)
|
||||
{
|
||||
buf[i] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendDirect
|
||||
(
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
|
||||
buf[0x02] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 104; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendDirectExtended
|
||||
(
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
|
||||
buf[0x02] = HYPERX_COLOR_CHANNEL_EXTENDED;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0x08; i <= 0x93; i++)
|
||||
{
|
||||
buf[i] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*-----------------------------------------*\
|
||||
| HyperXKeyboardController.h |
|
||||
| |
|
||||
| Definitions and types for HyperX RGB |
|
||||
| Keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_PACKET_ID_SET_EFFECT = 0x02, /* Set profile effect packet */
|
||||
HYPERX_PACKET_ID_SET_COLOR = 0x06, /* Set profile color packet */
|
||||
HYPERX_PACKET_ID_DIRECT = 0x16, /* Direct control packet */
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_DIRECTION_RIGHT = 0x00,
|
||||
HYPERX_DIRECTION_LEFT = 0x01,
|
||||
HYPERX_DIRECTION_UP = 0x02,
|
||||
HYPERX_DIRECTION_DOWN = 0x03,
|
||||
HYPERX_DIRECTION_IN = 0x04,
|
||||
HYPERX_DIRECTION_OUT = 0x05
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_MODE_WAVE = 0x00,
|
||||
HYPERX_MODE_STATIC = 0x01,
|
||||
HYPERX_MODE_BREATHING = 0x02,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_REACTIVE_MODE_TRIGGER = 0x03,
|
||||
HYPERX_REACTIVE_MODE_EXPLOSION = 0x04,
|
||||
HYPERX_REACTIVE_MODE_HYPERX_FLAME = 0x05,
|
||||
HYPERX_REACTIVE_MODE_NONE = 0xFF
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_COLOR_MODE_SINGLE = 0x00,
|
||||
HYPERX_COLOR_MODE_DUAL = 0x01,
|
||||
HYPERX_COLOR_MODE_SPECTRUM = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_COLOR_CHANNEL_RED = 0x01,
|
||||
HYPERX_COLOR_CHANNEL_GREEN = 0x02,
|
||||
HYPERX_COLOR_CHANNEL_BLUE = 0x03,
|
||||
HYPERX_COLOR_CHANNEL_EXTENDED = 0x04
|
||||
};
|
||||
|
||||
class HyperXKeyboardController
|
||||
{
|
||||
public:
|
||||
HyperXKeyboardController(hid_device* dev_handle);
|
||||
~HyperXKeyboardController();
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char direction,
|
||||
unsigned char speed,
|
||||
std::vector<RGBColor> colors
|
||||
);
|
||||
|
||||
void SetLEDsDirect(std::vector<RGBColor> colors);
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
unsigned char active_mode;
|
||||
unsigned char active_direction;
|
||||
unsigned char active_speed;
|
||||
|
||||
void SelectProfile
|
||||
(
|
||||
unsigned char profile
|
||||
);
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char mode,
|
||||
unsigned char direction,
|
||||
unsigned char reactive_mode,
|
||||
unsigned char speed,
|
||||
unsigned char color_mode,
|
||||
unsigned char red_single,
|
||||
unsigned char grn_single,
|
||||
unsigned char blu_single,
|
||||
unsigned char red_dual_1,
|
||||
unsigned char grn_dual_1,
|
||||
unsigned char blu_dual_1,
|
||||
unsigned char red_dual_2,
|
||||
unsigned char grn_dual_2,
|
||||
unsigned char blu_dual_2
|
||||
);
|
||||
|
||||
void SendColor
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendExtendedColor
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendDirectExtended
|
||||
(
|
||||
unsigned char* color_data
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "HyperXKeyboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HyperXKeyboard.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define HYPERX_KEYBOARD_VID 0x0951
|
||||
#define HYPERX_ALLOY_ELITE_PID 0x16BE
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHyperXKeyboardControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a HyperX Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev = NULL;
|
||||
|
||||
hid_init();
|
||||
|
||||
info = hid_enumerate(HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID);
|
||||
|
||||
//Look for HyperX Keyboard, Interface 2
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == HYPERX_KEYBOARD_VID)
|
||||
&&(info->product_id == HYPERX_ALLOY_ELITE_PID)
|
||||
&&(info->interface_number == 2))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
|
||||
|
||||
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*-----------------------------------------*\
|
||||
| MSI3ZoneController.cpp |
|
||||
| |
|
||||
| Driver for MSI/Steelseries 3-Zone |
|
||||
| Keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "MSI3ZoneController.h"
|
||||
|
||||
MSI3ZoneController::MSI3ZoneController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
//strcpy(device_name, "MSI 3-Zone Keyboard");
|
||||
}
|
||||
|
||||
MSI3ZoneController::~MSI3ZoneController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* MSI3ZoneController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
void MSI3ZoneController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
//Shout out to bparker06 for reverse engineering the MSI keyboard USB protocol!
|
||||
// https://github.com/bparker06/msi-keyboard/blob/master/keyboard.cpp for original implementation
|
||||
unsigned char buf[8] = { 0 };
|
||||
|
||||
buf[0] = 1;
|
||||
buf[1] = 2;
|
||||
buf[2] = 64;
|
||||
buf[3] = 1;
|
||||
buf[4] = RGBGetRValue(colors[0]);
|
||||
buf[5] = RGBGetGValue(colors[0]);
|
||||
buf[6] = RGBGetBValue(colors[0]);
|
||||
buf[7] = 236;
|
||||
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 2;
|
||||
buf[4] = RGBGetRValue(colors[1]);
|
||||
buf[5] = RGBGetGValue(colors[1]);
|
||||
buf[6] = RGBGetBValue(colors[1]);
|
||||
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 3;
|
||||
buf[4] = RGBGetRValue(colors[2]);
|
||||
buf[5] = RGBGetGValue(colors[2]);
|
||||
buf[6] = RGBGetBValue(colors[2]);
|
||||
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 4;
|
||||
buf[4] = RGBGetRValue(colors[3]);
|
||||
buf[5] = RGBGetGValue(colors[3]);
|
||||
buf[6] = RGBGetBValue(colors[3]);
|
||||
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 5;
|
||||
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 6;
|
||||
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
|
||||
buf[3] = 7;
|
||||
|
||||
hid_send_feature_report(dev, buf, 8);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*-----------------------------------------*\
|
||||
| MSI3ZoneController.h |
|
||||
| |
|
||||
| Definitions and types for MSI/Steelseries|
|
||||
| 3-Zone Keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
class MSI3ZoneController
|
||||
{
|
||||
public:
|
||||
MSI3ZoneController(hid_device* dev_handle);
|
||||
~MSI3ZoneController();
|
||||
|
||||
char* GetDeviceName();
|
||||
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
hid_device* dev;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "MSI3ZoneController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_MSI3Zone.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define MSI_3_ZONE_KEYBOARD_VID 0x1770
|
||||
#define MSI_3_ZONE_KEYBOARD_PID 0xFF00
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectMSI3ZoneControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an MSI/SteelSeries 3-zone Keyboard controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for MSI/Steelseries 3-zone Keyboard
|
||||
hid_init();
|
||||
|
||||
dev = hid_open(MSI_3_ZONE_KEYBOARD_VID, MSI_3_ZONE_KEYBOARD_PID, 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
MSI3ZoneController* controller = new MSI3ZoneController(dev);
|
||||
|
||||
RGBController_MSI3Zone* rgb_controller = new RGBController_MSI3Zone(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void PatriotViperController::SetEffectColor(unsigned char red, unsigned char gre
|
||||
ViperRegisterWrite(VIPER_REG_LED3_EFFECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED4_EFFECT_COLOR, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ void PatriotViperController::SetLEDEffectColor(unsigned int led, unsigned char r
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
@@ -143,19 +143,20 @@ void PatriotViperController::SetLEDEffectColor(unsigned int slot, unsigned int l
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetMode(unsigned char new_mode)
|
||||
void PatriotViperController::SetMode(unsigned char new_mode, unsigned char new_speed)
|
||||
{
|
||||
direct = false;
|
||||
mode = new_mode;
|
||||
mode = new_mode;
|
||||
speed = new_speed;
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, new_mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,16 @@ enum
|
||||
VIPER_MODE_NEON = 0x08, /* Neon mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
VIPER_SPEED_MIN = 0xC8, /* Slowest speed for non-breathing mode */
|
||||
VIPER_SPEED_DEFAULT = 0x64, /* Default speed for non-breathing mode */
|
||||
VIPER_SPEED_MAX = 0x14, /* Fastest speed for non-breathing mode */
|
||||
VIPER_SPEED_BREATHING_MIN = 0xFF, /* Slowest speed for breathing mode */
|
||||
VIPER_SPEED_BREATHING_DEFAULT = 0x0C, /* Default speed for breathing mode */
|
||||
VIPER_SPEED_BREATHING_MAX = 0x00, /* Fastest speed for breathing mode */
|
||||
};
|
||||
|
||||
class PatriotViperController
|
||||
{
|
||||
public:
|
||||
@@ -56,7 +66,7 @@ public:
|
||||
unsigned int GetLEDCount();
|
||||
unsigned int GetSlotCount();
|
||||
unsigned int GetMode();
|
||||
void SetMode(unsigned char new_mode);
|
||||
void SetMode(unsigned char new_mode, unsigned char new_speed);
|
||||
void SetDirect();
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
@@ -75,5 +85,6 @@ private:
|
||||
unsigned char slots_valid;
|
||||
i2c_smbus_interface* bus;
|
||||
viper_dev_id dev;
|
||||
unsigned int mode;
|
||||
unsigned char mode;
|
||||
unsigned char speed;
|
||||
};
|
||||
|
||||
@@ -25,8 +25,20 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
|
||||
|
||||
case FIRMWARE_VER_2_PT_00:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 2.00");
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 2.00");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_08:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 2.08");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_10:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 2.10");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_3_PT_00:
|
||||
@@ -76,45 +88,38 @@ unsigned int PolychromeController::GetLEDCount()
|
||||
|
||||
unsigned int PolychromeController::GetMode()
|
||||
{
|
||||
return(0);
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void PolychromeController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
bool PolychromeController::IsAsrLed()
|
||||
{
|
||||
return(asr_led);
|
||||
}
|
||||
|
||||
void PolychromeController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char colors[3] = { red, green, blue };
|
||||
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, active_mode, 3, colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char colors[3] = { red, green, blue };
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetLEDColor(unsigned int /*led*/, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char colors[3] = { red, green, blue };
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetMode(unsigned char mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, ASRLED_REG_MODE, 1, &active_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, POLYCHROME_REG_MODE, mode);
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_MODE, 1, &active_mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ enum
|
||||
{
|
||||
FIRMWARE_VER_1_PT_10 = 0x010A, /* Firmware nu51_1.10 */
|
||||
FIRMWARE_VER_2_PT_00 = 0x0200, /* Firmware nu51_2.00 */
|
||||
FIRMWARE_VER_2_PT_08 = 0x0208, /* Firmware nu51_2.08 */
|
||||
FIRMWARE_VER_2_PT_10 = 0x020A, /* Firmware nu51_2.10 */
|
||||
FIRMWARE_VER_3_PT_00 = 0x0300, /* Firmware nu51_3.00 */
|
||||
};
|
||||
|
||||
@@ -77,8 +79,8 @@ public:
|
||||
char* GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
unsigned int GetMode();
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
bool IsAsrLed();
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
unsigned short GetFirmwareVersion();
|
||||
|
||||
@@ -86,7 +88,8 @@ private:
|
||||
bool asr_led;
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
unsigned char active_mode;
|
||||
i2c_smbus_interface* bus;
|
||||
polychrome_dev_id dev;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
/*-----------------------------------------*\
|
||||
| PoseidonZRGBController.cpp |
|
||||
| |
|
||||
| Driver for Thermaltake Poseidon Z RGB |
|
||||
| Keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "PoseidonZRGBController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x15,
|
||||
0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
|
||||
0x24, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
|
||||
0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x40,
|
||||
0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C,
|
||||
0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x66, 0x67, 0x68, 0x69, 0x6A,
|
||||
0x6C, 0x6D, 0x6F, 0x70, 0x72, 0x73, 0x75, 0x76, 0x77, 0x78, 0x7C, 0x80, 0x81 };
|
||||
|
||||
PoseidonZRGBController::PoseidonZRGBController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
PoseidonZRGBController::~PoseidonZRGBController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetMode(unsigned char mode, unsigned char direction, unsigned char speed)
|
||||
{
|
||||
active_mode = mode;
|
||||
active_direction = direction;
|
||||
active_speed = speed;
|
||||
|
||||
SendControl
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
active_direction,
|
||||
active_mode,
|
||||
POSEIDONZ_BRIGHTNESS_MAX,
|
||||
active_speed
|
||||
);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_grn_buf[264];
|
||||
unsigned char blu_buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffers |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(red_grn_buf, 0x00, sizeof(red_grn_buf));
|
||||
memset(blu_buf, 0x00, sizeof(blu_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packets |
|
||||
\*-----------------------------------------------------*/
|
||||
red_grn_buf[0] = 0x07;
|
||||
red_grn_buf[1] = POSEIDONZ_PACKET_ID_SET_DIRECT;
|
||||
red_grn_buf[2] = POSEIDONZ_PROFILE_P1;
|
||||
red_grn_buf[3] = POSEIDONZ_DIRECT_RED_GREEN;
|
||||
red_grn_buf[4] = 0x00;
|
||||
red_grn_buf[5] = 0x00;
|
||||
red_grn_buf[6] = 0x00;
|
||||
red_grn_buf[7] = 0x00;
|
||||
|
||||
blu_buf[0] = 0x07;
|
||||
blu_buf[1] = POSEIDONZ_PACKET_ID_SET_DIRECT;
|
||||
blu_buf[2] = POSEIDONZ_PROFILE_P1;
|
||||
blu_buf[3] = POSEIDONZ_DIRECT_BLUE;
|
||||
blu_buf[4] = 0x00;
|
||||
blu_buf[5] = 0x00;
|
||||
blu_buf[6] = 0x00;
|
||||
blu_buf[7] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
{
|
||||
red_grn_buf[keys[i] ] = RGBGetRValue(colors[i]);
|
||||
red_grn_buf[keys[i] + 128] = RGBGetGValue(colors[i]);
|
||||
blu_buf[ keys[i] ] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packets |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, red_grn_buf, 264);
|
||||
hid_send_feature_report(dev, blu_buf, 264);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[104];
|
||||
unsigned char grn_color_data[104];
|
||||
unsigned char blu_color_data[104];
|
||||
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
{
|
||||
red_color_data[i] = RGBGetRValue(colors[i]);
|
||||
grn_color_data[i] = RGBGetGValue(colors[i]);
|
||||
blu_color_data[i] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
SendColor
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_COLOR_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
SendColor
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_COLOR_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
SendColor
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_COLOR_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
SendControl
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
active_direction,
|
||||
active_mode,
|
||||
POSEIDONZ_BRIGHTNESS_MAX,
|
||||
active_speed
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void PoseidonZRGBController::SendColor
|
||||
(
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Color packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = POSEIDONZ_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile_to_edit;
|
||||
buf[0x03] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 104; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SendControl
|
||||
(
|
||||
unsigned char profile_to_activate,
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char direction,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Effect packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = POSEIDONZ_PACKET_ID_SET_EFFECT;
|
||||
buf[0x02] = profile_to_activate;
|
||||
buf[0x08] = profile_to_edit;
|
||||
buf[0x0A] = direction;
|
||||
buf[0x0C] = mode;
|
||||
buf[0x0D] = brightness;
|
||||
buf[0x10] = 0x08;
|
||||
buf[0x12] = speed;
|
||||
buf[0x13] = 0x50;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*-----------------------------------------*\
|
||||
| PoseidonZRGBController.h |
|
||||
| |
|
||||
| Definitions and types for Thermaltake |
|
||||
| Poseidon Z RGB Keyboard lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define POSEIDONZ_START 0x07
|
||||
#define POSEIDONZ_PROFILE 0x01
|
||||
#define POSEIDONZ_LED_CMD 0x0E
|
||||
#define POSEIDONZ_RED_GRN_CH 0x01
|
||||
#define POSEIDONZ_BLU_CH 0x02
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_PACKET_ID_SET_EFFECT = 0x02, /* Set profile effect packet */
|
||||
POSEIDONZ_PACKET_ID_SET_COLOR = 0x09, /* Set profile color packet */
|
||||
POSEIDONZ_PACKET_ID_SET_DIRECT = 0x0E, /* Set direct color packet */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_MODE_STATIC = 0x00,
|
||||
POSEIDONZ_MODE_REACTIVE = 0x01,
|
||||
POSEIDONZ_MODE_ARROW_FLOW = 0x02,
|
||||
POSEIDONZ_MODE_WAVE = 0x03,
|
||||
POSEIDONZ_MODE_RIPPLE = 0x04
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_PROFILE_P1 = 0x01,
|
||||
POSEIDONZ_PROFILE_P2 = 0x02,
|
||||
POSEIDONZ_PROFILE_P3 = 0x03,
|
||||
POSEIDONZ_PROFILE_P4 = 0x04,
|
||||
POSEIDONZ_PROFILE_P5 = 0x05
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_BRIGHTNESS_MIN = 0x00,
|
||||
POSEIDONZ_BRIGHTNESS_MAX = 0x04
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_COLOR_RED = 0x01,
|
||||
POSEIDONZ_COLOR_GREEN = 0x02,
|
||||
POSEIDONZ_COLOR_BLUE = 0x03
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_DIRECT_RED_GREEN = 0x01,
|
||||
POSEIDONZ_DIRECT_BLUE = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_SPEED_SLOW = 0x10,
|
||||
POSEIDONZ_SPEED_FAST = 0x05
|
||||
};
|
||||
|
||||
class PoseidonZRGBController
|
||||
{
|
||||
public:
|
||||
PoseidonZRGBController(hid_device* dev_handle);
|
||||
~PoseidonZRGBController();
|
||||
|
||||
void SetMode(unsigned char mode, unsigned char direction, unsigned char speed);
|
||||
void SetLEDsDirect(std::vector<RGBColor> colors);
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
unsigned char active_mode;
|
||||
unsigned char active_direction;
|
||||
unsigned char active_speed;
|
||||
|
||||
void SendControl
|
||||
(
|
||||
unsigned char profile_to_activate,
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char direction,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
void SendColor
|
||||
(
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "PoseidonZRGBController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_PoseidonZRGB.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define TT_POSEIDON_Z_RGB_VID 0x264A
|
||||
#define TT_POSEIDON_Z_RGB_PID 0x3006
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectPoseidonZRGBControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Thermaltake Poseidon Z RGB Keyboard controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev = NULL;
|
||||
|
||||
hid_init();
|
||||
|
||||
info = hid_enumerate(TT_POSEIDON_Z_RGB_VID, TT_POSEIDON_Z_RGB_PID);
|
||||
|
||||
//Look for Thermaltake Poseidon Z RGB, Interface 2
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == TT_POSEIDON_Z_RGB_VID)
|
||||
&&(info->product_id == TT_POSEIDON_Z_RGB_PID)
|
||||
&&(info->interface_number == 2))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
|
||||
|
||||
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2Controller.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus RGB Fusion 2.0 |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/15/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBFusion2Controller.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
RGBFusion2Controller::RGBFusion2Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
// Set Device name
|
||||
strcpy(device_name, "Gigabyte Motherboard");
|
||||
|
||||
// Set LED count
|
||||
led_count = 8;
|
||||
}
|
||||
|
||||
RGBFusion2Controller::~RGBFusion2Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string RGBFusion2Controller::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string RGBFusion2Controller::GetDeviceLocation()
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
unsigned int RGBFusion2Controller::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char RGBFusion2Controller::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBFusion2Controller::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
}
|
||||
|
||||
void RGBFusion2Controller::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0xCC, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01,
|
||||
0x5A, 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,
|
||||
};
|
||||
|
||||
usb_buf[0x01] = (0x20 | led);
|
||||
usb_buf[0x02] = (0x01 << led );
|
||||
|
||||
usb_buf[0x0E] = blue;
|
||||
usb_buf[0x0F] = green;
|
||||
usb_buf[0x10] = red;
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, 64);
|
||||
|
||||
SendApply();
|
||||
}
|
||||
|
||||
void RGBFusion2Controller::SendApply()
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0xCC, 0x28, 0xFF, 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,
|
||||
};
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void RGBFusion2Controller::SetMode(unsigned char mode)
|
||||
{
|
||||
}
|
||||
|
||||
void RGBFusion2Controller::dump()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2Controller.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| RGB Fusion 2.0 lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/15/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
class RGBFusion2Controller
|
||||
{
|
||||
public:
|
||||
RGBFusion2Controller(hid_device* dev_handle);
|
||||
~RGBFusion2Controller();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
unsigned char GetMode();
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
private:
|
||||
void dump();
|
||||
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
|
||||
void SendApply();
|
||||
|
||||
hid_device* dev;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "RGBFusion2Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RGBFusion2.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define RGB_FUSION_2_VID 0x048D
|
||||
#define RGB_FUSION_2_PID 0x8297
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRGBFusion2Controllers *
|
||||
* *
|
||||
* Detect RGB Fusion 2.0 controllers on the USB interface. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRGBFusion2Controllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for RGB Fusion 2.0 Controller
|
||||
hid_init();
|
||||
|
||||
dev = hid_open(RGB_FUSION_2_VID, RGB_FUSION_2_PID, 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
RGBFusion2Controller* controller = new RGBFusion2Controller(dev);
|
||||
|
||||
RGBController_RGBFusion2* rgb_controller = new RGBController_RGBFusion2(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
} /* DetectRGBFusionControllers() */
|
||||
@@ -102,11 +102,13 @@ void RGBFusionController::SetLEDColor(unsigned int led, unsigned char red, unsig
|
||||
}
|
||||
}
|
||||
|
||||
void RGBFusionController::SetMode(unsigned char mode)
|
||||
void RGBFusionController::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
switch_bank(0);
|
||||
set_mode_ch_0(mode);
|
||||
set_timers_ch_0(speed_table[0][speed], speed_table[1][speed]);
|
||||
set_mode_ch_1(mode);
|
||||
set_timers_ch_1(speed_table[0][speed], speed_table[1][speed]);
|
||||
}
|
||||
|
||||
void RGBFusionController::dump()
|
||||
@@ -170,6 +172,22 @@ void RGBFusionController::set_mode_ch_1(unsigned char mode)
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_timers_ch_0(unsigned short timer0, unsigned short timer1)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_MSB, timer0 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_LSB, timer0 & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_MSB, timer1 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_LSB, timer1 & 0xFF);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_timers_ch_1(unsigned short timer0, unsigned short timer1)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_MSB, timer0 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_LSB, timer0 & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_MSB, timer1 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_LSB, timer1 & 0xFF);
|
||||
}
|
||||
|
||||
void RGBFusionController::switch_bank(unsigned char bank)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_SWITCH_REG, bank);
|
||||
|
||||
@@ -17,7 +17,23 @@ typedef unsigned char rgb_fusion_dev_id;
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_BANK_0_REG_CH_0_MODE = 0x03, /* Channel 0 Mode Selection */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_MSB
|
||||
= 0x06, /* Channel 0 Timer 0 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_LSB
|
||||
= 0x07, /* Channel 0 Timer 0 LSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_MSB
|
||||
= 0x08, /* Channel 0 Timer 1 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_LSB
|
||||
= 0x09, /* Channel 0 Timer 1 LSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_MODE = 0x13, /* Channel 1 Mode Selection */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_MSB
|
||||
= 0x16, /* Channel 1 Timer 0 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_LSB
|
||||
= 0x17, /* Channel 1 Timer 0 LSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_MSB
|
||||
= 0x18, /* Channel 1 Timer 1 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_LSB
|
||||
= 0x19, /* Channel 1 Timer 1 LSB */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_R = 0x00, /* Channel 0 Red Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_G = 0x01, /* Channel 0 Green Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_B = 0x02, /* Channel 0 Blue Value */
|
||||
@@ -27,6 +43,19 @@ enum
|
||||
RGB_FUSION_BANK_SWITCH_REG = 0xF0, /* Bank Switch Register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_SPEED_SLOW = 0x00, /* Slowest speed */
|
||||
RGB_FUSION_SPEED_NORMAL = 0x01, /* Normal speed */
|
||||
RGB_FUSION_SPEED_FAST = 0x02, /* Fastest speed */
|
||||
};
|
||||
|
||||
static const short speed_table[2][3] =
|
||||
{
|
||||
{ 0x01E0, 0x00F0, 0x0078 },
|
||||
{ 0x4000, 0x2000, 0x1000 }
|
||||
};
|
||||
|
||||
#define RGB_FUSION_NUMBER_MODES 3 /* Number of RGB Fusion modes */
|
||||
#define RGB_FUSION_WRITE_MODE_OFST 0x10 /* offset to add when writing mode */
|
||||
|
||||
@@ -49,7 +78,7 @@ public:
|
||||
unsigned char GetMode();
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
private:
|
||||
void dump();
|
||||
@@ -61,6 +90,8 @@ private:
|
||||
void set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void set_mode_ch_0(unsigned char mode);
|
||||
void set_mode_ch_1(unsigned char mode);
|
||||
void set_timers_ch_0(unsigned short timer0, unsigned short timer1);
|
||||
void set_timers_ch_1(unsigned short timer0, unsigned short timer1);
|
||||
void switch_bank(unsigned char bank);
|
||||
|
||||
char device_name[32];
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusionGPUController.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus RGB Fusion GPU |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/20/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBFusionGPUController.h"
|
||||
|
||||
RGBFusionGPUController::RGBFusionGPUController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
}
|
||||
|
||||
RGBFusionGPUController::~RGBFusionGPUController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string RGBFusionGPUController::GetDeviceLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
char addr[5];
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void RGBFusionGPUController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte(dev, RGB_FUSION_GPU_REG_COLOR);
|
||||
bus->i2c_smbus_write_byte(dev, red);
|
||||
bus->i2c_smbus_write_byte(dev, green);
|
||||
bus->i2c_smbus_write_byte(dev, blue);
|
||||
}
|
||||
|
||||
void RGBFusionGPUController::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
bus->i2c_smbus_write_byte(dev, RGB_FUSION_GPU_REG_MODE);
|
||||
bus->i2c_smbus_write_byte(dev, mode);
|
||||
bus->i2c_smbus_write_byte(dev, speed);
|
||||
bus->i2c_smbus_write_byte(dev, 0x63);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusionGPUController.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| RGB Fusion GPU lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/20/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char rgb_fusion_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_GPU_REG_COLOR = 0x40,
|
||||
RGB_FUSION_GPU_REG_MODE = 0x88
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_GPU_MODE_STATIC = 0x01,
|
||||
RGB_FUSION_GPU_MODE_BREATHING = 0x02,
|
||||
RGB_FUSION_GPU_MODE_FLASHING = 0x04,
|
||||
RGB_FUSION_GPU_MODE_DUAL_FLASHING = 0x08,
|
||||
RGB_FUSION_GPU_MODE_SPECTRUM_CYCLE = 0x11
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_GPU_SPEED_SLOWEST = 0x00,
|
||||
RGB_FUSION_GPU_SPEED_NORMAL = 0x05,
|
||||
RGB_FUSION_GPU_SPEED_FASTEST = 0x09
|
||||
};
|
||||
|
||||
class RGBFusionGPUController
|
||||
{
|
||||
public:
|
||||
RGBFusionGPUController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
|
||||
~RGBFusionGPUController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
private:
|
||||
i2c_smbus_interface* bus;
|
||||
rgb_fusion_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "RGBFusionGPUController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RGBFusionGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForRGBFusionGPUController *
|
||||
* *
|
||||
* Tests the given address to see if an RGB Fusion controller exists there. First *
|
||||
* does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForRGBFusionGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
int res;
|
||||
|
||||
//Write out 0xAB 0x00 0x00 0x00 sequence
|
||||
res = bus->i2c_smbus_write_byte(address, 0xAB);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
bus->i2c_smbus_write_byte(address, 0x00);
|
||||
bus->i2c_smbus_write_byte(address, 0x00);
|
||||
bus->i2c_smbus_write_byte(address, 0x00);
|
||||
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte(address);
|
||||
|
||||
if (res != 0xAB)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte(address);
|
||||
|
||||
if(res != 0x14)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
bus->i2c_smbus_read_byte(address);
|
||||
bus->i2c_smbus_read_byte(address);
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForRGBFusionGPUController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRGBFusionGPUControllers *
|
||||
* *
|
||||
* Detect RGB Fusion controllers on the enumerated I2C busses at address 0x47. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
|
||||
* dev - I2C address of RGB Fusion device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
RGBFusionGPUController* new_rgb_fusion;
|
||||
RGBController_RGBFusionGPU* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for RGB Fusion controller at 0x47
|
||||
if (TestForRGBFusionGPUController(busses[bus], 0x47))
|
||||
{
|
||||
new_rgb_fusion = new RGBFusionGPUController(busses[bus], 0x47);
|
||||
new_controller = new RGBController_RGBFusionGPU(new_rgb_fusion);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectRGBFusionGPUControllers() */
|
||||
@@ -0,0 +1,117 @@
|
||||
/*-----------------------------------------*\
|
||||
| ThermaltakeRiingController.cpp |
|
||||
| |
|
||||
| Definitions and types for Thermaltake |
|
||||
| Riing Plus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/7/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "ThermaltakeRiingController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
ThermaltakeRiingController::ThermaltakeRiingController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
SendInit();
|
||||
|
||||
channel_leds[0] = 9;
|
||||
channel_leds[1] = 9;
|
||||
channel_leds[2] = 9;
|
||||
channel_leds[3] = 0;
|
||||
channel_leds[4] = 0;
|
||||
}
|
||||
|
||||
ThermaltakeRiingController::~ThermaltakeRiingController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char* color_data = new unsigned char[3 * colors.size()];
|
||||
|
||||
for(int color = 0; color < colors.size(); color++)
|
||||
{
|
||||
int color_idx = color * 3;
|
||||
color_data[color_idx + 0] = RGBGetGValue(colors[color]);
|
||||
color_data[color_idx + 1] = RGBGetRValue(colors[color]);
|
||||
color_data[color_idx + 2] = RGBGetBValue(colors[color]);
|
||||
}
|
||||
|
||||
SendRGB(channel, current_mode, current_speed, colors.size(), color_data);
|
||||
|
||||
delete[] color_data;
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void ThermaltakeRiingController::SendInit()
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Init packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xFE;
|
||||
usb_buf[0x01] = 0x33;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SendRGB
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char num_colors,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up RGB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x32;
|
||||
usb_buf[0x01] = 0x52;
|
||||
usb_buf[0x02] = port;
|
||||
usb_buf[0x03] = mode + ( speed & 0x03 );
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in GRB color data |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x04], color_data, (num_colors * 3));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*-----------------------------------------*\
|
||||
| ThermaltakeRiingController.h |
|
||||
| |
|
||||
| Definitions and types for Thermaltake |
|
||||
| Riing Plus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/7/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_PORT_1 = 0x01,
|
||||
THERMALTAKE_PORT_2 = 0x02,
|
||||
THERMALTAKE_PORT_3 = 0x03,
|
||||
THERMALTAKE_PORT_4 = 0x04,
|
||||
THERMALTAKE_PORT_5 = 0x05
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_MODE_FLOW = 0x00,
|
||||
THERMALTAKE_MODE_SPECTRUM = 0x04,
|
||||
THERMALTAKE_MODE_RIPPLE = 0x08,
|
||||
THERMALTAKE_MODE_BLINK = 0x0C,
|
||||
THERMALTAKE_MODE_PULSE = 0x10,
|
||||
THERMALTAKE_MODE_WAVE = 0x14,
|
||||
THERMALTAKE_MODE_PER_LED = 0x18,
|
||||
THERMALTAKE_MODE_FULL = 0x19
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_SPEED_SLOW = 0x03,
|
||||
THERMALTAKE_SPEED_NORMAL = 0x02,
|
||||
THERMALTAKE_SPEED_FAST = 0x01,
|
||||
THERMALTAKE_SPEED_EXTREME = 0x00
|
||||
};
|
||||
|
||||
class ThermaltakeRiingController
|
||||
{
|
||||
public:
|
||||
ThermaltakeRiingController(libusb_device_handle* dev_handle);
|
||||
~ThermaltakeRiingController();
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
unsigned int channel_leds[5];
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
void SendInit();
|
||||
|
||||
void SendRGB
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char num_colors,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendFan();
|
||||
void SendSave();
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "ThermaltakeRiingController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ThermaltakeRiing.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define THERMALTAKE_RIING_VID 0x264A
|
||||
#define THERMALTAKE_RIING_PID_BEGIN 0x1FA5
|
||||
#define THERMALTAKE_RIING_PID_END 0x1FB5
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectThermaltakeRiingControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an AMD Wraith Prism controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
for(int pid = THERMALTAKE_RIING_PID_BEGIN; pid <= THERMALTAKE_RIING_PID_END; pid++)
|
||||
{
|
||||
//Look for Thermaltake Riing device
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, THERMALTAKE_RIING_VID, pid);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
ThermaltakeRiingController* controller = new ThermaltakeRiingController(dev);
|
||||
|
||||
RGBController_ThermaltakeRiing* rgb_controller = new RGBController_ThermaltakeRiing(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
-72
@@ -13,15 +13,13 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <regex>
|
||||
#include "i2c_smbus_piix4.h"
|
||||
#include "i2c_smbus_i801.h"
|
||||
#include "i2c_smbus_nct6775.h"
|
||||
#include "i2c_smbus_nvapi.h"
|
||||
#include "super_io.h"
|
||||
#include "wmi.h"
|
||||
#include "inpout32.h"
|
||||
|
||||
#pragma comment(lib, "inpout32.lib")
|
||||
#else /* WIN32 */
|
||||
|
||||
#include "i2c_smbus_linux.h"
|
||||
@@ -36,68 +34,6 @@ std::vector<i2c_smbus_interface*> busses;
|
||||
std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
#ifdef WIN32
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* Nuvoton Super IO constants *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#define SIO_NCT5577_ID 0xC330 /* Device ID for NCT5577D (C333) */
|
||||
#define SIO_NCT6102_ID 0x1060 /* Device ID for NCT6102D/6106D (1061) */
|
||||
#define SIO_NCT6793_ID 0xd120 /* Device ID for NCT6793D (D121) */
|
||||
#define SIO_NCT6796_ID 0xd420 /* Device ID for NCT6796D (D421) */
|
||||
#define SIO_REG_LOGDEV 0x07 /* Logical Device Register */
|
||||
#define SIO_REG_DEVID 0x20 /* Device ID Register */
|
||||
#define SIO_REG_SMBA 0x62 /* SMBus Base Address Register */
|
||||
#define SIO_LOGDEV_SMBUS 0x0B /* Logical Device for SMBus */
|
||||
#define SIO_ID_MASK 0xFFF8 /* Device ID mask */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_enter *
|
||||
* *
|
||||
* Put the Super IO chip into Extended Function Mode *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_enter(int ioreg)
|
||||
{
|
||||
Out32(ioreg, 0x87);
|
||||
Out32(ioreg, 0x87);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_outb *
|
||||
* *
|
||||
* Write a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_outb(int ioreg, int reg, int val)
|
||||
{
|
||||
Out32(ioreg, reg);
|
||||
Out32(ioreg + 1, val);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_inb *
|
||||
* *
|
||||
* Read a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
int superio_inb(int ioreg, int reg)
|
||||
{
|
||||
Out32(ioreg, reg);
|
||||
return Inp32(ioreg + 1);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectNuvotonI2CBusses (Windows) *
|
||||
@@ -152,6 +88,33 @@ void DetectNuvotonI2CBusses()
|
||||
|
||||
} /* DetectNuvotonI2CBusses() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectNvAPII2CBusses (Windows) *
|
||||
* *
|
||||
* Detects available NVidia NvAPI I2C adapters and enumerates *
|
||||
* i2c_smbus_interface objects for them. Only enumerates the first bus for each GPU *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectNvAPII2CBusses()
|
||||
{
|
||||
static NV_PHYSICAL_GPU_HANDLE gpu_handles[64];
|
||||
static NV_S32 gpu_count = 0;
|
||||
|
||||
NV_STATUS initialize = NvAPI_Initialize();
|
||||
|
||||
NvAPI_EnumPhysicalGPUs(gpu_handles, &gpu_count);
|
||||
|
||||
for(NV_S32 gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++)
|
||||
{
|
||||
i2c_smbus_nvapi * nvapi_bus = new i2c_smbus_nvapi(gpu_handles[gpu_idx]);
|
||||
|
||||
sprintf(nvapi_bus->device_name, "NVidia NvAPI I2C on GPU %d", gpu_idx);
|
||||
|
||||
busses.push_back(nvapi_bus);
|
||||
}
|
||||
} /* DetectNvAPII2CBusses() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -235,6 +198,9 @@ void DetectI2CBusses()
|
||||
// Detect Nuvoton Super IO SMBus adapters
|
||||
DetectNuvotonI2CBusses();
|
||||
|
||||
// Detect NVidia NvAPI I2C adapters
|
||||
DetectNvAPII2CBusses();
|
||||
|
||||
} /* DetectI2CBusses() */
|
||||
|
||||
#else /* WIN32 */
|
||||
@@ -320,18 +286,26 @@ void DetectI2CBusses()
|
||||
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectRazerChromaSDKControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -348,9 +322,12 @@ void DetectRGBControllers(void)
|
||||
DetectAuraControllers(busses, rgb_controllers);
|
||||
DetectCorsairControllers(busses, rgb_controllers);
|
||||
DetectCorsairProControllers(busses, rgb_controllers);
|
||||
DetectCrucialControllers(busses, rgb_controllers);
|
||||
DetectHyperXControllers(busses, rgb_controllers);
|
||||
DetectPatriotViperControllers(busses, rgb_controllers);
|
||||
DetectPolychromeControllers(busses, rgb_controllers);
|
||||
DetectRGBFusionGPUControllers(busses, rgb_controllers);
|
||||
|
||||
DetectRGBFusionControllers(busses, rgb_controllers);
|
||||
|
||||
DetectLEDStripControllers(rgb_controllers);
|
||||
@@ -358,21 +335,27 @@ void DetectRGBControllers(void)
|
||||
DetectHuePlusControllers(rgb_controllers);
|
||||
|
||||
DetectAMDWraithPrismControllers(rgb_controllers);
|
||||
|
||||
DetectMSI3ZoneControllers(rgb_controllers);
|
||||
DetectPoseidonZRGBControllers(rgb_controllers);
|
||||
DetectHyperXKeyboardControllers(rgb_controllers);
|
||||
DetectCorsairCmdrProControllers(rgb_controllers);
|
||||
DetectCorsairKeyboardControllers(rgb_controllers);
|
||||
DetectCorsairNodeProControllers(rgb_controllers);
|
||||
DetectThermaltakeRiingControllers(rgb_controllers);
|
||||
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
|
||||
/*-------------------------------------*\
|
||||
| Windows-only devices |
|
||||
\*-------------------------------------*/
|
||||
#ifdef WIN32
|
||||
DetectRazerChromaSDKControllers(rgb_controllers);
|
||||
//DetectAorusGPUControllers(rgb_controllers);
|
||||
|
||||
DetectOpenRazerControllers(rgb_controllers);
|
||||
/*-------------------------------------*\
|
||||
| Linux-only devices |
|
||||
\*-------------------------------------*/
|
||||
#else
|
||||
DetectOpenRazerControllers(rgb_controllers);
|
||||
DetectFaustusControllers(rgb_controllers);
|
||||
#endif
|
||||
|
||||
} /* DetectRGBControllers() */
|
||||
|
||||
+122
-16
@@ -11,22 +11,32 @@ INCLUDEPATH += \
|
||||
i2c_tools/ \
|
||||
net_port/ \
|
||||
serial_port/ \
|
||||
super_io/ \
|
||||
Controllers/AMDWraithPrismController/ \
|
||||
Controllers/AuraController/ \
|
||||
Controllers/CorsairController/ \
|
||||
Controllers/CorsairCmdrProController/ \
|
||||
Controllers/CorsairKeyboardController/ \
|
||||
Controllers/CorsairNodeProController/ \
|
||||
Controllers/CorsairProController/ \
|
||||
Controllers/CrucialController/ \
|
||||
Controllers/Hue2Controller/ \
|
||||
Controllers/HuePlusController/ \
|
||||
Controllers/HyperXController/ \
|
||||
Controllers/HyperXKeyboardController/ \
|
||||
Controllers/LEDStripController/ \
|
||||
Controllers/MSI3ZoneController/ \
|
||||
Controllers/PatriotViperController/ \
|
||||
Controllers/PolychromeController/ \
|
||||
Controllers/PoseidonZRGBController/ \
|
||||
Controllers/RGBFusionController/ \
|
||||
Controllers/RGBFusion2Controller/ \
|
||||
Controllers/RGBFusionGPUController/ \
|
||||
Controllers/ThermaltakeRiingController/ \
|
||||
RGBController/ \
|
||||
qt/
|
||||
|
||||
SOURCES += \
|
||||
RGBController/RGBController.cpp \
|
||||
dependencies/libe131/src/e131.c \
|
||||
main.cpp \
|
||||
OpenRGB.cpp \
|
||||
@@ -40,44 +50,75 @@ SOURCES += \
|
||||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
qt/hsv.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
super_io/super_io.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
|
||||
Controllers/AuraController/AuraController.cpp \
|
||||
Controllers/AuraController/AuraControllerDetect.cpp \
|
||||
Controllers/CorsairController/CorsairController.cpp \
|
||||
Controllers/CorsairController/CorsairControllerDetect.cpp \
|
||||
Controllers/CorsairCmdrProController/CorsairCmdrProController.cpp \
|
||||
Controllers/CorsairCmdrProController/CorsairCmdrProControllerDetect.cpp \
|
||||
Controllers/CorsairKeyboardController/CorsairKeyboardController.cpp \
|
||||
Controllers/CorsairKeyboardController/CorsairKeyboardControllerDetect.cpp \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProController.cpp \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp \
|
||||
Controllers/CorsairProController/CorsairProController.cpp \
|
||||
Controllers/CorsairProController/CorsairProControllerDetect.cpp \
|
||||
Controllers/CrucialController/CrucialController.cpp \
|
||||
Controllers/CrucialController/CrucialControllerDetect.cpp \
|
||||
Controllers/Hue2Controller/Hue2Controller.cpp \
|
||||
Controllers/Hue2Controller/Hue2ControllerDetect.cpp \
|
||||
Controllers/HuePlusController/HuePlusController.cpp \
|
||||
Controllers/HuePlusController/HuePlusControllerDetect.cpp \
|
||||
Controllers/HyperXController/HyperXController.cpp \
|
||||
Controllers/HyperXController/HyperXControllerDetect.cpp \
|
||||
Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp \
|
||||
Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp \
|
||||
Controllers/LEDStripController/LEDStripController.cpp \
|
||||
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
|
||||
Controllers/PatriotViperController/PatriotViperController.cpp \
|
||||
Controllers/PatriotViperController/PatriotViperControllerDetect.cpp \
|
||||
Controllers/PolychromeController/PolychromeController.cpp \
|
||||
Controllers/PolychromeController/PolychromeControllerDetect.cpp \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBController.cpp \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBControllerDetect.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionController.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
|
||||
Controllers/RGBFusion2Controller/RGBFusion2Controller.cpp \
|
||||
Controllers/RGBFusion2Controller/RGBFusion2ControllerDetect.cpp \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUController.cpp \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUControllerDetect.cpp \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
|
||||
RGBController/RGBController.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_AMDWraithPrism.cpp \
|
||||
RGBController/RGBController_Aura.cpp \
|
||||
RGBController/RGBController_Corsair.cpp \
|
||||
RGBController/RGBController_CorsairCmdrPro.cpp \
|
||||
RGBController/RGBController_CorsairKeyboard.cpp \
|
||||
RGBController/RGBController_CorsairNodePro.cpp \
|
||||
RGBController/RGBController_CorsairPro.cpp \
|
||||
RGBController/RGBController_Crucial.cpp \
|
||||
RGBController/RGBController_Hue2.cpp \
|
||||
RGBController/RGBController_HuePlus.cpp \
|
||||
RGBController/RGBController_HyperX.cpp \
|
||||
RGBController/RGBController_HyperXKeyboard.cpp \
|
||||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_MSI3Zone.cpp \
|
||||
RGBController/RGBController_PatriotViper.cpp \
|
||||
RGBController/RGBController_Polychrome.cpp \
|
||||
RGBController/RGBController_RGBFusion.cpp
|
||||
RGBController/RGBController_PoseidonZRGB.cpp \
|
||||
RGBController/RGBController_RGBFusion.cpp \
|
||||
RGBController/RGBController_RGBFusion2.cpp \
|
||||
RGBController/RGBController_RGBFusionGPU.cpp \
|
||||
RGBController/RGBController_ThermaltakeRiing.cpp \
|
||||
|
||||
HEADERS += \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
qt/OpenRGBDialog.h \
|
||||
@@ -88,29 +129,50 @@ HEADERS += \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
serial_port/find_usb_serial_port.h \
|
||||
serial_port/serial_port.h \
|
||||
super_io/super_io.h \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
|
||||
Controllers/AuraController/AuraController.h \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
Controllers/CorsairCmdrProController/CorsairCmdrProController.h \
|
||||
Controllers/CorsairKeyboardController/CorsairKeyboardController.h \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProController.h \
|
||||
Controllers/CorsairProController/CorsairProController.h \
|
||||
Controllers/CrucialController/CrucialController.h \
|
||||
Controllers/Hue2Controller/Hue2Controller.h \
|
||||
Controllers/HuePlusController/HuePlusController.h \
|
||||
Controllers/HyperXController/HyperXController.h \
|
||||
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
Controllers/PatriotViperController/PatriotViperController.h \
|
||||
Controllers/PolychromeController/PolychromeController.h \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
Controllers/RGBFusion2Controller/RGBFusion2Controller.h \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUController.h \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_AMDWraithPrism.h \
|
||||
RGBController/RGBController_Aura.h \
|
||||
RGBController/RGBController_Corsair.h \
|
||||
RGBController/RGBController_CorsairCmdrPro.h \
|
||||
RGBController/RGBController_CorsairNodePro.h \
|
||||
RGBController/RGBController_CorsairPro.h \
|
||||
RGBController/RGBController_Crucial.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
RGBController/RGBController_Hue2.h \
|
||||
RGBController/RGBController_HuePlus.h \
|
||||
RGBController/RGBController_HyperX.h \
|
||||
RGBController/RGBController_HyperXKeyboard.h \
|
||||
RGBController/RGBController_LEDStrip.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
RGBController/RGBController_PatriotViper.h \
|
||||
RGBController/RGBController_Polychrome.h \
|
||||
RGBController/RGBController_RGBFusion.h
|
||||
RGBController/RGBController_PoseidonZRGB.h \
|
||||
RGBController/RGBController_RGBFusion.h \
|
||||
RGBController/RGBController_RGBFusion2.h \
|
||||
RGBController/RGBController_RGBFusionGPU.h \
|
||||
RGBController/RGBController_ThermaltakeRiing.h \
|
||||
|
||||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
@@ -127,34 +189,48 @@ FORMS += \
|
||||
#-----------------------------------------------
|
||||
win32:INCLUDEPATH += \
|
||||
dependencies/inpout32_1501/Win32/ \
|
||||
dependencies/razer-chroma-2.9.0/inc \
|
||||
dependencies/libusb-1.0.22/include \
|
||||
dependencies/hidapi \
|
||||
dependencies/NVFC \
|
||||
dependencies/openrazer-win32 \
|
||||
wmi/ \
|
||||
|
||||
win32:SOURCES += \
|
||||
dependencies/NVFC/nvapi.cpp \
|
||||
i2c_smbus/i2c_smbus_i801.cpp \
|
||||
i2c_smbus/i2c_smbus_nct6775.cpp \
|
||||
i2c_smbus/i2c_smbus_nvapi.cpp \
|
||||
i2c_smbus/i2c_smbus_piix4.cpp \
|
||||
serial_port/find_usb_serial_port_win.cpp \
|
||||
wmi/wmi.cpp \
|
||||
RGBController/AorusGPUDetect.cpp \
|
||||
RGBController/RGBController_AorusGPU.cpp \
|
||||
RGBController/RazerChromaSDKDetect.cpp \
|
||||
RGBController/RGBController_RazerChromaSDK.cpp \
|
||||
RGBController/OpenRazerWindowsDetect.cpp \
|
||||
RGBController/RGBController_OpenRazerWindows.cpp \
|
||||
|
||||
win32:HEADERS += \
|
||||
dependencies/inpout32_1501/Win32/inpout32.h \
|
||||
dependencies/NVFC/nvapi.h \
|
||||
i2c_smbus/i2c_smbus_i801.h \
|
||||
i2c_smbus/i2c_smbus_nct6775.h \
|
||||
i2c_smbus/i2c_smbus_nvapi.h \
|
||||
i2c_smbus/i2c_smbus_piix4.h \
|
||||
wmi/wmi.h \
|
||||
RGBController/RGBController_AorusGPU.h \
|
||||
RGBController/RGBController_RazerChromaSDK.h \
|
||||
RGBController/RGBController_OpenRazerWindows.h \
|
||||
|
||||
win32:LIBS += \
|
||||
-lws2_32 \
|
||||
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
|
||||
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0
|
||||
win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
LIBS += \
|
||||
-lws2_32 \
|
||||
-L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \
|
||||
-L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \
|
||||
-L"$$PWD/dependencies/hidapi-win/x64/" -lhidapi
|
||||
}
|
||||
|
||||
win32:contains(QMAKE_TARGET.arch, x86) {
|
||||
LIBS += \
|
||||
-lws2_32 \
|
||||
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
|
||||
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
|
||||
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi
|
||||
}
|
||||
|
||||
win32:DEFINES -= \
|
||||
UNICODE
|
||||
@@ -166,6 +242,23 @@ win32:DEFINES += \
|
||||
_WINSOCK_DEPRECATED_NO_WARNINGS \
|
||||
WIN32_LEAN_AND_MEAN
|
||||
|
||||
# Copy OpenRazer.dll to output directory
|
||||
win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\dependencies\\openrazer-win32\\OpenRazer64.dll)\" \"$$shell_path($$OUT_PWD)\"
|
||||
first.depends = $(first) copydata
|
||||
export(first.depends)
|
||||
export(copydata.commands)
|
||||
QMAKE_EXTRA_TARGETS += first copydata
|
||||
}
|
||||
|
||||
win32:contains(QMAKE_TARGET.arch, x86) {
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\dependencies\\openrazer-win32\\OpenRazer.dll)\" \"$$shell_path($$OUT_PWD)\"
|
||||
first.depends = $(first) copydata
|
||||
export(first.depends)
|
||||
export(copydata.commands)
|
||||
QMAKE_EXTRA_TARGETS += first copydata
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# Linux specific project configuration
|
||||
#-----------------------------------------------
|
||||
@@ -173,12 +266,25 @@ unix:INCLUDEPATH += \
|
||||
|
||||
unix:HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
RGBController/RGBController_Faustus.h \
|
||||
|
||||
unix:LIBS += \
|
||||
-lusb-1.0
|
||||
-lusb-1.0 \
|
||||
|
||||
packagesExist(hidapi-libusb){
|
||||
unix:LIBS += -lhidapi-libusb
|
||||
} else {
|
||||
packagesExist(hidapi) {
|
||||
unix:LIBS += -lhidapi
|
||||
} else {
|
||||
unix:LIBS += -lhidapi-libusb
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unix:SOURCES += \
|
||||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
RGBController/OpenRazerDetect.cpp \
|
||||
RGBController/RGBController_Faustus.cpp \
|
||||
RGBController/RGBController_OpenRazer.cpp \
|
||||
|
||||
@@ -8,25 +8,7 @@ After getting a solid Aura implementation, the project branched out into other m
|
||||
|
||||
## Supported Devices
|
||||
|
||||
* Asus Aura (SMBus variants only)
|
||||
|
||||
* Gigabyte RGB Fusion 1.0
|
||||
|
||||
* Asus Aura RAM
|
||||
|
||||
* Corsair Vengeance RGB
|
||||
|
||||
* Corsair Vengeance Pro RGB
|
||||
|
||||
* HyperX Predator RGB
|
||||
|
||||
* NZXT Hue+
|
||||
|
||||
* KeyboardVisualizer Arduino LED Strips
|
||||
|
||||
* E1.31 (Linux only)
|
||||
|
||||
* OpenRazer (Linux only)
|
||||
See the [Project Wiki](https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/home) for the current list of supported devices.
|
||||
|
||||
## Installation
|
||||
#### Windows
|
||||
@@ -39,13 +21,21 @@ After getting a solid Aura implementation, the project branched out into other m
|
||||
**You must run the application as Administrator the first time to allow InpOut32 to set up. It can be run as a normal user afterwards**
|
||||
|
||||
#### Linux:
|
||||
1. Either open the project using QT Creator or build it using qmake. You will need the libusb-1.0-0 (or equivalent) development package from your distribution's package manager installed.
|
||||
1. Either open the project using QT Creator or build it using qmake. You will need the libusb-1.0-0 (or equivalent) and libhidapi development packages from your distribution's package manager installed.
|
||||
|
||||
git clone https://gitlab.com/CalcProgrammer1/OpenRGB
|
||||
cd OpenRGB
|
||||
git submodule update --init --recursive
|
||||
qmake OpenRGB.pro
|
||||
make
|
||||
* sudo apt install qt5-default libusb-1.0-0-dev libhidapi-dev
|
||||
|
||||
* git clone https://gitlab.com/CalcProgrammer1/OpenRGB
|
||||
|
||||
* cd OpenRGB
|
||||
|
||||
* git submodule update --init --recursive
|
||||
|
||||
* qmake OpenRGB.pro
|
||||
|
||||
* make -j8
|
||||
|
||||
* ./OpenRGB
|
||||
|
||||
|
||||
2. Allow access to SMBus:<br>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AorusGPU.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAorusGPUControllers *
|
||||
* *
|
||||
* Detect devices supported by the Aorus GPU driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
RGBController_AorusGPU * aorus_rgb = new RGBController_AorusGPU();
|
||||
|
||||
rgb_controllers.push_back(aorus_rgb);
|
||||
} /* DetectLEDStripControllers() */
|
||||
@@ -58,7 +58,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
break;
|
||||
|
||||
case 7:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerchromahdk/");
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razeraccessory/");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(device_string);
|
||||
|
||||
if(razer_rgb->device != -1)
|
||||
if(razer_rgb->device_index != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,387 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_OpenRazerWindows.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/hid.h>
|
||||
|
||||
#ifdef _WIN64
|
||||
#define OPENRAZERDLL "OpenRazer64.dll"
|
||||
#elif WIN32
|
||||
#define OPENRAZERDLL "OpenRazer.dll"
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectOpenRazerControllers *
|
||||
* *
|
||||
* Detect devices supported by the OpenRazer kernel drivers *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
static HMODULE module = LoadLibrary(OPENRAZERDLL);
|
||||
|
||||
if(module == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// map DLL calls
|
||||
typedef unsigned int(*INITRAZERDRIVER)(struct hid_device** hdev);
|
||||
|
||||
INITRAZERDRIVER init_razer_kbd_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kbd_driver"));
|
||||
static struct device_attribute devkbd_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_device_type"));
|
||||
static struct device_attribute devkbd_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_device_serial"));
|
||||
static struct device_attribute devkbd_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_firmware_version"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devkbd_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devkbd_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_brightness"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_none"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_static"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_mousemat_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mousemat_driver"));
|
||||
static struct device_attribute devmousemat_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_device_type"));
|
||||
static struct device_attribute devmousemat_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_device_serial"));
|
||||
static struct device_attribute devmousemat_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_firmware_version"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devmousemat_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devmousemat_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_brightness"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_none"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_static"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_mouse_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mouse_driver"));
|
||||
static struct device_attribute devmouse_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_device_type"));
|
||||
static struct device_attribute devmouse_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_device_serial"));
|
||||
static struct device_attribute devmouse_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_firmware_version"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devmouse_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devmouse_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_brightness"));
|
||||
static struct device_attribute devmouse_attr_logo_led_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_led_brightness"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_brightness"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_none"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_none"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_none"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_static"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_static"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_static"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_reactive"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_reactive"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_effect = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_effect"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_rgb = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_rgb"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_state = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_state"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_accessory_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_accessory_driver"));
|
||||
static struct device_attribute devaccessory_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_device_type"));
|
||||
static struct device_attribute devaccessory_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_device_serial"));
|
||||
static struct device_attribute devaccessory_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_firmware_version"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devaccessory_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devaccessory_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_brightness"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_none"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_static"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_spectrum"));
|
||||
//static struct device_attribute devaccessory_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_kraken_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kraken_driver"));
|
||||
static struct device_attribute devkraken_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_device_type"));
|
||||
static struct device_attribute devkraken_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_device_serial"));
|
||||
static struct device_attribute devkraken_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_firmware_version"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_custom"));
|
||||
//static struct device_attribute devkraken_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_custom_frame"));
|
||||
//static struct device_attribute devkraken_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_brightness"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_none"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_static"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_spectrum"));
|
||||
|
||||
INITRAZERDRIVER init_razer_core_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_core_driver"));
|
||||
static struct device_attribute devcore_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_device_type"));
|
||||
static struct device_attribute devcore_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_device_serial"));
|
||||
static struct device_attribute devcore_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_firmware_version"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devcore_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devcore_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_brightness"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_none"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_static"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_wave"));
|
||||
|
||||
struct hid_device* hdev;
|
||||
unsigned int num;
|
||||
|
||||
hdev = NULL;
|
||||
num = init_razer_kbd_driver(&hdev);
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devkbd_attr_device_type;
|
||||
device_fn->device_serial = &devkbd_attr_device_serial;
|
||||
device_fn->firmware_version = &devkbd_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devkbd_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devkbd_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devkbd_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devkbd_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devkbd_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devkbd_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devkbd_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devkbd_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devkbd_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
}
|
||||
|
||||
hdev = NULL;
|
||||
num = init_razer_mouse_driver(&hdev);
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devmouse_attr_device_type;
|
||||
device_fn->device_serial = &devmouse_attr_device_serial;
|
||||
device_fn->firmware_version = &devmouse_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devmouse_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devmouse_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devmouse_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devmouse_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devmouse_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devmouse_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devmouse_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devmouse_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devmouse_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
}
|
||||
|
||||
hdev = NULL;
|
||||
num = init_razer_mousemat_driver(&hdev);
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devmousemat_attr_device_type;
|
||||
device_fn->device_serial = &devmousemat_attr_device_serial;
|
||||
device_fn->firmware_version = &devmousemat_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devmousemat_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devmousemat_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devmousemat_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devmousemat_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devmousemat_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devmousemat_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devmousemat_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devmousemat_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devmousemat_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
}
|
||||
|
||||
hdev = NULL;
|
||||
num = init_razer_accessory_driver(&hdev);
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devaccessory_attr_device_type;
|
||||
device_fn->device_serial = &devaccessory_attr_device_serial;
|
||||
device_fn->firmware_version = &devaccessory_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devaccessory_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devaccessory_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devaccessory_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devaccessory_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devaccessory_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devaccessory_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devaccessory_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = NULL;//&devaccessory_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devaccessory_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
}
|
||||
|
||||
hdev = NULL;
|
||||
num = init_razer_kraken_driver(&hdev);
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devkraken_attr_device_type;
|
||||
device_fn->device_serial = &devkraken_attr_device_serial;
|
||||
device_fn->firmware_version = &devkraken_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devkraken_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = NULL;//&devkraken_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = NULL;//&devkraken_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devkraken_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devkraken_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devkraken_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devkraken_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = NULL;//&devkraken_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = NULL;//&devkraken_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
}
|
||||
|
||||
hdev = NULL;
|
||||
num = init_razer_core_driver(&hdev);
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devcore_attr_device_type;
|
||||
device_fn->device_serial = &devcore_attr_device_serial;
|
||||
device_fn->firmware_version = &devcore_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devcore_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devcore_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devcore_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devcore_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devcore_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devcore_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devcore_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devcore_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devcore_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectOpenRazerControllers() */
|
||||
@@ -44,3 +44,15 @@ void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
|
||||
UpdateZoneLEDs(zone);
|
||||
}
|
||||
|
||||
int RGBController::GetMode()
|
||||
{
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController::SetMode(int mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
|
||||
UpdateMode();
|
||||
}
|
||||
@@ -20,16 +20,73 @@ typedef unsigned int RGBColor;
|
||||
|
||||
#define ToRGBColor(r, g, b) ((b << 16) | (g << 8) | (r))
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Flags |
|
||||
\*------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
MODE_FLAG_HAS_SPEED = (1 << 0), /* Mode has speed parameter */
|
||||
MODE_FLAG_HAS_DIRECTION_LR = (1 << 1), /* Mode has left/right parameter */
|
||||
MODE_FLAG_HAS_DIRECTION_UD = (1 << 2), /* Mode has up/down parameter */
|
||||
MODE_FLAG_HAS_DIRECTION_HV = (1 << 3), /* Mode has horiz/vert parameter */
|
||||
MODE_FLAG_HAS_BRIGHTNESS = (1 << 4), /* Mode has brightness parameter */
|
||||
MODE_FLAG_HAS_PER_LED_COLOR = (1 << 5), /* Mode has per-LED colors */
|
||||
MODE_FLAG_HAS_MODE_SPECIFIC_COLOR = (1 << 6), /* Mode has mode specific colors */
|
||||
MODE_FLAG_HAS_RANDOM_COLOR = (1 << 7), /* Mode has random color option */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Directions |
|
||||
\*------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
MODE_DIRECTION_LEFT = 0, /* Mode direction left */
|
||||
MODE_DIRECTION_RIGHT = 1, /* Mode direction right */
|
||||
MODE_DIRECTION_UP = 2, /* Mode direction up */
|
||||
MODE_DIRECTION_DOWN = 3, /* Mode direction down */
|
||||
MODE_DIRECTION_HORIZONTAL = 4, /* Mode direction horizontal */
|
||||
MODE_DIRECTION_VERTICAL = 5, /* Mode direction vertical */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MODE_COLORS_NONE = 0, /* Mode has no colors */
|
||||
MODE_COLORS_PER_LED = 1, /* Mode has per LED colors selected */
|
||||
MODE_COLORS_MODE_SPECIFIC = 2, /* Mode specific colors selected */
|
||||
MODE_COLORS_RANDOM = 3, /* Mode has random colors selected */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Type |
|
||||
\*------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
/*--------------------------------------------------------------*\
|
||||
| Mode Information |
|
||||
\*--------------------------------------------------------------*/
|
||||
std::string name; /* Mode name */
|
||||
int value; /* Device-specific mode value */
|
||||
unsigned int flags; /* Mode flags bitfield */
|
||||
unsigned int speed_min; /* speed minimum value */
|
||||
unsigned int speed_max; /* speed maximum value */
|
||||
unsigned int colors_min; /* minimum number of mode colors*/
|
||||
unsigned int colors_max; /* maximum numver of mode colors*/
|
||||
|
||||
/*--------------------------------------------------------------*\
|
||||
| Mode Settings |
|
||||
\*--------------------------------------------------------------*/
|
||||
unsigned int speed; /* Mode speed parameter value */
|
||||
unsigned int direction; /* Mode direction value */
|
||||
unsigned int color_mode; /* Mode color selection */
|
||||
std::vector<RGBColor>
|
||||
colors; /* mode-specific colors */
|
||||
} mode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* LED name */
|
||||
} led;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* Mode name */
|
||||
} mode;
|
||||
|
||||
typedef int zone_type;
|
||||
|
||||
enum
|
||||
@@ -76,6 +133,7 @@ public:
|
||||
std::vector<mode> modes; /* Modes */
|
||||
std::vector<RGBColor> colors; /* Color buffer */
|
||||
device_type type; /* device type */
|
||||
int active_mode = 0;/* active mode */
|
||||
|
||||
virtual ~RGBController() = default;
|
||||
|
||||
@@ -87,13 +145,16 @@ public:
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Functions to be implemented in device implementation |
|
||||
\*---------------------------------------------------------*/
|
||||
virtual int GetMode() = 0;
|
||||
virtual void SetMode(int mode) = 0;
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void UpdateLEDs() = 0;
|
||||
virtual void UpdateZoneLEDs(int zone) = 0;
|
||||
virtual void UpdateSingleLED(int led) = 0;
|
||||
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void UpdateMode() = 0;
|
||||
};
|
||||
|
||||
@@ -17,9 +17,72 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
version = wraith->GetFirmwareVersionString();
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Breathing.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColorCycle.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
ColorCycle.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
ColorCycle.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Rainbow.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
Rainbow.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Bounce;
|
||||
Bounce.name = "Bounce";
|
||||
Bounce.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE;
|
||||
Bounce.flags = MODE_FLAG_HAS_SPEED;
|
||||
Bounce.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Bounce.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Bounce.color_mode = MODE_COLORS_NONE;
|
||||
Bounce.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Bounce);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Chase.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Chase.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Chase.color_mode = MODE_COLORS_PER_LED;
|
||||
Chase.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Chase);
|
||||
|
||||
mode Swirl;
|
||||
Swirl.name = "Swirl";
|
||||
Swirl.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL;
|
||||
Swirl.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Swirl.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Swirl.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Swirl.color_mode = MODE_COLORS_PER_LED;
|
||||
Swirl.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Swirl);
|
||||
|
||||
led logo_led;
|
||||
logo_led.name = "Logo";
|
||||
@@ -66,21 +129,6 @@ RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
|
||||
|
||||
}
|
||||
|
||||
int RGBController_AMDWraithPrism::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
@@ -124,3 +172,45 @@ void RGBController_AMDWraithPrism::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateMode()
|
||||
{
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
|
||||
wraith->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].direction, random);
|
||||
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE:
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW:
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE:
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, random);
|
||||
break;
|
||||
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING:
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, random);
|
||||
break;
|
||||
|
||||
default:
|
||||
if(random)
|
||||
{
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, random);
|
||||
}
|
||||
else
|
||||
{
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, random);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ class RGBController_AMDWraithPrism : public RGBController
|
||||
public:
|
||||
RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr);
|
||||
~RGBController_AMDWraithPrism();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AMDWraithPrismController* wraith;
|
||||
};
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AorusGPU.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Aorus GPU |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/17/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AorusGPU.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
static HMODULE handle;
|
||||
static unsigned char data[] = { 0x8E, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00,
|
||||
0x64, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
int RGBController_AorusGPU::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::UpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
data[9] = RGBGetRValue(color);
|
||||
data[10] = RGBGetGValue(color);
|
||||
data[11] = RGBGetBValue(color);
|
||||
|
||||
GvWriteI2C(0x00000000, data, 0x00000000);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
RGBController_AorusGPU::RGBController_AorusGPU()
|
||||
{
|
||||
name = "Aorus GPU";
|
||||
type = DEVICE_TYPE_GPU;
|
||||
|
||||
handle = LoadLibrary("GvDisplay.dll");
|
||||
|
||||
GvWriteI2C = (_GvWriteI2C)GetProcAddress(handle, "GvWriteI2C");
|
||||
GvFreeDispLib = (_GvFreeDispLib)GetProcAddress(handle, "GvFreeDispLib");
|
||||
GvInitDispLib = (_GvInitDispLib)GetProcAddress(handle, "GvInitDispLib");
|
||||
|
||||
GvFreeDispLib();
|
||||
GvInitDispLib();
|
||||
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
mode aorus_mode;
|
||||
aorus_mode.name = "Static";
|
||||
modes.push_back(aorus_mode);
|
||||
|
||||
led aorus_led;
|
||||
aorus_led.name = "GPU LED";
|
||||
leds.push_back(aorus_led);
|
||||
|
||||
zone aorus_zone;
|
||||
aorus_zone.name = "GPU LED";
|
||||
std::vector<int> aorus_zone_map;
|
||||
aorus_zone_map.push_back(0);
|
||||
aorus_zone.map.push_back(aorus_zone_map);
|
||||
zones.push_back(aorus_zone);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AorusGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Aorus GPU |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/17/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
|
||||
typedef unsigned int uint32;
|
||||
typedef uint32(*_GvWriteI2C)(uint32, void*, uint32);
|
||||
typedef void (*_GvFreeDispLib)();
|
||||
typedef void (*_GvInitDispLib)();
|
||||
|
||||
class RGBController_AorusGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AorusGPU();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
_GvWriteI2C GvWriteI2C;
|
||||
_GvFreeDispLib GvFreeDispLib;
|
||||
_GvInitDispLib GvInitDispLib;
|
||||
};
|
||||
@@ -9,34 +9,51 @@
|
||||
|
||||
#include "RGBController_Aura.h"
|
||||
|
||||
int RGBController_Aura::GetMode()
|
||||
int RGBController_Aura::GetDeviceMode()
|
||||
{
|
||||
int dev_mode = aura->AuraRegisterRead(AURA_REG_MODE);
|
||||
int color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
if (aura->AuraRegisterRead(AURA_REG_DIRECT))
|
||||
{
|
||||
return(0);
|
||||
dev_mode = 0xFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
return(aura->AuraRegisterRead(AURA_REG_MODE) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetMode(int mode)
|
||||
{
|
||||
if (mode == 0)
|
||||
switch(dev_mode)
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetMode(mode - 1);
|
||||
aura->SetDirect(false);
|
||||
}
|
||||
}
|
||||
case AURA_MODE_OFF:
|
||||
case AURA_MODE_RAINBOW:
|
||||
case AURA_MODE_SPECTRUM_CYCLE:
|
||||
case AURA_MODE_RANDOM_FLICKER:
|
||||
color_mode = MODE_COLORS_NONE;
|
||||
break;
|
||||
|
||||
void RGBController_Aura::SetCustomMode()
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE:
|
||||
dev_mode = AURA_MODE_CHASE;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_BREATHING:
|
||||
dev_mode = AURA_MODE_BREATHING;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE:
|
||||
dev_mode = AURA_MODE_CHASE_FADE;
|
||||
color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
}
|
||||
|
||||
for(int mode = 0; mode < modes.size(); mode++)
|
||||
{
|
||||
if(modes[mode].value == dev_mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
modes[mode].color_mode = color_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController_Aura::UpdateLEDs()
|
||||
@@ -118,28 +135,75 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
name = "ASUS Aura Motherboard";
|
||||
}
|
||||
|
||||
mode aura_modes[AURA_NUMBER_MODES + 1];
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
aura_modes[0].name = "Direct";
|
||||
aura_modes[1].name = "Off";
|
||||
aura_modes[2].name = "Static";
|
||||
aura_modes[3].name = "Breathing";
|
||||
aura_modes[4].name = "Flashing";
|
||||
aura_modes[5].name = "Spectrum Cycle";
|
||||
aura_modes[6].name = "Rainbow";
|
||||
aura_modes[7].name = "Spectrum Cycle Breathing";
|
||||
aura_modes[8].name = "Chase Fade";
|
||||
aura_modes[9].name = "Spectrum Cycle Chase Fade";
|
||||
aura_modes[10].name = "Chase";
|
||||
aura_modes[11].name = "Spectrum Cycle Chase";
|
||||
aura_modes[12].name = "Spectrum Cycle Wave";
|
||||
aura_modes[13].name = "Chase Rainbow Pulse";
|
||||
aura_modes[14].name = "Random Flicker";
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AURA_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
for (std::size_t i = 0; i < (AURA_NUMBER_MODES + 1); i++)
|
||||
{
|
||||
modes.push_back(aura_modes[i]);
|
||||
}
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AURA_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Flashing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AURA_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = 0;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AURA_MODE_RAINBOW;
|
||||
Rainbow.flags = 0;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode ChaseFade;
|
||||
ChaseFade.name = "Chase Fade";
|
||||
ChaseFade.value = AURA_MODE_CHASE_FADE;
|
||||
ChaseFade.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
ChaseFade.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(ChaseFade);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AURA_MODE_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Chase.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Chase);
|
||||
|
||||
mode RandomFlicker;
|
||||
RandomFlicker.name = "Random Flicker";
|
||||
RandomFlicker.value = AURA_MODE_RANDOM_FLICKER;
|
||||
RandomFlicker.flags = 0;
|
||||
RandomFlicker.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(RandomFlicker);
|
||||
|
||||
colors.resize(aura->GetLEDCount());
|
||||
|
||||
@@ -205,4 +269,43 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize active mode
|
||||
active_mode = GetDeviceMode();
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_Aura::UpdateMode()
|
||||
{
|
||||
if (modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int new_mode = modes[active_mode].value;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_RANDOM)
|
||||
{
|
||||
switch(new_mode)
|
||||
{
|
||||
case AURA_MODE_CHASE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE;
|
||||
break;
|
||||
case AURA_MODE_BREATHING:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_BREATHING;
|
||||
break;
|
||||
case AURA_MODE_CHASE_FADE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aura->SetMode(new_mode);
|
||||
aura->SetDirect(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,15 @@ class RGBController_Aura : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Aura(AuraController* aura_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AuraController* aura;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
|
||||
@@ -9,21 +9,6 @@
|
||||
|
||||
#include "RGBController_Corsair.h"
|
||||
|
||||
int RGBController_Corsair::GetMode()
|
||||
{
|
||||
return(CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetMode(int mode)
|
||||
{
|
||||
corsair->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
@@ -53,16 +38,26 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode corsair_modes[CORSAIR_NUMBER_MODES];
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_VENGEANCE_RGB_MODE_SINGLE;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
corsair_modes[0].name = "Static";
|
||||
corsair_modes[1].name = "Fade";
|
||||
corsair_modes[2].name = "Pulse";
|
||||
mode Fade;
|
||||
Fade.name = "Fade";
|
||||
Fade.value = CORSAIR_VENGEANCE_RGB_MODE_FADE;
|
||||
Fade.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Fade.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Fade);
|
||||
|
||||
for (int i = 0; i < CORSAIR_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
mode Pulse;
|
||||
Pulse.name = "Pulse";
|
||||
Pulse.value = CORSAIR_VENGEANCE_RGB_MODE_PULSE;
|
||||
Pulse.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Pulse.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Pulse);
|
||||
|
||||
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
@@ -90,3 +85,13 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateMode()
|
||||
{
|
||||
corsair->SetMode(modes[active_mode].value);
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ class RGBController_Corsair : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Corsair(CorsairController* corsair_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairController* corsair;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairCmdrPro.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Commander Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/16/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairCmdrPro.h"
|
||||
|
||||
|
||||
RGBController_CorsairCmdrPro::RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = "Corsair Commander Pro";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode RainbowWave;
|
||||
RainbowWave.name = "Rainbow Wave";
|
||||
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
|
||||
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
RainbowWave.direction = MODE_DIRECTION_RIGHT;
|
||||
RainbowWave.color_mode = MODE_COLORS_NONE;
|
||||
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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorShift.colors_min = 2;
|
||||
ColorShift.colors_max = 2;
|
||||
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorShift.colors.resize(2);
|
||||
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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorPulse.colors_min = 2;
|
||||
ColorPulse.colors_max = 2;
|
||||
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorPulse.colors.resize(2);
|
||||
modes.push_back(ColorPulse);
|
||||
|
||||
mode ColorWave;
|
||||
ColorWave.name = "Color Wave";
|
||||
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
|
||||
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorWave.colors_min = 2;
|
||||
ColorWave.colors_max = 2;
|
||||
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorWave.direction = MODE_DIRECTION_RIGHT;
|
||||
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorWave.colors.resize(2);
|
||||
modes.push_back(ColorWave);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Temperature;
|
||||
Temperature.name = "Temperature";
|
||||
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
|
||||
Temperature.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Temperature.colors_min = 3;
|
||||
Temperature.colors_max = 3;
|
||||
Temperature.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Temperature.colors.resize(3);
|
||||
modes.push_back(Temperature);
|
||||
|
||||
mode Visor;
|
||||
Visor.name = "Visor";
|
||||
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
|
||||
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Visor.colors_min = 2;
|
||||
Visor.colors_max = 2;
|
||||
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Visor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Visor.colors.resize(2);
|
||||
modes.push_back(Visor);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Marquee.colors_min = 1;
|
||||
Marquee.colors_max = 1;
|
||||
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Marquee.colors.resize(1);
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Blink.colors_min = 2;
|
||||
Blink.colors_max = 2;
|
||||
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Blink.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Blink.colors.resize(2);
|
||||
modes.push_back(Blink);
|
||||
|
||||
mode Sequential;
|
||||
Sequential.name = "Sequential";
|
||||
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
|
||||
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Sequential.colors_min = 1;
|
||||
Sequential.colors_max = 1;
|
||||
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Sequential.direction = MODE_DIRECTION_RIGHT;
|
||||
Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Sequential.colors.resize(1);
|
||||
modes.push_back(Sequential);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_count = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
led_count += corsair->channel_leds[channel_idx];
|
||||
}
|
||||
colors.resize(led_count);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_idx = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
if(corsair->channel_leds[channel_idx] > 0)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
new_zone->name = "Corsair Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Corsair Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
|
||||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx);
|
||||
|
||||
new_zone_map->push_back(led_idx);
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone->map.push_back(*new_zone_map);
|
||||
zones.push_back(*new_zone);
|
||||
zones_channel.push_back(channel_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds_channel[led];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
|
||||
{
|
||||
unsigned int direction = 0;
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_RIGHT)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
unsigned char mode_colors[9];
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
for(int i = 0; i < modes[active_mode].colors.size(); i++)
|
||||
{
|
||||
mode_colors[(3 * i) + 0] = RGBGetRValue(modes[active_mode].colors[i]);
|
||||
mode_colors[(3 * i) + 1] = RGBGetGValue(modes[active_mode].colors[i]);
|
||||
mode_colors[(3 * i) + 2] = RGBGetBValue(modes[active_mode].colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
corsair->SetChannelEffect(channel,
|
||||
modes[active_mode].value,
|
||||
modes[active_mode].speed,
|
||||
direction,
|
||||
random,
|
||||
mode_colors[0],
|
||||
mode_colors[1],
|
||||
mode_colors[2],
|
||||
mode_colors[3],
|
||||
mode_colors[4],
|
||||
mode_colors[5],
|
||||
mode_colors[6],
|
||||
mode_colors[7],
|
||||
mode_colors[8]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairCmdrPro.h |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Commander Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/16/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CorsairCmdrProController.h"
|
||||
|
||||
class RGBController_CorsairCmdrPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairCmdrProController* corsair;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
@@ -0,0 +1,209 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairKeyboard.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair RGB |
|
||||
| keyboards |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairKeyboard.h"
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
"Media Keys"
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104,
|
||||
7
|
||||
};
|
||||
|
||||
static const char* led_names[] =
|
||||
{
|
||||
"Key: Escape", //0
|
||||
"Key: `", //1
|
||||
"Key: Tab", //2
|
||||
"Key: Caps Lock", //3
|
||||
"Key: Left Shift", //4
|
||||
"Key: Left Control", //5
|
||||
"Key: F12", //6
|
||||
"Key: =", //7
|
||||
"Key: Lock", //8
|
||||
"Key: Number Pad 7", //9
|
||||
"Key: F1", //12
|
||||
"Key: 1", //13
|
||||
"Key: Q", //14
|
||||
"Key: A", //15
|
||||
"Key: Left Windows", //17
|
||||
"Key: Print Screen", //18
|
||||
"Media Mute", //20
|
||||
"Key: Number Pad 8", //21
|
||||
"Key: F2", //24
|
||||
"Key: 2", //25
|
||||
"Key: W", //26
|
||||
"Key: S", //27
|
||||
"Key: Z", //28
|
||||
"Key: Left Alt", //29
|
||||
"Key: Scroll Lock", //30
|
||||
"Key: Backspace", //31
|
||||
"Media Stop", //32
|
||||
"Key: Number Pad 9", //33
|
||||
"Key: F3", //36
|
||||
"Key: 3", //37
|
||||
"Key: E", //38
|
||||
"Key: D", //39
|
||||
"Key: X", //40
|
||||
"Key: Pause/Break", //42
|
||||
"Key: Delete", //43
|
||||
"Media Previous", //44
|
||||
"Key: F4", //48
|
||||
"Key: 4", //49
|
||||
"Key: R", //50
|
||||
"Key: F", //51
|
||||
"Key: C", //52
|
||||
"Key: Space", //53
|
||||
"Key: Insert", //54
|
||||
"Key: End", //55
|
||||
"Media Play/Pause", //56
|
||||
"Key: Number Pad 4", //57
|
||||
"Key: F5", //60
|
||||
"Key: 5", //61
|
||||
"Key: T", //62
|
||||
"Key: G", //63
|
||||
"Key: V", //64
|
||||
"Key: Home", //66
|
||||
"Key: Page Down", //67
|
||||
"Media Next", //68
|
||||
"Key: Number Pad 5", //69
|
||||
"Key: F6", //72
|
||||
"Key: 6", //73
|
||||
"Key: Y", //74
|
||||
"Key: H", //75
|
||||
"Key: B", //76
|
||||
"Key: Page Up", //78
|
||||
"Key: Right Shift", //79
|
||||
"Key: Num Lock", //80
|
||||
"Key: Number Pad 6", //81
|
||||
"Key: F7", //84
|
||||
"Key: 7", //85
|
||||
"Key: U", //86
|
||||
"Key: J", //87
|
||||
"Key: N", //88
|
||||
"Key: Right Alt", //89
|
||||
"Key: ]", //90
|
||||
"Key: Right Control", //91
|
||||
"Key: Number Pad /", //92
|
||||
"Key: Number Pad 1", //93
|
||||
"Key: F8", //96
|
||||
"Key: 8", //97
|
||||
"Key: I", //98
|
||||
"Key: K", //99
|
||||
"Key: M", //100
|
||||
"Key: Right Windows", //101
|
||||
"Key: \\", //102
|
||||
"Key: Up Arrow", //103
|
||||
"Key: Number Pad *", //104
|
||||
"Key: Number Pad 2", //105
|
||||
"Key: F9", //108
|
||||
"Key: 9", //109
|
||||
"Key: O", //110
|
||||
"Key: L", //111
|
||||
"Key: ,", //112
|
||||
"Key: Context", //113
|
||||
"Key: Left Arrow", //115
|
||||
"Key: Number Pad -", //116
|
||||
"Key: Number Pad 3", //117
|
||||
"Key: F10", //120
|
||||
"Key: 0", //121
|
||||
"Key: P", //122
|
||||
"Key: ;", //123
|
||||
"Key: .", //124
|
||||
"Key: Enter", //126
|
||||
"Key: Down Arrow", //127
|
||||
"Key: Number Pad +", //128
|
||||
"Key: Number Pad 0", //129
|
||||
"Key: F11", //132
|
||||
"Key: -", //133
|
||||
"Key: [", //134
|
||||
"Key: '", //135
|
||||
"Key: /", //136
|
||||
"Key: Brightness", //137
|
||||
"Key: Right Arrow", //139
|
||||
"Key: Number Pad Enter",//140
|
||||
"Key: Number Pad .", //141
|
||||
"Key: F12"
|
||||
};
|
||||
|
||||
RGBController_CorsairKeyboard::RGBController_CorsairKeyboard(CorsairKeyboardController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = "Corsair RGB Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
colors.resize(111);
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 2; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name.append(zone_names[zone_idx]);
|
||||
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for(unsigned int led_count = 0; led_count < zone_sizes[zone_idx]; led_count++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name.append(led_names[led_idx]);
|
||||
leds.push_back(new_led);
|
||||
|
||||
new_zone_map.push_back(led_idx);
|
||||
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone.map.push_back(new_zone_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_CorsairKeyboard::~RGBController_CorsairKeyboard()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CorsairKeyboard::UpdateLEDs()
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairKeyboard::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairKeyboard::UpdateSingleLED(int led)
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairKeyboard::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairKeyboard::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairKeyboard.h |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair RGB |
|
||||
| keyboards |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CorsairKeyboardController.h"
|
||||
|
||||
class RGBController_CorsairKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairKeyboard(CorsairKeyboardController* corsair_ptr);
|
||||
~RGBController_CorsairKeyboard();
|
||||
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairKeyboardController* corsair;
|
||||
};
|
||||
@@ -0,0 +1,331 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairNodePro.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Lighting Node Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairNodePro.h"
|
||||
|
||||
|
||||
RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = "Corsair Lighting Node Pro";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode RainbowWave;
|
||||
RainbowWave.name = "Rainbow Wave";
|
||||
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
|
||||
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
RainbowWave.direction = MODE_DIRECTION_RIGHT;
|
||||
RainbowWave.color_mode = MODE_COLORS_NONE;
|
||||
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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorShift.colors_min = 2;
|
||||
ColorShift.colors_max = 2;
|
||||
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorShift.colors.resize(2);
|
||||
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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorPulse.colors_min = 2;
|
||||
ColorPulse.colors_max = 2;
|
||||
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorPulse.colors.resize(2);
|
||||
modes.push_back(ColorPulse);
|
||||
|
||||
mode ColorWave;
|
||||
ColorWave.name = "Color Wave";
|
||||
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
|
||||
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorWave.colors_min = 2;
|
||||
ColorWave.colors_max = 2;
|
||||
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorWave.direction = MODE_DIRECTION_RIGHT;
|
||||
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorWave.colors.resize(2);
|
||||
modes.push_back(ColorWave);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Temperature;
|
||||
Temperature.name = "Temperature";
|
||||
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
|
||||
Temperature.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Temperature.colors_min = 3;
|
||||
Temperature.colors_max = 3;
|
||||
Temperature.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Temperature.colors.resize(3);
|
||||
modes.push_back(Temperature);
|
||||
|
||||
mode Visor;
|
||||
Visor.name = "Visor";
|
||||
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
|
||||
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Visor.colors_min = 2;
|
||||
Visor.colors_max = 2;
|
||||
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Visor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Visor.colors.resize(2);
|
||||
modes.push_back(Visor);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Marquee.colors_min = 1;
|
||||
Marquee.colors_max = 1;
|
||||
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Marquee.colors.resize(1);
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Blink.colors_min = 2;
|
||||
Blink.colors_max = 2;
|
||||
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Blink.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Blink.colors.resize(2);
|
||||
modes.push_back(Blink);
|
||||
|
||||
mode Sequential;
|
||||
Sequential.name = "Sequential";
|
||||
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
|
||||
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Sequential.colors_min = 1;
|
||||
Sequential.colors_max = 1;
|
||||
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Sequential.direction = MODE_DIRECTION_RIGHT;
|
||||
Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Sequential.colors.resize(1);
|
||||
modes.push_back(Sequential);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_count = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_NODE_PRO_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
led_count += corsair->channel_leds[channel_idx];
|
||||
}
|
||||
colors.resize(led_count);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_idx = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_NODE_PRO_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
if(corsair->channel_leds[channel_idx] > 0)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
new_zone->name = "Corsair Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Corsair Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
|
||||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx);
|
||||
|
||||
new_zone_map->push_back(led_idx);
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone->map.push_back(*new_zone_map);
|
||||
zones.push_back(*new_zone);
|
||||
zones_channel.push_back(channel_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds_channel[led];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
|
||||
{
|
||||
unsigned int direction = 0;
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_RIGHT)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
unsigned char mode_colors[9];
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
for(int i = 0; i < modes[active_mode].colors.size(); i++)
|
||||
{
|
||||
mode_colors[(3 * i) + 0] = RGBGetRValue(modes[active_mode].colors[i]);
|
||||
mode_colors[(3 * i) + 1] = RGBGetGValue(modes[active_mode].colors[i]);
|
||||
mode_colors[(3 * i) + 2] = RGBGetBValue(modes[active_mode].colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
corsair->SetChannelEffect(channel,
|
||||
modes[active_mode].value,
|
||||
modes[active_mode].speed,
|
||||
direction,
|
||||
random,
|
||||
mode_colors[0],
|
||||
mode_colors[1],
|
||||
mode_colors[2],
|
||||
mode_colors[3],
|
||||
mode_colors[4],
|
||||
mode_colors[5],
|
||||
mode_colors[6],
|
||||
mode_colors[7],
|
||||
mode_colors[8]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairNodePro.h |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Lighting Node Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CorsairNodeProController.h"
|
||||
|
||||
class RGBController_CorsairNodePro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairNodePro(CorsairNodeProController* corsair_ptr);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairNodeProController* corsair;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
@@ -9,53 +9,6 @@
|
||||
|
||||
#include "RGBController_CorsairPro.h"
|
||||
|
||||
int RGBController_CorsairPro::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetMode(int mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_SHIFT);
|
||||
break;
|
||||
case 1:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_PULSE);
|
||||
break;
|
||||
case 2:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAINBOW_WAVE);
|
||||
break;
|
||||
case 3:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_WAVE);
|
||||
break;
|
||||
case 4:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_VISOR);
|
||||
break;
|
||||
case 5:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAIN);
|
||||
break;
|
||||
case 6:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_MARQUEE);
|
||||
break;
|
||||
case 7:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAINBOW);
|
||||
break;
|
||||
case 8:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_SEQUENTIAL);
|
||||
break;
|
||||
case 9:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_STATIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetCustomMode()
|
||||
{
|
||||
corsair->SetCustom();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::UpdateLEDs()
|
||||
{
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
@@ -95,23 +48,133 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode corsair_modes[CORSAIR_PRO_NUMBER_MODES];
|
||||
mode ColorShift;
|
||||
ColorShift.name = "Color Shift";
|
||||
ColorShift.value = CORSAIR_PRO_MODE_COLOR_SHIFT;
|
||||
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorShift.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorShift.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
ColorShift.colors_min = 2;
|
||||
ColorShift.colors_max = 2;
|
||||
ColorShift.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorShift.colors.resize(2);
|
||||
modes.push_back(ColorShift);
|
||||
|
||||
corsair_modes[0].name = "Color Shift";
|
||||
corsair_modes[1].name = "Color Pulse";
|
||||
corsair_modes[2].name = "Rainbow Wave";
|
||||
corsair_modes[3].name = "Color Wave";
|
||||
corsair_modes[4].name = "Visor";
|
||||
corsair_modes[5].name = "Rain";
|
||||
corsair_modes[6].name = "Marquee";
|
||||
corsair_modes[7].name = "Rainbow";
|
||||
corsair_modes[8].name = "Sequential";
|
||||
corsair_modes[9].name = "Static";
|
||||
mode ColorPulse;
|
||||
ColorPulse.name = "Color Pulse";
|
||||
ColorPulse.value = CORSAIR_PRO_MODE_COLOR_PULSE;
|
||||
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorPulse.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorPulse.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
ColorPulse.colors_min = 2;
|
||||
ColorPulse.colors_max = 2;
|
||||
ColorPulse.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorPulse.colors.resize(2);
|
||||
modes.push_back(ColorPulse);
|
||||
|
||||
for (int i = 0; i < CORSAIR_PRO_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
mode RainbowWave;
|
||||
RainbowWave.name = "Rainbow Wave";
|
||||
RainbowWave.value = CORSAIR_PRO_MODE_RAINBOW_WAVE;
|
||||
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD;
|
||||
RainbowWave.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
RainbowWave.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
RainbowWave.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
RainbowWave.direction = MODE_DIRECTION_DOWN;
|
||||
RainbowWave.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(RainbowWave);
|
||||
|
||||
mode ColorWave;
|
||||
ColorWave.name = "Color Wave";
|
||||
ColorWave.value = CORSAIR_PRO_MODE_COLOR_WAVE;
|
||||
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorWave.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorWave.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
ColorWave.colors_min = 2;
|
||||
ColorWave.colors_max = 2;
|
||||
ColorWave.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorWave.direction = MODE_DIRECTION_DOWN;
|
||||
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorWave.colors.resize(2);
|
||||
modes.push_back(ColorWave);
|
||||
|
||||
mode Visor;
|
||||
Visor.name = "Visor";
|
||||
Visor.value = CORSAIR_PRO_MODE_VISOR;
|
||||
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_HV | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Visor.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Visor.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Visor.colors_min = 2;
|
||||
Visor.colors_max = 2;
|
||||
Visor.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Visor.direction = MODE_DIRECTION_VERTICAL;
|
||||
Visor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Visor.colors.resize(2);
|
||||
modes.push_back(Visor);
|
||||
|
||||
mode Rain;
|
||||
Rain.name = "Rain";
|
||||
Rain.value = CORSAIR_PRO_MODE_RAIN;
|
||||
Rain.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Rain.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Rain.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Rain.colors_min = 2;
|
||||
Rain.colors_max = 2;
|
||||
Rain.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Rain.direction = MODE_DIRECTION_DOWN;
|
||||
Rain.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Rain.colors.resize(2);
|
||||
modes.push_back(Rain);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = CORSAIR_PRO_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Marquee.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Marquee.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Marquee.colors_min = 1;
|
||||
Marquee.colors_max = 1;
|
||||
Marquee.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Marquee.colors.resize(1);
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CORSAIR_PRO_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Rainbow.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Rainbow.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Sequential;
|
||||
Sequential.name = "Sequential";
|
||||
Sequential.value = CORSAIR_PRO_MODE_SEQUENTIAL;
|
||||
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Sequential.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Sequential.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Sequential.colors_min = 1;
|
||||
Sequential.colors_max = 1;
|
||||
Sequential.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Sequential.direction = MODE_DIRECTION_DOWN;
|
||||
Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Sequential.colors.resize(1);
|
||||
modes.push_back(Sequential);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_PRO_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.speed_min = 0;
|
||||
Static.speed_max = 0;
|
||||
Static.speed = 0;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
active_mode = 9;
|
||||
|
||||
colors.resize(corsair->GetLEDCount());
|
||||
|
||||
@@ -140,3 +203,62 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetCustomMode()
|
||||
{
|
||||
active_mode = 9;
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::UpdateMode()
|
||||
{
|
||||
unsigned int corsair_direction;
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
unsigned char mode_colors[6];
|
||||
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_LEFT;
|
||||
break;
|
||||
case MODE_DIRECTION_RIGHT:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_RIGHT;
|
||||
break;
|
||||
case MODE_DIRECTION_UP:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_UP;
|
||||
break;
|
||||
case MODE_DIRECTION_DOWN:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_DOWN;
|
||||
break;
|
||||
case MODE_DIRECTION_HORIZONTAL:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_HORIZONTAL;
|
||||
break;
|
||||
case MODE_DIRECTION_VERTICAL:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_VERTICAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
mode_colors[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
mode_colors[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
mode_colors[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(modes[active_mode].colors.size() == 2)
|
||||
{
|
||||
mode_colors[3] = RGBGetRValue(modes[active_mode].colors[1]);
|
||||
mode_colors[4] = RGBGetGValue(modes[active_mode].colors[1]);
|
||||
mode_colors[5] = RGBGetBValue(modes[active_mode].colors[1]);
|
||||
}
|
||||
}
|
||||
|
||||
corsair->SetEffect(modes[active_mode].value,
|
||||
modes[active_mode].speed,
|
||||
corsair_direction,
|
||||
random,
|
||||
mode_colors[0],
|
||||
mode_colors[1],
|
||||
mode_colors[2],
|
||||
mode_colors[3],
|
||||
mode_colors[4],
|
||||
mode_colors[5]);
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ class RGBController_CorsairPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairPro(CorsairProController* corsair_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairProController* corsair;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Crucial.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Crucial |
|
||||
| Ballistix RGB controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Crucial.h"
|
||||
|
||||
void RGBController_Crucial::UpdateLEDs()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
crucial->SetAllColorsDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
|
||||
{
|
||||
crucial = crucial_ptr;
|
||||
|
||||
location = crucial->GetDeviceLocation();
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = "Crucial DRAM";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
#if 0
|
||||
mode Shift;
|
||||
Shift.name = "Shift";
|
||||
Shift.value = CRUCIAL_MODE_SHIFT;
|
||||
Shift.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Shift.colors_min = 1;
|
||||
Shift.colors_max = 1;
|
||||
Shift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Shift.colors.resize(1);
|
||||
modes.push_back(Shift);
|
||||
|
||||
mode GradientShift;
|
||||
GradientShift.name = "Gradient Shift";
|
||||
GradientShift.value = CRUCIAL_MODE_GRADIENT_SHIFT;
|
||||
GradientShift.flags = 0;
|
||||
GradientShift.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(GradientShift);
|
||||
|
||||
mode Fill;
|
||||
Fill.name = "Fill";
|
||||
Fill.value = CRUCIAL_MODE_FILL;
|
||||
Fill.flags = 0;
|
||||
Fill.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Fill);
|
||||
|
||||
mode Stack;
|
||||
Stack.name = "Stack";
|
||||
Stack.value = CRUCIAL_MODE_STACK;
|
||||
Stack.flags = 0;
|
||||
Stack.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode DoubleStack;
|
||||
DoubleStack.name = "Double Stack";
|
||||
DoubleStack.value = CRUCIAL_MODE_DOUBLE_STACK;
|
||||
DoubleStack.flags = 0;
|
||||
modes.push_back(DoubleStack);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CRUCIAL_MODE_BREATHING;
|
||||
Breathing.flags = 0;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode MotionPoint;
|
||||
MotionPoint.name = "Motion Point";
|
||||
MotionPoint.value = CRUCIAL_MODE_MOTION_POINT;
|
||||
MotionPoint.flags = 0;
|
||||
modes.push_back(MotionPoint);
|
||||
|
||||
mode InsideOut;
|
||||
InsideOut.name = "Inside Out";
|
||||
InsideOut.value = CRUCIAL_MODE_INSIDE_OUT;
|
||||
InsideOut.flags = 0;
|
||||
modes.push_back(InsideOut);
|
||||
|
||||
mode ColorStep;
|
||||
ColorStep.name = "Color Step";
|
||||
ColorStep.value = CRUCIAL_MODE_COLOR_STEP;
|
||||
ColorStep.flags = 0;
|
||||
modes.push_back(ColorStep);
|
||||
|
||||
mode WaterWave;
|
||||
WaterWave.name = "Water Wave (Color Blending)";
|
||||
WaterWave.value = CRUCIAL_MODE_WATER_WAVE;
|
||||
WaterWave.flags = 0;
|
||||
modes.push_back(WaterWave);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = CRUCIAL_MODE_FLASHING;
|
||||
Flashing.flags = 0;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CRUCIAL_MODE_STATIC;
|
||||
Static.flags = 0;
|
||||
modes.push_back(Static);
|
||||
#endif
|
||||
|
||||
zone new_zone;
|
||||
new_zone.name = "DRAM";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for(int led_idx = 0; led_idx < 8; led_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "DRAM LED";
|
||||
|
||||
leds.push_back(new_led);
|
||||
new_zone_map.push_back(led_idx);
|
||||
}
|
||||
|
||||
new_zone.map.push_back(new_zone_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
|
||||
void RGBController_Crucial::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateMode()
|
||||
{
|
||||
crucial->SetMode(modes[active_mode].value);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Crucial.h |
|
||||
| |
|
||||
| Generic RGB Interface for Crucial |
|
||||
| Ballistix RGB controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CrucialController.h"
|
||||
|
||||
class RGBController_Crucial : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Crucial(CrucialController* crucial_ptr);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CrucialController* crucial;
|
||||
};
|
||||
@@ -18,22 +18,33 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
devices = device_list;
|
||||
|
||||
unsigned int led_zone_idx = 0;
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
sockfd = e131_socket();
|
||||
|
||||
colors.resize(0);
|
||||
|
||||
for (std::size_t i = 0; i < devices.size(); i++)
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| Add LEDs |
|
||||
\*-----------------------------------------*/
|
||||
colors.resize(colors.size() + devices[i].num_leds);
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
char id_buf[16];
|
||||
snprintf(id_buf, 16, "%d", led_idx);
|
||||
|
||||
led new_led;
|
||||
new_led.name = devices[i].name + " LED";
|
||||
new_led.name = devices[i].name + " LED ";
|
||||
new_led.name.append(id_buf);
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
@@ -86,21 +97,6 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_E131::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_E131::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateLEDs()
|
||||
{
|
||||
int color_idx = 0;
|
||||
@@ -171,3 +167,13 @@ void RGBController_E131::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -37,13 +37,13 @@ class RGBController_E131 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_E131(std::vector<E131Device> device_list);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
std::vector<E131Device> devices;
|
||||
std::vector<e131_packet_t> packets;
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
#include "RGBController_Faustus.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
RGBController_Faustus::RGBController_Faustus(const std::string& dev_path)
|
||||
{
|
||||
name = "Faustus";
|
||||
description = "ASUS TUF Keyboard Backlight";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
|
||||
modes.resize(4);
|
||||
modes[0].name = "Static";
|
||||
modes[0].value = FAUSTUS_MODE_STATIC;
|
||||
modes[0].flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes[0].color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
modes[1].name = "Breathing";
|
||||
modes[1].value = FAUSTUS_MODE_BREATHING;
|
||||
modes[1].flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes[1].speed_min = FAUSTUS_SPEED_SLOWEST;
|
||||
modes[1].speed_max = FAUSTUS_SPEED_FASTEST;
|
||||
modes[1].color_mode = MODE_COLORS_PER_LED;
|
||||
modes[1].speed = FAUSTUS_SPEED_NORMAL;
|
||||
|
||||
modes[2].name = "Color Cycle";
|
||||
modes[2].value = FAUSTUS_MODE_COLOR_CYCLE;
|
||||
modes[2].flags = MODE_FLAG_HAS_SPEED;
|
||||
modes[2].speed_min = FAUSTUS_SPEED_SLOWEST;
|
||||
modes[2].speed_max = FAUSTUS_SPEED_FASTEST;
|
||||
modes[2].color_mode = MODE_COLORS_NONE;
|
||||
modes[2].speed = FAUSTUS_SPEED_NORMAL;
|
||||
|
||||
modes[3].name = "Strobe";
|
||||
modes[3].value = FAUSTUS_MODE_STROBE;
|
||||
modes[3].flags = MODE_FLAG_HAS_SPEED;
|
||||
modes[3].speed_min = FAUSTUS_SPEED_SLOWEST;
|
||||
modes[3].speed_max = FAUSTUS_SPEED_FASTEST;
|
||||
modes[3].color_mode = MODE_COLORS_NONE;
|
||||
modes[3].speed = FAUSTUS_SPEED_NORMAL;
|
||||
|
||||
colors.resize(1);
|
||||
leds.resize(1);
|
||||
leds[0].name = "Keyboard backlight LED";
|
||||
zones.resize(1);
|
||||
zones[0].type = ZONE_TYPE_SINGLE;
|
||||
zones[0].name = "Keyboard backlight zone";
|
||||
zones[0].map.push_back(std::vector<int>(1, 0));
|
||||
|
||||
// Prepare file streams
|
||||
r_path = dev_path;
|
||||
g_path = dev_path;
|
||||
b_path = dev_path;
|
||||
mode_path = dev_path;
|
||||
flags_path = dev_path;
|
||||
set_path = dev_path;
|
||||
|
||||
r_path.append("/kbbl_red");
|
||||
g_path.append("/kbbl_green");
|
||||
b_path.append("/kbbl_blue");
|
||||
mode_path.append("/kbbl_mode");
|
||||
flags_path.append("/kbbl_flags");
|
||||
set_path.append("/kbbl_set");
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateLEDs()
|
||||
{
|
||||
int rv = uint8_t(RGBGetRValue(colors[0]));
|
||||
int gv = uint8_t(RGBGetGValue(colors[0]));
|
||||
int bv = uint8_t(RGBGetBValue(colors[0]));
|
||||
|
||||
std::ofstream str_r;
|
||||
std::ofstream str_g;
|
||||
std::ofstream str_b;
|
||||
std::ofstream str_mode;
|
||||
std::ofstream str_flags;
|
||||
std::ofstream str_set;
|
||||
|
||||
str_r.open(r_path, std::ios::out | std::ios::trunc);
|
||||
str_g.open(g_path, std::ios::out | std::ios::trunc);
|
||||
str_b.open(b_path, std::ios::out | std::ios::trunc);
|
||||
str_mode.open(mode_path, std::ios::out | std::ios::trunc);
|
||||
str_flags.open(flags_path, std::ios::out | std::ios::trunc);
|
||||
str_set.open(set_path, std::ios::out | std::ios::trunc);
|
||||
|
||||
str_r << std::hex;
|
||||
str_g << std::hex;
|
||||
str_b << std::hex;
|
||||
str_mode << std::hex;
|
||||
str_flags << std::hex;
|
||||
str_set << std::hex;
|
||||
|
||||
str_r << rv;
|
||||
str_g << gv;
|
||||
str_b << bv;
|
||||
str_mode << active_mode;
|
||||
str_flags << 0x2a; // All of em
|
||||
str_set << 2;
|
||||
|
||||
// Flush everything
|
||||
str_r.close();
|
||||
str_g.close();
|
||||
str_b.close();
|
||||
str_mode.close();
|
||||
str_flags.close();
|
||||
str_set.close();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateMode()
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
const char* base_path = "/sys/devices/platform/faustus/kbbl";
|
||||
DIR* dir = opendir(base_path);
|
||||
if(!dir) return;
|
||||
// Directory is present - we pretty much have a driver confirmation already, but double check for all files required just in case
|
||||
struct dirent* dent = readdir(dir);
|
||||
if(!dent) return;
|
||||
int found = 0;
|
||||
while(dent)
|
||||
{
|
||||
const char* fname = dent->d_name;
|
||||
if(!strcmp(fname, "kbbl_red") || !strcmp(fname, "kbbl_green") || !strcmp(fname, "kbbl_blue") || !strcmp(fname, "kbbl_mode") || !strcmp(fname, "kbbl_flags") || !strcmp(fname, "kbbl_set"))
|
||||
{
|
||||
++found;
|
||||
}
|
||||
dent = readdir(dir);
|
||||
}
|
||||
closedir(dir);
|
||||
if(found != 6) return;
|
||||
rgb_controllers.push_back(new RGBController_Faustus(base_path));
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef RGBCONTROLLER_FAUSTUS_H
|
||||
#define RGBCONTROLLER_FAUSTUS_H
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <fstream>
|
||||
|
||||
enum
|
||||
{
|
||||
FAUSTUS_MODE_STATIC = 0,
|
||||
FAUSTUS_MODE_BREATHING = 1,
|
||||
FAUSTUS_MODE_COLOR_CYCLE = 2,
|
||||
FAUSTUS_MODE_STROBE = 3
|
||||
};
|
||||
enum
|
||||
{
|
||||
FAUSTUS_SPEED_SLOWEST = 0,
|
||||
FAUSTUS_SPEED_NORMAL = 1,
|
||||
FAUSTUS_SPEED_FASTEST = 2,
|
||||
};
|
||||
|
||||
class RGBController_Faustus : public RGBController
|
||||
{
|
||||
private:
|
||||
std::string r_path;
|
||||
std::string g_path;
|
||||
std::string b_path;
|
||||
std::string mode_path;
|
||||
std::string flags_path;
|
||||
std::string set_path;
|
||||
|
||||
public:
|
||||
RGBController_Faustus(const std::string& dev_path);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
};
|
||||
|
||||
#endif // RGBCONTROLLER_FAUSTUS_H
|
||||
@@ -17,9 +17,104 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HUE_2_MODE_FIXED;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Fading;
|
||||
Fading.name = "Fading";
|
||||
Fading.value = HUE_2_MODE_FADING;
|
||||
Fading.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Fading.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Fading.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Fading.colors_min = 1;
|
||||
Fading.colors_max = 8;
|
||||
Fading.speed = HUE_2_SPEED_NORMAL;
|
||||
Fading.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Fading.colors.resize(1);
|
||||
modes.push_back(Fading);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = HUE_2_MODE_SPECTRUM;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
SpectrumCycle.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = HUE_2_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = HUE_2_SPEED_NORMAL;
|
||||
SpectrumCycle.direction = MODE_DIRECTION_RIGHT;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = HUE_2_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Marquee.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Marquee.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Marquee.colors_min = 1;
|
||||
Marquee.colors_max = 1;
|
||||
Marquee.speed = HUE_2_SPEED_NORMAL;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Marquee.colors.resize(1);
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode CoverMarquee;
|
||||
CoverMarquee.name = "Cover Marquee";
|
||||
CoverMarquee.value = HUE_2_MODE_COVER_MARQUEE;
|
||||
CoverMarquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
CoverMarquee.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
CoverMarquee.speed_max = HUE_2_SPEED_FASTEST;
|
||||
CoverMarquee.colors_min = 1;
|
||||
CoverMarquee.colors_max = 8;
|
||||
CoverMarquee.speed = HUE_2_SPEED_NORMAL;
|
||||
CoverMarquee.direction = MODE_DIRECTION_RIGHT;
|
||||
CoverMarquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
CoverMarquee.colors.resize(1);
|
||||
modes.push_back(CoverMarquee);
|
||||
|
||||
mode Alternating;
|
||||
Alternating.name = "Alternating";
|
||||
Alternating.value = HUE_2_MODE_ALTERNATING;
|
||||
Alternating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Alternating.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Alternating.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Alternating.colors_min = 1;
|
||||
Alternating.colors_max = 2;
|
||||
Alternating.speed = HUE_2_SPEED_NORMAL;
|
||||
Alternating.direction = MODE_DIRECTION_RIGHT;
|
||||
Alternating.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Alternating.colors.resize(1);
|
||||
modes.push_back(Alternating);
|
||||
|
||||
mode Pulsing;
|
||||
Pulsing.name = "Pulsing";
|
||||
Pulsing.value = HUE_2_MODE_PULSING;
|
||||
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Pulsing.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Pulsing.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Pulsing.colors_min = 1;
|
||||
Pulsing.colors_max = 8;
|
||||
Pulsing.speed = HUE_2_SPEED_NORMAL;
|
||||
Pulsing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Pulsing.colors.resize(1);
|
||||
modes.push_back(Pulsing);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HUE_2_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Breathing.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 8;
|
||||
Breathing.speed = HUE_2_SPEED_NORMAL;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
@@ -75,24 +170,9 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_Hue2::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx <= zones.size(); zone_idx++)
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
@@ -152,3 +232,54 @@ void RGBController_Hue2::UpdateSingleLED(int led)
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateMode()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
bool direction = false;
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_LEFT)
|
||||
{
|
||||
direction = true;
|
||||
}
|
||||
|
||||
hue2->SetMode(modes[active_mode].value, modes[active_mode].speed, direction);
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
hue2->SetChannelLEDs(channel, modes[active_mode].colors);
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_NONE)
|
||||
{
|
||||
std::vector<RGBColor> temp_colors;
|
||||
temp_colors.push_back(0x00000000);
|
||||
|
||||
hue2->SetChannelLEDs(channel, temp_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,19 @@
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "Hue2Controller.h"
|
||||
|
||||
class RGBController_Hue2 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Hue2(Hue2Controller* hue2_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
Hue2Controller* hue2;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
|
||||
@@ -17,11 +17,146 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
location = hueplus->GetLEDString();
|
||||
location = hueplus->GetLocation();
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HUE_PLUS_MODE_FIXED;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Fading;
|
||||
Fading.name = "Fading";
|
||||
Fading.value = HUE_PLUS_MODE_FADING;
|
||||
Fading.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Fading.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Fading.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Fading.colors_min = 1;
|
||||
Fading.colors_max = 8;
|
||||
Fading.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Fading.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Fading.colors.resize(2);
|
||||
modes.push_back(Fading);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = HUE_PLUS_MODE_SPECTRUM;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
SpectrumCycle.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
SpectrumCycle.direction = MODE_DIRECTION_RIGHT;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = HUE_PLUS_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Marquee.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Marquee.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Marquee.colors_min = 1;
|
||||
Marquee.colors_max = 1;
|
||||
Marquee.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Marquee.colors.resize(1);
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode CoverMarquee;
|
||||
CoverMarquee.name = "Cover Marquee";
|
||||
CoverMarquee.value = HUE_PLUS_MODE_COVER_MARQUEE;
|
||||
CoverMarquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
CoverMarquee.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
CoverMarquee.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
CoverMarquee.colors_min = 1;
|
||||
CoverMarquee.colors_max = 8;
|
||||
CoverMarquee.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
CoverMarquee.direction = MODE_DIRECTION_RIGHT;
|
||||
CoverMarquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
CoverMarquee.colors.resize(2);
|
||||
modes.push_back(CoverMarquee);
|
||||
|
||||
mode Alternating;
|
||||
Alternating.name = "Alternating";
|
||||
Alternating.value = HUE_PLUS_MODE_ALTERNATING;
|
||||
Alternating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Alternating.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Alternating.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Alternating.colors_min = 1;
|
||||
Alternating.colors_max = 2;
|
||||
Alternating.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Alternating.direction = MODE_DIRECTION_RIGHT;
|
||||
Alternating.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Alternating.colors.resize(2);
|
||||
modes.push_back(Alternating);
|
||||
|
||||
mode Pulsing;
|
||||
Pulsing.name = "Pulsing";
|
||||
Pulsing.value = HUE_PLUS_MODE_PULSING;
|
||||
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Pulsing.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Pulsing.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Pulsing.colors_min = 1;
|
||||
Pulsing.colors_max = 8;
|
||||
Pulsing.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Pulsing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Pulsing.colors.resize(2);
|
||||
modes.push_back(Pulsing);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HUE_PLUS_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Breathing.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 8;
|
||||
Breathing.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(2);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Alert;
|
||||
Alert.name = "Alert";
|
||||
Alert.value = HUE_PLUS_MODE_ALERT;
|
||||
Alert.flags = 0;
|
||||
Alert.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Alert);
|
||||
|
||||
mode Candlelight;
|
||||
Candlelight.name = "Candlelight";
|
||||
Candlelight.value = HUE_PLUS_MODE_CANDLELIGHT;
|
||||
Candlelight.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Candlelight.colors_min = 1;
|
||||
Candlelight.colors_max = 1;
|
||||
Candlelight.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Candlelight.colors.resize(1);
|
||||
modes.push_back(Candlelight);
|
||||
|
||||
mode Wings;
|
||||
Wings.name = "Wings";
|
||||
Wings.value = HUE_PLUS_MODE_WINGS;
|
||||
Wings.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Wings.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Wings.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Wings.colors_min = 1;
|
||||
Wings.colors_max = 1;
|
||||
Wings.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Wings.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Wings.colors.resize(1);
|
||||
modes.push_back(Wings);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = HUE_PLUS_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Wave.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Wave.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Wave.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Wave.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Wave);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
@@ -77,24 +212,9 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_HuePlus::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx <= zones.size(); zone_idx++)
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
@@ -154,3 +274,55 @@ void RGBController_HuePlus::UpdateSingleLED(int led)
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateMode()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
bool direction = false;
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_LEFT)
|
||||
{
|
||||
direction = true;
|
||||
}
|
||||
|
||||
hueplus->SetMode(modes[active_mode].value, modes[active_mode].speed, direction);
|
||||
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
hueplus->SetModeColors(channel, modes[active_mode].colors);
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_NONE)
|
||||
{
|
||||
std::vector<RGBColor> temp_colors;
|
||||
temp_colors.push_back(0x00000000);
|
||||
|
||||
hueplus->SetModeColors(channel, temp_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ class RGBController_HuePlus : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HuePlus(HuePlusController* hueplus_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
HuePlusController* hueplus;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
|
||||
@@ -9,20 +9,6 @@
|
||||
|
||||
#include "RGBController_HyperX.h"
|
||||
|
||||
int RGBController_HyperX::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetMode(int mode)
|
||||
{
|
||||
hyperx->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetCustomMode()
|
||||
{
|
||||
hyperx->SetMode(HYPERX_MODE_DIRECT);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateLEDs()
|
||||
{
|
||||
@@ -105,22 +91,109 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode hyperx_modes[HYPERX_NUMBER_MODES];
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HYPERX_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
hyperx_modes[0].name = "Direct";
|
||||
hyperx_modes[1].name = "Static";
|
||||
hyperx_modes[2].name = "Rainbow";
|
||||
hyperx_modes[3].name = "Comet";
|
||||
hyperx_modes[4].name = "Heartbeat";
|
||||
hyperx_modes[5].name = "Spectrum Cycle";
|
||||
hyperx_modes[6].name = "Breathing";
|
||||
hyperx_modes[7].name = "Bounce";
|
||||
hyperx_modes[8].name = "Blink";
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = HYPERX_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = HYPERX_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = HYPERX_SPEED_RAINBOW_SLOW;
|
||||
Rainbow.speed_max = HYPERX_SPEED_RAINBOW_FAST;
|
||||
Rainbow.speed = HYPERX_SPEED_RAINBOW_NORMAL;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Comet;
|
||||
Comet.name = "Comet";
|
||||
Comet.value = HYPERX_MODE_COMET;
|
||||
Comet.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Comet.speed_min = HYPERX_SPEED_COMET_SLOW;
|
||||
Comet.speed_max = HYPERX_SPEED_COMET_FAST;
|
||||
Comet.colors_min = 1;
|
||||
Comet.colors_max = 1;
|
||||
Comet.speed = HYPERX_SPEED_COMET_NORMAL;
|
||||
Comet.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Comet.colors.resize(1);
|
||||
modes.push_back(Comet);
|
||||
|
||||
mode Heartbeat;
|
||||
Heartbeat.name = "Heartbeat";
|
||||
Heartbeat.value = HYPERX_MODE_HEARTBEAT;
|
||||
Heartbeat.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Heartbeat.speed_min = HYPERX_SPEED_COMET_SLOW;
|
||||
Heartbeat.speed_max = HYPERX_SPEED_COMET_FAST;
|
||||
Heartbeat.colors_min = 1;
|
||||
Heartbeat.colors_max = 1;
|
||||
Heartbeat.speed = HYPERX_SPEED_COMET_NORMAL;
|
||||
Heartbeat.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Heartbeat.colors.resize(1);
|
||||
modes.push_back(Heartbeat);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = HYPERX_MODE_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
SpectrumCycle.speed_min = HYPERX_SPEED_CYCLE_SLOW;
|
||||
SpectrumCycle.speed_max = HYPERX_SPEED_CYCLE_FAST;
|
||||
SpectrumCycle.speed = HYPERX_SPEED_CYCLE_NORMAL;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
for (int i = 0; i < HYPERX_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(hyperx_modes[i]);
|
||||
}
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HYPERX_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.speed_min = HYPERX_SPEED_BREATHING_SLOW;
|
||||
Breathing.speed_max = HYPERX_SPEED_BREATHING_FAST;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.speed = HYPERX_SPEED_BREATHING_NORMAL;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Bounce;
|
||||
Bounce.name = "Bounce";
|
||||
Bounce.value = HYPERX_MODE_BOUNCE;
|
||||
Bounce.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Bounce.speed_min = HYPERX_SPEED_BOUNCE_SLOW;
|
||||
Bounce.speed_max = HYPERX_SPEED_BOUNCE_FAST;
|
||||
Bounce.colors_min = 1;
|
||||
Bounce.colors_max = 1;
|
||||
Bounce.speed = HYPERX_SPEED_BOUNCE_NORMAL;
|
||||
Bounce.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Bounce.colors.resize(1);
|
||||
modes.push_back(Bounce);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = HYPERX_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Blink.speed_min = HYPERX_SPEED_BLINK_SLOW;
|
||||
Blink.speed_max = HYPERX_SPEED_BLINK_FAST;
|
||||
Blink.colors_min = 1;
|
||||
Blink.colors_max = 1;
|
||||
Blink.speed = HYPERX_SPEED_BLINK_NORMAL;
|
||||
Blink.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Blink.colors.resize(1);
|
||||
modes.push_back(Blink);
|
||||
|
||||
colors.resize(hyperx->GetLEDCount());
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
|
||||
@@ -139,8 +212,6 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
|
||||
for(int led_slot_idx = 0; led_slot_idx < 5; led_slot_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
led* new_led = new led();
|
||||
|
||||
char led_idx_str[3];
|
||||
@@ -160,3 +231,25 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateMode()
|
||||
{
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
|
||||
hyperx->SetMode(modes[active_mode].value, random, modes[active_mode].speed);
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
hyperx->SetEffectColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ class RGBController_HyperX : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperX(HyperXController* hyperx_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
HyperXController* hyperx;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXKeyboard.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX RGB |
|
||||
| Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/2/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_HyperXKeyboard.h"
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
"RGB Strip",
|
||||
"Media Keys"
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104,
|
||||
18,
|
||||
4
|
||||
};
|
||||
|
||||
static const char* led_names[] =
|
||||
{
|
||||
"Key: Escape",
|
||||
"Key: `",
|
||||
"Key: Tab",
|
||||
"Key: Caps Lock",
|
||||
"Key: Left Shift",
|
||||
"Key: Left Control",
|
||||
"Key: F12",
|
||||
"Key: =",
|
||||
"Key: F9",
|
||||
"Key: 9",
|
||||
"Key: O",
|
||||
"Key: L",
|
||||
"Key: ,",
|
||||
"Key: Context",
|
||||
"Key: Left Arrow",
|
||||
"Key: F1",
|
||||
"Key: 1",
|
||||
"Key: Q",
|
||||
"Key: A",
|
||||
"Key: Left Windows",
|
||||
"Key: Print Screen",
|
||||
"Key: F10",
|
||||
"Key: 0",
|
||||
"Key: P",
|
||||
"Key: ;",
|
||||
"Key: .",
|
||||
"Key: Enter",
|
||||
"Key: Down Arrow",
|
||||
"Key: F2",
|
||||
"Key: 2",
|
||||
"Key: W",
|
||||
"Key: S",
|
||||
"Key: Z",
|
||||
"Key: Left Alt",
|
||||
"Key: Scroll Lock",
|
||||
"Key: Backspace",
|
||||
"Key: F11",
|
||||
"Key: -",
|
||||
"Key: [",
|
||||
"Key: '",
|
||||
"Key: /",
|
||||
"Key: Right Arrow",
|
||||
"Key: F3",
|
||||
"Key: 3",
|
||||
"Key: E",
|
||||
"Key: D",
|
||||
"Key: X",
|
||||
"Key: Pause/Break",
|
||||
"Key: Delete",
|
||||
"Key: Number Pad 7",
|
||||
"Key: Num Lock",
|
||||
"Key: Number Pad 6",
|
||||
"Key: F4",
|
||||
"Key: 4",
|
||||
"Key: R",
|
||||
"Key: F",
|
||||
"Key: C",
|
||||
"Key: Space",
|
||||
"Key: Insert",
|
||||
"Key: End",
|
||||
"Key: Number Pad 8",
|
||||
"Key: Number Pad /",
|
||||
"Key: Number Pad 1",
|
||||
"Key: F5",
|
||||
"Key: 5",
|
||||
"Key: T",
|
||||
"Key: G",
|
||||
"Key: V",
|
||||
"Key: Home",
|
||||
"Key: Page Down",
|
||||
"Key: Number Pad 9",
|
||||
"Key: Number Pad *",
|
||||
"Key: Number Pad 2",
|
||||
"Key: F6",
|
||||
"Key: 6",
|
||||
"Key: Y",
|
||||
"Key: H",
|
||||
"Key: B",
|
||||
"Key: Page Up",
|
||||
"Key: Right Shift",
|
||||
"Key: Number Pad -",
|
||||
"Key: Number Pad 3",
|
||||
"Key: F7",
|
||||
"Key: 7",
|
||||
"Key: U",
|
||||
"Key: J",
|
||||
"Key: N",
|
||||
"Key: Right Alt",
|
||||
"Key: ]",
|
||||
"Key: Right Control",
|
||||
"Key: Number Pad 4",
|
||||
"Key: Number Pad +",
|
||||
"Key: Number Pad 0",
|
||||
"Key: F8",
|
||||
"Key: 8",
|
||||
"Key: I",
|
||||
"Key: K",
|
||||
"Key: M",
|
||||
"Key: Right Windows",
|
||||
"Key: \\",
|
||||
"Key: Up Arrow",
|
||||
"Key: Number Pad 5",
|
||||
"Key: Number Pad Enter",
|
||||
"Key: Number Pad .",
|
||||
"RGB Strip 1",
|
||||
"RGB Strip 2",
|
||||
"RGB Strip 3",
|
||||
"RGB Strip 4",
|
||||
"RGB Strip 5",
|
||||
"RGB Strip 6",
|
||||
"RGB Strip 7",
|
||||
"RGB Strip 8",
|
||||
"RGB Strip 9",
|
||||
"RGB Strip 10",
|
||||
"RGB Strip 11",
|
||||
"RGB Strip 12",
|
||||
"RGB Strip 13",
|
||||
"RGB Strip 14",
|
||||
"RGB Strip 15",
|
||||
"RGB Strip 16",
|
||||
"RGB Strip 17",
|
||||
"RGB Strip 18",
|
||||
"Media Previous",
|
||||
"Media Play/Pause",
|
||||
"Media Next",
|
||||
"Media Mute"
|
||||
};
|
||||
|
||||
RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardController* hyperx_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
|
||||
name = "HyperX RGB Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HYPERX_MODE_STATIC;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = HYPERX_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = HYPERX_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.speed_min = 0x00;
|
||||
Wave.speed_max = 0x09;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
Wave.speed = 0x09;
|
||||
Wave.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HYPERX_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.speed_min = 0x00;
|
||||
Breathing.speed_max = 0x09;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 2;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed = 0x09;
|
||||
Breathing.colors.resize(2);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
colors.resize(126);
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 3; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name.append(zone_names[zone_idx]);
|
||||
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for(unsigned int led_count = 0; led_count < zone_sizes[zone_idx]; led_count++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name.append(led_names[led_idx]);
|
||||
leds.push_back(new_led);
|
||||
|
||||
new_zone_map.push_back(led_idx);
|
||||
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone.map.push_back(new_zone_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateLEDs()
|
||||
{
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SetLEDsDirect(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
hyperx->SetLEDs(colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::SetCustomMode()
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, modes[active_mode].colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<RGBColor> temp_colors;
|
||||
hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXKeyboard.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX RGB |
|
||||
| Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/2/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "HyperXKeyboardController.h"
|
||||
|
||||
class RGBController_HyperXKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXKeyboard(HyperXKeyboardController* hyperx_ptr);
|
||||
~RGBController_HyperXKeyboard();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
HyperXKeyboardController* hyperx;
|
||||
};
|
||||
@@ -18,15 +18,24 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
colors.resize(strip->num_leds);
|
||||
|
||||
for (int i = 0; i < strip->num_leds; i++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
char id_buf[16];
|
||||
snprintf(id_buf, 16, "%d", i);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "LED Strip";
|
||||
new_led.name = "LED ";
|
||||
new_led.name.append(id_buf);
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
@@ -41,21 +50,6 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
zones.push_back(led_zone);
|
||||
}
|
||||
|
||||
int RGBController_LEDStrip::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
@@ -70,3 +64,13 @@ void RGBController_LEDStrip::UpdateSingleLED(int led)
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,12 @@ class RGBController_LEDStrip : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LEDStrip(LEDStripController* ledstrip_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
LEDStripController* strip;
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_MSI3Zone.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for MSI/Steelseries|
|
||||
| 3-Zone Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_MSI3Zone.h"
|
||||
|
||||
RGBController_MSI3Zone::RGBController_MSI3Zone(MSI3ZoneController* msi_ptr)
|
||||
{
|
||||
msi = msi_ptr;
|
||||
|
||||
name = "MSI 3-Zone Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
led left_led;
|
||||
left_led.name = "Keyboard Left";
|
||||
leds.push_back(left_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
led mid_led;
|
||||
mid_led.name = "Keyboard Middle";
|
||||
leds.push_back(mid_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
led right_led;
|
||||
right_led.name = "Keyboard Right";
|
||||
leds.push_back(right_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
zone keyboard_zone;
|
||||
keyboard_zone.name = "Keyboard";
|
||||
keyboard_zone.type = ZONE_TYPE_LINEAR;
|
||||
std::vector<int> keyboard_zone_map;
|
||||
keyboard_zone_map.push_back(0);
|
||||
keyboard_zone_map.push_back(1);
|
||||
keyboard_zone_map.push_back(2);
|
||||
keyboard_zone.map.push_back(keyboard_zone_map);
|
||||
zones.push_back(keyboard_zone);
|
||||
|
||||
led aux_led;
|
||||
aux_led.name = "Aux";
|
||||
leds.push_back(aux_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
zone aux_zone;
|
||||
aux_zone.name = "Aux";
|
||||
aux_zone.type = ZONE_TYPE_SINGLE;
|
||||
std::vector<int> aux_zone_map;
|
||||
aux_zone_map.push_back(3);
|
||||
aux_zone.map.push_back(aux_zone_map);
|
||||
zones.push_back(aux_zone);
|
||||
}
|
||||
|
||||
RGBController_MSI3Zone::~RGBController_MSI3Zone()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::UpdateLEDs()
|
||||
{
|
||||
msi->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
msi->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::UpdateSingleLED(int led)
|
||||
{
|
||||
msi->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_MSI3Zone.h |
|
||||
| |
|
||||
| Generic RGB Interface for MSI/Steelseries|
|
||||
| 3-Zone Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "MSI3ZoneController.h"
|
||||
|
||||
class RGBController_MSI3Zone : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_MSI3Zone(MSI3ZoneController* msi_ptr);
|
||||
~RGBController_MSI3Zone();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
MSI3ZoneController* msi;
|
||||
};
|
||||
@@ -11,84 +11,6 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
int RGBController_OpenRazer::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetMode(int mode)
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
matrix_effect_custom.write(&update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
matrix_effect_none.write(&update_value, 1);
|
||||
matrix_effect_none.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
matrix_effect_spectrum.write(&update_value, 1);
|
||||
matrix_effect_spectrum.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_WAVE:
|
||||
matrix_effect_wave.write(&update_value, 1);
|
||||
matrix_effect_wave.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
matrix_effect_reactive.write(&update_value, 1);
|
||||
matrix_effect_reactive.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
update_value = 0;
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
update_value = '4';
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
SetMode(RAZER_MODE_CUSTOM);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateLEDs()
|
||||
{
|
||||
@@ -158,7 +80,7 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
unsigned int output_array_size = 3;
|
||||
@@ -184,6 +106,7 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
scroll_led_effect.flush();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,59 +120,8 @@ void RGBController_OpenRazer::UpdateSingleLED(int led)
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
static std::string GetDeviceTypeString(std::string dev_path)
|
||||
{
|
||||
// Read device_type for device name string
|
||||
std::string dev_type_path = dev_path + "/device_type";
|
||||
std::ifstream dev_type_file;
|
||||
std::string ret_str;
|
||||
|
||||
dev_type_file.open(dev_type_path);
|
||||
std::getline(dev_type_file, ret_str);
|
||||
dev_type_file.close();
|
||||
|
||||
return(ret_str);
|
||||
}
|
||||
|
||||
static std::string GetFirmwareVersionString(std::string dev_path)
|
||||
{
|
||||
// Read firmware_version for firmware version string
|
||||
std::string firm_ver_path = dev_path + "/firmware_version";
|
||||
std::ifstream firm_ver_file;
|
||||
std::string ret_str;
|
||||
|
||||
firm_ver_file.open(firm_ver_path);
|
||||
std::getline(firm_ver_file, ret_str);
|
||||
firm_ver_file.close();
|
||||
|
||||
return(ret_str);
|
||||
}
|
||||
|
||||
static std::string GetSerialNumberString(std::string dev_path)
|
||||
{
|
||||
// Read device_serial for serial number string
|
||||
std::string ser_num_path = dev_path + "/device_serial";
|
||||
std::ifstream ser_num_file;
|
||||
std::string ret_str;
|
||||
|
||||
ser_num_file.open(ser_num_path);
|
||||
std::getline(ser_num_file, ret_str);
|
||||
ser_num_file.close();
|
||||
|
||||
return(ret_str);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols)
|
||||
{
|
||||
matrix_custom_frame.open(dev_path + "/matrix_custom_frame");
|
||||
matrix_effect_custom.open(dev_path + "/matrix_effect_custom");
|
||||
matrix_effect_breath.open(dev_path + "/matrix_effect_breath");
|
||||
matrix_effect_none.open(dev_path + "/matrix_effect_none");
|
||||
matrix_effect_reactive.open(dev_path + "/matrix_effect_reactive");
|
||||
matrix_effect_spectrum.open(dev_path + "/matrix_effect_spectrum");
|
||||
matrix_effect_static.open(dev_path + "/matrix_effect_static");
|
||||
matrix_effect_wave.open(dev_path + "/matrix_effect_wave");
|
||||
|
||||
if(!matrix_custom_frame)
|
||||
{
|
||||
if(!matrix_effect_custom)
|
||||
@@ -275,27 +147,60 @@ void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned i
|
||||
|
||||
void RGBController_OpenRazer::SetupNonMatrixDevice(std::string dev_path)
|
||||
{
|
||||
logo_led_effect.open(dev_path + "/logo_led_effect");
|
||||
logo_led_rgb.open(dev_path + "/logo_led_rgb");
|
||||
scroll_led_effect.open(dev_path + "/scroll_led_effect");
|
||||
scroll_led_rgb.open(dev_path + "/scroll_led_rgb");
|
||||
|
||||
matrix_type = RAZER_TYPE_NOMATRIX;
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::OpenFunctions(std::string dev_path)
|
||||
{
|
||||
device_type.open( dev_path + "/device_type");
|
||||
device_serial.open( dev_path + "/device_serial");
|
||||
firmware_version.open( dev_path + "/firmware_version");
|
||||
|
||||
matrix_custom_frame.open( dev_path + "/matrix_custom_frame");
|
||||
matrix_brightness.open( dev_path + "/matrix_brightness");
|
||||
|
||||
matrix_effect_custom.open( dev_path + "/matrix_effect_custom");
|
||||
matrix_effect_none.open( dev_path + "/matrix_effect_none");
|
||||
matrix_effect_static.open( dev_path + "/matrix_effect_static");
|
||||
matrix_effect_breath.open( dev_path + "/matrix_effect_breath");
|
||||
matrix_effect_spectrum.open( dev_path + "/matrix_effect_spectrum");
|
||||
matrix_effect_reactive.open( dev_path + "/matrix_effect_reactive");
|
||||
matrix_effect_wave.open( dev_path + "/matrix_effect_wave");
|
||||
|
||||
logo_led_brightness.open( dev_path + "/logo_led_brightness");
|
||||
logo_matrix_effect_none.open( dev_path + "/logo_matrix_effect_none");
|
||||
logo_matrix_effect_static.open( dev_path + "/logo_matrix_effect_static");
|
||||
logo_matrix_effect_spectrum.open( dev_path + "/logo_matrix_effect_spectrum");
|
||||
logo_matrix_effect_reactive.open( dev_path + "/logo_matrix_effect_reactive");
|
||||
|
||||
scroll_led_brightness.open( dev_path + "/scroll_led_brightness");
|
||||
scroll_matrix_effect_none.open( dev_path + "/scroll_matrix_effect_none");
|
||||
scroll_matrix_effect_static.open( dev_path + "/scroll_matrix_effect_static");
|
||||
scroll_matrix_effect_spectrum.open(dev_path + "/scroll_matrix_effect_spectrum");
|
||||
scroll_matrix_effect_reactive.open(dev_path + "/scroll_matrix_effect_reactive");
|
||||
|
||||
scroll_led_effect.open( dev_path + "/scroll_led_effect");
|
||||
scroll_led_rgb.open( dev_path + "/scroll_led_rgb");
|
||||
}
|
||||
|
||||
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
{
|
||||
unsigned int led_count = 0;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Open the OpenRazer device functions |
|
||||
\*-----------------------------------------------------------------*/
|
||||
OpenFunctions(dev_path);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Start device at -1. This indicates the device was not detected |
|
||||
\*-----------------------------------------------------------------*/
|
||||
device = -1;
|
||||
device_index = -1;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the device name from the OpenRazer driver |
|
||||
\*-----------------------------------------------------------------*/
|
||||
name = GetDeviceTypeString(dev_path);
|
||||
std::getline(device_type, name);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set the description to indicate this is an OpenRazer device |
|
||||
@@ -310,12 +215,12 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the serial number from the dev path |
|
||||
\*-----------------------------------------------------------------*/
|
||||
serial = GetSerialNumberString(dev_path);
|
||||
std::getline(device_serial, serial);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the firmware version from the dev path |
|
||||
\*-----------------------------------------------------------------*/
|
||||
version = GetFirmwareVersionString(dev_path);
|
||||
std::getline(firmware_version, version);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Loop through all known devices to look for a name match |
|
||||
@@ -327,7 +232,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
/*---------------------------------------------------------*\
|
||||
| Set device ID |
|
||||
\*---------------------------------------------------------*/
|
||||
device = i;
|
||||
device_index = i;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set device type |
|
||||
@@ -337,19 +242,81 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize modes |
|
||||
\*---------------------------------------------------------*/
|
||||
mode razer_modes[RAZER_NUM_MODES];
|
||||
|
||||
razer_modes[0].name = "Custom";
|
||||
razer_modes[1].name = "Off";
|
||||
razer_modes[2].name = "Static";
|
||||
razer_modes[3].name = "Breathing";
|
||||
razer_modes[4].name = "Spectrum Cycle";
|
||||
razer_modes[5].name = "Wave";
|
||||
razer_modes[6].name = "Reactive";
|
||||
|
||||
for (int i = 0; i < RAZER_NUM_MODES; i++)
|
||||
if(matrix_effect_custom)
|
||||
{
|
||||
modes.push_back(razer_modes[i]);
|
||||
mode Custom;
|
||||
Custom.name = "Custom";
|
||||
Custom.value = RAZER_MODE_CUSTOM;
|
||||
Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Custom.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Custom);
|
||||
}
|
||||
|
||||
if(matrix_effect_none)
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = RAZER_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
}
|
||||
|
||||
if(matrix_effect_static)
|
||||
{
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = RAZER_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
}
|
||||
|
||||
if(matrix_effect_breath)
|
||||
{
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = RAZER_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 2;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
}
|
||||
|
||||
if(matrix_effect_spectrum)
|
||||
{
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = RAZER_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = 0;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
}
|
||||
|
||||
if(matrix_effect_wave)
|
||||
{
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = RAZER_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.direction = MODE_DIRECTION_RIGHT;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Wave);
|
||||
}
|
||||
|
||||
if(matrix_effect_reactive)
|
||||
{
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
Reactive.value = RAZER_MODE_REACTIVE;
|
||||
Reactive.flags = 0;
|
||||
Reactive.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Reactive);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -401,3 +368,123 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
active_mode = RAZER_MODE_CUSTOM;
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateMode()
|
||||
{
|
||||
char update_value[6];
|
||||
|
||||
update_value[0] = 1;
|
||||
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
matrix_effect_custom.write(update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
matrix_effect_none.write(update_value, 1);
|
||||
matrix_effect_none.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
update_value[0] = RGBGetRValue(modes[RAZER_MODE_STATIC].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[RAZER_MODE_STATIC].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[RAZER_MODE_STATIC].colors[0]);
|
||||
matrix_effect_static.write(update_value, 3);
|
||||
matrix_effect_static.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
switch(modes[RAZER_MODE_BREATHING].color_mode)
|
||||
{
|
||||
case MODE_COLORS_MODE_SPECIFIC:
|
||||
update_value[0] = RGBGetRValue(modes[RAZER_MODE_BREATHING].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[RAZER_MODE_BREATHING].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[RAZER_MODE_BREATHING].colors[0]);
|
||||
|
||||
if(modes[RAZER_MODE_BREATHING].colors.size() == 2)
|
||||
{
|
||||
update_value[3] = RGBGetRValue(modes[RAZER_MODE_BREATHING].colors[1]);
|
||||
update_value[4] = RGBGetGValue(modes[RAZER_MODE_BREATHING].colors[1]);
|
||||
update_value[5] = RGBGetBValue(modes[RAZER_MODE_BREATHING].colors[1]);
|
||||
|
||||
matrix_effect_breath.write(update_value, 6);
|
||||
matrix_effect_breath.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix_effect_breath.write(update_value, 3);
|
||||
matrix_effect_breath.flush();
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_COLORS_RANDOM:
|
||||
matrix_effect_breath.write(update_value, 1);
|
||||
matrix_effect_breath.flush();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
matrix_effect_spectrum.write(update_value, 1);
|
||||
matrix_effect_spectrum.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_WAVE:
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
update_value[0] = '2';
|
||||
break;
|
||||
|
||||
default:
|
||||
update_value[0] = '1';
|
||||
break;
|
||||
}
|
||||
matrix_effect_wave.write(update_value, 1);
|
||||
matrix_effect_wave.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
matrix_effect_reactive.write(update_value, 1);
|
||||
matrix_effect_reactive.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
switch(active_mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
update_value = 0;
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
update_value = '4';
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,890 +10,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "OpenRazerDevices.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#define RAZER_MAX_ZONES 6
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
unsigned int type;
|
||||
unsigned int rows;
|
||||
unsigned int cols;
|
||||
} razer_zone;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
device_type type;
|
||||
bool matrix_type;
|
||||
unsigned int rows;
|
||||
unsigned int cols;
|
||||
const razer_zone* zones[RAZER_MAX_ZONES];
|
||||
} razer_device;
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| KEYBOARDS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer BlackWidow Chroma |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 22 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blackwidow_chroma_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_device blackwidow_chroma_device =
|
||||
{
|
||||
"Razer BlackWidow Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
{
|
||||
&blackwidow_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer BlackWidow Chroma Tournament Edition |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 22 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blackwidow_chroma_te_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_device blackwidow_chroma_te_device =
|
||||
{
|
||||
"Razer BlackWidow Chroma Tournament Edition",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
{
|
||||
&blackwidow_chroma_te_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Ornata Chroma |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 22 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone ornata_chroma_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_device ornata_chroma_device =
|
||||
{
|
||||
"Razer Ornata Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
{
|
||||
&ornata_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer DeathStalker Chroma |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Linear |
|
||||
| 12 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone deathstalker_chroma_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
12
|
||||
};
|
||||
|
||||
static const razer_device deathstalker_chroma_device =
|
||||
{
|
||||
"Razer DeathStalker Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
1,
|
||||
12,
|
||||
{
|
||||
&deathstalker_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| LAPTOPS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Blade Stealth |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 16 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blade_stealth_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
16
|
||||
};
|
||||
|
||||
static const razer_device blade_stealth_device =
|
||||
{
|
||||
"Razer Blade Stealth",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
16,
|
||||
{
|
||||
&blade_stealth_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Blade Pro (Late 2016) |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 25 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blade_pro_late_2016_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
25
|
||||
};
|
||||
|
||||
static const razer_device blade_pro_late_2016_device =
|
||||
{
|
||||
"Razer Blade Pro (Late 2016)",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
{
|
||||
&blade_pro_late_2016_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Blade Pro (2017) |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 25 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blade_pro_2017_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
25
|
||||
};
|
||||
|
||||
static const razer_device blade_pro_2017_device =
|
||||
{
|
||||
"Razer Blade Pro (2017)",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
{
|
||||
&blade_pro_2017_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| MICE |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Mamba Tournament Edition |
|
||||
| |
|
||||
| Zone "Left" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Right" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone mamba_te_left_zone =
|
||||
{
|
||||
"Left LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone mamba_te_right_zone =
|
||||
{
|
||||
"Right LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone mamba_te_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone mamba_te_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device mamba_te_device =
|
||||
{
|
||||
"Razer Mamba Tournament Edition",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
true,
|
||||
1,
|
||||
16,
|
||||
{
|
||||
&mamba_te_left_zone,
|
||||
&mamba_te_right_zone,
|
||||
&mamba_te_logo_zone,
|
||||
&mamba_te_scroll_wheel_zone,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Diamondback Chroma |
|
||||
| |
|
||||
| Zone "Right" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Bottom" |
|
||||
| Linear |
|
||||
| 5 LEDs |
|
||||
| |
|
||||
| Zone "Left" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone diamondback_chroma_right_zone =
|
||||
{
|
||||
"Right LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_bottom_zone =
|
||||
{
|
||||
"Bottom LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
5
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_left_zone =
|
||||
{
|
||||
"Left LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device diamondback_chroma_device =
|
||||
{
|
||||
"Razer Diamondback Chroma",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
true,
|
||||
1,
|
||||
21,
|
||||
{
|
||||
&diamondback_chroma_right_zone,
|
||||
&diamondback_chroma_bottom_zone,
|
||||
&diamondback_chroma_left_zone,
|
||||
&diamondback_chroma_logo_zone,
|
||||
&diamondback_chroma_scroll_wheel_zone,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer DeathAdder Chroma |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone deathadder_chroma_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone deathadder_chroma_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device deathadder_chroma_device =
|
||||
{
|
||||
"Razer DeathAdder Chroma",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
false,
|
||||
1,
|
||||
2,
|
||||
{
|
||||
&deathadder_chroma_logo_zone,
|
||||
&deathadder_chroma_scroll_wheel_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Naga Chroma |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Numpad" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone naga_chroma_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone naga_chroma_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone naga_chroma_numpad_zone =
|
||||
{
|
||||
"Numpad",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device naga_chroma_device =
|
||||
{
|
||||
"Razer Naga Chroma",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
false,
|
||||
1,
|
||||
3,
|
||||
{
|
||||
&naga_chroma_logo_zone,
|
||||
&naga_chroma_scroll_wheel_zone,
|
||||
&naga_chroma_numpad_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| KEYPADS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Orbweaver Chroma |
|
||||
| |
|
||||
| Zone "Keypad" |
|
||||
| Matrix |
|
||||
| 4 Rows, 5 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone orbweaver_chroma_zone =
|
||||
{
|
||||
"Keypad",
|
||||
ZONE_TYPE_MATRIX,
|
||||
4,
|
||||
5
|
||||
};
|
||||
|
||||
static const razer_device orbweaver_chroma_device =
|
||||
{
|
||||
"Razer Orbweaver Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
{
|
||||
&orbweaver_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Tartarus Chroma |
|
||||
| |
|
||||
| Zone "Keypad" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone tartarus_chroma_zone =
|
||||
{
|
||||
"Keypad",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device tartarus_chroma_device =
|
||||
{
|
||||
"Razer Tartarus Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&tartarus_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| MOUSEMATS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Firefly |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 15 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone firefly_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
15
|
||||
};
|
||||
|
||||
static const razer_device firefly_device =
|
||||
{
|
||||
"Razer Firefly",
|
||||
DEVICE_TYPE_MOUSEMAT,
|
||||
true,
|
||||
1,
|
||||
15,
|
||||
{
|
||||
&firefly_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Goliathus Extended |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone goliathus_extended_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device goliathus_extended_device =
|
||||
{
|
||||
"Razer Goliathus Extended",
|
||||
DEVICE_TYPE_MOUSEMAT,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&goliathus_extended_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| HEADSETS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Kraken 7.1 Chroma |
|
||||
| |
|
||||
| Zone "Headset" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone kraken_chroma_zone =
|
||||
{
|
||||
"Headset",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device kraken_chroma_device =
|
||||
{
|
||||
"Razer Kraken 7.1 Chroma",
|
||||
DEVICE_TYPE_HEADSET,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&kraken_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Kraken 7.1 V2 |
|
||||
| |
|
||||
| Zone "Headset" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone kraken_v2_zone =
|
||||
{
|
||||
"Headset",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device kraken_v2_device =
|
||||
{
|
||||
"Razer Kraken 7.1 V2",
|
||||
DEVICE_TYPE_HEADSET,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&kraken_v2_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| OTHER |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Core |
|
||||
| |
|
||||
| Zone "Side Window Lights" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 8 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone core_side_zone =
|
||||
{
|
||||
"Side Window Lights",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone core_led_strip_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
8
|
||||
};
|
||||
|
||||
static const razer_device core_device =
|
||||
{
|
||||
"Razer Core",
|
||||
DEVICE_TYPE_UNKNOWN,
|
||||
true,
|
||||
1,
|
||||
9,
|
||||
{
|
||||
&core_side_zone,
|
||||
&core_led_strip_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Chroma Mug Holder |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 15 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone mug_holder_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
15
|
||||
};
|
||||
|
||||
static const razer_device mug_holder_device =
|
||||
{
|
||||
"Razer Chroma Mug Holder",
|
||||
DEVICE_TYPE_UNKNOWN,
|
||||
true,
|
||||
1,
|
||||
15,
|
||||
{
|
||||
&mug_holder_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Chroma HDK |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone chromahdk_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
16
|
||||
};
|
||||
|
||||
static const razer_device chromahdk_device =
|
||||
{
|
||||
"Razer Chroma HDK",
|
||||
DEVICE_TYPE_LEDSTRIP,
|
||||
true,
|
||||
4,
|
||||
16,
|
||||
{
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| DEVICE MASTER LIST |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#define RAZER_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const razer_device* device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| KEYBOARDS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&blackwidow_chroma_device,
|
||||
&blackwidow_chroma_te_device,
|
||||
&ornata_chroma_device,
|
||||
&deathstalker_chroma_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| LAPTOPS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&blade_stealth_device,
|
||||
&blade_pro_late_2016_device,
|
||||
&blade_pro_2017_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| MICE |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&mamba_te_device,
|
||||
&diamondback_chroma_device,
|
||||
&deathadder_chroma_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| KEYPADS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&orbweaver_chroma_device,
|
||||
&tartarus_chroma_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| MOUSEMATS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&firefly_device,
|
||||
&goliathus_extended_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| HEADSETS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&kraken_chroma_device,
|
||||
&kraken_v2_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| OTHER |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&core_device,
|
||||
&mug_holder_device,
|
||||
&chromahdk_device
|
||||
};
|
||||
|
||||
|
||||
class RGBController_OpenRazer : public RGBController
|
||||
{
|
||||
public:
|
||||
@@ -920,14 +40,14 @@ public:
|
||||
|
||||
public:
|
||||
RGBController_OpenRazer(std::string dev_path);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
int device;
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
int device_index;
|
||||
|
||||
private:
|
||||
void SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols);
|
||||
@@ -937,19 +57,35 @@ private:
|
||||
unsigned int matrix_rows;
|
||||
unsigned int matrix_cols;
|
||||
|
||||
//OpenRazer Sysfs Entries for Matrix Devices
|
||||
void OpenFunctions(std::string dev_path);
|
||||
|
||||
std::ifstream device_type;
|
||||
std::ifstream device_serial;
|
||||
std::ifstream firmware_version;
|
||||
|
||||
std::ofstream matrix_custom_frame;
|
||||
std::ofstream matrix_brightness;
|
||||
|
||||
std::ofstream matrix_effect_custom;
|
||||
std::ofstream matrix_effect_breath;
|
||||
std::ofstream matrix_effect_none;
|
||||
std::ofstream matrix_effect_reactive;
|
||||
std::ofstream matrix_effect_spectrum;
|
||||
std::ofstream matrix_effect_static;
|
||||
std::ofstream matrix_effect_breath;
|
||||
std::ofstream matrix_effect_spectrum;
|
||||
std::ofstream matrix_effect_reactive;
|
||||
std::ofstream matrix_effect_wave;
|
||||
|
||||
//OpenRazer Sysfs Entries for Non-Matrix Devices
|
||||
std::ofstream logo_led_effect;
|
||||
std::ofstream logo_led_rgb;
|
||||
std::ofstream logo_led_brightness;
|
||||
std::ofstream logo_matrix_effect_none;
|
||||
std::ofstream logo_matrix_effect_static;
|
||||
std::ofstream logo_matrix_effect_spectrum;
|
||||
std::ofstream logo_matrix_effect_reactive;
|
||||
|
||||
std::ofstream scroll_led_brightness;
|
||||
std::ofstream scroll_matrix_effect_none;
|
||||
std::ofstream scroll_matrix_effect_static;
|
||||
std::ofstream scroll_matrix_effect_spectrum;
|
||||
std::ofstream scroll_matrix_effect_reactive;
|
||||
|
||||
std::ofstream scroll_led_effect;
|
||||
std::ofstream scroll_led_rgb;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,476 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_OpenRazer.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRazer |
|
||||
| kernel drivers for Chroma peripherals |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_OpenRazerWindows.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/hid.h>
|
||||
|
||||
void RGBController_OpenRazer::UpdateLEDs()
|
||||
{
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
case RAZER_TYPE_MATRIX_STATIC:
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
for (unsigned int row = 0; row < matrix_rows; row++)
|
||||
{
|
||||
unsigned int output_array_size;
|
||||
unsigned int output_offset;
|
||||
unsigned int row_offset = (row * matrix_cols);
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
output_array_size = 3 + (matrix_cols* 3);
|
||||
output_offset = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
output_array_size = 3;
|
||||
output_offset = 0;
|
||||
}
|
||||
|
||||
char* output_array = new char[output_array_size];
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
output_array[0] = row;
|
||||
output_array[1] = 0;
|
||||
output_array[2] = matrix_cols - 1;
|
||||
}
|
||||
|
||||
for(unsigned int col = 0; col < matrix_cols; col++)
|
||||
{
|
||||
unsigned int color_idx = col + row_offset;
|
||||
output_array[(col * 3) + 0 + output_offset] = (char)RGBGetRValue(colors[color_idx]);
|
||||
output_array[(col * 3) + 1 + output_offset] = (char)RGBGetGValue(colors[color_idx]);
|
||||
output_array[(col * 3) + 2 + output_offset] = (char)RGBGetBValue(colors[color_idx]);
|
||||
}
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
razer_functions->matrix_custom_frame->store(razer_device, NULL, output_array, output_array_size);
|
||||
}
|
||||
else if(matrix_type == RAZER_TYPE_MATRIX_NOFRAME)
|
||||
{
|
||||
razer_functions->matrix_effect_custom->store(razer_device, NULL, output_array, output_array_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
razer_functions->matrix_effect_static->store(razer_device, NULL, output_array, output_array_size);
|
||||
}
|
||||
}
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
razer_functions->matrix_effect_custom->store(razer_device, NULL, &update_value, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
unsigned int output_array_size = 3;
|
||||
char output_array[output_array_size];
|
||||
char update_value = 0;
|
||||
|
||||
output_array[0] = (char)RGBGetRValue(colors[0]);
|
||||
output_array[1] = (char)RGBGetGValue(colors[0]);
|
||||
output_array[2] = (char)RGBGetBValue(colors[0]);
|
||||
logo_led_rgb.write(output_array, output_array_size);
|
||||
|
||||
output_array[0] = (char)RGBGetRValue(colors[1]);
|
||||
output_array[1] = (char)RGBGetGValue(colors[1]);
|
||||
output_array[2] = (char)RGBGetBValue(colors[1]);
|
||||
scroll_led_rgb.write(output_array, output_array_size);
|
||||
|
||||
logo_led_rgb.flush();
|
||||
scroll_led_rgb.flush();
|
||||
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupMatrixDevice(device * razer_device, device_fn_type* razer_functions, unsigned int rows, unsigned int cols)
|
||||
{
|
||||
if(!razer_functions->matrix_custom_frame)
|
||||
{
|
||||
if(!razer_functions->matrix_effect_custom)
|
||||
{
|
||||
matrix_type = RAZER_TYPE_MATRIX_STATIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix_type = RAZER_TYPE_MATRIX_NOFRAME;
|
||||
}
|
||||
|
||||
matrix_rows = 1;
|
||||
matrix_cols = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix_type = RAZER_TYPE_MATRIX_FRAME;
|
||||
|
||||
matrix_rows = rows;
|
||||
matrix_cols = cols;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupNonMatrixDevice(device * razer_device, device_fn_type* razer_functions)
|
||||
{
|
||||
matrix_type = RAZER_TYPE_NOMATRIX;
|
||||
}
|
||||
|
||||
RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_fn_type* razer_functions)
|
||||
{
|
||||
char string_buf[1024];
|
||||
|
||||
this->razer_device = razer_device;
|
||||
this->razer_functions = razer_functions;
|
||||
|
||||
unsigned int led_count = 0;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Initialize buffer |
|
||||
\*-----------------------------------------------------------------*/
|
||||
memset(string_buf, 0xFF, sizeof(string_buf));
|
||||
string_buf[1023] = '\0';
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Start device at -1. This indicates the device was not detected |
|
||||
\*-----------------------------------------------------------------*/
|
||||
device_index = -1;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the device name from the OpenRazer driver |
|
||||
\*-----------------------------------------------------------------*/
|
||||
razer_functions->device_type->show(razer_device, NULL, string_buf);
|
||||
name = string_buf;
|
||||
name.erase(std::remove(name.begin(), name.end(), '\n'), name.end());
|
||||
name.erase(std::remove(name.begin(), name.end(), '\r'), name.end());
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set the description to indicate this is an OpenRazer device |
|
||||
\*-----------------------------------------------------------------*/
|
||||
description = "OpenRazer Device";
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set the device path as the location |
|
||||
\*-----------------------------------------------------------------*/
|
||||
location = "";
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Initialize buffer |
|
||||
\*-----------------------------------------------------------------*/
|
||||
//memset(string_buf, 0xFF, sizeof(string_buf));
|
||||
//string_buf[1023] = '\0';
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the serial number from the dev path |
|
||||
\*-----------------------------------------------------------------*/
|
||||
//razer_functions->device_serial->show(razer_device, NULL, string_buf);
|
||||
//serial = string_buf;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Initialize buffer |
|
||||
\*-----------------------------------------------------------------*/
|
||||
//memset(string_buf, 0xFF, sizeof(string_buf));
|
||||
//string_buf[1023] = '\0';
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the firmware version from the dev path |
|
||||
\*-----------------------------------------------------------------*/
|
||||
//razer_functions->firmware_version->show(razer_device, NULL, string_buf);
|
||||
//version = string_buf;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Loop through all known devices to look for a name match |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for (unsigned int i = 0; i < RAZER_NUM_DEVICES; i++)
|
||||
{
|
||||
if (device_list[i]->name == name)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set device ID |
|
||||
\*---------------------------------------------------------*/
|
||||
device_index = i;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set device type |
|
||||
\*---------------------------------------------------------*/
|
||||
type = device_list[i]->type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize modes |
|
||||
\*---------------------------------------------------------*/
|
||||
if(razer_functions->matrix_effect_custom)
|
||||
{
|
||||
mode Custom;
|
||||
Custom.name = "Custom";
|
||||
Custom.value = RAZER_MODE_CUSTOM;
|
||||
Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Custom.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Custom);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_none)
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = RAZER_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_static)
|
||||
{
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = RAZER_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_breath)
|
||||
{
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = RAZER_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 2;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(2);
|
||||
modes.push_back(Breathing);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_spectrum)
|
||||
{
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = RAZER_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = 0;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_wave)
|
||||
{
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = RAZER_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.direction = MODE_DIRECTION_RIGHT;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Wave);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_reactive)
|
||||
{
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
Reactive.value = RAZER_MODE_REACTIVE;
|
||||
Reactive.flags = 0;
|
||||
Reactive.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Reactive);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize file descriptors |
|
||||
\*---------------------------------------------------------*/
|
||||
if(device_list[i]->matrix_type == true)
|
||||
{
|
||||
SetupMatrixDevice(razer_device, razer_functions, device_list[i]->rows, device_list[i]->cols);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetupNonMatrixDevice(razer_device, razer_functions);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Fill in zone information based on device table |
|
||||
\*---------------------------------------------------------*/
|
||||
for (int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
|
||||
{
|
||||
if (device_list[i]->zones[zone_id] != NULL)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = device_list[i]->zones[zone_id]->name;
|
||||
new_zone.type = device_list[i]->zones[zone_id]->type;
|
||||
|
||||
for (unsigned int row_id = 0; row_id < device_list[i]->zones[zone_id]->rows; row_id++)
|
||||
{
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for (unsigned int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
|
||||
{
|
||||
char id_buf[8];
|
||||
snprintf(id_buf, 8, "%d", col_id + 1);
|
||||
|
||||
RGBColor new_color = 0x00000000;
|
||||
colors.push_back(new_color);
|
||||
|
||||
led* new_led = new led();
|
||||
new_led->name = device_list[i]->zones[zone_id]->name + " LED ";
|
||||
new_led->name.append(id_buf);
|
||||
leds.push_back(*new_led);
|
||||
|
||||
new_zone_map.push_back(led_count);
|
||||
|
||||
led_count++;
|
||||
}
|
||||
|
||||
new_zone.map.push_back(new_zone_map);
|
||||
}
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
SetMode(RAZER_MODE_CUSTOM);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateMode()
|
||||
{
|
||||
char update_value[6];
|
||||
|
||||
update_value[0] = 1;
|
||||
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
razer_functions->matrix_effect_custom->store(razer_device, NULL, update_value, 1);
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
razer_functions->matrix_effect_none->store(razer_device, NULL, update_value, 1);
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
update_value[0] = RGBGetRValue(modes[RAZER_MODE_STATIC].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[RAZER_MODE_STATIC].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[RAZER_MODE_STATIC].colors[0]);
|
||||
razer_functions->matrix_effect_static->store(razer_device, NULL, update_value, 3);
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
switch(modes[RAZER_MODE_BREATHING].color_mode)
|
||||
{
|
||||
case MODE_COLORS_MODE_SPECIFIC:
|
||||
update_value[0] = RGBGetRValue(modes[RAZER_MODE_BREATHING].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[RAZER_MODE_BREATHING].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[RAZER_MODE_BREATHING].colors[0]);
|
||||
|
||||
if(modes[RAZER_MODE_BREATHING].colors.size() == 2)
|
||||
{
|
||||
update_value[3] = RGBGetRValue(modes[RAZER_MODE_BREATHING].colors[1]);
|
||||
update_value[4] = RGBGetGValue(modes[RAZER_MODE_BREATHING].colors[1]);
|
||||
update_value[5] = RGBGetBValue(modes[RAZER_MODE_BREATHING].colors[1]);
|
||||
|
||||
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_COLORS_RANDOM:
|
||||
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
razer_functions->matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
|
||||
break;
|
||||
|
||||
case RAZER_MODE_WAVE:
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
update_value[0] = '2';
|
||||
break;
|
||||
|
||||
default:
|
||||
update_value[0] = '1';
|
||||
break;
|
||||
}
|
||||
razer_functions->matrix_effect_wave->store(razer_device, NULL, update_value, 1);
|
||||
break;
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
razer_functions->matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
update_value = 0;
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
update_value = '4';
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_OpenRazerWindows.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRazer |
|
||||
| kernel drivers for Chroma peripherals |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "OpenRazerDevices.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/hid.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct device_attribute * device_type;
|
||||
struct device_attribute * device_serial;
|
||||
struct device_attribute * firmware_version;
|
||||
|
||||
struct device_attribute * matrix_custom_frame;
|
||||
struct device_attribute * matrix_brightness;
|
||||
|
||||
struct device_attribute * matrix_effect_custom;
|
||||
struct device_attribute * matrix_effect_none;
|
||||
struct device_attribute * matrix_effect_static;
|
||||
struct device_attribute * matrix_effect_breath;
|
||||
struct device_attribute * matrix_effect_spectrum;
|
||||
struct device_attribute * matrix_effect_reactive;
|
||||
struct device_attribute * matrix_effect_wave;
|
||||
|
||||
struct device_attribute * logo_led_brightness;
|
||||
struct device_attribute * logo_matrix_effect_none;
|
||||
struct device_attribute * logo_matrix_effect_static;
|
||||
struct device_attribute * logo_matrix_effect_spectrum;
|
||||
struct device_attribute * logo_matrix_effect_reactive;
|
||||
|
||||
struct device_attribute * scroll_led_brightness;
|
||||
struct device_attribute * scroll_matrix_effect_none;
|
||||
struct device_attribute * scroll_matrix_effect_static;
|
||||
struct device_attribute * scroll_matrix_effect_spectrum;
|
||||
struct device_attribute * scroll_matrix_effect_reactive;
|
||||
|
||||
struct device_attribute * scroll_led_effect;
|
||||
struct device_attribute * scroll_led_rgb;
|
||||
} device_fn_type;
|
||||
|
||||
class RGBController_OpenRazer : public RGBController
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
RAZER_MODE_CUSTOM,
|
||||
RAZER_MODE_OFF,
|
||||
RAZER_MODE_STATIC,
|
||||
RAZER_MODE_BREATHING,
|
||||
RAZER_MODE_SPECTRUM_CYCLE,
|
||||
RAZER_MODE_WAVE,
|
||||
RAZER_MODE_REACTIVE,
|
||||
RAZER_NUM_MODES
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RAZER_TYPE_MATRIX_FRAME,
|
||||
RAZER_TYPE_MATRIX_NOFRAME,
|
||||
RAZER_TYPE_MATRIX_STATIC,
|
||||
RAZER_TYPE_NOMATRIX,
|
||||
RAZER_NUM_TYPES
|
||||
};
|
||||
|
||||
public:
|
||||
RGBController_OpenRazer(device * razer_device, device_fn_type* razer_functions);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
int device_index;
|
||||
|
||||
private:
|
||||
void SetupMatrixDevice(device * razer_device, device_fn_type* razer_functions, unsigned int rows, unsigned int cols);
|
||||
void SetupNonMatrixDevice(device * razer_device, device_fn_type* razer_functions);
|
||||
|
||||
unsigned int matrix_type;
|
||||
unsigned int matrix_rows;
|
||||
unsigned int matrix_cols;
|
||||
|
||||
device* razer_device;
|
||||
device_fn_type* razer_functions;
|
||||
|
||||
//OpenRazer Sysfs Entries for Matrix Devices
|
||||
std::ofstream matrix_custom_frame;
|
||||
std::ofstream matrix_effect_custom;
|
||||
std::ofstream matrix_effect_breath;
|
||||
std::ofstream matrix_effect_none;
|
||||
std::ofstream matrix_effect_reactive;
|
||||
std::ofstream matrix_effect_spectrum;
|
||||
std::ofstream matrix_effect_static;
|
||||
std::ofstream matrix_effect_wave;
|
||||
|
||||
//OpenRazer Sysfs Entries for Non-Matrix Devices
|
||||
std::ofstream logo_led_effect;
|
||||
std::ofstream logo_led_rgb;
|
||||
std::ofstream scroll_led_effect;
|
||||
std::ofstream scroll_led_rgb;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user