1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-23 09:16:11 +00:00

Add FX support for g910

This commit is contained in:
MatMoul 2017-01-04 03:37:33 +01:00
parent 36144826c4
commit 3af632a589
2 changed files with 58 additions and 72 deletions

View File

@ -611,6 +611,27 @@ bool Keyboard::populateAddressGroupInternal(KeyAddressGroup addressGroup, unsign
return true;
}
bool Keyboard::populateFXAddressInternal(unsigned char *data) {
switch (kbdProtocol) {
case KeyboardProtocol::generic:
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3c; // Base address
break;
case KeyboardProtocol::g910:
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x10; // Base address
data[3] = 0x3c; // Base address
break;
default:
return false;
break;
}
return true;
}
bool Keyboard::setKeysInternal(KeyAddressGroup addressGroup, KeyValue keyValues[], size_t keyValueCount) {
bool retval = false;
int data_size;
@ -867,12 +888,9 @@ bool Keyboard::setFXColor(KeyColors colors) {
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3c; // Base address
data[4] = 0x00; // Base address
data[5] = 0x01; // Base address
populateFXAddressInternal(data);
data[4] = 0x00; // Keys
data[5] = 0x01; // Effect
data[6] = colors.red;
data[7] = colors.green;
data[8] = colors.blue;
@ -881,12 +899,9 @@ bool Keyboard::setFXColor(KeyColors colors) {
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3c; // Base address
data[4] = 0x01; // Base address
data[5] = 0x01; // Base address
populateFXAddressInternal(data);
data[4] = 0x01; // Logo
data[5] = 0x01; // Effect
data[6] = colors.red;
data[7] = colors.green;
data[8] = colors.blue;
@ -904,12 +919,9 @@ bool Keyboard::setFXBreathing(KeyColors colors, uint8_t speed) {
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3c; // Base address
data[4] = 0x00; // Base address
data[5] = 0x02; // Base address
populateFXAddressInternal(data);
data[4] = 0x00; // Keys
data[5] = 0x02; // Effect
data[6] = colors.red;
data[7] = colors.green;
data[8] = colors.blue;
@ -921,12 +933,9 @@ bool Keyboard::setFXBreathing(KeyColors colors, uint8_t speed) {
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3c; // Base address
data[4] = 0x01; // Base address
data[5] = 0x02; // Base address
populateFXAddressInternal(data);
data[4] = 0x01; // Logo
data[5] = 0x02; // Effect
data[6] = colors.red;
data[7] = colors.green;
data[8] = colors.blue;
@ -947,12 +956,9 @@ bool Keyboard::setFXColorCycle(uint8_t speed) {
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3c; // Base address
data[4] = 0x00; // Base address
data[5] = 0x03; // Base address
populateFXAddressInternal(data);
data[4] = 0x00; // Keys
data[5] = 0x03; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
@ -966,12 +972,9 @@ bool Keyboard::setFXColorCycle(uint8_t speed) {
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3c; // Base address
data[4] = 0x01; // Base address
data[5] = 0x03; // Base address
populateFXAddressInternal(data);
data[4] = 0x01; // Logo
data[5] = 0x03; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
@ -994,12 +997,9 @@ bool Keyboard::setFXHWave(uint8_t speed) {
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x00; // Base address
data[5] = 0x04; // Base address
populateFXAddressInternal(data);
data[4] = 0x00; // Keys
data[5] = 0x04; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
@ -1014,12 +1014,9 @@ bool Keyboard::setFXHWave(uint8_t speed) {
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x01; // Base address
data[5] = 0x03; // Base address
populateFXAddressInternal(data);
data[4] = 0x01; // Logo
data[5] = 0x03; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
@ -1043,12 +1040,9 @@ bool Keyboard::setFXVWave(uint8_t speed) {
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x00; // Base address
data[5] = 0x04; // Base address
populateFXAddressInternal(data);
data[4] = 0x00; // Keys
data[5] = 0x04; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
@ -1063,12 +1057,9 @@ bool Keyboard::setFXVWave(uint8_t speed) {
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x01; // Base address
data[5] = 0x03; // Base address
populateFXAddressInternal(data);
data[4] = 0x01; // Logo
data[5] = 0x03; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
@ -1092,12 +1083,9 @@ bool Keyboard::setFXCWave(uint8_t speed) {
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x00; // Base address
data[5] = 0x04; // Base address
populateFXAddressInternal(data);
data[4] = 0x00; // Keys
data[5] = 0x04; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
@ -1112,12 +1100,9 @@ bool Keyboard::setFXCWave(uint8_t speed) {
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x01; // Base address
data[5] = 0x03; // Base address
populateFXAddressInternal(data);
data[4] = 0x01; // Logo
data[5] = 0x03; // Effect
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;

View File

@ -70,6 +70,7 @@ class Keyboard {
libusb_context *ctx = NULL;
bool populateAddressGroupInternal(KeyAddressGroup addressGroup, unsigned char *data);
bool populateFXAddressInternal(unsigned char *data);
bool sendDataInternal(unsigned char *data, uint16_t data_size);
bool setKeysInternal(KeyAddressGroup addressGroup, KeyValue keyValues[], size_t keyValueCount);