Split HyperX Alloy FPS and HyperX Alloy Elite into two separate controllers
This commit is contained in:
parent
4026aa488f
commit
98d7224220
10 changed files with 1203 additions and 134 deletions
|
|
@ -0,0 +1,504 @@
|
|||
/*-----------------------------------------*\
|
||||
| HyperXAlloyEliteController.cpp |
|
||||
| |
|
||||
| Driver for HyperX Alloy Elite Keyboard |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "HyperXAlloyEliteController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
|
||||
0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 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 };
|
||||
|
||||
HyperXAlloyEliteController::HyperXAlloyEliteController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
HyperXAlloyEliteController::~HyperXAlloyEliteController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string HyperXAlloyEliteController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string HyperXAlloyEliteController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void HyperXAlloyEliteController::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_ALLOY_ELITE_COLOR_MODE_SPECTRUM;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
color_mode = HYPERX_ALLOY_ELITE_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_ALLOY_ELITE_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_ALLOY_ELITE_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]
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
void HyperXAlloyEliteController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[106];
|
||||
unsigned char grn_color_data[106];
|
||||
unsigned char blu_color_data[106];
|
||||
unsigned char ext_color_data[150];
|
||||
|
||||
for(std::size_t i = 0; i < 106; 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 + 106]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 106]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 106]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirectExtended
|
||||
(
|
||||
ext_color_data
|
||||
);
|
||||
}
|
||||
|
||||
void HyperXAlloyEliteController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[106];
|
||||
unsigned char grn_color_data[106];
|
||||
unsigned char blu_color_data[106];
|
||||
unsigned char ext_color_data[150];
|
||||
|
||||
for(std::size_t i = 0; i < 106; 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 + 106]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 106]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 106]);
|
||||
}
|
||||
|
||||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendExtendedColor
|
||||
(
|
||||
0x01,
|
||||
ext_color_data
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HyperXAlloyEliteController::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 HyperXAlloyEliteController::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_ALLOY_ELITE_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 HyperXAlloyEliteController::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_ALLOY_ELITE_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile;
|
||||
buf[0x03] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 106; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXAlloyEliteController::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_ALLOY_ELITE_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile;
|
||||
buf[0x03] = HYPERX_ALLOY_ELITE_COLOR_CHANNEL_EXTENDED;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0x08; i < 0x94; i++)
|
||||
{
|
||||
buf[i] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXAlloyEliteController::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_ALLOY_ELITE_PACKET_ID_DIRECT;
|
||||
buf[0x02] = color_channel;
|
||||
buf[0x03] = 0xA0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 106; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXAlloyEliteController::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_ALLOY_ELITE_PACKET_ID_DIRECT;
|
||||
buf[0x02] = HYPERX_ALLOY_ELITE_COLOR_CHANNEL_EXTENDED;
|
||||
buf[0x03] = 0xA0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0x08; i < 0x94; i++)
|
||||
{
|
||||
buf[i] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*-----------------------------------------*\
|
||||
| HyperXAlloyEliteController.h |
|
||||
| |
|
||||
| Definitions and types for HyperX Alloy |
|
||||
| Elite Keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_ALLOY_ELITE_PACKET_ID_SET_EFFECT = 0x02, /* Set profile effect packet */
|
||||
HYPERX_ALLOY_ELITE_PACKET_ID_SET_COLOR = 0x06, /* Set profile color packet */
|
||||
HYPERX_ALLOY_ELITE_PACKET_ID_DIRECT = 0x16, /* Direct control packet */
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_ALLOY_ELITE_DIRECTION_RIGHT = 0x00,
|
||||
HYPERX_ALLOY_ELITE_DIRECTION_LEFT = 0x01,
|
||||
HYPERX_ALLOY_ELITE_DIRECTION_UP = 0x02,
|
||||
HYPERX_ALLOY_ELITE_DIRECTION_DOWN = 0x03,
|
||||
HYPERX_ALLOY_ELITE_DIRECTION_IN = 0x04,
|
||||
HYPERX_ALLOY_ELITE_DIRECTION_OUT = 0x05
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_ALLOY_ELITE_MODE_WAVE = 0x00,
|
||||
HYPERX_ALLOY_ELITE_MODE_STATIC = 0x01,
|
||||
HYPERX_ALLOY_ELITE_MODE_BREATHING = 0x02,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_ALLOY_ELITE_REACTIVE_MODE_TRIGGER = 0x03,
|
||||
HYPERX_ALLOY_ELITE_REACTIVE_MODE_EXPLOSION = 0x04,
|
||||
HYPERX_ALLOY_ELITE_REACTIVE_MODE_HYPERX_FLAME = 0x05,
|
||||
HYPERX_ALLOY_ELITE_REACTIVE_MODE_NONE = 0xFF
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_ALLOY_ELITE_COLOR_MODE_SINGLE = 0x00,
|
||||
HYPERX_ALLOY_ELITE_COLOR_MODE_DUAL = 0x01,
|
||||
HYPERX_ALLOY_ELITE_COLOR_MODE_SPECTRUM = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_RED = 0x01,
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_GREEN = 0x02,
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_BLUE = 0x03,
|
||||
HYPERX_ALLOY_ELITE_COLOR_CHANNEL_EXTENDED = 0x04
|
||||
};
|
||||
|
||||
class HyperXAlloyEliteController
|
||||
{
|
||||
public:
|
||||
HyperXAlloyEliteController(hid_device* dev_handle, const char* path);
|
||||
~HyperXAlloyEliteController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
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;
|
||||
std::string location;
|
||||
|
||||
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
|
||||
);
|
||||
};
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
/*-----------------------------------------*\
|
||||
| HyperXKeyboardController.cpp |
|
||||
| HyperXAlloyFPSController.cpp |
|
||||
| |
|
||||
| Driver for HyperX RGB Keyboard lighting |
|
||||
| controller |
|
||||
| Driver for HyperX Alloy FPS Keyboard |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "HyperXKeyboardController.h"
|
||||
#include "HyperXAlloyFPSController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
|
@ -27,23 +27,23 @@ static unsigned int extended_red[] = {0x08, 0x48, 0x88, 0x09, 0x89, 0x0A, 0x8A,
|
|||
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, const char* path)
|
||||
HyperXAlloyFPSController::HyperXAlloyFPSController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
HyperXKeyboardController::~HyperXKeyboardController()
|
||||
HyperXAlloyFPSController::~HyperXAlloyFPSController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string HyperXKeyboardController::GetDeviceLocation()
|
||||
std::string HyperXAlloyFPSController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string HyperXKeyboardController::GetSerialString()
|
||||
std::string HyperXAlloyFPSController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
|
@ -59,7 +59,7 @@ std::string HyperXKeyboardController::GetSerialString()
|
|||
return(return_string);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetMode
|
||||
void HyperXAlloyFPSController::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char direction,
|
||||
|
|
@ -80,18 +80,18 @@ void HyperXKeyboardController::SetMode
|
|||
{
|
||||
default:
|
||||
case 0:
|
||||
color_mode = HYPERX_COLOR_MODE_SPECTRUM;
|
||||
color_mode = HYPERX_ALLOY_FPS_COLOR_MODE_SPECTRUM;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
color_mode = HYPERX_COLOR_MODE_SINGLE;
|
||||
color_mode = HYPERX_ALLOY_FPS_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;
|
||||
color_mode = HYPERX_ALLOY_FPS_COLOR_MODE_DUAL;
|
||||
mode_colors[3] = RGBGetRValue(colors[0]);
|
||||
mode_colors[4] = RGBGetGValue(colors[0]);
|
||||
mode_colors[5] = RGBGetBValue(colors[0]);
|
||||
|
|
@ -106,7 +106,7 @@ void HyperXKeyboardController::SetMode
|
|||
0x01,
|
||||
active_mode,
|
||||
active_direction,
|
||||
HYPERX_REACTIVE_MODE_NONE,
|
||||
HYPERX_ALLOY_FPS_REACTIVE_MODE_NONE,
|
||||
active_speed,
|
||||
color_mode,
|
||||
mode_colors[0],
|
||||
|
|
@ -123,7 +123,7 @@ void HyperXKeyboardController::SetMode
|
|||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
void HyperXAlloyFPSController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[106];
|
||||
unsigned char grn_color_data[106];
|
||||
|
|
@ -146,7 +146,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
|||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_COLOR_CHANNEL_RED,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
|||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_COLOR_CHANNEL_GREEN,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
|||
|
||||
SendDirect
|
||||
(
|
||||
HYPERX_COLOR_CHANNEL_BLUE,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
|||
);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
void HyperXAlloyFPSController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[106];
|
||||
unsigned char grn_color_data[106];
|
||||
|
|
@ -198,7 +198,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
|||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_COLOR_CHANNEL_RED,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
|||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_COLOR_CHANNEL_GREEN,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
|||
SendColor
|
||||
(
|
||||
0x01,
|
||||
HYPERX_COLOR_CHANNEL_BLUE,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
|||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HyperXKeyboardController::SelectProfile
|
||||
void HyperXAlloyFPSController::SelectProfile
|
||||
(
|
||||
unsigned char profile
|
||||
)
|
||||
|
|
@ -261,7 +261,7 @@ void HyperXKeyboardController::SelectProfile
|
|||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendEffect
|
||||
void HyperXAlloyFPSController::SendEffect
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char mode,
|
||||
|
|
@ -291,7 +291,7 @@ void HyperXKeyboardController::SendEffect
|
|||
| Set up Effect packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_SET_EFFECT;
|
||||
buf[0x01] = HYPERX_ALLOY_FPS_PACKET_ID_SET_EFFECT;
|
||||
buf[0x02] = profile;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -363,7 +363,7 @@ void HyperXKeyboardController::SendEffect
|
|||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendColor
|
||||
void HyperXAlloyFPSController::SendColor
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char color_channel,
|
||||
|
|
@ -381,7 +381,7 @@ void HyperXKeyboardController::SendColor
|
|||
| Set up Color packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_SET_COLOR;
|
||||
buf[0x01] = HYPERX_ALLOY_FPS_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile;
|
||||
buf[0x03] = color_channel;
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ void HyperXKeyboardController::SendColor
|
|||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendExtendedColor
|
||||
void HyperXAlloyFPSController::SendExtendedColor
|
||||
(
|
||||
unsigned char profile,
|
||||
unsigned char* color_data
|
||||
|
|
@ -416,9 +416,9 @@ void HyperXKeyboardController::SendExtendedColor
|
|||
| Set up Color packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_SET_COLOR;
|
||||
buf[0x01] = HYPERX_ALLOY_FPS_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile;
|
||||
buf[0x03] = HYPERX_COLOR_CHANNEL_EXTENDED;
|
||||
buf[0x03] = HYPERX_ALLOY_FPS_COLOR_CHANNEL_EXTENDED;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
|
|
@ -434,7 +434,7 @@ void HyperXKeyboardController::SendExtendedColor
|
|||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendDirect
|
||||
void HyperXAlloyFPSController::SendDirect
|
||||
(
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
|
|
@ -451,7 +451,7 @@ void HyperXKeyboardController::SendDirect
|
|||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
|
||||
buf[0x01] = HYPERX_ALLOY_FPS_PACKET_ID_DIRECT;
|
||||
buf[0x02] = color_channel;
|
||||
buf[0x03] = 0xA0;
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ void HyperXKeyboardController::SendDirect
|
|||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SendDirectExtended
|
||||
void HyperXAlloyFPSController::SendDirectExtended
|
||||
(
|
||||
unsigned char* color_data
|
||||
)
|
||||
|
|
@ -485,8 +485,8 @@ void HyperXKeyboardController::SendDirectExtended
|
|||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
|
||||
buf[0x02] = HYPERX_COLOR_CHANNEL_EXTENDED;
|
||||
buf[0x01] = HYPERX_ALLOY_FPS_PACKET_ID_DIRECT;
|
||||
buf[0x02] = HYPERX_ALLOY_FPS_COLOR_CHANNEL_EXTENDED;
|
||||
buf[0x03] = 0xA0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/*-----------------------------------------*\
|
||||
| HyperXKeyboardController.h |
|
||||
| HyperXAlloyFPSController.h |
|
||||
| |
|
||||
| Definitions and types for HyperX RGB |
|
||||
| Keyboard lighting controller |
|
||||
| Definitions and types for HyperX Alloy |
|
||||
| Elite Keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
|
@ -16,57 +16,57 @@
|
|||
|
||||
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 */
|
||||
HYPERX_ALLOY_FPS_PACKET_ID_SET_EFFECT = 0x02, /* Set profile effect packet */
|
||||
HYPERX_ALLOY_FPS_PACKET_ID_SET_COLOR = 0x06, /* Set profile color packet */
|
||||
HYPERX_ALLOY_FPS_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
|
||||
HYPERX_ALLOY_FPS_DIRECTION_RIGHT = 0x00,
|
||||
HYPERX_ALLOY_FPS_DIRECTION_LEFT = 0x01,
|
||||
HYPERX_ALLOY_FPS_DIRECTION_UP = 0x02,
|
||||
HYPERX_ALLOY_FPS_DIRECTION_DOWN = 0x03,
|
||||
HYPERX_ALLOY_FPS_DIRECTION_IN = 0x04,
|
||||
HYPERX_ALLOY_FPS_DIRECTION_OUT = 0x05
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_MODE_WAVE = 0x00,
|
||||
HYPERX_MODE_STATIC = 0x01,
|
||||
HYPERX_MODE_BREATHING = 0x02,
|
||||
HYPERX_ALLOY_FPS_MODE_WAVE = 0x00,
|
||||
HYPERX_ALLOY_FPS_MODE_STATIC = 0x01,
|
||||
HYPERX_ALLOY_FPS_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
|
||||
HYPERX_ALLOY_FPS_REACTIVE_MODE_TRIGGER = 0x03,
|
||||
HYPERX_ALLOY_FPS_REACTIVE_MODE_EXPLOSION = 0x04,
|
||||
HYPERX_ALLOY_FPS_REACTIVE_MODE_HYPERX_FLAME = 0x05,
|
||||
HYPERX_ALLOY_FPS_REACTIVE_MODE_NONE = 0xFF
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_COLOR_MODE_SINGLE = 0x00,
|
||||
HYPERX_COLOR_MODE_DUAL = 0x01,
|
||||
HYPERX_COLOR_MODE_SPECTRUM = 0x02
|
||||
HYPERX_ALLOY_FPS_COLOR_MODE_SINGLE = 0x00,
|
||||
HYPERX_ALLOY_FPS_COLOR_MODE_DUAL = 0x01,
|
||||
HYPERX_ALLOY_FPS_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
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_RED = 0x01,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_GREEN = 0x02,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_BLUE = 0x03,
|
||||
HYPERX_ALLOY_FPS_COLOR_CHANNEL_EXTENDED = 0x04
|
||||
};
|
||||
|
||||
class HyperXKeyboardController
|
||||
class HyperXAlloyFPSController
|
||||
{
|
||||
public:
|
||||
HyperXKeyboardController(hid_device* dev_handle, const char* path);
|
||||
~HyperXKeyboardController();
|
||||
HyperXAlloyFPSController(hid_device* dev_handle, const char* path);
|
||||
~HyperXAlloyFPSController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
#include "Detector.h"
|
||||
#include "HyperXAlloyEliteController.h"
|
||||
#include "HyperXAlloyElite2Controller.h"
|
||||
#include "HyperXAlloyFPSController.h"
|
||||
#include "HyperXAlloyOriginsController.h"
|
||||
#include "HyperXAlloyOriginsCoreController.h"
|
||||
#include "HyperXKeyboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HyperXAlloyElite.h"
|
||||
#include "RGBController_HyperXAlloyElite2.h"
|
||||
#include "RGBController_HyperXAlloyFPS.h"
|
||||
#include "RGBController_HyperXAlloyOrigins.h"
|
||||
#include "RGBController_HyperXAlloyOriginsCore.h"
|
||||
#include "RGBController_HyperXKeyboard.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -20,13 +22,40 @@
|
|||
#define HYPERX_ALLOY_ORIGINS_PID 0x16E5
|
||||
#define HYPERX_ALLOY_ORIGINS_CORE_PID 0x16E6
|
||||
|
||||
void DetectHyperXKeyboards(hid_device_info* info, const std::string& name)
|
||||
void DetectHyperXAlloyElite(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXKeyboardController* controller = new HyperXKeyboardController(dev, info->path);
|
||||
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
|
||||
HyperXAlloyEliteController* controller = new HyperXAlloyEliteController(dev, info->path);
|
||||
RGBController_HyperXAlloyElite* rgb_controller = new RGBController_HyperXAlloyElite(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectHyperXAlloyElite2(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXAlloyElite2Controller* controller = new HyperXAlloyElite2Controller(dev, info->path);
|
||||
RGBController_HyperXAlloyElite2* rgb_controller = new RGBController_HyperXAlloyElite2(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectHyperXAlloyFPS(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXAlloyFPSController* controller = new HyperXAlloyFPSController(dev, info->path);
|
||||
RGBController_HyperXAlloyFPS* rgb_controller = new RGBController_HyperXAlloyFPS(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
|
|
@ -35,9 +64,10 @@ void DetectHyperXKeyboards(hid_device_info* info, const std::string& name)
|
|||
void DetectHyperXAlloyOrigins(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXAlloyOriginsController* controller = new HyperXAlloyOriginsController(dev, info->path);
|
||||
HyperXAlloyOriginsController* controller = new HyperXAlloyOriginsController(dev, info->path);
|
||||
RGBController_HyperXAlloyOrigins* rgb_controller = new RGBController_HyperXAlloyOrigins(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
|
|
@ -47,29 +77,18 @@ void DetectHyperXAlloyOrigins(hid_device_info* info, const std::string& name)
|
|||
void DetectHyperXAlloyOriginsCore(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXAlloyOriginsCoreController* controller = new HyperXAlloyOriginsCoreController(dev, info);
|
||||
HyperXAlloyOriginsCoreController* controller = new HyperXAlloyOriginsCoreController(dev, info);
|
||||
RGBController_HyperXAlloyOriginsCore* rgb_controller = new RGBController_HyperXAlloyOriginsCore(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectHyperXAlloyElite2(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
HyperXAlloyElite2Controller* controller = new HyperXAlloyElite2Controller(dev, info->path);
|
||||
RGBController_HyperXAlloyElite2* rgb_controller = new RGBController_HyperXAlloyElite2(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite RGB", DetectHyperXKeyboards, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("HyperX Alloy FPS RGB", DetectHyperXKeyboards, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_FPS_RGB_PID, 2, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite RGB", DetectHyperXAlloyElite, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("HyperX Alloy FPS RGB", DetectHyperXAlloyFPS, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_FPS_RGB_PID, 2, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins Core", DetectHyperXAlloyOriginsCore, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_CORE_PID, 2);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
|||
|
|
@ -0,0 +1,362 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXAlloyElite.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX Alloy |
|
||||
| Elite Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/2/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_HyperXAlloyElite.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][23] =
|
||||
{ { 0, NA, 16, 30, 44, 54, NA, 65, 75, 84, 95, NA, 8, 23 , 38, 6 , 22, 36, 49, NA, NA, NA, NA },
|
||||
{ 1, 17, 31, 45, 55, 66, 76, 85, 96, 9, 24, NA, 39, 7 , 37, NA , 60, 70, 80, 52, 63, 73, 82 },
|
||||
{ 2, NA, 18, 32, 46, 56, NA, 67, 77, 86, 97, 10, 25, 40 , 90, 101, 50, 61, 71, 51, 62, 72, 93 },
|
||||
{ 3, NA, 19, 33, 47, 57, NA, 68, 78, 87, 98, 11, 26, 41 , 28, 14 , NA, NA, NA, 92, 103, 53, NA },
|
||||
{ 4, 20, 34, 48, 58, 69, NA, 79, NA, 88, 99, 12, 27, 42 , 81, NA , NA, 102, NA, 64, 74, 83, 104 },
|
||||
{ 5, 21, 35, NA, NA, NA, NA, 59, NA, NA, NA, NA, 89, 100, 13, 91 , 15, 29, 43, 94, NA, 105, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
"RGB Strip",
|
||||
"Media Keys"
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
ZONE_TYPE_LINEAR,
|
||||
ZONE_TYPE_SINGLE
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
106,
|
||||
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: Menu",
|
||||
"Key: Enter (ISO)",
|
||||
"Key: Left Arrow",
|
||||
"Key: F1",
|
||||
"Key: 1",
|
||||
"Key: Q",
|
||||
"Key: A",
|
||||
"Key: \\ (ISO)",
|
||||
"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: \\ (ANSI)",
|
||||
"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",
|
||||
"Key: Media Previous",
|
||||
"Key: Media Play/Pause",
|
||||
"Key: Media Next",
|
||||
"Key: Media Mute"
|
||||
};
|
||||
|
||||
RGBController_HyperXAlloyElite::RGBController_HyperXAlloyElite(HyperXAlloyEliteController* hyperx_ptr)
|
||||
{
|
||||
controller = hyperx_ptr;
|
||||
|
||||
name = "HyperX Alloy Elite";
|
||||
vendor = "HyperX";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "HyperX Alloy Elite Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HYPERX_ALLOY_ELITE_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_ALLOY_ELITE_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_ALLOY_ELITE_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_ALLOY_ELITE_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);
|
||||
|
||||
SetupZones();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The HyperX Alloy Elite requires a steady stream of |
|
||||
| packets in order to not revert out of direct mode. |
|
||||
| Start a thread to continuously refresh the device |
|
||||
\*-----------------------------------------------------*/
|
||||
keepalive_thread_run = true;
|
||||
keepalive_thread = new std::thread(&RGBController_HyperXAlloyElite::KeepaliveThreadFunction, this);
|
||||
}
|
||||
|
||||
RGBController_HyperXAlloyElite::~RGBController_HyperXAlloyElite()
|
||||
{
|
||||
keepalive_thread_run = false;
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 3; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 6;
|
||||
new_zone.matrix_map->width = 23;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx];
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::DeviceUpdateLEDs()
|
||||
{
|
||||
last_update_time = std::chrono::steady_clock::now();
|
||||
|
||||
if(active_mode == 0)
|
||||
{
|
||||
controller->SetLEDsDirect(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, modes[active_mode].colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<RGBColor> temp_colors;
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperXAlloyElite::KeepaliveThreadFunction()
|
||||
{
|
||||
while(keepalive_thread_run)
|
||||
{
|
||||
if(active_mode == 0)
|
||||
{
|
||||
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
}
|
||||
std::this_thread::sleep_for(10ms);;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXAlloyElite.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX Alloy |
|
||||
| Elite Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/2/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXAlloyEliteController.h"
|
||||
|
||||
class RGBController_HyperXAlloyElite : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXAlloyElite(HyperXAlloyEliteController* hyperx_ptr);
|
||||
~RGBController_HyperXAlloyElite();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void KeepaliveThreadFunction();
|
||||
|
||||
private:
|
||||
HyperXAlloyEliteController* controller;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::thread* keepalive_thread;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXKeyboard.cpp |
|
||||
| RGBController_HyperXAlloyFPS.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX RGB |
|
||||
| Keyboard |
|
||||
| Generic RGB Interface for HyperX Alloy |
|
||||
| FPS Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/2/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_HyperXKeyboard.h"
|
||||
#include "RGBController_HyperXAlloyFPS.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
|
@ -175,34 +175,34 @@ static const char *led_names[] =
|
|||
"Key: Media Mute"
|
||||
};
|
||||
|
||||
RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardController* hyperx_ptr)
|
||||
RGBController_HyperXAlloyFPS::RGBController_HyperXAlloyFPS(HyperXAlloyFPSController* hyperx_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
controller = hyperx_ptr;
|
||||
|
||||
name = "HyperX RGB Keyboard";
|
||||
name = "HyperX Alloy FPS";
|
||||
vendor = "HyperX";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "HyperX RGB Keyboard Device";
|
||||
location = hyperx->GetDeviceLocation();
|
||||
serial = hyperx->GetSerialString();
|
||||
description = "HyperX Alloy FPS Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HYPERX_MODE_STATIC;
|
||||
Direct.value = HYPERX_ALLOY_FPS_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.value = HYPERX_ALLOY_FPS_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.value = HYPERX_ALLOY_FPS_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.speed_min = 0x00;
|
||||
Wave.speed_max = 0x09;
|
||||
|
|
@ -213,7 +213,7 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
|
|||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HYPERX_MODE_BREATHING;
|
||||
Breathing.value = HYPERX_ALLOY_FPS_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;
|
||||
|
|
@ -227,16 +227,15 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
|
|||
SetupZones();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| 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 |
|
||||
| The HyperX Alloy FPS requires a steady stream of |
|
||||
| packets in order to not revert out of direct mode. |
|
||||
| Start a thread to continuously refresh the device |
|
||||
\*-----------------------------------------------------*/
|
||||
keepalive_thread_run = true;
|
||||
keepalive_thread = new std::thread(&RGBController_HyperXKeyboard::KeepaliveThreadFunction, this);
|
||||
keepalive_thread = new std::thread(&RGBController_HyperXAlloyFPS::KeepaliveThreadFunction, this);
|
||||
}
|
||||
|
||||
RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard()
|
||||
RGBController_HyperXAlloyFPS::~RGBController_HyperXAlloyFPS()
|
||||
{
|
||||
keepalive_thread_run = false;
|
||||
keepalive_thread->join();
|
||||
|
|
@ -253,10 +252,10 @@ RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard()
|
|||
}
|
||||
}
|
||||
|
||||
delete hyperx;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::SetupZones()
|
||||
void RGBController_HyperXAlloyFPS::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
|
|
@ -298,56 +297,56 @@ void RGBController_HyperXKeyboard::SetupZones()
|
|||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
void RGBController_HyperXAlloyFPS::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::DeviceUpdateLEDs()
|
||||
void RGBController_HyperXAlloyFPS::DeviceUpdateLEDs()
|
||||
{
|
||||
last_update_time = std::chrono::steady_clock::now();
|
||||
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SetLEDsDirect(colors);
|
||||
controller->SetLEDsDirect(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
hyperx->SetLEDs(colors);
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_HyperXAlloyFPS::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_HyperXAlloyFPS::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::SetCustomMode()
|
||||
void RGBController_HyperXAlloyFPS::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::DeviceUpdateMode()
|
||||
void RGBController_HyperXAlloyFPS::DeviceUpdateMode()
|
||||
{
|
||||
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);
|
||||
controller->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);
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::KeepaliveThreadFunction()
|
||||
void RGBController_HyperXAlloyFPS::KeepaliveThreadFunction()
|
||||
{
|
||||
while(keepalive_thread_run)
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXKeyboard.h |
|
||||
| RGBController_HyperXAlloyFPS.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX RGB |
|
||||
| Keyboard |
|
||||
| Generic RGB Interface for HyperX Alloy |
|
||||
| FPS Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/2/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
|
@ -13,13 +13,13 @@
|
|||
#include <thread>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXKeyboardController.h"
|
||||
#include "HyperXAlloyFPSController.h"
|
||||
|
||||
class RGBController_HyperXKeyboard : public RGBController
|
||||
class RGBController_HyperXAlloyFPS : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXKeyboard(HyperXKeyboardController* hyperx_ptr);
|
||||
~RGBController_HyperXKeyboard();
|
||||
RGBController_HyperXAlloyFPS(HyperXAlloyFPSController* hyperx_ptr);
|
||||
~RGBController_HyperXAlloyFPS();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
|
|
@ -35,8 +35,8 @@ public:
|
|||
void KeepaliveThreadFunction();
|
||||
|
||||
private:
|
||||
HyperXKeyboardController* hyperx;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::thread* keepalive_thread;
|
||||
HyperXAlloyFPSController* controller;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::thread* keepalive_thread;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue