Add support for mode specific colors in HyperX keyboard breathing mode
This commit is contained in:
parent
ef33d7e2c4
commit
8d0915de6e
3 changed files with 104 additions and 8 deletions
|
|
@ -46,12 +46,48 @@ HyperXKeyboardController::~HyperXKeyboardController()
|
|||
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetMode(unsigned char mode, unsigned char direction, unsigned char speed)
|
||||
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,
|
||||
|
|
@ -59,8 +95,19 @@ void HyperXKeyboardController::SetMode(unsigned char mode, unsigned char directi
|
|||
active_direction,
|
||||
HYPERX_REACTIVE_MODE_NONE,
|
||||
active_speed,
|
||||
HYPERX_COLOR_MODE_SPECTRUM
|
||||
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)
|
||||
|
|
@ -202,7 +249,16 @@ void HyperXKeyboardController::SendEffect
|
|||
unsigned char direction,
|
||||
unsigned char reactive_mode,
|
||||
unsigned char speed,
|
||||
unsigned char color_mode
|
||||
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];
|
||||
|
|
@ -243,6 +299,19 @@ void HyperXKeyboardController::SendEffect
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,14 @@ public:
|
|||
HyperXKeyboardController(hid_device* dev_handle);
|
||||
~HyperXKeyboardController();
|
||||
|
||||
void SetMode(unsigned char mode, unsigned char direction, unsigned char speed);
|
||||
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);
|
||||
|
||||
|
|
@ -90,7 +97,16 @@ private:
|
|||
unsigned char direction,
|
||||
unsigned char reactive_mode,
|
||||
unsigned char speed,
|
||||
unsigned char color_mode
|
||||
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
|
||||
|
|
|
|||
|
|
@ -188,11 +188,14 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
|
|||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HYPERX_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED;
|
||||
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.color_mode = MODE_COLORS_NONE;
|
||||
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);
|
||||
|
|
@ -256,5 +259,13 @@ void RGBController_HyperXKeyboard::SetCustomMode()
|
|||
|
||||
void RGBController_HyperXKeyboard::UpdateMode()
|
||||
{
|
||||
hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue