Compare commits
145
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13414ec9b8 | ||
|
|
74faee0f73 | ||
|
|
3f0027aa90 | ||
|
|
d22aa1ed6c | ||
|
|
23d51f65d0 | ||
|
|
cad356efca | ||
|
|
70e83c13cc | ||
|
|
7ca0a1b6ab | ||
|
|
9bd5536d07 | ||
|
|
eaa3b9a368 | ||
|
|
599c468de8 | ||
|
|
9f21814395 | ||
|
|
cb8a551683 | ||
|
|
7f1156d81c | ||
|
|
5beee08166 | ||
|
|
1334129078 | ||
|
|
216b492f24 | ||
|
|
1b65bb9cc3 | ||
|
|
0f4ddd164f | ||
|
|
e6aadc414b | ||
|
|
883a78ad9d | ||
|
|
15d23d3009 | ||
|
|
e2c2b8c1df | ||
|
|
5133c30242 | ||
|
|
69e1e19bf9 | ||
|
|
46f08f7423 | ||
|
|
352b9928ca | ||
|
|
87854d5781 | ||
|
|
1b3f8f9eb4 | ||
|
|
6438c15dd3 | ||
|
|
dbe29991f0 | ||
|
|
a5e9a3de05 | ||
|
|
edf1b251c0 | ||
|
|
9ff4314840 | ||
|
|
3ad0986ae7 | ||
|
|
6bfc9dd9db | ||
|
|
9b8a0d465e | ||
|
|
119741b736 | ||
|
|
2fe958783c | ||
|
|
1c59ef6b80 | ||
|
|
9e44e4ba4f | ||
|
|
b8e14ea067 | ||
|
|
525071c205 | ||
|
|
bfe03b0564 | ||
|
|
04b87ce2eb | ||
|
|
81acc47cd6 | ||
|
|
6e426b1403 | ||
|
|
6509e53a9b | ||
|
|
5b42b3d11d | ||
|
|
8bd515296d | ||
|
|
2bbf66c0ee | ||
|
|
d716973642 | ||
|
|
25f7a87a79 | ||
|
|
0619a16be2 | ||
|
|
4a3802f344 | ||
|
|
105f5642ef | ||
|
|
54ab57cea6 | ||
|
|
e3e6c0347e | ||
|
|
4d6706ce61 | ||
|
|
39c5aff864 | ||
|
|
450f438538 | ||
|
|
0270c745ce | ||
|
|
e2dfcd5b0f | ||
|
|
68fa3c2def | ||
|
|
cde7469191 | ||
|
|
7c1a1396ca | ||
|
|
7f052f21aa | ||
|
|
dff667751b | ||
|
|
2625807c1a | ||
|
|
7af283fdbf | ||
|
|
c7ffe3b926 | ||
|
|
46339c5f86 | ||
|
|
cf69598fd1 | ||
|
|
594f66ab23 | ||
|
|
01e0808e41 | ||
|
|
2dc443ff1e | ||
|
|
0ab0586dfa | ||
|
|
88fa6bf25a | ||
|
|
9346490e4a | ||
|
|
7d4e5d6122 | ||
|
|
d4a03b23c8 | ||
|
|
47b5c94310 | ||
|
|
079a984f8d | ||
|
|
b6e35c4155 | ||
|
|
c9d1ac5d8f | ||
|
|
427c635ed8 | ||
|
|
0703bcd0a8 | ||
|
|
984c6bb7f5 | ||
|
|
d27095dacd | ||
|
|
9228b5c4cd | ||
|
|
7fe87703e5 | ||
|
|
c65edbeebc | ||
|
|
b6bf34279c | ||
|
|
68e444aa3b | ||
|
|
3d12930067 | ||
|
|
3de7f32a3a | ||
|
|
216fe063e0 | ||
|
|
ef6195271e | ||
|
|
86eb273e46 | ||
|
|
22813c06dc | ||
|
|
9840f0a8b6 | ||
|
|
69539432b5 | ||
|
|
4433760cab | ||
|
|
ba2ce98a3e | ||
|
|
1e171fcfb0 | ||
|
|
dc88b1a752 | ||
|
|
3f2a118a39 | ||
|
|
b8c80e6ba5 | ||
|
|
405bbc5464 | ||
|
|
5371fe1cc2 | ||
|
|
cdce79bd07 | ||
|
|
87395d0b0d | ||
|
|
7050a0dac1 | ||
|
|
bc01b53de5 | ||
|
|
680c143ad7 | ||
|
|
38c3f2d94c | ||
|
|
5344806a85 | ||
|
|
21f29a1a56 | ||
|
|
c5149b2521 | ||
|
|
f9a25c9612 | ||
|
|
4b4d3bf790 | ||
|
|
3a11ed4e43 | ||
|
|
238dc0f0ae | ||
|
|
0568fc5ed2 | ||
|
|
37241ee6f2 | ||
|
|
1f91dd227f | ||
|
|
facfa05062 | ||
|
|
6fd6c7f176 | ||
|
|
d947cc2499 | ||
|
|
5db52e5dc2 | ||
|
|
1249814e93 | ||
|
|
dda8e9470f | ||
|
|
72482d4ff9 | ||
|
|
a50049e63b | ||
|
|
2970e56324 | ||
|
|
aa1ad8db85 | ||
|
|
7f865cfee9 | ||
|
|
c7b9fe90a6 | ||
|
|
0c7009b973 | ||
|
|
d791361f22 | ||
|
|
5719956441 | ||
|
|
eba9fc0213 | ||
|
|
556fb634bb | ||
|
|
e39617a665 | ||
|
|
9f6c3819bd |
@@ -1,6 +1,3 @@
|
||||
[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
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraCoreController.cpp |
|
||||
| |
|
||||
| Driver for ASUS ROG Aura Core RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraCoreController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraCoreController::AuraCoreController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
AuraCoreController::~AuraCoreController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AuraCoreController::SendBrightness
|
||||
(
|
||||
unsigned char brightness
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5A;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_BRIGHTNESS;
|
||||
usb_buf[0x02] = 0xC5;
|
||||
usb_buf[0x03] = 0xC4;
|
||||
usb_buf[0x04] = brightness;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_UPDATE;
|
||||
usb_buf[0x02] = zone;
|
||||
usb_buf[0x03] = mode;
|
||||
usb_buf[0x04] = red;
|
||||
usb_buf[0x05] = green;
|
||||
usb_buf[0x06] = blue;
|
||||
usb_buf[0x07] = speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendSet()
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_SET;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendApply()
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_APPLY;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraCoreController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS ROG Aura |
|
||||
| Core RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_MODE_STATIC = 0, /* Static color mode */
|
||||
AURA_CORE_MODE_BREATHING = 1, /* Breathing effect mode */
|
||||
AURA_CORE_MODE_SPECTRUM_CYCLE = 2, /* Spectrum Cycle mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_COMMAND_UPDATE = 0xB3, /* Update mode and color */
|
||||
AURA_CORE_COMMAND_SET = 0xB5, /* Set command */
|
||||
AURA_CORE_COMMAND_APPLY = 0xB4, /* Apply command */
|
||||
AURA_CORE_COMMAND_BRIGHTNESS = 0xBA, /* Brightness command */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_ZONE_IDX_ALL = 0x00, /* Update all zones */
|
||||
AURA_CORE_ZONE_IDX_1 = 0x01, /* Update zone 1 */
|
||||
AURA_CORE_ZONE_IDX_2 = 0x02, /* Update zone 2 */
|
||||
AURA_CORE_ZONE_IDX_3 = 0x03, /* Update zone 3 */
|
||||
AURA_CORE_ZONE_IDX_4 = 0x04, /* Update zone 4 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_SPEED_SLOW = 0xE1, /* Slowest speed */
|
||||
AURA_CORE_SPEED_NORMAL = 0xEB, /* Normal speed */
|
||||
AURA_CORE_SPEED_FAST = 0xF5, /* Fastest speed */
|
||||
};
|
||||
|
||||
class AuraCoreController
|
||||
{
|
||||
public:
|
||||
AuraCoreController(hid_device* dev_handle);
|
||||
~AuraCoreController();
|
||||
|
||||
void SendBrightness
|
||||
(
|
||||
unsigned char brightness
|
||||
);
|
||||
|
||||
void SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendSet();
|
||||
|
||||
void SendApply();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "AuraCoreController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraCore.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_CORE_VID 0x0B05
|
||||
|
||||
#define NUM_PIDS 3
|
||||
static const unsigned short pid_table[] =
|
||||
{
|
||||
0x1854,
|
||||
0x1869,
|
||||
0x1866
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraCoreControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus ROG Aura Core controller exists there *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraCoreControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for Asus ROG Aura Core RGB controller
|
||||
hid_init();
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_CORE_VID, pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraCoreController* controller = new AuraCoreController(dev);
|
||||
|
||||
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,14 +51,13 @@ static const unsigned char aura_ram_addresses[] =
|
||||
/*---------------------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura motherboards |
|
||||
\*---------------------------------------------------------------------------------*/
|
||||
#define AURA_MOBO_ADDRESS_COUNT 4
|
||||
#define AURA_MOBO_ADDRESS_COUNT 3
|
||||
|
||||
static const unsigned char aura_mobo_addresses[] =
|
||||
{
|
||||
0x40,
|
||||
0x4E,
|
||||
0x4F,
|
||||
0x66
|
||||
0x4F
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraAddressableController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB Addressable |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraAddressableController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraAddressableController::AuraAddressableController(hid_device* dev_handle) : AuraUSBController(dev_handle)
|
||||
{
|
||||
channel_count = config_table[2];
|
||||
}
|
||||
|
||||
AuraAddressableController::~AuraAddressableController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendDirectApply(channel);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
SendEffect
|
||||
(
|
||||
channel,
|
||||
mode,
|
||||
red,
|
||||
grn,
|
||||
blu
|
||||
);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_ADDRESSABLE_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x05] = red;
|
||||
usb_buf[0x06] = grn;
|
||||
usb_buf[0x07] = blu;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_ADDRESSABLE_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = device;
|
||||
usb_buf[0x03] = start_led;
|
||||
usb_buf[0x04] = led_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], led_data, led_count * 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_ADDRESSABLE_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = 0x80 | channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraAddressableController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| Addressable RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_ADDRESSABLE_CONTROL_MODE_EFFECT = 0x3B, /* Effect control mode */
|
||||
AURA_ADDRESSABLE_CONTROL_MODE_DIRECT = 0x40, /* Direct control mode */
|
||||
};
|
||||
|
||||
class AuraAddressableController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraAddressableController(hid_device* dev_handle);
|
||||
~AuraAddressableController();
|
||||
|
||||
void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
);
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
);
|
||||
|
||||
void SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,176 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraMainboardController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB mainboard |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraMainboardController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraMainboardController::AuraMainboardController(hid_device* dev_handle) : AuraUSBController(dev_handle), mode(AURA_MODE_DIRECT)
|
||||
{
|
||||
channel_count = 5;
|
||||
}
|
||||
|
||||
AuraMainboardController::~AuraMainboardController()
|
||||
{
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
SendEffect(channel, mode);
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
this->mode = mode;
|
||||
unsigned char led_data[3];
|
||||
led_data[0] = red;
|
||||
led_data[1] = grn;
|
||||
led_data[2] = blu;
|
||||
|
||||
SendEffect
|
||||
(
|
||||
channel,
|
||||
mode
|
||||
);
|
||||
SendDirect
|
||||
(
|
||||
channel,
|
||||
0,
|
||||
1,
|
||||
led_data
|
||||
);
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
if(mode == AURA_MODE_DIRECT) {
|
||||
mode = AURA_MODE_STATIC;
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = channel;
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = start_led;
|
||||
usb_buf[0x03] = 0xff;
|
||||
usb_buf[0x04] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], led_data, led_count * 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendCommit()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_COMMIT;
|
||||
usb_buf[0x02] = 0x55;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraMainboardController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB Mainboard RGB lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MAINBOARD_CONTROL_MODE_EFFECT = 0x35, /* Effect control mode */
|
||||
AURA_MAINBOARD_CONTROL_MODE_DIRECT = 0x36, /* Direct control mode */
|
||||
AURA_MAINBOARD_CONTROL_MODE_COMMIT = 0x3F, /* Direct control mode */
|
||||
};
|
||||
|
||||
class AuraMainboardController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraMainboardController(hid_device* dev_handle);
|
||||
~AuraMainboardController();
|
||||
|
||||
void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
);
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
unsigned int mode;
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode
|
||||
);
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
};
|
||||
@@ -0,0 +1,104 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraUSBController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraUSBController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraUSBController::AuraUSBController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
GetFirmwareVersion();
|
||||
GetConfigTable();
|
||||
}
|
||||
|
||||
AuraUSBController::~AuraUSBController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int AuraUSBController::GetChannelCount()
|
||||
{
|
||||
return( channel_count );
|
||||
}
|
||||
|
||||
std::string AuraUSBController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
void AuraUSBController::GetConfigTable()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_CONFIG_TABLE;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x30)
|
||||
{
|
||||
memcpy(config_table, &usb_buf[4], 60);
|
||||
|
||||
for(int i = 0; i < 60; i+=6)
|
||||
{
|
||||
printf("%02X %02X %02X %02X %02X %02X\r\n", config_table[i + 0],
|
||||
config_table[i + 1],
|
||||
config_table[i + 2],
|
||||
config_table[i + 3],
|
||||
config_table[i + 4],
|
||||
config_table[i + 5]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuraUSBController::GetFirmwareVersion()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up firmware version request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_FIRMWARE_VERSION;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x02)
|
||||
{
|
||||
memcpy(device_name, &usb_buf[2], 16);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraUSBController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB RGB lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MODE_OFF = 0, /* OFF mode */
|
||||
AURA_MODE_STATIC = 1, /* Static color mode */
|
||||
AURA_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
AURA_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
AURA_MODE_RAINBOW = 5, /* Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_BREATHING = 6, /* Rainbow Breathing effect mode */
|
||||
AURA_MODE_CHASE_FADE = 7, /* Chase with Fade effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE = 8, /* Chase with Fade, Rainbow effect mode */
|
||||
AURA_MODE_CHASE = 9, /* Chase effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE = 10, /* Chase with Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
|
||||
AURA_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
AURA_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
AURA_MODE_MUSIC = 14, /* Music effect mode */
|
||||
AURA_MODE_DIRECT = 0xFF, /* Direct control mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_REQUEST_FIRMWARE_VERSION = 0x82, /* Request firmware string */
|
||||
AURA_REQUEST_CONFIG_TABLE = 0xB0, /* Request configuration table */
|
||||
};
|
||||
|
||||
class AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraUSBController(hid_device* dev_handle);
|
||||
virtual ~AuraUSBController();
|
||||
|
||||
unsigned int GetChannelCount();
|
||||
|
||||
std::string GetDeviceName();
|
||||
|
||||
virtual void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
) = 0;
|
||||
|
||||
virtual void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
) = 0;
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
unsigned int channel_count;
|
||||
unsigned char config_table[60];
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
unsigned int led_count;
|
||||
|
||||
void GetConfigTable();
|
||||
|
||||
void GetFirmwareVersion();
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "AuraAddressableController.h"
|
||||
#include "AuraMainboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraUSB.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_USB_VID 0x0B05
|
||||
|
||||
#define NUM_ADDRESSABLE_PIDS 4
|
||||
static const unsigned short addressable_pid_table[] =
|
||||
{
|
||||
0x1867,
|
||||
0x1872,
|
||||
0x1889,
|
||||
0x18A3
|
||||
};
|
||||
|
||||
#define NUM_MAINBOARD_PIDS 1
|
||||
static const unsigned short mainboard_pid_table[] =
|
||||
{
|
||||
0x18f3
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraUSBControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus Aura USB RGB header controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraUSBControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for Asus Aura addressable RGB header controller
|
||||
hid_init();
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_ADDRESSABLE_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_USB_VID, addressable_pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraAddressableController* controller = new AuraAddressableController(dev);
|
||||
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_MAINBOARD_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_USB_VID, mainboard_pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraMainboardController* controller = new AuraMainboardController(dev);
|
||||
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMMP750Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 16th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMMP750Controller.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
CMMP750Controller::CMMP750Controller(libusb_device_handle* dev_handle, unsigned int _inAddr, unsigned int _outAddr, int _interface)
|
||||
{
|
||||
dev = dev_handle;
|
||||
inAddr = _inAddr;
|
||||
outAddr = _outAddr;
|
||||
interface = _interface;
|
||||
|
||||
libusb_device* device = libusb_get_device(dev);
|
||||
int bus = libusb_get_bus_number(device);
|
||||
int bus_addr = libusb_get_device_address(device);
|
||||
int port = libusb_get_port_number(device);
|
||||
location = "Bus: " + std::to_string(bus) + " Addr: " + std::to_string(bus_addr) + " Port: " + std::to_string(port);
|
||||
|
||||
strcpy(device_name, "Cooler Master MP750");
|
||||
|
||||
current_mode = MP750_MODE_STATIC;
|
||||
current_speed = MP750_SPEED_NORMAL;
|
||||
}
|
||||
|
||||
CMMP750Controller::~CMMP750Controller()
|
||||
{
|
||||
libusb_release_interface(dev, interface);
|
||||
libusb_attach_kernel_driver(dev, interface);
|
||||
}
|
||||
|
||||
char* CMMP750Controller::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
char* CMMP750Controller::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string CMMP750Controller::GetLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
void CMMP750Controller::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMMP750Controller::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
current_red = red;
|
||||
current_green = green;
|
||||
current_blue = blue;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMMP750Controller::SendUpdate()
|
||||
{
|
||||
int actual = 0;
|
||||
unsigned char buffer[0x40] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
for(int i = 0; i < CM_COLOUR_MODE_DATA_SIZE; i++)
|
||||
{
|
||||
buffer[i] = colour_mode_data[current_mode][i];
|
||||
}
|
||||
|
||||
if(current_mode > MP750_MODE_BREATHING)
|
||||
{
|
||||
//If the mode is random colours set SPEED at BYTE2
|
||||
buffer[CM_RED_BYTE] = speed_mode_data[current_mode][current_speed];
|
||||
}
|
||||
else
|
||||
{
|
||||
//Otherwise SPEED is BYTE5
|
||||
buffer[CM_RED_BYTE] = current_red;
|
||||
buffer[CM_GREEN_BYTE] = current_green;
|
||||
buffer[CM_BLUE_BYTE] = current_blue;
|
||||
buffer[CM_SPEED_BYTE] = speed_mode_data[current_mode][current_speed];
|
||||
}
|
||||
|
||||
//Nothing will be done with the "actual" transfer length
|
||||
libusb_interrupt_transfer(dev, outAddr, buffer, buffer_size, nullptr, CM_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMMP750Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 16th Apr 2020 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| BYTE0 = Mode (0x01 thru 0x05 |
|
||||
| BYTE1 = ?? Must be set to 0x04 for colour modes otherwise ignored |
|
||||
| BYTE2 = Colour Modes: RED else Cycle SPEED |
|
||||
| BYTE3 = Colour Modes: GREEN else ignored |
|
||||
| BYTE4 = Colour Modes: BLUE else ignored |
|
||||
| BYTE5 = Colour Modes: SPEED else ignored |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data) / sizeof(colour_mode_data[0]))
|
||||
#define CM_INTERRUPT_TIMEOUT 250
|
||||
|
||||
enum
|
||||
{
|
||||
CM_MODE_BYTE = 0,
|
||||
CM_RED_BYTE = 2,
|
||||
CM_GREEN_BYTE = 3,
|
||||
CM_BLUE_BYTE = 4,
|
||||
CM_SPEED_BYTE = 5
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MP750_MODE_STATIC = 0x00, //Static Mode
|
||||
MP750_MODE_BLINK = 0x01, //Blinking Mode
|
||||
MP750_MODE_BREATHING = 0x02, //Breathing Mode
|
||||
MP750_MODE_COLOR_CYCLE = 0x03, //Color Cycle Mode
|
||||
MP750_MODE_BREATH_CYCLE = 0x04 //Breathing Cycle Mode
|
||||
};
|
||||
|
||||
static unsigned char colour_mode_data[][6] =
|
||||
{
|
||||
{ 0x01, 0x04, 0xFF, 0x00, 0xFF, 0x00 }, /* Static */
|
||||
{ 0x02, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Blinking */
|
||||
{ 0x03, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Breathing */
|
||||
{ 0x04, 0x04, 0x80, 0x00, 0x00, 0x00 }, /* Colour Cycle */
|
||||
{ 0x05, 0x04, 0x80, 0x00, 0x00, 0x00 } /* Colour Breath */
|
||||
};
|
||||
|
||||
static unsigned char speed_mode_data[][9] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },/* Static */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Blinking */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Breathing */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Colour Cycle */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF } /* Colour Breath */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MP750_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
MP750_SPEED_SLOWER = 0x01, /* Slower speed */
|
||||
MP750_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
MP750_SPEED_SLOWISH = 0x03, /* Slowish speed */
|
||||
MP750_SPEED_NORMAL = 0x04, /* Normal speed */
|
||||
MP750_SPEED_FASTISH = 0x05, /* Fastish speed */
|
||||
MP750_SPEED_FAST = 0x06, /* Fast speed */
|
||||
MP750_SPEED_FASTER = 0x07, /* Faster speed */
|
||||
MP750_SPEED_FASTEST = 0x08, /* Fastest speed */
|
||||
};
|
||||
|
||||
class CMMP750Controller
|
||||
{
|
||||
public:
|
||||
CMMP750Controller(libusb_device_handle *dev_handle, unsigned int _inAddr, unsigned int _outAddr, int _interface);
|
||||
~CMMP750Controller();
|
||||
|
||||
char* GetDeviceName();
|
||||
char* GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
char serial[32];
|
||||
std::string location;
|
||||
libusb_device_handle* dev;
|
||||
unsigned char inAddr;
|
||||
unsigned char outAddr;
|
||||
int interface;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
|
||||
void SendUpdate();
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "CMMP750Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define COOLERMASTER_VID 0x2516
|
||||
|
||||
#define COOLERMASTER_NUM_DEVICES (sizeof(cm_pids) / sizeof(cm_pids[ 0 ]))
|
||||
|
||||
enum
|
||||
{
|
||||
CM_PID = 0,
|
||||
CM_INADDR = 1,
|
||||
CM_OUTADDR = 2,
|
||||
CM_INTERFACE = 3
|
||||
};
|
||||
|
||||
static const unsigned int cm_pids[][4] =
|
||||
{ //PID, inAddr, outAddr, interface
|
||||
{ 0x0109, 0x82, 0x03, 0x00 } //Coolermaster MP750
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCoolerMasterControllers *
|
||||
* *
|
||||
* Tests the USB address to see if any CoolerMaster controllers exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * context;
|
||||
libusb_init(&context);
|
||||
|
||||
for(int cm_pid_idx = 0; cm_pid_idx < COOLERMASTER_NUM_DEVICES; cm_pid_idx++)
|
||||
{
|
||||
//Look for the passed in cm_pids
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(context, COOLERMASTER_VID, cm_pids[cm_pid_idx][CM_PID]);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
int status = libusb_detach_kernel_driver(dev, cm_pids[cm_pid_idx][CM_INTERFACE]);
|
||||
status = libusb_claim_interface(dev, cm_pids[cm_pid_idx][CM_INTERFACE]);
|
||||
|
||||
if(status == 0)
|
||||
{
|
||||
// Success: Device has been claimed
|
||||
CMMP750Controller* controller = new CMMP750Controller(dev, cm_pids[cm_pid_idx][CM_INADDR], cm_pids[cm_pid_idx][CM_OUTADDR], cm_pids[cm_pid_idx][CM_INTERFACE]);
|
||||
RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -151,8 +151,12 @@ void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
|
||||
|
||||
void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char color_data[50];
|
||||
unsigned char pkt_max;
|
||||
unsigned char red_color_data[50];
|
||||
unsigned char grn_color_data[50];
|
||||
unsigned char blu_color_data[50];
|
||||
unsigned char pkt_offset = 0;
|
||||
unsigned char pkt_size = 0;
|
||||
unsigned int colors_remaining = num_colors;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Port State packet |
|
||||
@@ -160,114 +164,32 @@ void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBCol
|
||||
SendPortState(channel, CORSAIR_LIGHTING_NODE_PORT_STATE_SOFTWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 1 |
|
||||
| Loop through colors and send 50 at a time |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > num_colors)
|
||||
while(colors_remaining > 0)
|
||||
{
|
||||
pkt_max = (unsigned char)num_colors;
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (num_colors > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(num_colors - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
if(colors_remaining < 50)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx+50]);
|
||||
pkt_size = colors_remaining;
|
||||
}
|
||||
else
|
||||
{
|
||||
pkt_size = 50;
|
||||
}
|
||||
|
||||
for(int color_idx = 0; color_idx < pkt_size; color_idx++)
|
||||
{
|
||||
red_color_data[color_idx] = RGBGetRValue(colors[pkt_offset + color_idx]);
|
||||
grn_color_data[color_idx] = RGBGetGValue(colors[pkt_offset + color_idx]);
|
||||
blu_color_data[color_idx] = RGBGetBValue(colors[pkt_offset + color_idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, color_data);
|
||||
}
|
||||
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, red_color_data);
|
||||
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, grn_color_data);
|
||||
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, blu_color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > num_colors)
|
||||
{
|
||||
pkt_max = (unsigned char)num_colors;
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (num_colors > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(num_colors - 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_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > num_colors)
|
||||
{
|
||||
pkt_max = (unsigned char)num_colors;
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (num_colors > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(num_colors - 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_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, color_data);
|
||||
colors_remaining -= pkt_size;
|
||||
pkt_offset += pkt_size;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
||||
@@ -11,6 +11,17 @@
|
||||
|
||||
#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[] = {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,
|
||||
@@ -30,6 +41,8 @@ static void send_usb_msg(hid_device* dev, char * data_pkt)
|
||||
}
|
||||
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
|
||||
bytes++;
|
||||
|
||||
Sleep(2);
|
||||
}
|
||||
|
||||
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
/*-----------------------------------------*\
|
||||
| MSIMysticLightController.cpp |
|
||||
| |
|
||||
| Driver for MSI Mystic Light USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| T-bond 3/4/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "MSIMysticLightController.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
|
||||
MSIMysticLightController::MSIMysticLightController(hid_device* handle, const char *path)
|
||||
{
|
||||
dev = handle;
|
||||
|
||||
if(dev)
|
||||
{
|
||||
loc = path;
|
||||
|
||||
ReadName();
|
||||
ReadSerial();
|
||||
ReadFwVersion();
|
||||
ReadSettings();
|
||||
}
|
||||
}
|
||||
|
||||
MSIMysticLightController::~MSIMysticLightController()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int MSIMysticLightController::GetZoneMinLedCount(ZONE /*zone*/)
|
||||
{
|
||||
return 1u;
|
||||
}
|
||||
|
||||
unsigned int MSIMysticLightController::GetZoneMaxLedCount(ZONE zone)
|
||||
{
|
||||
switch (zone)
|
||||
{
|
||||
case J_RAINBOW_1:
|
||||
case J_RAINBOW_2:
|
||||
case J_CORSAIR:
|
||||
return 4u; // TODO: It can be different by zone and by mobo
|
||||
default:
|
||||
return 1u;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int MSIMysticLightController::GetZoneLedCount(ZONE zone)
|
||||
{
|
||||
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
|
||||
|
||||
if (!requestedZone)
|
||||
{
|
||||
return GetZoneMaxLedCount(zone);
|
||||
}
|
||||
|
||||
return requestedZone->cycle_or_led_num;
|
||||
}
|
||||
|
||||
void MSIMysticLightController::SetZoneLedCount(ZONE zone, unsigned int led_count)
|
||||
{
|
||||
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
|
||||
|
||||
if (!requestedZone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
led_count = std::min(GetZoneMaxLedCount(zone), std::max(GetZoneMinLedCount(zone), led_count));
|
||||
requestedZone->cycle_or_led_num = led_count;
|
||||
}
|
||||
|
||||
void MSIMysticLightController::SetMode(ZONE zone, EFFECT mode, SPEED speed, BRIGHTNESS brightness, bool rainbow_color)
|
||||
{
|
||||
ZoneData* zoneData = GetZoneData(zone);
|
||||
if(!zoneData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
zoneData->effect = mode;
|
||||
zoneData->speedAndBrightnessFlags = (zoneData->speedAndBrightnessFlags & 128u) | brightness << 2u | speed;
|
||||
zoneData->colorFlags = BitSet(zoneData->colorFlags, !rainbow_color, 7u);
|
||||
}
|
||||
|
||||
std::string MSIMysticLightController::GetDeviceName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string MSIMysticLightController::GetFWVersion()
|
||||
{
|
||||
return std::string("AP/LD ").append(version_APROM).append(" / ").append(version_LDROM);
|
||||
}
|
||||
|
||||
std::string MSIMysticLightController::GetDeviceLocation()
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
std::string MSIMysticLightController::GetSerial()
|
||||
{
|
||||
return chip_id;
|
||||
}
|
||||
|
||||
bool MSIMysticLightController::ReadSettings()
|
||||
{
|
||||
return hid_get_feature_report(dev, reinterpret_cast<unsigned char *>(&data), sizeof data) == sizeof data;
|
||||
}
|
||||
|
||||
bool MSIMysticLightController::Update()
|
||||
{
|
||||
return hid_send_feature_report(dev, reinterpret_cast<unsigned char *>(&data), sizeof data) == sizeof data;
|
||||
}
|
||||
|
||||
void MSIMysticLightController::SaveOnUpdate(bool save)
|
||||
{
|
||||
data.save_data = save;
|
||||
}
|
||||
|
||||
void MSIMysticLightController::SetZoneColor(ZONE zone, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2)
|
||||
{
|
||||
ZoneData* zoneData = GetZoneData(zone);
|
||||
if(!zoneData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
zoneData->color.R = r1;
|
||||
zoneData->color.G = g1;
|
||||
zoneData->color.B = b1;
|
||||
|
||||
zoneData->color2.R = r2;
|
||||
zoneData->color2.G = g2;
|
||||
zoneData->color2.B = b2;
|
||||
}
|
||||
|
||||
std::pair<Color, Color> MSIMysticLightController::GetZoneColor(ZONE zone)
|
||||
{
|
||||
ZoneData *zoneData = GetZoneData(zone);
|
||||
if (!zoneData)
|
||||
{
|
||||
return std::make_pair(Color{}, Color{});
|
||||
}
|
||||
|
||||
return std::make_pair(Color{
|
||||
zoneData->color.R,
|
||||
zoneData->color.G,
|
||||
zoneData->color.B},
|
||||
Color{zoneData->color2.R, zoneData->color2.G, zoneData->color2.B});
|
||||
}
|
||||
|
||||
ZoneData *MSIMysticLightController::GetZoneData(ZONE zone)
|
||||
{
|
||||
switch (zone)
|
||||
{
|
||||
case J_RGB_1:
|
||||
return &data.j_rgb_1;
|
||||
case J_RGB_2:
|
||||
return &data.j_rgb_2;
|
||||
case J_RAINBOW_1:
|
||||
return &data.j_rainbow_1;
|
||||
case J_RAINBOW_2:
|
||||
return &data.j_rainbow_2;
|
||||
case J_PIPE_1:
|
||||
return &data.j_pipe_1;
|
||||
case J_PIPE_2:
|
||||
return &data.j_pipe_2;
|
||||
case ON_BOARD_LED:
|
||||
return &data.on_board_led;
|
||||
case ON_BOARD_LED_1:
|
||||
return &data.on_board_led_1;
|
||||
case ON_BOARD_LED_2:
|
||||
return &data.on_board_led_2;
|
||||
case ON_BOARD_LED_3:
|
||||
return &data.on_board_led_3;
|
||||
case ON_BOARD_LED_4:
|
||||
return &data.on_board_led_4;
|
||||
case ON_BOARD_LED_5:
|
||||
return &data.on_board_led_5;
|
||||
case ON_BOARD_LED_6:
|
||||
return &data.on_board_led_6;
|
||||
case ON_BOARD_LED_7:
|
||||
return &data.on_board_led_7;
|
||||
case ON_BOARD_LED_8:
|
||||
return &data.on_board_led_8;
|
||||
case ON_BOARD_LED_9:
|
||||
return &data.on_board_led_9;
|
||||
case J_CORSAIR_OUTERLL120:
|
||||
return &data.j_corsair_outerll120;
|
||||
default:
|
||||
case J_CORSAIR:
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RainbowZoneData *MSIMysticLightController::GetRainbowZoneData(ZONE zone)
|
||||
{
|
||||
switch (zone)
|
||||
{
|
||||
case J_RAINBOW_1:
|
||||
return &data.j_rainbow_1;
|
||||
case J_RAINBOW_2:
|
||||
return &data.j_rainbow_2;
|
||||
case J_CORSAIR:
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool MSIMysticLightController::ReadFwVersion()
|
||||
{
|
||||
// First read the APROM
|
||||
// Checksum also available at report ID 180, with highCheksum stored at index 8, and low at 9
|
||||
int num = 1;
|
||||
unsigned char request[64] = {1, 176};
|
||||
unsigned char response[64];
|
||||
|
||||
std::fill_n(request + 2, sizeof request - 2, 204);
|
||||
num &= hid_write(dev, request, 64);
|
||||
num &= hid_read(dev, response, 64);
|
||||
|
||||
unsigned char highValue = response[2] >> 4;
|
||||
unsigned char lowValue = response[2] & 15;
|
||||
|
||||
version_APROM = std::to_string(static_cast<int>(highValue)).append(".").append(std::to_string(static_cast<int>(lowValue)));
|
||||
|
||||
// Now read the LDROM
|
||||
// Checksum also available at report ID 184, with highCheksum stored at index 8, and low at 9
|
||||
request[1] = 182u;
|
||||
num &= hid_write(dev, request, 64);
|
||||
num &= hid_read(dev, response, 64);
|
||||
|
||||
highValue = response[2] >> 4u;
|
||||
lowValue = response[2] & 15u;
|
||||
|
||||
version_LDROM = std::to_string(static_cast<int>(highValue)).append(".").append(std::to_string(static_cast<int>(lowValue)));
|
||||
|
||||
return num == 1;
|
||||
}
|
||||
|
||||
void MSIMysticLightController::ReadSerial()
|
||||
{
|
||||
wchar_t serial[256];
|
||||
hid_get_serial_number_string(dev, serial, 256);
|
||||
std::wstring wserial = std::wstring(serial);
|
||||
chip_id = std::string(wserial.begin(), wserial.end());
|
||||
}
|
||||
|
||||
void MSIMysticLightController::ReadName()
|
||||
{
|
||||
wchar_t tname[256];
|
||||
hid_get_manufacturer_string(dev, tname, 256);
|
||||
std::wstring wname = std::wstring(tname);
|
||||
name = std::string(wname.begin(), wname.end());
|
||||
|
||||
hid_get_product_string(dev, tname, 256);
|
||||
wname = std::wstring(tname);
|
||||
name.append(" ").append(std::string(wname.begin(), wname.end()));
|
||||
}
|
||||
|
||||
void MSIMysticLightController::SetDeviceSettings(bool is_fan, FAN_TYPE fan_type,
|
||||
unsigned char corsair_device_quantity,
|
||||
bool is_LL120Outer_individual)
|
||||
{
|
||||
// If is_fan false, it is a stripe
|
||||
CorsairZoneData &settingsZone = data.j_corsair;
|
||||
settingsZone.fan_flags = (settingsZone.fan_flags & 128u) | fan_type << 1u | is_fan;
|
||||
settingsZone.corsair_quantity = corsair_device_quantity << 2u;
|
||||
settingsZone.is_individual = BitSet(settingsZone.is_individual, is_LL120Outer_individual, 0u);
|
||||
}
|
||||
|
||||
bool MSIMysticLightController::SetVolume(unsigned char main, unsigned char left, unsigned char right)
|
||||
{
|
||||
unsigned char packet[64];
|
||||
std::fill_n(packet, sizeof packet, 204u);
|
||||
|
||||
if(main > 100u)
|
||||
{
|
||||
main = 100u;
|
||||
}
|
||||
|
||||
if(left > 100u)
|
||||
{
|
||||
left = 100u;
|
||||
}
|
||||
|
||||
if(right > 100u)
|
||||
{
|
||||
right = 100u;
|
||||
}
|
||||
|
||||
packet[0] = 1u;
|
||||
packet[1] = 192u;
|
||||
packet[3] = main;
|
||||
packet[4] = left;
|
||||
packet[5] = right;
|
||||
|
||||
return hid_write(dev, packet, sizeof packet);
|
||||
}
|
||||
|
||||
void MSIMysticLightController::SetBoardSyncSettings(bool onboard_sync, bool combine_JRGB, bool combine_JPIPE1,
|
||||
bool combine_JPIPE2, bool combine_JRAINBOW1, bool combine_JRAINBOW2,
|
||||
bool combine_crossair)
|
||||
{
|
||||
ZoneData &syncZone = data.on_board_led;
|
||||
syncZone.colorFlags = BitSet(syncZone.colorFlags, onboard_sync, 0u);
|
||||
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW1, 1u);
|
||||
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW2, 2u);
|
||||
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_crossair, 3u);
|
||||
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE1, 4u);
|
||||
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE2, 5u);
|
||||
|
||||
syncZone.speedAndBrightnessFlags = BitSet(syncZone.speedAndBrightnessFlags, combine_JRGB, 7u);
|
||||
}
|
||||
|
||||
void MSIMysticLightController::GetMode(ZONE zone, EFFECT &mode, SPEED &speed, BRIGHTNESS &brightness, bool &rainbow_color)
|
||||
{
|
||||
ZoneData *zoneData = GetZoneData(zone);
|
||||
if (!zoneData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mode = static_cast<EFFECT>(zoneData->effect);
|
||||
speed = static_cast<SPEED>(zoneData->speedAndBrightnessFlags & 3u);
|
||||
brightness = static_cast<BRIGHTNESS>((zoneData->speedAndBrightnessFlags >> 2u) & 31u);
|
||||
rainbow_color = (zoneData->colorFlags & 128u) >> 7u;
|
||||
}
|
||||
|
||||
unsigned char MSIMysticLightController::BitSet(unsigned char value, bool bit, unsigned int position)
|
||||
{
|
||||
return static_cast<unsigned char>(std::bitset<8>(value).set(position, bit).to_ulong());
|
||||
}
|
||||
|
||||
void MSIMysticLightController::SetCycleCount(ZONE zone, unsigned char cycle_num)
|
||||
{
|
||||
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
|
||||
|
||||
if (!requestedZone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
requestedZone->cycle_or_led_num = cycle_num;
|
||||
}
|
||||
|
||||
unsigned char MSIMysticLightController::GetCycleCount(ZONE zone)
|
||||
{
|
||||
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
|
||||
|
||||
if (!requestedZone)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return requestedZone->cycle_or_led_num;
|
||||
}
|
||||
|
||||
void MSIMysticLightController::GetBoardSyncSettings(bool &onboard_sync, bool &combine_JRGB, bool &combine_JPIPE1,
|
||||
bool &combine_JPIPE2, bool &combine_JRAINBOW1,
|
||||
bool &combine_JRAINBOW2, bool &combine_crossair)
|
||||
{
|
||||
ZoneData &syncZone = data.on_board_led;
|
||||
onboard_sync = syncZone.colorFlags & 1u;
|
||||
combine_JRAINBOW1 = syncZone.colorFlags >> 1u & 1u;
|
||||
combine_JRAINBOW2 = syncZone.colorFlags >> 1u & 1u;
|
||||
combine_crossair = syncZone.colorFlags >> 3u & 1u;
|
||||
combine_JPIPE1 = syncZone.colorFlags >> 4u & 1u;
|
||||
combine_JPIPE2 = syncZone.colorFlags >> 5u & 1u;
|
||||
|
||||
combine_JRGB = (syncZone.speedAndBrightnessFlags & 128u) >> 7u;
|
||||
}
|
||||
|
||||
void MSIMysticLightController::GetDeviceSettings(bool &stripe_or_fan, FAN_TYPE &fan_type,
|
||||
unsigned char &corsair_device_quantity,
|
||||
bool &is_LL120Outer_individual)
|
||||
{
|
||||
CorsairZoneData &settingsZone = data.j_corsair;
|
||||
stripe_or_fan = settingsZone.fan_flags & 1u;
|
||||
fan_type = static_cast<FAN_TYPE >((settingsZone.fan_flags & 14u) >> 1u);
|
||||
corsair_device_quantity = (settingsZone.corsair_quantity & 252u) >> 2u;
|
||||
is_LL120Outer_individual = settingsZone.is_individual & 1u;
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
/*-----------------------------------------*\
|
||||
| MSIMysticLightController.h |
|
||||
| |
|
||||
| Definitions and types for MSI Mystic |
|
||||
| Light USB lighting controllers |
|
||||
| |
|
||||
| T-bond 3/4/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <cstring>
|
||||
#include <hidapi/hidapi.h>
|
||||
#include <limits>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum ZONE
|
||||
{
|
||||
J_RGB_1 = 1,
|
||||
J_RGB_2 = 174,
|
||||
J_PIPE_1 = 11,
|
||||
J_PIPE_2 = 21,
|
||||
J_RAINBOW_1 = 31,
|
||||
J_RAINBOW_2 = 42,
|
||||
J_CORSAIR = 53,
|
||||
J_CORSAIR_OUTERLL120 = 64,
|
||||
ON_BOARD_LED = 74,
|
||||
ON_BOARD_LED_1 = 84,
|
||||
ON_BOARD_LED_2 = 94,
|
||||
ON_BOARD_LED_3 = 104,
|
||||
ON_BOARD_LED_4 = 114,
|
||||
ON_BOARD_LED_5 = 124,
|
||||
ON_BOARD_LED_6 = 134,
|
||||
ON_BOARD_LED_7 = 144,
|
||||
ON_BOARD_LED_8 = 154,
|
||||
ON_BOARD_LED_9 = 164
|
||||
};
|
||||
|
||||
struct ZoneDescription
|
||||
{
|
||||
std::string name;
|
||||
ZONE value;
|
||||
};
|
||||
|
||||
enum EFFECT
|
||||
{
|
||||
DISABLE,
|
||||
STATIC,
|
||||
BREATHING,
|
||||
FLASHING,
|
||||
DOUBLE_FLASHING,
|
||||
LIGHTNING,
|
||||
MSI_MARQUEE,
|
||||
METEOR,
|
||||
WATER_DROP,
|
||||
MSI_RAINBOW,
|
||||
POP,
|
||||
RAP,
|
||||
JAZZ,
|
||||
PLAY,
|
||||
MOVIE,
|
||||
COLOR_RING,
|
||||
PLANETARY,
|
||||
DOUBLE_METEOR,
|
||||
ENERGY,
|
||||
BLINK,
|
||||
CLOCK,
|
||||
COLOR_PULSE,
|
||||
COLOR_SHIFT,
|
||||
COLOR_WAVE,
|
||||
MARQUEE,
|
||||
RAINBOW,
|
||||
RAINBOW_WAVE,
|
||||
VISOR,
|
||||
JRAINBOW,
|
||||
RAINBOW_FLASHING,
|
||||
RAINBOW_DOUBLE_FLASHING,
|
||||
RANDOM,
|
||||
FAN_CONTROL,
|
||||
DISABLE_2,
|
||||
COLOR_RING_FLASHING,
|
||||
COLOR_RING_DOUBLE_FLASHING,
|
||||
STACK,
|
||||
CORSAIR_QUE,
|
||||
FIRE,
|
||||
LAVA
|
||||
};
|
||||
|
||||
enum SPEED
|
||||
{
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH
|
||||
};
|
||||
|
||||
enum FAN_TYPE
|
||||
{
|
||||
SP,
|
||||
HD,
|
||||
LL
|
||||
};
|
||||
|
||||
enum BRIGHTNESS
|
||||
{
|
||||
OFF,
|
||||
LEVEL_10,
|
||||
LEVEL_20,
|
||||
LEVEL_30,
|
||||
LEVEL_40,
|
||||
LEVEL_50,
|
||||
LEVEL_60,
|
||||
LEVEL_70,
|
||||
LEVEL_80,
|
||||
LEVEL_90,
|
||||
LEVEL_100
|
||||
};
|
||||
|
||||
struct Color
|
||||
{
|
||||
unsigned char R;
|
||||
unsigned char G;
|
||||
unsigned char B;
|
||||
};
|
||||
|
||||
struct CorsairZoneData
|
||||
{
|
||||
unsigned char effect = EFFECT::STATIC;
|
||||
Color color { std::numeric_limits<unsigned char>::max(), 0, 0 };
|
||||
unsigned char fan_flags = 40;
|
||||
unsigned char corsair_quantity;
|
||||
unsigned char padding[3];
|
||||
|
||||
unsigned char is_individual = 0;
|
||||
};
|
||||
|
||||
struct ZoneData
|
||||
{
|
||||
unsigned char effect = EFFECT::STATIC;
|
||||
Color color { std::numeric_limits<unsigned char>::max(), 0u, 0u };
|
||||
unsigned char speedAndBrightnessFlags = 40u;
|
||||
Color color2 { 0, std::numeric_limits<unsigned char>::max(), 0u };
|
||||
unsigned char colorFlags = 128u;
|
||||
|
||||
const unsigned char padding = 0u;
|
||||
};
|
||||
|
||||
struct RainbowZoneData : ZoneData
|
||||
{
|
||||
unsigned char cycle_or_led_num = 20u;
|
||||
};
|
||||
|
||||
struct FeaturePacket
|
||||
{
|
||||
const unsigned char report_id = 82u; // Report ID
|
||||
ZoneData j_rgb_1; // 1
|
||||
ZoneData j_pipe_1; // 11
|
||||
ZoneData j_pipe_2; // 21
|
||||
RainbowZoneData j_rainbow_1; // 31
|
||||
RainbowZoneData j_rainbow_2; // 42
|
||||
CorsairZoneData j_corsair; // 53
|
||||
ZoneData j_corsair_outerll120; // 64
|
||||
ZoneData on_board_led; // 74
|
||||
ZoneData on_board_led_1; // 84
|
||||
ZoneData on_board_led_2; // 94
|
||||
ZoneData on_board_led_3; // 104
|
||||
ZoneData on_board_led_4; // 114
|
||||
ZoneData on_board_led_5; // 124
|
||||
ZoneData on_board_led_6; // 134
|
||||
ZoneData on_board_led_7; // 144
|
||||
ZoneData on_board_led_8; // 154
|
||||
ZoneData on_board_led_9; // 164
|
||||
ZoneData j_rgb_2; // 174
|
||||
|
||||
unsigned char save_data = 0u; // 184
|
||||
};
|
||||
|
||||
|
||||
class MSIMysticLightController
|
||||
{
|
||||
public:
|
||||
MSIMysticLightController(hid_device* handle, const char *path);
|
||||
~MSIMysticLightController();
|
||||
|
||||
unsigned int GetZoneMinLedCount(ZONE zone);
|
||||
unsigned int GetZoneMaxLedCount(ZONE zone);
|
||||
unsigned int GetZoneLedCount(ZONE zone);
|
||||
void SetZoneLedCount(ZONE zone, unsigned int led_count);
|
||||
|
||||
void SetMode(ZONE zone, EFFECT mode, SPEED speed, BRIGHTNESS brightness, bool rainbow_color);
|
||||
void GetMode(ZONE zone, EFFECT &mode, SPEED &speed, BRIGHTNESS &brightness, bool &rainbow_color);
|
||||
void SetZoneColor(ZONE zone, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
|
||||
void SetCycleCount(ZONE zone, unsigned char cycle_num);
|
||||
unsigned char GetCycleCount(ZONE zone);
|
||||
std::pair<Color, Color>
|
||||
GetZoneColor(ZONE zone);
|
||||
bool Update();
|
||||
|
||||
void SetDeviceSettings(bool stripe_or_fan, FAN_TYPE fan_type, unsigned char corsair_device_quantity, bool is_LL120Outer_individual);
|
||||
void GetDeviceSettings(bool &stripe_or_fan, FAN_TYPE &fan_type, unsigned char &corsair_device_quantity, bool &is_LL120Outer_individual);
|
||||
bool SetVolume(unsigned char main, unsigned char left, unsigned char right);
|
||||
void SetBoardSyncSettings(bool onboard_sync, bool combine_JRGB, bool combine_JPIPE1, bool combine_JPIPE2, bool combine_JRAINBOW1, bool combine_JRAINBOW2, bool combine_crossair);
|
||||
void GetBoardSyncSettings(bool &onboard_sync, bool &combine_JRGB, bool &combine_JPIPE1, bool &combine_JPIPE2, bool &combine_JRAINBOW1, bool &combine_JRAINBOW2, bool &combine_crossair);
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFWVersion();
|
||||
std::string GetSerial();
|
||||
|
||||
private:
|
||||
bool ReadSettings();
|
||||
void SaveOnUpdate(bool send);
|
||||
bool ReadFwVersion();
|
||||
void ReadSerial();
|
||||
void ReadName();
|
||||
ZoneData* GetZoneData(ZONE zone);
|
||||
RainbowZoneData*
|
||||
GetRainbowZoneData(ZONE zone);
|
||||
static unsigned char BitSet(unsigned char value, bool bit, unsigned int position);
|
||||
|
||||
hid_device* dev;
|
||||
std::string name;
|
||||
std::string loc;
|
||||
std::string version_APROM;
|
||||
std::string version_LDROM;
|
||||
std::string chip_id;
|
||||
|
||||
FeaturePacket data;
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "MSIMysticLightController.h"
|
||||
#include "RGBController_MSIMysticLight.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define MSI_VID 0x1462
|
||||
|
||||
constexpr unsigned short SupportedPIDs[41] =
|
||||
{
|
||||
31847, // MS_7C67
|
||||
31504, // MS_7B10
|
||||
31879, // MS_7C87
|
||||
31635, // MS_7B93
|
||||
31796, // MS_7C34
|
||||
31797, // MS_7C35
|
||||
31798, // MS_7C36
|
||||
31799, // MS_7C37
|
||||
31810, // MS_7C42
|
||||
31876, // MS_7C84
|
||||
31636, // MS_7B94
|
||||
31638, // MS_7B96
|
||||
31833, // MS_7C59
|
||||
31840, // MS_7C60
|
||||
31856, // MS_7C70
|
||||
31857, // MS_7C71
|
||||
31859, // MS_7C73
|
||||
31861, // MS_7C75
|
||||
31862, // MS_7C76
|
||||
31863, // MS_7C77
|
||||
31865, // MS_7C79
|
||||
31872, // MS_7C80
|
||||
31896, // MS_7C98
|
||||
31897, // MS_7C99
|
||||
31873, // MS_7C81
|
||||
31874, // MS_7C82
|
||||
31875, // MS_7C83
|
||||
31877, // MS_7C85
|
||||
31878, // MS_7C86
|
||||
31880, // MS_7C88
|
||||
31881, // MS_7C89
|
||||
17497, // MS_4459
|
||||
16036, // MS_3EA4
|
||||
36957, // MS_905D
|
||||
31888, // MS_7C90
|
||||
31889, // MS_7C91
|
||||
31890, // MS_7C92
|
||||
31892, // MS_7C94
|
||||
31893, // MS_7C95
|
||||
31894, // MS_7C96
|
||||
31830 // MS_7C56
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectMSIMysticLightControllers *
|
||||
* *
|
||||
* Detect MSI Mystic Light devices that use NCT6775 RGB controllers *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectMSIMysticLightControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
if(hid_init() < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hid_device_info * device_list = hid_enumerate(MSI_VID, 0);
|
||||
if(!device_list)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hid_device_info * device = device_list;
|
||||
while(device)
|
||||
{
|
||||
if(std::find(std::begin(SupportedPIDs), std::end(SupportedPIDs), device->product_id) != std::end(SupportedPIDs))
|
||||
{
|
||||
hid_device * dev = hid_open_path(device->path);
|
||||
if(dev)
|
||||
{
|
||||
MSIMysticLightController * controller = new MSIMysticLightController(dev, device_list->path);
|
||||
RGBController_MSIMysticLight * rgb_controller = new RGBController_MSIMysticLight(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
device = device->next;
|
||||
}
|
||||
|
||||
hid_free_enumeration(device_list);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Driver for NZXT Kraken |
|
||||
| |
|
||||
| Martin Hartl (inlart), 04/04/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "NZXTKrakenController.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
|
||||
const int NZXT_KRAKEN_READ_ENDPOINT = 0x81;
|
||||
const int NZXT_KRAKEN_WRITE_ENDPOINT = 0x01;
|
||||
|
||||
static void SetColor(const std::vector<RGBColor>& colors, unsigned char* color_data)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < colors.size(); idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx];
|
||||
color_data[pixel_idx + 0x00] = RGBGetRValue(color);
|
||||
color_data[pixel_idx + 0x01] = RGBGetGValue(color);
|
||||
color_data[pixel_idx + 0x02] = RGBGetBValue(color);
|
||||
}
|
||||
}
|
||||
|
||||
static RGBColor ToLogoColor(RGBColor rgb)
|
||||
{
|
||||
return ToRGBColor(RGBGetGValue(rgb), RGBGetRValue(rgb), RGBGetBValue(rgb));
|
||||
}
|
||||
|
||||
NZXTKrakenController::NZXTKrakenController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the firmware version |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateStatus();
|
||||
}
|
||||
|
||||
NZXTKrakenController::~NZXTKrakenController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string NZXTKrakenController::GetFirmwareVersion()
|
||||
{
|
||||
return firmware_version;
|
||||
}
|
||||
|
||||
void NZXTKrakenController::UpdateStatus()
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
libusb_interrupt_transfer(dev, NZXT_KRAKEN_READ_ENDPOINT, usb_buf, sizeof(usb_buf), &actual, 0);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Extract cooler information |
|
||||
\*-----------------------------------------------------*/
|
||||
liquid_temperature = usb_buf[0x1] + (usb_buf[0x2] * 0.1);
|
||||
fan_speed = usb_buf[0x3] << 8 | usb_buf[0x4];
|
||||
pump_speed = usb_buf[0x5] << 8 | usb_buf[0x6];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Extract firmware version |
|
||||
\*-----------------------------------------------------*/
|
||||
int major = usb_buf[0xb];
|
||||
int minor = usb_buf[0xc] << 8 | usb_buf[0xd];
|
||||
int patch = usb_buf[0xe];
|
||||
std::stringstream ss;
|
||||
ss << major << '.' << minor << '.' << patch;
|
||||
firmware_version = ss.str();
|
||||
}
|
||||
|
||||
void NZXTKrakenController::UpdateEffect
|
||||
(
|
||||
NZXTKrakenChannel_t channel,
|
||||
unsigned char mode,
|
||||
bool direction,
|
||||
unsigned char speed,
|
||||
int seq,
|
||||
std::vector<RGBColor> colors
|
||||
)
|
||||
{
|
||||
unsigned char color_data[9 * 3];
|
||||
memset(color_data, 0, sizeof(color_data));
|
||||
|
||||
if(!colors.empty() && channel != NZXT_KRAKEN_CHANNEL_RING)
|
||||
{
|
||||
colors[0] = ToLogoColor(colors[0]);
|
||||
}
|
||||
|
||||
SetColor(colors, color_data);
|
||||
SendEffect(channel, mode, direction, color_data, speed, false, seq);
|
||||
}
|
||||
|
||||
void NZXTKrakenController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
bool direction,
|
||||
unsigned char* color_data,
|
||||
unsigned char speed /* = 0x02 */,
|
||||
bool movement /* = false */,
|
||||
int cis /* = 0 */,
|
||||
int size /* = 0 */
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set effect mode |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x02;
|
||||
usb_buf[0x01] = 0x4c;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set effect channel, movement and direction |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x02] |= movement ? ( 1 << 3 ) : 0;
|
||||
usb_buf[0x02] |= direction ? ( 1 << 4 ) : 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x03] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set effect speed, size and color in set |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x04] = speed;
|
||||
usb_buf[0x04] |= size << 3;
|
||||
usb_buf[0x04] |= cis << 5;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
if(color_data)
|
||||
{
|
||||
memcpy(usb_buf + 0x05, color_data, 9 * 3);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send effect |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer
|
||||
(
|
||||
dev,
|
||||
NZXT_KRAKEN_WRITE_ENDPOINT,
|
||||
usb_buf,
|
||||
sizeof(usb_buf),
|
||||
&actual,
|
||||
0
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for NZXT Kraken |
|
||||
| |
|
||||
| Martin Hartl (inlart), 04/04/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
enum NZXTKrakenChannel_t
|
||||
{
|
||||
NZXT_KRAKEN_CHANNEL_SYNC = 0x00, /* Sync Channel */
|
||||
NZXT_KRAKEN_CHANNEL_LOGO = 0x01, /* Logo Channel */
|
||||
NZXT_KRAKEN_CHANNEL_RING = 0x02, /* Ring Channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NZXT_KRAKEN_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
NZXT_KRAKEN_MODE_FADING = 0x01, /* Fading mode */
|
||||
NZXT_KRAKEN_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
|
||||
NZXT_KRAKEN_MODE_MARQUEE = 0x03, /* Marquee mode */
|
||||
NZXT_KRAKEN_MODE_COVER_MARQUEE = 0x04, /* Cover marquee mode */
|
||||
NZXT_KRAKEN_MODE_ALTERNATING = 0x05, /* Alternating mode */
|
||||
NZXT_KRAKEN_MODE_BREATHING = 0x06, /* Breathing mode */
|
||||
NZXT_KRAKEN_MODE_PULSE = 0x07, /* Pulse mode */
|
||||
NZXT_KRAKEN_MODE_TAI_CHI = 0x08, /* Tai Chi mode */
|
||||
NZXT_KRAKEN_MODE_WATER_COOLER = 0x09, /* Water color mode */
|
||||
NZXT_KRAKEN_MODE_LOADING = 0x0a, /* Loading mode */
|
||||
NZXT_KRAKEN_MODE_WINGS = 0x0c, /* Wings mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NZXT_KRAKEN_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
NZXT_KRAKEN_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
NZXT_KRAKEN_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
NZXT_KRAKEN_SPEED_FAST = 0x03, /* Fast speed */
|
||||
NZXT_KRAKEN_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class NZXTKrakenController
|
||||
{
|
||||
public:
|
||||
NZXTKrakenController(libusb_device_handle* dev_handle);
|
||||
~NZXTKrakenController();
|
||||
|
||||
std::string GetFirmwareVersion();
|
||||
|
||||
void UpdateEffect
|
||||
(
|
||||
NZXTKrakenChannel_t channel,
|
||||
unsigned char mode,
|
||||
bool direction,
|
||||
unsigned char speed,
|
||||
int seq,
|
||||
std::vector<RGBColor> colors
|
||||
);
|
||||
|
||||
private:
|
||||
void UpdateStatus();
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
bool direction,
|
||||
unsigned char* color_data,
|
||||
unsigned char speed = 0x02,
|
||||
bool movement = false,
|
||||
int cis = 0 ,
|
||||
int size = 0
|
||||
);
|
||||
|
||||
libusb_device_handle* dev;
|
||||
|
||||
// -- status
|
||||
std::string firmware_version;
|
||||
double liquid_temperature;
|
||||
unsigned int fan_speed;
|
||||
unsigned int pump_speed;
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "NZXTKrakenController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_NZXTKraken.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define NZXT_KRAKEN_VID 0x1E71
|
||||
#define NZXT_KRAKEN_PID 0x170E
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectNZXTKrakenControllers *
|
||||
* *
|
||||
* Detect devices supported by the NZXTKraken driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectNZXTKrakenControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, NZXT_KRAKEN_VID, NZXT_KRAKEN_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
NZXTKrakenController* controller = new NZXTKrakenController(dev);
|
||||
|
||||
RGBController_NZXTKraken* rgb_controller = new RGBController_NZXTKraken(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,49 +15,31 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
switch (GetFirmwareVersion())
|
||||
unsigned short fw_version = GetFirmwareVersion();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Determine whether the device uses ASR LED or |
|
||||
| Polychrome protocol by checking firmware version. |
|
||||
| Versions 1.xx and 2.xx use ASR LED, 3.xx uses |
|
||||
| Polychrome |
|
||||
\*-----------------------------------------------------*/
|
||||
if(((fw_version >> 8) < 0x03) && ((fw_version >> 8) > 0x00))
|
||||
{
|
||||
case FIRMWARE_VER_1_PT_10:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 1.10");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_00:
|
||||
led_count = 1;
|
||||
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:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 3.00");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_3_PT_04:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 3.04");
|
||||
break;
|
||||
|
||||
default:
|
||||
led_count = 0;
|
||||
strcpy(device_name, "");
|
||||
break;
|
||||
snprintf(device_name, 32, "ASRock ASR LED FW %d.%02d", (fw_version >> 8), (fw_version & 0xFF));
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
}
|
||||
else if(fw_version == 0x03)
|
||||
{
|
||||
snprintf(device_name, 32, "ASRock Polychrome FW %d.%02d", (fw_version >> 8), (fw_version & 0xFF));
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_count = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PolychromeController::~PolychromeController()
|
||||
|
||||
@@ -14,16 +14,6 @@
|
||||
|
||||
typedef unsigned char polychrome_dev_id;
|
||||
|
||||
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 */
|
||||
FIRMWARE_VER_3_PT_04 = 0x0304, /* Firmware nu51_3.04 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ASRLED_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2SMBusController.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus RGB Fusion 2 |
|
||||
| SMBus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/12/2020 |
|
||||
| Matt Harper 5/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBFusion2SMBusController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#endif
|
||||
|
||||
RGBFusion2SMBusController::RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
memset(led_data, 0, 10*16);
|
||||
|
||||
led_count = 10; // Protocol supports 10 'slots'
|
||||
}
|
||||
|
||||
unsigned int RGBFusion2SMBusController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
std::string RGBFusion2SMBusController::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);
|
||||
}
|
||||
|
||||
/* Writes are performed in 32 byte chunks. If we need to write the second 16 bytes,
|
||||
* we must necessarily write the first 16 as well. Given that reading the existing state
|
||||
* from the device is not yet possible, unfortunately we may overwrite existing device
|
||||
* states if the state transition did not occur within in the same OpenRGB instance.
|
||||
* That is to say, the current behavior is non-deal but the best we have
|
||||
*/
|
||||
void RGBFusion2SMBusController::WriteLED(int led)
|
||||
{
|
||||
unsigned short register_offset = led / 2; // Relying on integer division to truncate
|
||||
unsigned short write_register = RGB_FUSION_2_LED_START_ADDR + 2*register_offset;
|
||||
|
||||
// Adjust if we are writing the second 16 bytes
|
||||
if(led % 2)
|
||||
{
|
||||
led -= 1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
std::cout << std::hex << write_register << "\t";
|
||||
for(int i = 0; i < 2; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
std::cout << std::setw(2) << std::setfill('0') << std::hex << (int)led_data[led+i][j] << " ";
|
||||
}
|
||||
std::cout << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
#endif
|
||||
|
||||
bus->i2c_smbus_write_block_data(RGB_FUSION_2_SMBUS_ADDR, write_register, 32, led_data[led]);
|
||||
}
|
||||
|
||||
void RGBFusion2SMBusController::Apply()
|
||||
{
|
||||
// Protocol expects terminating sequence 0x01ff written to register 0x17
|
||||
bus->i2c_smbus_write_word_data(RGB_FUSION_2_SMBUS_ADDR,
|
||||
RGB_FUSION_2_APPLY_ADDR,
|
||||
RGB_FUSION_2_ACTION_APPLY);
|
||||
}
|
||||
|
||||
void RGBFusion2SMBusController::SetLEDEffect
|
||||
(
|
||||
unsigned int led,
|
||||
int mode,
|
||||
unsigned int speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
led_data[led][RGB_FUSION_2_IDX_MODE] = mode;
|
||||
led_data[led][RGB_FUSION_2_IDX_RED] = red;
|
||||
led_data[led][RGB_FUSION_2_IDX_GREEN] = green;
|
||||
led_data[led][RGB_FUSION_2_IDX_BLUE] = blue;
|
||||
led_data[led][RGB_FUSION_2_IDX_BRIGHTNESS] = 0x64;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case RGB_FUSION_2_MODE_PULSE:
|
||||
// Timer 1: On time
|
||||
// Timer 2: Off time
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_LSB] = 0x20 * speed;
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_MSB] = 0x03 * speed;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_LSB] = 0x20 * speed;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_MSB] = 0x03 * speed;
|
||||
break;
|
||||
|
||||
case RGB_FUSION_2_MODE_COLOR_CYCLE:
|
||||
// Timer 1: Cycle time
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_LSB] = 0x00;
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_MSB] = 0x03 * speed;
|
||||
led_data[led][RGB_FUSION_2_IDX_OPT_1] = 0x07; // Number of colors to cycle through. Valid range [1-7]
|
||||
led_data[led][RGB_FUSION_2_IDX_OPT_2] = 0x00; // Color cycle, or color cycle and pulse. [0,1]
|
||||
break;
|
||||
|
||||
case RGB_FUSION_2_MODE_FLASHING:
|
||||
/* Timer 1: On time
|
||||
* Timer 2: Interval
|
||||
* Timer 3: Cycle time */
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_LSB] = 0x64;
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_MSB] = 0;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_LSB] = 0xc8;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_MSB] = 0;
|
||||
led_data[led][RGB_FUSION_2_TIMER_3_LSB] = 0xd0;
|
||||
led_data[led][RGB_FUSION_2_TIMER_3_MSB] = 0x07;
|
||||
|
||||
led_data[led][RGB_FUSION_2_IDX_OPT_1] = speed; // Controls number of flashes
|
||||
break;
|
||||
}
|
||||
|
||||
WriteLED(led);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2SMBusController.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| RGB Fusion 2 SMBus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char rgb_fusion_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_IDX_MODE = 0x01, /* Mode index */
|
||||
RGB_FUSION_2_IDX_BRIGHTNESS = 0x02, /* Brightness index */
|
||||
RGB_FUSION_2_IDX_MAX_BRIGHTNESS = 0x02, /* Max brightness index */
|
||||
RGB_FUSION_2_IDX_MIN_BRIGHTNESS = 0x03, /* Minimum brightness index */
|
||||
RGB_FUSION_2_IDX_BLUE = 0x04, /* Blue index */
|
||||
RGB_FUSION_2_IDX_GREEN = 0x05, /* Green index */
|
||||
RGB_FUSION_2_IDX_RED = 0x06, /* Red index */
|
||||
RGB_FUSION_2_IDX_WHITE = 0x07, /* White index */
|
||||
RGB_FUSION_2_TIMER_1_LSB = 0x08, /* Timer 1 LSB. Valid timer values [0-65535] */
|
||||
RGB_FUSION_2_TIMER_1_MSB = 0x09, /* Timer 1 MSB. Timer unis are milliseconds */
|
||||
RGB_FUSION_2_TIMER_2_LSB = 0x0A, /* Timer 2 LSB */
|
||||
RGB_FUSION_2_TIMER_2_MSB = 0x0B, /* Timer 2 MSB */
|
||||
RGB_FUSION_2_TIMER_3_LSB = 0x0C, /* Timer 3 LSB */
|
||||
RGB_FUSION_2_TIMER_3_MSB = 0x0D, /* Timer 3 MSB */
|
||||
RGB_FUSION_2_IDX_OPT_1 = 0x0E, /* Option 1. Use case varies by mode */
|
||||
RGB_FUSION_2_IDX_OPT_2 = 0x0F, /* Option 2. Use case varies by mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_APPLY_ADDR = 0x17,
|
||||
RGB_FUSION_2_LED_START_ADDR = 0x20,
|
||||
RGB_FUSION_2_SMBUS_ADDR = 0x68,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_ACTION_APPLY = 0x01ff,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_MODE_PULSE = 0x01, /* Pulse mode */
|
||||
RGB_FUSION_2_MODE_MUSIC = 0x02, /* Music mode */
|
||||
RGB_FUSION_2_MODE_COLOR_CYCLE = 0x03, /* Color cycle mode */
|
||||
RGB_FUSION_2_MODE_STATIC = 0x04, /* Static color mode */
|
||||
RGB_FUSION_2_MODE_FLASHING = 0x05, /* Flashing / Double Flashing mode */
|
||||
RGB_FUSION_2_MODE_TRANSITION = 0x09, /* Gradual transition from current */
|
||||
RGB_FUSION_2_MODE_DIGITAL_A = 0x0A, /* Wave mode */
|
||||
RGB_FUSION_2_MODE_DIGITAL_B = 0x0B, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_C = 0x0C, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_D = 0x0D, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_E = 0x0E, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_F = 0x0F, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_G = 0x10, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_H = 0x11, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_I = 0x12, /* */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_SPEED_FAST = 0x01,
|
||||
RGB_FUSION_2_SPEED_NORMAL = 0x02,
|
||||
RGB_FUSION_2_SPEED_SLOW = 0x04,
|
||||
};
|
||||
|
||||
class RGBFusion2SMBusController
|
||||
{
|
||||
public:
|
||||
RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
|
||||
~RGBFusion2SMBusController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void Apply();
|
||||
|
||||
void SetLEDEffect
|
||||
(
|
||||
unsigned int led,
|
||||
int mode,
|
||||
unsigned int speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
rgb_fusion_dev_id dev;
|
||||
|
||||
unsigned char led_data[10][16];
|
||||
|
||||
void WriteLED(int);
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "RGBFusion2SMBusController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RGBFusion2SMBus.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForRGBFusion2SMBusController *
|
||||
* *
|
||||
* Tests the given address to see if an RGB 2 Fusion controller exists there. First *
|
||||
* does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForRGBFusion2SMBusController(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;
|
||||
|
||||
// res = bus->i2c_smbus_read_byte_data(address, 0xF2);
|
||||
|
||||
// if (res != 0xC4)
|
||||
// {
|
||||
// pass = false;
|
||||
// }
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForRGBFusion2SMBusController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRGBFusion2SMBusControllers *
|
||||
* *
|
||||
* Detect RGB Fusion 2 controllers on the enumerated I2C busses at address 0x68. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
|
||||
* dev - I2C address of RGB Fusion device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
RGBFusion2SMBusController* new_rgb_fusion;
|
||||
RGBController_RGBFusion2SMBus* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// TODO - Is this necessary? Or an artifact of my own system?
|
||||
// Skip dmcd devices
|
||||
std::string device_name = std::string(busses[bus]->device_name);
|
||||
if (device_name.find("dmdc") == std::string::npos)
|
||||
{
|
||||
// Check for RGB Fusion 2 controller at 0x68
|
||||
if (TestForRGBFusion2SMBusController(busses[bus], 0x68))
|
||||
{
|
||||
new_rgb_fusion = new RGBFusion2SMBusController(busses[bus], 0x68);
|
||||
new_controller = new RGBController_RGBFusion2SMBus(new_rgb_fusion);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectRGBFusion2SMBusControllers() */
|
||||
@@ -107,7 +107,6 @@ void RGBFusion2USBController::SetCalibration()
|
||||
|
||||
void RGBFusion2USBController::SetLedCount(unsigned int count)
|
||||
{
|
||||
led_count = count;
|
||||
LEDCount s0 = LedCountToEnum(count);
|
||||
SendPacket(0x34, s0 | (s0 << 4)); // D_LED1 | D_LED2
|
||||
}
|
||||
|
||||
@@ -186,7 +186,6 @@ private:
|
||||
|
||||
hid_device* dev;
|
||||
int mode;
|
||||
unsigned int led_count;
|
||||
IT8297Report report;
|
||||
std::string name;
|
||||
std::string loc;
|
||||
|
||||
@@ -9,14 +9,17 @@
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define REDRAGON_K556_VID 0x0C45
|
||||
#define REDRAGON_KEYBOARD_VID 0x0C45
|
||||
#define REDRAGON_K550_PID 0x5204
|
||||
#define REDRAGON_K556_PID 0x5004
|
||||
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Mouse product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define REDRAGON_M711_VID 0x04D9
|
||||
#define REDRAGON_MOUSE_VID 0x04D9
|
||||
#define REDRAGON_M711_PID 0xFC30
|
||||
#define REDRAGON_M715_PID 0xFC39
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -34,11 +37,13 @@ static const redragon_device device_list[] =
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ REDRAGON_K556_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
|
||||
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
|
||||
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ REDRAGON_M711_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
|
||||
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
|
||||
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
@@ -90,6 +95,8 @@ void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
RedragonK556Controller* controller = new RedragonK556Controller(dev);
|
||||
|
||||
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
@@ -99,6 +106,8 @@ void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
RedragonM711Controller* controller = new RedragonM711Controller(dev);
|
||||
|
||||
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -39,10 +39,60 @@ void RedragonK556Controller::SetKeyboardColors
|
||||
}
|
||||
}
|
||||
|
||||
void RedragonK556Controller::SendKeyboardMode
|
||||
(
|
||||
unsigned char mode
|
||||
)
|
||||
{
|
||||
SendKeyboardParameter(REDRAGON_K556_PARAMETER_MODE, 1, &mode);
|
||||
}
|
||||
|
||||
void RedragonK556Controller::SendKeyboardModeEx
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char random_flag,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char parameter_data[8];
|
||||
|
||||
parameter_data[0] = mode;
|
||||
parameter_data[1] = brightness;
|
||||
parameter_data[2] = speed;
|
||||
parameter_data[3] = direction;
|
||||
parameter_data[4] = random_flag;
|
||||
parameter_data[5] = red;
|
||||
parameter_data[6] = green;
|
||||
parameter_data[7] = blue;
|
||||
|
||||
SendKeyboardParameter(0, 8, parameter_data);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void RedragonK556Controller::ComputeChecksum
|
||||
(
|
||||
char usb_buf[64]
|
||||
)
|
||||
{
|
||||
unsigned short checksum = 0;
|
||||
|
||||
for(unsigned int byte_idx = 0x03; byte_idx < 64; byte_idx++)
|
||||
{
|
||||
checksum += usb_buf[byte_idx];
|
||||
}
|
||||
|
||||
usb_buf[0x01] = checksum & 0xFF;
|
||||
usb_buf[0x02] = checksum >> 8;
|
||||
}
|
||||
|
||||
void RedragonK556Controller::SendKeyboardBegin()
|
||||
{
|
||||
char usb_buf[64];
|
||||
@@ -53,12 +103,40 @@ void RedragonK556Controller::SendKeyboardBegin()
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard Begin packet |
|
||||
| Set up Keyboard Begin (0x01) packet |
|
||||
| Note: Not computing checksum as packet contents are |
|
||||
| fixed |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x01] = REDRAGON_K556_COMMAND_BEGIN;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = 0x01;
|
||||
usb_buf[0x03] = REDRAGON_K556_COMMAND_BEGIN;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void RedragonK556Controller::SendKeyboardEnd()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard End (0x02) packet |
|
||||
| Note: Not computing checksum as packet contents are |
|
||||
| fixed |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x01] = REDRAGON_K556_COMMAND_END;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = REDRAGON_K556_COMMAND_END;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
@@ -82,12 +160,11 @@ void RedragonK556Controller::SendKeyboardData
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard End packet |
|
||||
| Set up Keyboard Color Data (0x11) packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x01] = 0x11 + data_offset;
|
||||
usb_buf[0x02] = data_size;
|
||||
usb_buf[0x03] = ( data_size / 3 ) - 1;
|
||||
usb_buf[0x03] = 0x11;
|
||||
|
||||
usb_buf[0x04] = data_size;
|
||||
usb_buf[0x05] = data_offset & 0x00FF;
|
||||
usb_buf[0x06] = data_offset >> 8;
|
||||
@@ -97,6 +174,11 @@ void RedragonK556Controller::SendKeyboardData
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x08], data, data_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Compute Checksum |
|
||||
\*-----------------------------------------------------*/
|
||||
ComputeChecksum(usb_buf);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -104,9 +186,11 @@ void RedragonK556Controller::SendKeyboardData
|
||||
hid_read(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void RedragonK556Controller::SendKeyboardMode
|
||||
void RedragonK556Controller::SendKeyboardParameter
|
||||
(
|
||||
unsigned char mode
|
||||
unsigned char parameter,
|
||||
unsigned char parameter_size,
|
||||
unsigned char* parameter_data
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
@@ -117,40 +201,23 @@ void RedragonK556Controller::SendKeyboardMode
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard End packet |
|
||||
| Set up Keyboard Parameter (0x06) packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x01] = 0x00;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = 0x06;
|
||||
usb_buf[0x04] = 0x01;
|
||||
|
||||
usb_buf[0x08] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void RedragonK556Controller::SendKeyboardEnd()
|
||||
{
|
||||
char usb_buf[64];
|
||||
usb_buf[0x03] = REDRAGON_K556_COMMAND_SET_PARAMETER;
|
||||
usb_buf[0x04] = parameter_size;
|
||||
usb_buf[0x05] = parameter;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
memcpy(&usb_buf[0x08], parameter_data, parameter_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard End packet |
|
||||
| Compute Checksum |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x01] = 0x02;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = 0x02;
|
||||
|
||||
ComputeChecksum(usb_buf);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
@@ -16,27 +16,77 @@
|
||||
|
||||
#define REDRAGON_K556_MAX_PACKET_SIZE ( 0x36 ) /* max packet size for color*/
|
||||
/* update packets */
|
||||
enum
|
||||
{
|
||||
REDRAGON_K556_COMMAND_BEGIN = 0x01, /* Begin packet command */
|
||||
REDRAGON_K556_COMMAND_END = 0x02, /* End packet command */
|
||||
REDRAGON_K556_COMMAND_SET_PARAMETER = 0x06, /* Set parameter command */
|
||||
REDRAGON_K556_COMMAND_READ_CUSTOM_COLOR_DATA = 0x10, /* Read custom color data */
|
||||
REDRAGON_K556_COMMAND_WRITE_CUSTOM_COLOR_DATA = 0x11, /* Write custom color data */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
REDRAGON_K556_MODE_COLOR_WAVE_SHORT = 0x01, /* "Go with the stream" */
|
||||
REDRAGON_K556_MODE_COLOR_WAVE_LONG = 0x02, /* "Clouds fly" */
|
||||
REDRAGON_K556_MODE_COLOR_WHEEL = 0x03, /* "Winding paths" */
|
||||
REDRAGON_K556_MODE_SPECTRUM_CYCLE = 0x04, /* "The trial of light" */
|
||||
REDRAGON_K556_MODE_BREATHING = 0x05, /* "Breathing" */
|
||||
REDRAGON_K556_MODE_STATIC = 0x06, /* "Normally on" */
|
||||
REDRAGON_K556_MODE_REACTIVE = 0x07, /* "Pass without trace" */
|
||||
REDRAGON_K556_MODE_REACTIVE_RIPPLE = 0x08, /* "Ripple graff" */
|
||||
REDRAGON_K556_MODE_REACTIVE_LINE = 0x09, /* "Fast run without trace" */
|
||||
REDRAGON_K556_MODE_STARLIGHT_FAST = 0x0A, /* "Swift action" */
|
||||
REDRAGON_K556_MODE_BLOOMING = 0x0B, /* "Flowers blooming" */
|
||||
REDRAGON_K556_MODE_RAINBOW_WAVE_VERTICAL = 0x0C, /* "Snow winter jasmine" */
|
||||
REDRAGON_K556_MODE_HURRICANE = 0x0D, /* "Hurricane" */
|
||||
REDRAGON_K556_MODE_ACCUMULATE = 0x0E, /* "Accumulate" */
|
||||
REDRAGON_K556_MODE_STARLIGHT_SLOW = 0x0F, /* "Digital times" */
|
||||
REDRAGON_K556_MODE_VISOR = 0x10, /* "Both ways" */
|
||||
REDRAGON_K556_MODE_RAINBOW_WAVE_CIRCLE = 0x12, /* "Fast and the Furious" */
|
||||
REDRAGON_K556_MODE_CUSTOM = 0x14, /* "Coastal" */
|
||||
REDRAGON_K556_PARAMETER_MODE = 0x00, /* Mode parameter */
|
||||
REDRAGON_K556_PARAMETER_BRIGHTNESS = 0x01, /* Brightness parameter */
|
||||
REDRAGON_K556_PARAMETER_SPEED = 0x02, /* Speed parameter */
|
||||
REDRAGON_K556_PARAMETER_DIRECTION = 0x03, /* Direction parameter */
|
||||
REDRAGON_K556_PARAMETER_RANDOM_COLOR_FLAG = 0x04, /* Random color parameter */
|
||||
REDRAGON_K556_PARAMETER_MODE_COLOR = 0x05, /* Mode color (RGB) */
|
||||
REDRAGON_K556_PARAMETER_POLLING_RATE = 0x0F, /* Polling rate */
|
||||
REDRAGON_K556_PARAMETER_SURMOUNT_MODE_COLOR = 0x11, /* Surmount mode color */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
REDRAGON_K556_MODE_COLOR_WAVE_SHORT = 0x01, /* "Go with the stream" */
|
||||
REDRAGON_K556_MODE_COLOR_WAVE_LONG = 0x02, /* "Clouds fly" */
|
||||
REDRAGON_K556_MODE_COLOR_WHEEL = 0x03, /* "Winding paths" */
|
||||
REDRAGON_K556_MODE_SPECTRUM_CYCLE = 0x04, /* "The trial of light" */
|
||||
REDRAGON_K556_MODE_BREATHING = 0x05, /* "Breathing" */
|
||||
REDRAGON_K556_MODE_STATIC = 0x06, /* "Normally on" */
|
||||
REDRAGON_K556_MODE_REACTIVE = 0x07, /* "Pass without trace" */
|
||||
REDRAGON_K556_MODE_REACTIVE_RIPPLE = 0x08, /* "Ripple graff" */
|
||||
REDRAGON_K556_MODE_REACTIVE_LINE = 0x09, /* "Fast run without trace" */
|
||||
REDRAGON_K556_MODE_STARLIGHT_FAST = 0x0A, /* "Swift action" */
|
||||
REDRAGON_K556_MODE_BLOOMING = 0x0B, /* "Flowers blooming" */
|
||||
REDRAGON_K556_MODE_RAINBOW_WAVE_VERTICAL = 0x0C, /* "Snow winter jasmine" */
|
||||
REDRAGON_K556_MODE_HURRICANE = 0x0D, /* "Hurricane" */
|
||||
REDRAGON_K556_MODE_ACCUMULATE = 0x0E, /* "Accumulate" */
|
||||
REDRAGON_K556_MODE_STARLIGHT_SLOW = 0x0F, /* "Digital times" */
|
||||
REDRAGON_K556_MODE_VISOR = 0x10, /* "Both ways" */
|
||||
REDRAGON_K556_MODE_SURMOUNT = 0x11, /* "Surmount" */
|
||||
REDRAGON_K556_MODE_RAINBOW_WAVE_CIRCLE = 0x12, /* "Fast and the Furious" */
|
||||
REDRAGON_K556_MODE_CUSTOM = 0x14, /* "Coastal" */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
REDRAGON_K556_BRIGHTNESS_LOWEST = 0x00, /* Lowest brightness (off) */
|
||||
REDRAGON_K556_BRIGHTNESS_HIGHEST = 0x05, /* Highest brightness */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
REDRAGON_K556_SPEED_SLOWEST = 0x05, /* Slowest speed setting */
|
||||
REDRAGON_K556_SPEED_NORMAL = 0x03, /* Normal speed setting */
|
||||
REDRAGON_K556_SPEED_FASTEST = 0x00, /* Fastest speed setting */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
REDRAGON_K556_SURMOUNT_MODE_COLOR_RED = 0x01, /* Red surmount color */
|
||||
REDRAGON_K556_SURMOUNT_MODE_COLOR_YELLOW = 0x02, /* Yellow surmount color */
|
||||
REDRAGON_K556_SURMOUNT_MODE_COLOR_GREEN = 0x03, /* Green surmount color */
|
||||
REDRAGON_K556_SURMOUNT_MODE_COLOR_BLUE = 0x04, /* Blue surmount color */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
REDRAGON_K556_POLLING_RATE_125HZ = 0x00, /* 125Hz polling rate */
|
||||
REDRAGON_K556_POLLING_RATE_250HZ = 0x01, /* 250Hz polling rate */
|
||||
REDRAGON_K556_POLLING_RATE_500HZ = 0x02, /* 500Hz polling rate */
|
||||
REDRAGON_K556_POLLING_RATE_1000HZ = 0x03, /* 1000Hz polling rate */
|
||||
};
|
||||
|
||||
class RedragonK556Controller
|
||||
@@ -58,6 +108,18 @@ public:
|
||||
unsigned char mode
|
||||
);
|
||||
|
||||
void SendKeyboardModeEx
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char random_flag,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendKeyboardData
|
||||
(
|
||||
unsigned char * data,
|
||||
@@ -69,4 +131,16 @@ public:
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
void ComputeChecksum
|
||||
(
|
||||
char usb_buf[64]
|
||||
);
|
||||
|
||||
void SendKeyboardParameter
|
||||
(
|
||||
unsigned char parameter,
|
||||
unsigned char parameter_size,
|
||||
unsigned char* parameter_data
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,569 @@
|
||||
/*-----------------------------------------*\
|
||||
| NetworkClient.cpp |
|
||||
| |
|
||||
| Client code for OpenRGB SDK |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "NetworkClient.h"
|
||||
#include "RGBController_Network.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#define MSG_NOSIGNAL 0
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controllers(control)
|
||||
{
|
||||
strcpy(port_ip, "127.0.0.1");
|
||||
port_num = 1337;
|
||||
server_connected = false;
|
||||
server_controller_count = 0;
|
||||
}
|
||||
|
||||
void NetworkClient::ClientInfoChanged()
|
||||
{
|
||||
ClientInfoChangeMutex.lock();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
for(unsigned int callback_idx = 0; callback_idx < ClientInfoChangeCallbacks.size(); callback_idx++)
|
||||
{
|
||||
ClientInfoChangeCallbacks[callback_idx](ClientInfoChangeCallbackArgs[callback_idx]);
|
||||
}
|
||||
|
||||
ClientInfoChangeMutex.unlock();
|
||||
}
|
||||
|
||||
const char * NetworkClient::GetIP()
|
||||
{
|
||||
return(port_ip);
|
||||
}
|
||||
|
||||
unsigned short NetworkClient::GetPort()
|
||||
{
|
||||
return port_num;
|
||||
}
|
||||
|
||||
bool NetworkClient::GetOnline()
|
||||
{
|
||||
return server_connected;
|
||||
}
|
||||
|
||||
void NetworkClient::RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg)
|
||||
{
|
||||
ClientInfoChangeCallbacks.push_back(new_callback);
|
||||
ClientInfoChangeCallbackArgs.push_back(new_callback_arg);
|
||||
}
|
||||
|
||||
void NetworkClient::SetIP(const char *new_ip)
|
||||
{
|
||||
if(server_connected == false)
|
||||
{
|
||||
strcpy(port_ip, new_ip);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkClient::SetName(const char *new_name)
|
||||
{
|
||||
client_name = new_name;
|
||||
|
||||
if(server_connected == true)
|
||||
{
|
||||
SendData_ClientString();
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkClient::SetPort(unsigned short new_port)
|
||||
{
|
||||
if(server_connected == false)
|
||||
{
|
||||
port_num = new_port;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkClient::StartClient()
|
||||
{
|
||||
//Start a TCP server and launch threads
|
||||
char port_str[6];
|
||||
snprintf(port_str, 6, "%d", port_num);
|
||||
|
||||
port.tcp_client(port_ip, port_str);
|
||||
|
||||
//Start the connection thread
|
||||
ConnectionThread = new std::thread(&NetworkClient::ConnectionThreadFunction, this);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkClient::StopClient()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NetworkClient::ConnectionThreadFunction()
|
||||
{
|
||||
unsigned int requested_controllers;
|
||||
|
||||
//This thread manages the connection to the server
|
||||
while(1)
|
||||
{
|
||||
if(server_connected == false)
|
||||
{
|
||||
//Connect to server and reconnect if the connection is lost
|
||||
server_initialized = false;
|
||||
|
||||
//Try to connect to server
|
||||
if(port.tcp_client_connect() == true)
|
||||
{
|
||||
client_sock = port.sock;
|
||||
printf( "Connected to server\n" );
|
||||
|
||||
//Server is now connected
|
||||
server_connected = true;
|
||||
|
||||
//Start the listener thread
|
||||
ListenThread = new std::thread(&NetworkClient::ListenThreadFunction, this);
|
||||
|
||||
//Server is not initialized
|
||||
server_initialized = false;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "Connection attempt failed\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if(server_initialized == false && server_connected == true)
|
||||
{
|
||||
requested_controllers = 0;
|
||||
server_controller_count = 0;
|
||||
|
||||
//Wait for server to connect
|
||||
Sleep(100);
|
||||
|
||||
//Once server is connected, send client string
|
||||
SendData_ClientString();
|
||||
|
||||
//Request number of controllers
|
||||
SendRequest_ControllerCount();
|
||||
|
||||
//Wait for server controller count
|
||||
while(server_controller_count == 0)
|
||||
{
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
printf("Client: Received controller count from server: %d\r\n", server_controller_count);
|
||||
|
||||
//Once count is received, request controllers
|
||||
while(requested_controllers < server_controller_count)
|
||||
{
|
||||
printf("Client: Requesting controller %d\r\n", requested_controllers);
|
||||
|
||||
SendRequest_ControllerData(requested_controllers);
|
||||
|
||||
//Wait until controller is received
|
||||
while(server_controllers.size() == requested_controllers)
|
||||
{
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
requested_controllers++;
|
||||
}
|
||||
|
||||
//All controllers received, add them to master list
|
||||
printf("Client: All controllers received, adding them to master list\r\n");
|
||||
for(std::size_t controller_idx = 0; controller_idx < server_controllers.size(); controller_idx++)
|
||||
{
|
||||
controllers.push_back(server_controllers[controller_idx]);
|
||||
}
|
||||
|
||||
server_initialized = true;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
int NetworkClient::recv_select(SOCKET s, char *buf, int len, int flags)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(s, &set); /* add our file descriptor to the set */
|
||||
|
||||
int rv = select(s + 1, &set, NULL, NULL, &timeout);
|
||||
|
||||
if(rv == SOCKET_ERROR || server_connected == false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if(rv == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// socket has something to read
|
||||
return(recv(s, buf, len, flags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkClient::ListenThreadFunction()
|
||||
{
|
||||
printf("Network client listener started\n");
|
||||
//This thread handles messages received from the server
|
||||
while(server_connected = true)
|
||||
{
|
||||
NetPacketHeader header;
|
||||
int bytes_read = 0;
|
||||
char * data = NULL;
|
||||
|
||||
//Read first byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[0], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test first character of magic - 'O'
|
||||
if(header.pkt_magic[0] != 'O')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read second byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[1], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test second character of magic - 'R'
|
||||
if(header.pkt_magic[1] != 'R')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read third byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[2], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test third character of magic - 'G'
|
||||
if(header.pkt_magic[2] != 'G')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read fourth byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[3], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test fourth character of magic - 'B'
|
||||
if(header.pkt_magic[3] != 'B')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//If we get to this point, the magic is correct. Read the rest of the header
|
||||
bytes_read = 0;
|
||||
do
|
||||
{
|
||||
int tmp_bytes_read = 0;
|
||||
|
||||
tmp_bytes_read = recv_select(client_sock, (char *)&header.pkt_dev_idx + bytes_read, sizeof(header) - sizeof(header.pkt_magic) - bytes_read, 0);
|
||||
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
} while(bytes_read != sizeof(header) - sizeof(header.pkt_magic));
|
||||
|
||||
//printf( "Client: Received header, now receiving data of size %d\r\n", header.pkt_size);
|
||||
|
||||
//Header received, now receive the data
|
||||
if(header.pkt_size > 0)
|
||||
{
|
||||
bytes_read = 0;
|
||||
|
||||
data = new char[header.pkt_size];
|
||||
|
||||
do
|
||||
{
|
||||
int tmp_bytes_read = 0;
|
||||
|
||||
tmp_bytes_read = recv_select(client_sock, &data[bytes_read], header.pkt_size - bytes_read, 0);
|
||||
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
} while (bytes_read < header.pkt_size);
|
||||
}
|
||||
|
||||
//printf( "Client: Received header and data\r\n" );
|
||||
//printf( "Client: Packet ID: %d \r\n", header.pkt_id);
|
||||
|
||||
//Entire request received, select functionality based on request ID
|
||||
switch(header.pkt_id)
|
||||
{
|
||||
case NET_PACKET_ID_REQUEST_CONTROLLER_COUNT:
|
||||
printf( "Client: NET_PACKET_ID_REQUEST_CONTROLLER_COUNT\r\n" );
|
||||
|
||||
ProcessReply_ControllerCount(header.pkt_size, data);
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_REQUEST_CONTROLLER_DATA:
|
||||
printf( "Client: NET_PACKET_ID_REQUEST_CONTROLLER_DATA\r\n");
|
||||
|
||||
ProcessReply_ControllerData(header.pkt_size, data, header.pkt_dev_idx);
|
||||
break;
|
||||
}
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
listen_done:
|
||||
printf( "Client socket has been closed");
|
||||
server_initialized = false;
|
||||
server_connected = false;
|
||||
|
||||
for(int server_controller_idx = 0; server_controller_idx < server_controllers.size(); server_controller_idx++)
|
||||
{
|
||||
for(int controller_idx = 0; controller_idx < controllers.size(); controller_idx++)
|
||||
{
|
||||
if(controllers[controller_idx] == server_controllers[server_controller_idx])
|
||||
{
|
||||
controllers.erase(controllers.begin() + controller_idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete server_controllers[server_controller_idx];
|
||||
}
|
||||
|
||||
server_controllers.clear();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkClient::ProcessReply_ControllerCount(unsigned int data_size, char * data)
|
||||
{
|
||||
if(data_size == sizeof(unsigned int))
|
||||
{
|
||||
memcpy(&server_controller_count, data, sizeof(unsigned int));
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkClient::ProcessReply_ControllerData(unsigned int data_size, char * data, unsigned int dev_idx)
|
||||
{
|
||||
RGBController_Network * new_controller = new RGBController_Network(this, dev_idx);
|
||||
|
||||
new_controller->ReadDeviceDescription((unsigned char *)data);
|
||||
|
||||
printf("Received controller: %s\r\n", new_controller->name.c_str());
|
||||
|
||||
server_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
void NetworkClient::SendData_ClientString()
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = 0;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_SET_CLIENT_NAME;
|
||||
reply_hdr.pkt_size = strlen(client_name.c_str()) + 1;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)client_name.c_str(), reply_hdr.pkt_size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_ControllerCount()
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = 0;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_COUNT;
|
||||
reply_hdr.pkt_size = 0;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_ControllerData(unsigned int dev_idx)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_DATA;
|
||||
reply_hdr.pkt_size = 0;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
int reply_data[2];
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE;
|
||||
reply_hdr.pkt_size = sizeof(reply_data);
|
||||
|
||||
reply_data[0] = zone;
|
||||
reply_data[1] = new_size;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)&reply_data, sizeof(reply_data), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, 0);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateZoneLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateSingleLED(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_SetCustomMode(unsigned int dev_idx)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE;
|
||||
reply_hdr.pkt_size = 0;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*-----------------------------------------*\
|
||||
| NetworkClient.h |
|
||||
| |
|
||||
| Client header for OpenRGB SDK |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "NetworkProtocol.h"
|
||||
#include "net_port.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef void (*NetClientCallback)(void *);
|
||||
|
||||
class NetworkClient
|
||||
{
|
||||
public:
|
||||
NetworkClient(std::vector<RGBController *>& control);
|
||||
|
||||
void ClientInfoChanged();
|
||||
|
||||
const char * GetIP();
|
||||
unsigned short GetPort();
|
||||
bool GetOnline();
|
||||
|
||||
void RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg);
|
||||
|
||||
void SetIP(const char *new_ip);
|
||||
void SetName(const char *new_name);
|
||||
void SetPort(unsigned short new_port);
|
||||
|
||||
void StartClient();
|
||||
void StopClient();
|
||||
|
||||
void ConnectionThreadFunction();
|
||||
void ListenThreadFunction();
|
||||
|
||||
void ProcessReply_ControllerCount(unsigned int data_size, char * data);
|
||||
void ProcessReply_ControllerData(unsigned int data_size, char * data, unsigned int dev_idx);
|
||||
|
||||
void SendData_ClientString();
|
||||
|
||||
void SendRequest_ControllerCount();
|
||||
void SendRequest_ControllerData(unsigned int dev_idx);
|
||||
|
||||
void SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size);
|
||||
|
||||
void SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size);
|
||||
void SendRequest_RGBController_UpdateZoneLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size);
|
||||
void SendRequest_RGBController_UpdateSingleLED(unsigned int dev_idx, unsigned char * data, unsigned int size);
|
||||
|
||||
void SendRequest_RGBController_SetCustomMode(unsigned int dev_idx);
|
||||
|
||||
void SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size);
|
||||
|
||||
std::vector<RGBController *> server_controllers;
|
||||
|
||||
protected:
|
||||
std::vector<RGBController *>& controllers;
|
||||
|
||||
|
||||
private:
|
||||
SOCKET client_sock;
|
||||
std::string client_name;
|
||||
net_port port;
|
||||
char port_ip[20];
|
||||
unsigned short port_num;
|
||||
bool server_connected;
|
||||
bool server_initialized;
|
||||
unsigned int server_controller_count;
|
||||
|
||||
std::thread * ConnectionThread;
|
||||
std::thread * ListenThread;
|
||||
|
||||
std::mutex ClientInfoChangeMutex;
|
||||
std::vector<NetClientCallback> ClientInfoChangeCallbacks;
|
||||
std::vector<void *> ClientInfoChangeCallbackArgs;
|
||||
|
||||
int recv_select(SOCKET s, char *buf, int len, int flags);
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "NetworkProtocol.h"
|
||||
|
||||
NetPacketHeader * InitNetPacketHeader
|
||||
(
|
||||
unsigned int pkt_dev_idx,
|
||||
unsigned int pkt_id,
|
||||
unsigned int pkt_size
|
||||
)
|
||||
{
|
||||
NetPacketHeader * new_header = new NetPacketHeader;
|
||||
|
||||
new_header->pkt_magic[0] = 'O';
|
||||
new_header->pkt_magic[1] = 'R';
|
||||
new_header->pkt_magic[2] = 'G';
|
||||
new_header->pkt_magic[3] = 'B';
|
||||
|
||||
new_header->pkt_dev_idx = pkt_dev_idx;
|
||||
new_header->pkt_id = pkt_id;
|
||||
new_header->pkt_size = pkt_size;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*-----------------------------------------*\
|
||||
| NetworkProtocol.h |
|
||||
| |
|
||||
| Protocol header for OpenRGB SDK |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef struct NetPacketHeader
|
||||
{
|
||||
char pkt_magic[4]; /* Magic value "ORGB" identifies beginning of packet */
|
||||
unsigned int pkt_dev_idx; /* Device index */
|
||||
unsigned int pkt_id; /* Packet ID */
|
||||
unsigned int pkt_size; /* Packet size */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
| Network requests |
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
NET_PACKET_ID_REQUEST_CONTROLLER_COUNT = 0, /* Request RGBController device count from server */
|
||||
NET_PACKET_ID_REQUEST_CONTROLLER_DATA = 1, /* Request RGBController data block */
|
||||
NET_PACKET_ID_SET_CLIENT_NAME = 50, /* Send client name string to server */
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
| RGBController class functions |
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE = 1000, /* RGBController::ResizeZone() */
|
||||
|
||||
NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS = 1050, /* RGBController::UpdateLEDs() */
|
||||
NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS = 1051, /* RGBController::UpdateZoneLEDs() */
|
||||
NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED = 1052, /* RGBController::UpdateSingleLED() */
|
||||
|
||||
NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE = 1100, /* RGBController::SetCustomMode() */
|
||||
NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE = 1101, /* RGBController::UpdateMode() */
|
||||
};
|
||||
@@ -0,0 +1,611 @@
|
||||
/*-----------------------------------------*\
|
||||
| NetworkServer.cpp |
|
||||
| |
|
||||
| Server code for OpenRGB SDK |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "NetworkServer.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#include <memory.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
const char yes = 1;
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
NetworkServer::NetworkServer(std::vector<RGBController *>& control) : controllers(control)
|
||||
{
|
||||
port_num = 1337;
|
||||
server_online = false;
|
||||
}
|
||||
|
||||
void NetworkServer::ClientInfoChanged()
|
||||
{
|
||||
ClientInfoChangeMutex.lock();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
for(unsigned int callback_idx = 0; callback_idx < ClientInfoChangeCallbacks.size(); callback_idx++)
|
||||
{
|
||||
ClientInfoChangeCallbacks[callback_idx](ClientInfoChangeCallbackArgs[callback_idx]);
|
||||
}
|
||||
|
||||
ClientInfoChangeMutex.unlock();
|
||||
}
|
||||
|
||||
unsigned short NetworkServer::GetPort()
|
||||
{
|
||||
return port_num;
|
||||
}
|
||||
|
||||
bool NetworkServer::GetOnline()
|
||||
{
|
||||
return server_online;
|
||||
}
|
||||
|
||||
unsigned int NetworkServer::GetNumClients()
|
||||
{
|
||||
return ServerClients.size();
|
||||
}
|
||||
|
||||
const char * NetworkServer::GetClientString(unsigned int client_num)
|
||||
{
|
||||
if(client_num < ServerClients.size())
|
||||
{
|
||||
return ServerClients[client_num]->client_string.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
const char * NetworkServer::GetClientIP(unsigned int client_num)
|
||||
{
|
||||
if(client_num < ServerClients.size())
|
||||
{
|
||||
return ServerClients[client_num]->client_ip;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkServer::RegisterClientInfoChangeCallback(NetServerCallback new_callback, void * new_callback_arg)
|
||||
{
|
||||
ClientInfoChangeCallbacks.push_back(new_callback);
|
||||
ClientInfoChangeCallbackArgs.push_back(new_callback_arg);
|
||||
}
|
||||
|
||||
void NetworkServer::SetPort(unsigned short new_port)
|
||||
{
|
||||
if(server_online == false)
|
||||
{
|
||||
port_num = new_port;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkServer::StartServer()
|
||||
{
|
||||
//Start a TCP server and launch threads
|
||||
char port_str[6];
|
||||
snprintf(port_str, 6, "%d", port_num);
|
||||
|
||||
sockaddr_in myAddress;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Windows requires WSAStartup before using sockets |
|
||||
\*-------------------------------------------------*/
|
||||
#ifdef WIN32
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsa) != NO_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Create the server socket |
|
||||
\*-------------------------------------------------*/
|
||||
server_sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (server_sock == INVALID_SOCKET)
|
||||
{
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Fill in server address info with port value |
|
||||
\*-------------------------------------------------*/
|
||||
myAddress.sin_family = AF_INET;
|
||||
myAddress.sin_addr.s_addr = inet_addr("0.0.0.0");
|
||||
myAddress.sin_port = htons(atoi(port_str));
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Bind the server socket |
|
||||
\*-------------------------------------------------*/
|
||||
if (bind(server_sock, (sockaddr*)&myAddress, sizeof(myAddress)) == SOCKET_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set socket options - no delay |
|
||||
\*-------------------------------------------------*/
|
||||
setsockopt(server_sock, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
|
||||
|
||||
server_online = true;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Start the connection thread |
|
||||
\*-------------------------------------------------*/
|
||||
ConnectionThread = new std::thread(&NetworkServer::ConnectionThreadFunction, this);
|
||||
}
|
||||
|
||||
void NetworkServer::StopServer()
|
||||
{
|
||||
server_online = false;
|
||||
|
||||
for(unsigned int client_idx = 0; client_idx < ServerClients.size(); client_idx++)
|
||||
{
|
||||
shutdown(ServerClients[client_idx]->client_sock, SD_RECEIVE);
|
||||
closesocket(ServerClients[client_idx]->client_sock);
|
||||
ServerClients[client_idx]->client_listen_thread->join();
|
||||
}
|
||||
|
||||
shutdown(server_sock, SD_RECEIVE);
|
||||
closesocket(server_sock);
|
||||
|
||||
ConnectionThread->join();
|
||||
|
||||
for(unsigned int client_idx = 0; client_idx < ServerClients.size(); client_idx++)
|
||||
{
|
||||
delete ServerClients[client_idx];
|
||||
}
|
||||
|
||||
ServerClients.clear();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkServer::ConnectionThreadFunction()
|
||||
{
|
||||
//This thread handles client connections
|
||||
|
||||
printf("Network connection thread started\n");
|
||||
while(server_online == true)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Create new socket for client connection |
|
||||
\*-------------------------------------------------*/
|
||||
NetworkClientInfo * client_info = new NetworkClientInfo();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Listen for incoming client connection on the |
|
||||
| server socket. This call blocks until a |
|
||||
| connection is established |
|
||||
\*-------------------------------------------------*/
|
||||
if(listen(server_sock, 10) < 0)
|
||||
{
|
||||
printf("Connection thread closed\r\n");
|
||||
server_online = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Accept the client connection |
|
||||
\*-------------------------------------------------*/
|
||||
struct sockaddr_in client_addr;
|
||||
socklen_t client_addr_len = sizeof(client_addr);
|
||||
client_info->client_sock = accept_select(server_sock, (struct sockaddr *)&client_addr, &client_addr_len);
|
||||
|
||||
if(client_info->client_sock < 0)
|
||||
{
|
||||
printf("Connection thread closed\r\n");
|
||||
server_online = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get the new client socket and store it in the |
|
||||
| clients vector |
|
||||
\*-------------------------------------------------*/
|
||||
u_long arg = 0;
|
||||
ioctlsocket(client_info->client_sock, FIONBIO, &arg);
|
||||
setsockopt(client_info->client_sock, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
|
||||
|
||||
inet_ntop(AF_INET, &client_addr.sin_addr, client_info->client_ip, INET_ADDRSTRLEN);
|
||||
|
||||
client_info->client_string = "Client";
|
||||
|
||||
//Start a listener thread for the new client socket
|
||||
client_info->client_listen_thread = new std::thread(&NetworkServer::ListenThreadFunction, this, client_info);
|
||||
|
||||
ServerClients.push_back(client_info);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
printf("Connection thread closed\r\n");
|
||||
server_online = false;
|
||||
}
|
||||
|
||||
int NetworkServer::accept_select(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(sockfd, &set); /* add our file descriptor to the set */
|
||||
|
||||
int rv = select(sockfd + 1, &set, NULL, NULL, &timeout);
|
||||
|
||||
if(rv == SOCKET_ERROR || server_online == false)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if(rv == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// socket has something to read
|
||||
return(accept(sockfd, addr, addrlen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int NetworkServer::recv_select(SOCKET s, char *buf, int len, int flags)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(s, &set); /* add our file descriptor to the set */
|
||||
|
||||
int rv = select(s + 1, &set, NULL, NULL, &timeout);
|
||||
|
||||
if(rv == SOCKET_ERROR || server_online == false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if(rv == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// socket has something to read
|
||||
return(recv(s, buf, len, flags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||
{
|
||||
SOCKET client_sock = client_info->client_sock;
|
||||
|
||||
printf("Network server started\n");
|
||||
//This thread handles messages received from clients
|
||||
while(server_online == true)
|
||||
{
|
||||
NetPacketHeader header;
|
||||
int bytes_read = 0;
|
||||
char * data = NULL;
|
||||
|
||||
//Read first byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[0], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test first character of magic - 'O'
|
||||
if(header.pkt_magic[0] != 'O')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read second byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[1], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test second character of magic - 'R'
|
||||
if(header.pkt_magic[1] != 'R')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read third byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[2], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test third character of magic - 'G'
|
||||
if(header.pkt_magic[2] != 'G')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read fourth byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[3], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test fourth character of magic - 'B'
|
||||
if(header.pkt_magic[3] != 'B')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//If we get to this point, the magic is correct. Read the rest of the header
|
||||
bytes_read = 0;
|
||||
do
|
||||
{
|
||||
int tmp_bytes_read = 0;
|
||||
|
||||
tmp_bytes_read = recv_select(client_sock, (char *)&header.pkt_dev_idx + bytes_read, sizeof(header) - sizeof(header.pkt_magic) - bytes_read, 0);
|
||||
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
} while(bytes_read != sizeof(header) - sizeof(header.pkt_magic));
|
||||
|
||||
//printf( "Server: Received header, now receiving data of size %d\r\n", header.pkt_size);
|
||||
|
||||
//Header received, now receive the data
|
||||
if(header.pkt_size > 0)
|
||||
{
|
||||
bytes_read = 0;
|
||||
|
||||
data = new char[header.pkt_size];
|
||||
|
||||
do
|
||||
{
|
||||
int tmp_bytes_read = 0;
|
||||
|
||||
tmp_bytes_read = recv_select(client_sock, &data[bytes_read], header.pkt_size - bytes_read, 0);
|
||||
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
} while (bytes_read < header.pkt_size);
|
||||
}
|
||||
|
||||
//printf( "Server: Received header and data\r\n" );
|
||||
//printf( "Server: Packet ID: %d \r\n", header.pkt_id);
|
||||
|
||||
//Entire request received, select functionality based on request ID
|
||||
switch(header.pkt_id)
|
||||
{
|
||||
case NET_PACKET_ID_REQUEST_CONTROLLER_COUNT:
|
||||
//printf( "NET_PACKET_ID_REQUEST_CONTROLLER_COUNT\r\n" );
|
||||
SendReply_ControllerCount(client_sock);
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_REQUEST_CONTROLLER_DATA:
|
||||
//printf( "NET_PACKET_ID_REQUEST_CONTROLLER_DATA\r\n" );
|
||||
SendReply_ControllerData(client_sock, header.pkt_dev_idx);
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_SET_CLIENT_NAME:
|
||||
printf( "NET_PACKET_ID_SET_CLIENT_NAME\r\n" );
|
||||
ProcessRequest_ClientString(client_sock, header.pkt_size, data);
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE:
|
||||
//printf( "NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE\r\n" );
|
||||
|
||||
if((header.pkt_dev_idx < controllers.size()) && (header.pkt_size == (2 * sizeof(int))))
|
||||
{
|
||||
int zone;
|
||||
int new_size;
|
||||
|
||||
memcpy(&zone, data, sizeof(int));
|
||||
memcpy(&new_size, data + sizeof(int), sizeof(int));
|
||||
|
||||
controllers[header.pkt_dev_idx]->ResizeZone(zone, new_size);
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS:
|
||||
//printf( "NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS\r\n" );
|
||||
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetColorDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->UpdateLEDs();
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS:
|
||||
//printf( "NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS\r\n" );
|
||||
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
int zone;
|
||||
|
||||
memcpy(&zone, &data[sizeof(unsigned int)], sizeof(int));
|
||||
|
||||
controllers[header.pkt_dev_idx]->SetZoneColorDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->UpdateZoneLEDs(zone);
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED:
|
||||
//printf( "NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED\r\n" );
|
||||
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
int led;
|
||||
|
||||
memcpy(&led, data, sizeof(int));
|
||||
|
||||
controllers[header.pkt_dev_idx]->SetSingleLEDColorDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->UpdateSingleLED(led);
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE:
|
||||
//printf( "NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE\r\n" );
|
||||
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetCustomMode();
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE:
|
||||
//printf( "NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE\r\n" );
|
||||
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetModeDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->UpdateMode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
listen_done:
|
||||
printf("Server connection closed\r\n");
|
||||
shutdown(client_info->client_sock, SD_RECEIVE);
|
||||
closesocket(client_info->client_sock);
|
||||
|
||||
for(unsigned int this_idx = 0; this_idx < ServerClients.size(); this_idx++)
|
||||
{
|
||||
if(ServerClients[this_idx] == client_info)
|
||||
{
|
||||
ServerClients.erase(ServerClients.begin() + this_idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkServer::ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data)
|
||||
{
|
||||
for(unsigned int this_idx = 0; this_idx < ServerClients.size(); this_idx++)
|
||||
{
|
||||
if(ServerClients[this_idx]->client_sock == client_sock)
|
||||
{
|
||||
ServerClients[this_idx]->client_string = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkServer::SendReply_ControllerCount(SOCKET client_sock)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
unsigned int reply_data;
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = 0;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_COUNT;
|
||||
reply_hdr.pkt_size = sizeof(unsigned int);
|
||||
|
||||
reply_data = controllers.size();
|
||||
|
||||
send(client_sock, (const char *)&reply_hdr, sizeof(NetPacketHeader), 0);
|
||||
send(client_sock, (const char *)&reply_data, sizeof(unsigned int), 0);
|
||||
}
|
||||
|
||||
void NetworkServer::SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx)
|
||||
{
|
||||
if(dev_idx < controllers.size())
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
unsigned char *reply_data = controllers[dev_idx]->GetDeviceDescription();
|
||||
unsigned int reply_size;
|
||||
|
||||
memcpy(&reply_size, reply_data, sizeof(reply_size));
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
reply_hdr.pkt_magic[3] = 'B';
|
||||
|
||||
reply_hdr.pkt_dev_idx = dev_idx;
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_DATA;
|
||||
reply_hdr.pkt_size = reply_size;
|
||||
|
||||
send(client_sock, (const char *)&reply_hdr, sizeof(NetPacketHeader), 0);
|
||||
send(client_sock, (const char *)reply_data, reply_size, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*-----------------------------------------*\
|
||||
| NetworkServer.h |
|
||||
| |
|
||||
| Server header for OpenRGB SDK |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "NetworkProtocol.h"
|
||||
#include "net_port.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef void (*NetServerCallback)(void *);
|
||||
|
||||
struct NetworkClientInfo
|
||||
{
|
||||
SOCKET client_sock;
|
||||
std::thread * client_listen_thread;
|
||||
std::string client_string;
|
||||
char client_ip[INET_ADDRSTRLEN];
|
||||
};
|
||||
|
||||
class NetworkServer
|
||||
{
|
||||
public:
|
||||
NetworkServer(std::vector<RGBController *>& control);
|
||||
|
||||
unsigned short GetPort();
|
||||
bool GetOnline();
|
||||
unsigned int GetNumClients();
|
||||
const char * GetClientString(unsigned int client_num);
|
||||
const char * GetClientIP(unsigned int client_num);
|
||||
|
||||
void ClientInfoChanged();
|
||||
void RegisterClientInfoChangeCallback(NetServerCallback, void * new_callback_arg);
|
||||
|
||||
void SetPort(unsigned short new_port);
|
||||
|
||||
void StartServer();
|
||||
void StopServer();
|
||||
|
||||
void ConnectionThreadFunction();
|
||||
void ListenThreadFunction(NetworkClientInfo * client_sock);
|
||||
|
||||
void ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data);
|
||||
|
||||
void SendReply_ControllerCount(SOCKET client_sock);
|
||||
void SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx);
|
||||
|
||||
protected:
|
||||
unsigned short port_num;
|
||||
bool server_online;
|
||||
|
||||
std::vector<RGBController *>& controllers;
|
||||
|
||||
std::vector<NetworkClientInfo *> ServerClients;
|
||||
std::thread * ConnectionThread;
|
||||
|
||||
std::mutex ClientInfoChangeMutex;
|
||||
std::vector<NetServerCallback> ClientInfoChangeCallbacks;
|
||||
std::vector<void *> ClientInfoChangeCallbackArgs;
|
||||
|
||||
private:
|
||||
#ifdef WIN32
|
||||
WSADATA wsa;
|
||||
#endif
|
||||
|
||||
SOCKET server_sock;
|
||||
|
||||
int accept_select(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
|
||||
int recv_select(SOCKET s, char *buf, int len, int flags);
|
||||
};
|
||||
+21
-5
@@ -57,6 +57,7 @@ void DetectNuvotonI2CBusses()
|
||||
case SIO_NCT6102_ID:
|
||||
case SIO_NCT6793_ID:
|
||||
case SIO_NCT6796_ID:
|
||||
case SIO_NCT6798_ID:
|
||||
bus = new i2c_smbus_nct6775();
|
||||
|
||||
// Set logical device register to get SMBus base address
|
||||
@@ -81,6 +82,9 @@ void DetectNuvotonI2CBusses()
|
||||
case SIO_NCT6796_ID:
|
||||
sprintf(bus->device_name, "Nuvoton NCT6796D SMBus at %X", smba);
|
||||
break;
|
||||
case SIO_NCT6798_ID:
|
||||
sprintf(bus->device_name, "Nuvoton NCT6798D SMBus at %X", smba);
|
||||
break;
|
||||
}
|
||||
|
||||
busses.push_back(bus);
|
||||
@@ -250,11 +254,8 @@ void DetectI2CBusses()
|
||||
memset(device_string, 0x00, sizeof(device_string));
|
||||
read(test_fd, device_string, sizeof(device_string));
|
||||
device_string[strlen(device_string) - 1] = 0x00;
|
||||
|
||||
|
||||
close(test_fd);
|
||||
|
||||
bus = new i2c_smbus_linux();
|
||||
strcpy(bus->device_name, device_string);
|
||||
|
||||
strcpy(device_string, "/dev/");
|
||||
strcat(device_string, ent->d_name);
|
||||
@@ -262,11 +263,12 @@ void DetectI2CBusses()
|
||||
|
||||
if (test_fd < 0)
|
||||
{
|
||||
delete bus;
|
||||
ent = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
|
||||
bus = new i2c_smbus_linux();
|
||||
strcpy(bus->device_name, device_string);
|
||||
bus->handle = test_fd;
|
||||
busses.push_back(bus);
|
||||
}
|
||||
@@ -289,13 +291,18 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
|
||||
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 DetectRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectMSIMysticLightControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAuraUSBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAuraCoreControllers(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 DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
@@ -305,6 +312,7 @@ void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controller
|
||||
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusion2USBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectNZXTKrakenControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -328,14 +336,21 @@ void DetectRGBControllers(void)
|
||||
DetectPolychromeControllers(busses, rgb_controllers);
|
||||
DetectRGBFusionGPUControllers(busses, rgb_controllers);
|
||||
|
||||
//TODO: Implement better detection before enabling this controller
|
||||
//DetectRGBFusion2SMBusControllers(busses, rgb_controllers);
|
||||
|
||||
DetectRGBFusionControllers(busses, rgb_controllers);
|
||||
DetectMSIMysticLightControllers(rgb_controllers);
|
||||
DetectMSIRGBControllers(rgb_controllers);
|
||||
|
||||
DetectAuraUSBControllers(rgb_controllers);
|
||||
DetectAuraCoreControllers(rgb_controllers);
|
||||
DetectLEDStripControllers(rgb_controllers);
|
||||
DetectHue2Controllers(rgb_controllers);
|
||||
DetectHuePlusControllers(rgb_controllers);
|
||||
|
||||
DetectAMDWraithPrismControllers(rgb_controllers);
|
||||
DetectCoolerMasterControllers(rgb_controllers);
|
||||
DetectMSI3ZoneControllers(rgb_controllers);
|
||||
DetectPoseidonZRGBControllers(rgb_controllers);
|
||||
DetectHyperXKeyboardControllers(rgb_controllers);
|
||||
@@ -344,6 +359,7 @@ void DetectRGBControllers(void)
|
||||
DetectThermaltakeRiingControllers(rgb_controllers);
|
||||
DetectRGBFusion2USBControllers(rgb_controllers);
|
||||
DetectRedragonControllers(rgb_controllers);
|
||||
DetectNZXTKrakenControllers(rgb_controllers);
|
||||
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
|
||||
|
||||
+60
-9
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
TARGET = OpenRGB
|
||||
TEMPLATE = app
|
||||
|
||||
VERSION = 0.1
|
||||
VERSION = 0.2
|
||||
win32:BUILDDATE = $$system(date /t)
|
||||
unix:BUILDDATE = $$system(date -R)
|
||||
GIT_COMMIT_ID = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ rev-parse HEAD)
|
||||
@@ -22,6 +22,7 @@ DEFINES += \
|
||||
RC_ICONS = qt/OpenRGB.ico
|
||||
|
||||
INCLUDEPATH += \
|
||||
dependencies/ColorWheel \
|
||||
dependencies/hidapi \
|
||||
dependencies/libe131/src/ \
|
||||
i2c_smbus/ \
|
||||
@@ -30,8 +31,11 @@ INCLUDEPATH += \
|
||||
serial_port/ \
|
||||
super_io/ \
|
||||
Controllers/AMDWraithPrismController/ \
|
||||
Controllers/AuraUSBController/ \
|
||||
Controllers/AuraCoreController/ \
|
||||
Controllers/AuraGPUController/ \
|
||||
Controllers/AuraSMBusController/ \
|
||||
Controllers/CoolerMasterController/ \
|
||||
Controllers/CorsairPeripheralController/ \
|
||||
Controllers/CorsairLightingNodeController/ \
|
||||
Controllers/CorsairVengeanceController/ \
|
||||
@@ -43,12 +47,15 @@ INCLUDEPATH += \
|
||||
Controllers/HyperXKeyboardController/ \
|
||||
Controllers/LEDStripController/ \
|
||||
Controllers/MSI3ZoneController/ \
|
||||
Controllers/MSIMysticLightController/ \
|
||||
Controllers/MSIRGBController/ \
|
||||
Controllers/NZXTKrakenController/ \
|
||||
Controllers/PatriotViperController/ \
|
||||
Controllers/PolychromeController/ \
|
||||
Controllers/PoseidonZRGBController/ \
|
||||
Controllers/RedragonController/ \
|
||||
Controllers/RGBFusionController/ \
|
||||
Controllers/RGBFusion2SMBusController/ \
|
||||
Controllers/RGBFusion2USBController/ \
|
||||
Controllers/RGBFusionGPUController/ \
|
||||
Controllers/ThermaltakeRiingController/ \
|
||||
@@ -56,11 +63,14 @@ INCLUDEPATH += \
|
||||
qt/
|
||||
|
||||
SOURCES += \
|
||||
dependencies/ColorWheel/ColorWheel.cpp \
|
||||
dependencies/hidapi/hidapi.c \
|
||||
dependencies/libe131/src/e131.c \
|
||||
main.cpp \
|
||||
cli.cpp \
|
||||
OpenRGB.cpp \
|
||||
NetworkClient.cpp \
|
||||
NetworkServer.cpp \
|
||||
ProfileManager.cpp \
|
||||
qt/OpenRGBDeviceInfoPage.cpp \
|
||||
qt/OpenRGBDevicePage.cpp \
|
||||
@@ -70,6 +80,7 @@ SOURCES += \
|
||||
net_port/net_port.cpp \
|
||||
qt/OpenRGBDialog2.cpp \
|
||||
qt/OpenRGBProfileSaveDialog.cpp \
|
||||
qt/OpenRGBServerInfoPage.cpp \
|
||||
qt/OpenRGBSoftwareInfoPage.cpp \
|
||||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
qt/OpenRGBZoneResizeDialog.cpp \
|
||||
@@ -78,10 +89,18 @@ SOURCES += \
|
||||
super_io/super_io.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
|
||||
Controllers/AuraUSBController/AuraUSBController.cpp \
|
||||
Controllers/AuraUSBController/AuraAddressableController.cpp \
|
||||
Controllers/AuraUSBController/AuraMainboardController.cpp \
|
||||
Controllers/AuraUSBController/AuraUSBControllerDetect.cpp \
|
||||
Controllers/AuraCoreController/AuraCoreController.cpp \
|
||||
Controllers/AuraCoreController/AuraCoreControllerDetect.cpp \
|
||||
Controllers/AuraGPUController/AuraGPUController.cpp \
|
||||
Controllers/AuraGPUController/AuraGPUControllerDetect.cpp \
|
||||
Controllers/AuraSMBusController/AuraSMBusController.cpp \
|
||||
Controllers/AuraSMBusController/AuraSMBusControllerDetect.cpp \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.cpp \
|
||||
Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeControllerDetect.cpp \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp \
|
||||
@@ -104,8 +123,12 @@ SOURCES += \
|
||||
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.cpp \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp \
|
||||
Controllers/MSIRGBController/MSIRGBController.cpp \
|
||||
Controllers/MSIRGBController/MSIRGBControllerDetect.cpp \
|
||||
Controllers/NZXTKrakenController/NZXTKrakenController.cpp \
|
||||
Controllers/NZXTKrakenController/NZXTKrakenControllerDetect.cpp \
|
||||
Controllers/PatriotViperController/PatriotViperController.cpp \
|
||||
Controllers/PatriotViperController/PatriotViperControllerDetect.cpp \
|
||||
Controllers/PolychromeController/PolychromeController.cpp \
|
||||
@@ -116,6 +139,8 @@ SOURCES += \
|
||||
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
|
||||
Controllers/RGBFusion2USBController/RGBFusion2USBController.cpp \
|
||||
Controllers/RGBFusion2USBController/RGBFusion2USBControllerDetect.cpp \
|
||||
Controllers/RGBFusion2SMBusController/RGBFusion2SMBusController.cpp \
|
||||
Controllers/RGBFusion2SMBusController/RGBFusion2SMBusControllerDetect.cpp \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUController.cpp \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUControllerDetect.cpp \
|
||||
Controllers/RedragonController/RedragonK556Controller.cpp \
|
||||
@@ -126,8 +151,11 @@ SOURCES += \
|
||||
RGBController/RGBController.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_AMDWraithPrism.cpp \
|
||||
RGBController/RGBController_AuraUSB.cpp \
|
||||
RGBController/RGBController_AuraCore.cpp \
|
||||
RGBController/RGBController_AuraGPU.cpp \
|
||||
RGBController/RGBController_AuraSMBus.cpp \
|
||||
RGBController/RGBController_CMMP750Controller.cpp \
|
||||
RGBController/RGBController_CorsairLightingNode.cpp \
|
||||
RGBController/RGBController_CorsairPeripheral.cpp \
|
||||
RGBController/RGBController_CorsairVengeance.cpp \
|
||||
@@ -141,18 +169,26 @@ SOURCES += \
|
||||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_MSI3Zone.cpp \
|
||||
RGBController/RGBController_MSIMysticLight.cpp \
|
||||
RGBController/RGBController_MSIRGB.cpp \
|
||||
RGBController/RGBController_Network.cpp \
|
||||
RGBController/RGBController_NZXTKraken.cpp \
|
||||
RGBController/RGBController_PatriotViper.cpp \
|
||||
RGBController/RGBController_Polychrome.cpp \
|
||||
RGBController/RGBController_PoseidonZRGB.cpp \
|
||||
RGBController/RGBController_RedragonK556.cpp \
|
||||
RGBController/RGBController_RedragonM711.cpp \
|
||||
RGBController/RGBController_RGBFusion.cpp \
|
||||
RGBController/RGBController_RGBFusion2SMBus.cpp \
|
||||
RGBController/RGBController_RGBFusion2USB.cpp \
|
||||
RGBController/RGBController_RGBFusionGPU.cpp \
|
||||
RGBController/RGBController_ThermaltakeRiing.cpp \
|
||||
|
||||
HEADERS += \
|
||||
dependencies/ColorWheel/ColorWheel.h \
|
||||
NetworkClient.h \
|
||||
NetworkProtocol.h \
|
||||
NetworkServer.h \
|
||||
ProfileManager.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
@@ -162,6 +198,7 @@ HEADERS += \
|
||||
net_port/net_port.h \
|
||||
qt/OpenRGBDialog2.h \
|
||||
qt/OpenRGBProfileSaveDialog.h \
|
||||
qt/OpenRGBServerInfoPage.h \
|
||||
qt/OpenRGBSoftwareInfoPage.h \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
qt/OpenRGBZoneResizeDialog.h \
|
||||
@@ -169,8 +206,13 @@ HEADERS += \
|
||||
serial_port/serial_port.h \
|
||||
super_io/super_io.h \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
|
||||
Controllers/AuraUSBController/AuraUSBController.h \
|
||||
Controllers/AuraUSBController/AuraAddressableController.h \
|
||||
Controllers/AuraUSBController/AuraMainboardController.h \
|
||||
Controllers/AuraCoreController/AuraCoreController.h \
|
||||
Controllers/AuraGPUController/AuraGPUController.h \
|
||||
Controllers/AuraSMBusController/AuraSMBusController.h \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.h \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.h \
|
||||
Controllers/CorsairVengeanceController/CorsairVengeanceController.h \
|
||||
@@ -182,20 +224,25 @@ HEADERS += \
|
||||
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.h \
|
||||
Controllers/MSIRGBController/MSIRGBController.h \
|
||||
Controllers/PatriotViperController/PatriotViperController.h \
|
||||
Controllers/PolychromeController/PolychromeController.h \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
Controllers/RGBFusion2USBController/RGBFusion2USBController.h \
|
||||
Controllers/RGBFusion2SMBusController/RGBFusion2SMBusController.h \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUController.h \
|
||||
Controllers/RedragonController/RedragonK556Controller.h \
|
||||
Controllers/RedragonController/RedragonM711Controller.h \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_AMDWraithPrism.h \
|
||||
RGBController/RGBController_AuraUSB.h \
|
||||
RGBController/RGBController_AuraCore.h \
|
||||
RGBController/RGBController_AuraGPU.h \
|
||||
RGBController/RGBController_AuraSMBus.h \
|
||||
RGBController/RGBController_CMMP750Controller.h \
|
||||
RGBController/RGBController_CorsairLightingNode.h \
|
||||
RGBController/RGBController_CorsairPeripheral.h \
|
||||
RGBController/RGBController_CorsairVengeance.h \
|
||||
@@ -209,13 +256,16 @@ HEADERS += \
|
||||
RGBController/RGBController_HyperXKeyboard.h \
|
||||
RGBController/RGBController_LEDStrip.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
RGBController/RGBController_MSIMysticLight.h \
|
||||
RGBController/RGBController_MSIRGB.h \
|
||||
RGBController/RGBController_Network.h \
|
||||
RGBController/RGBController_PatriotViper.h \
|
||||
RGBController/RGBController_Polychrome.h \
|
||||
RGBController/RGBController_PoseidonZRGB.h \
|
||||
RGBController/RGBController_RedragonK556.h \
|
||||
RGBController/RGBController_RedragonM711.h \
|
||||
RGBController/RGBController_RGBFusion.h \
|
||||
RGBController/RGBController_RGBFusion2SMBus.h \
|
||||
RGBController/RGBController_RGBFusion2USB.h \
|
||||
RGBController/RGBController_RGBFusionGPU.h \
|
||||
RGBController/RGBController_ThermaltakeRiing.h \
|
||||
@@ -224,14 +274,15 @@ RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
||||
FORMS += \
|
||||
qt/OpenRGBDeviceInfoPage.ui \
|
||||
qt/OpenRGBDevicePage.ui \
|
||||
qt/OpenRGBDialog.ui \
|
||||
qt/OpenRGBDialog2.ui \
|
||||
qt/OpenRGBProfileSaveDialog.ui \
|
||||
qt/OpenRGBSoftwareInfoPage.ui \
|
||||
qt/OpenRGBSystemInfoPage.ui \
|
||||
qt/OpenRGBZoneResizeDialog.ui
|
||||
qt/OpenRGBDeviceInfoPage.ui \
|
||||
qt/OpenRGBDevicePage.ui \
|
||||
qt/OpenRGBDialog.ui \
|
||||
qt/OpenRGBDialog2.ui \
|
||||
qt/OpenRGBProfileSaveDialog.ui \
|
||||
qt/OpenRGBServerInfoPage.ui \
|
||||
qt/OpenRGBSoftwareInfoPage.ui \
|
||||
qt/OpenRGBSystemInfoPage.ui \
|
||||
qt/OpenRGBZoneResizeDialog.ui \
|
||||
|
||||
#-----------------------------------------------
|
||||
# Windows specific project configuration
|
||||
|
||||
@@ -1,56 +1,137 @@
|
||||
# OpenRGB (formerly OpenAuraSDK)
|
||||
##  (formerly OpenAuraSDK)
|
||||
|
||||
The goal of this project is to create an easy-to-use open source software program and library for accessing and controlling RGB lights on various PC hardware including motherboards, RAM modules, graphics cards, cooling devices, and peripherals.
|
||||
|
||||
This project originally focused only on ASUS Aura. It was spun off of Keyboard Visualizer's AsusAuraWindows branch to learn more about the details behind the Aura protocol and to develop a more flexible, compatible, and reliable driver for Aura. Our Aura implementation is now quite solid and supports multiple generations of Aura controller across both Intel and AMD platforms. It also supports Aura-compatible controllers used across multiple manufacturers of RGB memory modules including G.Skill Trident Z RGB and others. It is still lacking a few capabilities, namely saving settings to persist across reboots, but the core functionality of setting colors and modes is there.
|
||||
|
||||
After getting a solid Aura implementation, the project branched out into other manufacturers and categories of RGB devices. A major focus was to develop a software API that could reliably represent as many RGB devices as possible, exposing their various modes and describing their LED layouts via zones, that was generic enough to write a user application without specifically targeting any one manufacturer. To this extent, the generic_rgb_interface_test branch was created which became the foundation of OpenRGB. The goal of OpenRGB is to both develop new drivers for unsupported devices and integrate existing open source drivers for devices that do have some sort of open support. The goal is to be the one-stop solution to open source RGB lighting control!
|
||||
One of the biggest complaints about RGB is the software ecosystem surrounding it. Every manufacturer has their own app, their own brand, their own style. If you want to mix and match devices, you end up with a ton of conflicting, functionally identical apps competing for your background resources. On top of that, these apps are proprietary and Windows-only. Some even require online accounts. What if there was a way to control all of your RGB devices from a single app, on both Windows and Linux, without any nonsense? That is what OpenRGB sets out to achieve. One app to rule them all.
|
||||
OpenRGB is still in its early stages and already supports quite a few products. I'm always on the lookout for good deals on more popular RGB devices to add support for.
|
||||
|
||||
## Supported Devices
|
||||
|
||||
See the [Project Wiki](https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/home) for the current list of supported devices.
|
||||
|
||||
## Installation
|
||||
#### Windows
|
||||
1. Download the latest Visual Studio Community Edition and Qt Creator.
|
||||
2. Update the submodules: git submodule update --init --recursive
|
||||
3. Open the OpenRGB_Win.pro project.
|
||||
4. Build the project for `x86` Architecture. The InpOut32 library I use does not support x64.
|
||||
5. Copy InpOut32.dll from dependencies to the same path as OpenAuraSDK.exe along with the Qt libraries.
|
||||
## WARNING!
|
||||
|
||||
**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**
|
||||
This project provides a tool to probe the SMBus. This is a potentially dangerous operation if you don't know what you're doing. Exercise caution when clicking the Detect Devices or Dump Device buttons. There have been reports of Gigabyte motherboards having serious issues (bricking the RGB or bricking the entire board) when dumping certain devices. On the same lines, exercise the same caution when using the i2cdump and i2cdetect commands on Linux, as they perform the same functionality. OpenRGB is not liable for damage caused by improper SMBus access.
|
||||
|
||||
#### Linux:
|
||||
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.
|
||||
As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues.
|
||||
|
||||

|
||||
|
||||
## Windows
|
||||
* Pre-built binaries are available under the Releases section on GitLab.
|
||||
|
||||
* If you wish to build the application yourself:
|
||||
|
||||
1. Download the latest Visual Studio Community Edition and Qt Creator.
|
||||
2. Open the OpenRGB.pro project in Qt Creator.
|
||||
3. Use the MSVC compiler kit, either 32- or 64-bit, to build the application.
|
||||
4. Run the project from Qt Creator. If you want to use your custom build standalone, download the latest matching Release package and replace the OpenRGB.exe in it with your new build.
|
||||
|
||||
* **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**
|
||||
|
||||
### USB Access
|
||||
|
||||
* Some USB devices (especially keyboards and mice) require installation of the WinUSB driver. You can do this with Zadig:
|
||||
- Download Zadig: https://zadig.akeo.ie/
|
||||
- Select "list all devices" from the menu
|
||||
- Select the last interface of your device
|
||||
- With "WinUSB" selected, click Install
|
||||
|
||||
## Linux
|
||||
* Pre-built binaries are not currently available for Linux
|
||||
|
||||
* You can build the project using Qt Creator or on the command line. The commands listed here work for Debian-based distros.
|
||||
|
||||
1. sudo apt install build-essential qtcreator qt5-default libusb-1.0-0-dev
|
||||
2. git clone https://gitlab.com/CalcProgrammer1/OpenRGB
|
||||
3. cd OpenRGB
|
||||
4. qmake OpenRGB.pro
|
||||
5. make -j8
|
||||
|
||||
* 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
|
||||
* Run the application with ./OpenRGB
|
||||
|
||||
### SMBus Access
|
||||
|
||||
2. Allow access to SMBus:<br>
|
||||
* SMBus access is necessary for controlling RGB RAM and certain motherboard on-board LEDs.
|
||||
|
||||
- This can be identified by your motherboard
|
||||
##### Intel
|
||||
- `modprobe i2c-dev i2c-i801`
|
||||
- Asus used the SMBus controller on the Super IO chip for on-board Aura chips on Intel motherboards. I have a kernel patch to add a driver for this chip [here](https://gitlab.com/CalcProgrammer1/OpenAuraSDK/issues/22). After patching the kernel, enable the Nuvoton NCT67xx SMBus driver in your kernel configuration. The driver may be loaded with `modprobe i2c-nct6775`
|
||||
##### AMD
|
||||
- `modprobe i2c-dev i2c-piix4`
|
||||
- The second SMBus isn't currently picked up by the kernel driver and that seems to be where Asus wired the Aura controllers so I have a kernel patch [here](https://gitlab.com/CalcProgrammer1/OpenAuraSDK/issues/9) that will allow the kernel to use the second bus (at `0x0b20`).
|
||||
* If you are not trying to use OpenRGB to control RGB RAM or motherboard LEDs, you may skip this section.
|
||||
|
||||
- You'll have to enable user access to your SMbus if you don't run as root.
|
||||
- List all SMBus controllers: `sudo i2cdetect -l`
|
||||
- Find out which control your Aura devices (PIIX4, I801, and NCT67xx)
|
||||
- Give user access to those controllers, for instance: `sudo chmod 777 /dev/i2c-0`
|
||||
* ASUS and ASRock motherboards have their RGB controller on an SMBus interface that is not accessible by an unmodified Linux kernel (for now). I am working on getting patches submitted upstream, but for now you must patch your kernel with the provided OpenRGB.patch file.
|
||||
|
||||
* Allowing access to SMBus:
|
||||
|
||||
1. Load the i2c-dev module: `sudo modprobe i2c-dev`
|
||||
|
||||
2. Load the i2c driver for your chipset:
|
||||
- Intel:
|
||||
- `sudo modprobe i2c-i801`
|
||||
- `sudo modprobe i2c-nct6775` - Secondary controller for motherboard LEDs (requires patch)
|
||||
- AMD:
|
||||
- `modprobe i2c-piix4`
|
||||
- Unmodified kernel will have one interface, patched kernel will have two. The first at 0x0B00 and the second at 0x0B20. The 0x0B20 interface is for motherboard LEDs.
|
||||
|
||||
* Instructions on patching the kernel:
|
||||
- https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/OpenRGB-Kernel-Patch
|
||||
|
||||
* Some Gigabyte/Aorus motherboards have an ACPI conflict with the SMBus controller.
|
||||
- Add `acpi_enforce_resources=lax` to your kernel command line and reboot. The controller should now show up.
|
||||
|
||||
* You'll have to enable user access to your SMBus if you don't run as root.
|
||||
- List all SMBus controllers: `sudo i2cdetect -l`
|
||||
- Note the number for PIIX4, I801, and NCT6775 controllers.
|
||||
- Give user access to those controllers, for instance: `sudo chmod 777 /dev/i2c-0`
|
||||
|
||||
### USB Access
|
||||
|
||||
* USB devices require udev rules to access as a normal user.
|
||||
|
||||
* You can run OpenRGB as root to detect all USB devices.
|
||||
|
||||
* Udev rules can be found here:
|
||||
- https://drive.google.com/drive/folders/1tWVbeOLiLns_IhgyNDWqSK3ZKtP-6oYM?usp=sharing
|
||||
- Copy the .rules files to /etc/udev/rules.d/
|
||||
- Reload rules with `sudo udevadm control --reload-rules && sudo udevadm trigger`
|
||||
- Add your user to the `plugdev` group: `sudo adduser username plugdev`
|
||||
|
||||
## Projects Used
|
||||
|
||||
* InpOutx64: http://www.highrez.co.uk/downloads/inpout32/
|
||||
|
||||
* libusb: https://github.com/libusb/libusb
|
||||
|
||||
* hidapi: https://github.com/libusb/hidapi
|
||||
|
||||
* libe131: https://github.com/hhromic/libe131
|
||||
|
||||
* NVFC: https://github.com/graphitemaster/NVFC
|
||||
|
||||
* OpenRazer: https://github.com/openrazer/openrazer
|
||||
|
||||
* OpenRazer-Win32: https://github.com/CalcProgrammer1/openrazer-win32
|
||||
|
||||
* Qt-Plus (ColorWheel): https://github.com/liuyanghejerry/Qt-Plus
|
||||
|
||||
## Projects Researched
|
||||
|
||||
While no code from these projects directly made its way into OpenRGB, these projects have been invaluable resources for protocol information.
|
||||
|
||||
* ckb-next: https://github.com/ckb-next/ckb-next
|
||||
|
||||
* linux_thermaltake_riing: https://github.com/chestm007/linux_thermaltake_riing
|
||||
|
||||
* Aura Addressable Header Controller: https://gitlab.com/cneil02/aura-addressable-header-controller
|
||||
|
||||
* OpenPyAURA: https://gitlab.com/thelastguardian/openpyaura
|
||||
|
||||
* AsrLed: https://github.com/EUA/AsrLed
|
||||
|
||||
* asrock-leds: https://github.com/RattyDAVE/asrock-leds
|
||||
|
||||
* hue-plus: https://github.com/kusti8/hue-plus
|
||||
|
||||
* rogauracore: https://github.com/wroberts/rogauracore
|
||||
|
||||
* msi-rgb: https://github.com/nagisa/msi-rgb
|
||||
|
||||
* OpenCorsairLink: https://github.com/audiohacked/OpenCorsairLink
|
||||
|
||||
* msi-keyboard: https://github.com/bparker06/msi-keyboard
|
||||
+1704
-116
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,91 @@
|
||||
#define OPENRAZERDLL "OpenRazer.dll"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct device_attribute* dev_attr_list[44];
|
||||
} device_fn_list_type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| This is a table of device attribute names. It should |
|
||||
| always match the order of the entries in the structure |
|
||||
\*---------------------------------------------------------*/
|
||||
static const char* device_fn_names[] =
|
||||
{
|
||||
"device_type",
|
||||
"device_serial",
|
||||
"firmware_version",
|
||||
|
||||
"matrix_custom_frame",
|
||||
"matrix_brightness",
|
||||
|
||||
"matrix_effect_custom",
|
||||
"matrix_effect_none",
|
||||
"matrix_effect_static",
|
||||
"matrix_effect_breath",
|
||||
"matrix_effect_spectrum",
|
||||
"matrix_effect_reactive",
|
||||
"matrix_effect_wave",
|
||||
|
||||
"logo_led_brightness",
|
||||
"logo_matrix_effect_none",
|
||||
"logo_matrix_effect_static",
|
||||
"logo_matrix_effect_breath",
|
||||
"logo_matrix_effect_spectrum",
|
||||
"logo_matrix_effect_reactive",
|
||||
|
||||
"scroll_led_brightness",
|
||||
"scroll_matrix_effect_none",
|
||||
"scroll_matrix_effect_static",
|
||||
"scroll_matrix_effect_breath",
|
||||
"scroll_matrix_effect_spectrum",
|
||||
"scroll_matrix_effect_reactive",
|
||||
|
||||
"left_led_brightness",
|
||||
"left_matrix_effect_none",
|
||||
"left_matrix_effect_static",
|
||||
"left_matrix_effect_breath",
|
||||
"left_matrix_effect_spectrum",
|
||||
"left_matrix_effect_reactive",
|
||||
"left_matrix_effect_wave",
|
||||
|
||||
"right_led_brightness",
|
||||
"right_matrix_effect_none",
|
||||
"right_matrix_effect_static",
|
||||
"right_matrix_effect_breath",
|
||||
"right_matrix_effect_spectrum",
|
||||
"right_matrix_effect_reactive",
|
||||
"right_matrix_effect_wave",
|
||||
|
||||
"logo_led_effect",
|
||||
"logo_led_rgb",
|
||||
"logo_led_state",
|
||||
|
||||
"scroll_led_effect",
|
||||
"scroll_led_rgb",
|
||||
"scroll_led_state"
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| This function searches the device attribute list of a |
|
||||
| given device to fill in a device_fn_type structure |
|
||||
\*---------------------------------------------------------*/
|
||||
static void load_device_fn(device_fn_type* device_fn, device* dev)
|
||||
{
|
||||
memset(device_fn, 0, sizeof(device_fn_type));
|
||||
|
||||
for (int table_idx = 0; table_idx < 44; table_idx++)
|
||||
{
|
||||
for (int list_idx = 0; list_idx < dev->attr_count; list_idx++)
|
||||
{
|
||||
if (strcmp(device_fn_names[table_idx], dev->attr_list[list_idx]->name) == 0)
|
||||
{
|
||||
((device_fn_list_type*)device_fn)->dev_attr_list[table_idx] = dev->attr_list[list_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectOpenRazerControllers *
|
||||
@@ -32,105 +117,22 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
return;
|
||||
}
|
||||
|
||||
// map DLL calls
|
||||
/*---------------------------------------------------------*\
|
||||
| Map DLL functions |
|
||||
\*---------------------------------------------------------*/
|
||||
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;
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize all OpenRazer driver modules and store devices |
|
||||
\*---------------------------------------------------------*/
|
||||
struct hid_device* hdev;
|
||||
unsigned int num;
|
||||
|
||||
hdev = NULL;
|
||||
@@ -138,30 +140,8 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
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;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
@@ -179,30 +159,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
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;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
@@ -221,30 +178,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
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;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
@@ -263,30 +197,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
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;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
@@ -305,30 +216,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
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;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
@@ -347,30 +235,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
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;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
|
||||
@@ -1,6 +1,29 @@
|
||||
#include "RGBController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
RGBController::RGBController()
|
||||
{
|
||||
DeviceThreadRunning = true;
|
||||
DeviceCallThread = new std::thread(&RGBController::DeviceCallThreadFunction, this);
|
||||
}
|
||||
|
||||
RGBController::~RGBController()
|
||||
{
|
||||
DeviceThreadRunning = false;
|
||||
DeviceCallThread->join();
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetDeviceDescription()
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
@@ -23,6 +46,7 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||
unsigned short *zone_name_len = new unsigned short[num_zones];
|
||||
unsigned short *led_name_len = new unsigned short[num_leds];
|
||||
|
||||
unsigned short *zone_matrix_len = new unsigned short[num_zones];
|
||||
unsigned short *mode_num_colors = new unsigned short[num_modes];
|
||||
|
||||
data_size += sizeof(data_size);
|
||||
@@ -66,6 +90,18 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||
data_size += sizeof(zones[zone_index].leds_min);
|
||||
data_size += sizeof(zones[zone_index].leds_max);
|
||||
data_size += sizeof(zones[zone_index].leds_count);
|
||||
|
||||
if(zones[zone_index].matrix_map == NULL)
|
||||
{
|
||||
zone_matrix_len[zone_index] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
zone_matrix_len[zone_index] = (2 * sizeof(unsigned int)) + (zones[zone_index].matrix_map->height * zones[zone_index].matrix_map->width * sizeof(unsigned int));
|
||||
}
|
||||
|
||||
data_size += sizeof(zone_matrix_len[zone_index]);
|
||||
data_size += zone_matrix_len[zone_index];
|
||||
}
|
||||
|
||||
data_size += sizeof(num_leds);
|
||||
@@ -286,6 +322,39 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &zones[zone_index].leds_count, sizeof(zones[zone_index].leds_count));
|
||||
data_ptr += sizeof(zones[zone_index].leds_count);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in size of zone matrix |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &zone_matrix_len[zone_index], sizeof(zone_matrix_len[zone_index]));
|
||||
data_ptr += sizeof(zone_matrix_len[zone_index]);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix data if size is nonzero |
|
||||
\*---------------------------------------------------------*/
|
||||
if(zone_matrix_len[zone_index] > 0)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix height |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &zones[zone_index].matrix_map->height, sizeof(zones[zone_index].matrix_map->height));
|
||||
data_ptr += sizeof(zones[zone_index].matrix_map->height);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix width |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &zones[zone_index].matrix_map->width, sizeof(zones[zone_index].matrix_map->width));
|
||||
data_ptr += sizeof(zones[zone_index].matrix_map->width);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int matrix_idx = 0; matrix_idx < (zones[zone_index].matrix_map->height * zones[zone_index].matrix_map->width); matrix_idx++)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &zones[zone_index].matrix_map->map[matrix_idx], sizeof(zones[zone_index].matrix_map->map[matrix_idx]));
|
||||
data_ptr += sizeof(zones[zone_index].matrix_map->map[matrix_idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -334,11 +403,11 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||
data_ptr += sizeof(colors[color_index]);
|
||||
}
|
||||
|
||||
|
||||
delete[] mode_name_len;
|
||||
delete[] zone_name_len;
|
||||
delete[] led_name_len;
|
||||
|
||||
delete[] zone_matrix_len;
|
||||
delete[] mode_num_colors;
|
||||
|
||||
return(data_buf);
|
||||
@@ -563,6 +632,54 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf)
|
||||
memcpy(&new_zone.leds_count, &data_buf[data_ptr], sizeof(new_zone.leds_count));
|
||||
data_ptr += sizeof(new_zone.leds_count);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in size of zone matrix |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned short zone_matrix_len;
|
||||
memcpy(&zone_matrix_len, &data_buf[data_ptr], sizeof(zone_matrix_len));
|
||||
data_ptr += sizeof(zone_matrix_len);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix data if size is nonzero |
|
||||
\*---------------------------------------------------------*/
|
||||
if(zone_matrix_len > 0)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a map data structure to fill in and attach it to |
|
||||
| the new zone |
|
||||
\*---------------------------------------------------------*/
|
||||
matrix_map_type * new_map = new matrix_map_type;
|
||||
|
||||
new_zone.matrix_map = new_map;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix height |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_map->height, &data_buf[data_ptr], sizeof(new_map->height));
|
||||
data_ptr += sizeof(new_map->height);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix width |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_map->width, &data_buf[data_ptr], sizeof(new_map->width));
|
||||
data_ptr += sizeof(new_map->width);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
new_map->map = new unsigned int[new_map->height * new_map->width];
|
||||
|
||||
for(int matrix_idx = 0; matrix_idx < (new_map->height * new_map->width); matrix_idx++)
|
||||
{
|
||||
memcpy(&new_map->map[matrix_idx], &data_buf[data_ptr], sizeof(new_map->map[matrix_idx]));
|
||||
data_ptr += sizeof(new_map->map[matrix_idx]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
|
||||
@@ -621,6 +738,457 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf)
|
||||
|
||||
colors.push_back(new_color);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Setup colors |
|
||||
\*---------------------------------------------------------*/
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetModeDescription(int mode)
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
unsigned int data_size = 0;
|
||||
|
||||
unsigned short mode_name_len;
|
||||
unsigned short mode_num_colors;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Calculate data size |
|
||||
\*---------------------------------------------------------*/
|
||||
mode_name_len = strlen(modes[mode].name.c_str()) + 1;
|
||||
mode_num_colors = modes[mode].colors.size();
|
||||
|
||||
data_size += sizeof(data_size);
|
||||
data_size += sizeof(mode);
|
||||
data_size += sizeof(mode_name_len);
|
||||
data_size += mode_name_len;
|
||||
data_size += sizeof(modes[mode].value);
|
||||
data_size += sizeof(modes[mode].flags);
|
||||
data_size += sizeof(modes[mode].speed_min);
|
||||
data_size += sizeof(modes[mode].speed_max);
|
||||
data_size += sizeof(modes[mode].colors_min);
|
||||
data_size += sizeof(modes[mode].colors_max);
|
||||
data_size += sizeof(modes[mode].speed);
|
||||
data_size += sizeof(modes[mode].direction);
|
||||
data_size += sizeof(modes[mode].color_mode);
|
||||
data_size += sizeof(mode_num_colors);
|
||||
data_size += (mode_num_colors * sizeof(RGBColor));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create data buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char *data_buf = new unsigned char[data_size];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in data size |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &data_size, sizeof(data_size));
|
||||
data_ptr += sizeof(data_size);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode index |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &mode, sizeof(int));
|
||||
data_ptr += sizeof(int);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode name (size+data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &mode_name_len, sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
strcpy((char *)&data_buf[data_ptr], modes[mode].name.c_str());
|
||||
data_ptr += mode_name_len;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode value (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].value, sizeof(modes[mode].value));
|
||||
data_ptr += sizeof(modes[mode].value);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode flags (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].flags, sizeof(modes[mode].flags));
|
||||
data_ptr += sizeof(modes[mode].flags);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode speed_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].speed_min, sizeof(modes[mode].speed_min));
|
||||
data_ptr += sizeof(modes[mode].speed_min);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode speed_max (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].speed_max, sizeof(modes[mode].speed_max));
|
||||
data_ptr += sizeof(modes[mode].speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].colors_min, sizeof(modes[mode].colors_min));
|
||||
data_ptr += sizeof(modes[mode].colors_min);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_max (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].colors_max, sizeof(modes[mode].colors_max));
|
||||
data_ptr += sizeof(modes[mode].colors_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode speed (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].speed, sizeof(modes[mode].speed));
|
||||
data_ptr += sizeof(modes[mode].speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].direction, sizeof(modes[mode].direction));
|
||||
data_ptr += sizeof(modes[mode].direction);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode color_mode (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].color_mode, sizeof(modes[mode].color_mode));
|
||||
data_ptr += sizeof(modes[mode].color_mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode number of colors |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &mode_num_colors, sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode mode colors |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int color_index = 0; color_index < mode_num_colors; color_index++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in color (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].colors[color_index], sizeof(modes[mode].colors[color_index]));
|
||||
data_ptr += sizeof(modes[mode].colors[color_index]);
|
||||
}
|
||||
|
||||
return(data_buf);
|
||||
}
|
||||
|
||||
void RGBController::SetModeDescription(unsigned char* data_buf)
|
||||
{
|
||||
int mode_idx;
|
||||
unsigned int data_ptr = sizeof(unsigned int);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode index |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&mode_idx, &data_buf[data_ptr], sizeof(int));
|
||||
data_ptr += sizeof(int);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get pointer to target mode |
|
||||
\*---------------------------------------------------------*/
|
||||
mode * new_mode = &modes[mode_idx];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set active mode to the new mode |
|
||||
\*---------------------------------------------------------*/
|
||||
active_mode = mode_idx;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode name (size+data) |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned short modename_len;
|
||||
memcpy(&modename_len, &data_buf[data_ptr], sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
new_mode->name = (char *)&data_buf[data_ptr];
|
||||
data_ptr += modename_len;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode value (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->value, &data_buf[data_ptr], sizeof(new_mode->value));
|
||||
data_ptr += sizeof(new_mode->value);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode flags (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->flags, &data_buf[data_ptr], sizeof(new_mode->flags));
|
||||
data_ptr += sizeof(new_mode->flags);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode speed_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->speed_min, &data_buf[data_ptr], sizeof(new_mode->speed_min));
|
||||
data_ptr += sizeof(new_mode->speed_min);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode speed_max (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->speed_max, &data_buf[data_ptr], sizeof(new_mode->speed_max));
|
||||
data_ptr += sizeof(new_mode->speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->colors_min, &data_buf[data_ptr], sizeof(new_mode->colors_min));
|
||||
data_ptr += sizeof(new_mode->colors_min);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_max (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->colors_max, &data_buf[data_ptr], sizeof(new_mode->colors_max));
|
||||
data_ptr += sizeof(new_mode->colors_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode speed (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->speed, &data_buf[data_ptr], sizeof(new_mode->speed));
|
||||
data_ptr += sizeof(new_mode->speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->direction, &data_buf[data_ptr], sizeof(new_mode->direction));
|
||||
data_ptr += sizeof(new_mode->direction);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode color_mode (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_mode->color_mode, &data_buf[data_ptr], sizeof(new_mode->color_mode));
|
||||
data_ptr += sizeof(new_mode->color_mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode number of colors |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned short mode_num_colors;
|
||||
memcpy(&mode_num_colors, &data_buf[data_ptr], sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode mode colors |
|
||||
\*---------------------------------------------------------*/
|
||||
new_mode->colors.clear();
|
||||
for(int color_index = 0; color_index < mode_num_colors; color_index++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in color (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBColor new_color;
|
||||
memcpy(&new_color, &data_buf[data_ptr], sizeof(RGBColor));
|
||||
data_ptr += sizeof(RGBColor);
|
||||
|
||||
new_mode->colors.push_back(new_color);
|
||||
}
|
||||
|
||||
printf("read data ptr %d\r\n", data_ptr);
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetColorDescription()
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
unsigned int data_size = 0;
|
||||
|
||||
unsigned short num_colors = colors.size();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Calculate data size |
|
||||
\*---------------------------------------------------------*/
|
||||
data_size += sizeof(data_size);
|
||||
data_size += sizeof(num_colors);
|
||||
data_size += num_colors * sizeof(RGBColor);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create data buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char *data_buf = new unsigned char[data_size];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in data size |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &data_size, sizeof(data_size));
|
||||
data_ptr += sizeof(data_size);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in number of colors (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &num_colors, sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in colors |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int color_index = 0; color_index < num_colors; color_index++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in color (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &colors[color_index], sizeof(colors[color_index]));
|
||||
data_ptr += sizeof(colors[color_index]);
|
||||
}
|
||||
|
||||
return(data_buf);
|
||||
}
|
||||
|
||||
void RGBController::SetColorDescription(unsigned char* data_buf)
|
||||
{
|
||||
unsigned int data_ptr = sizeof(unsigned int);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in number of colors (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned short num_colors;
|
||||
memcpy(&num_colors, &data_buf[data_ptr], sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in colors |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int color_index = 0; color_index < num_colors; color_index++)
|
||||
{
|
||||
RGBColor new_color;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in color (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_color, &data_buf[data_ptr], sizeof(RGBColor));
|
||||
data_ptr += sizeof(RGBColor);
|
||||
|
||||
colors[color_index] = new_color;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetZoneColorDescription(int zone)
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
unsigned int data_size = 0;
|
||||
|
||||
unsigned short num_colors = zones[zone].leds_count;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Calculate data size |
|
||||
\*---------------------------------------------------------*/
|
||||
data_size += sizeof(data_size);
|
||||
data_size += sizeof(zone);
|
||||
data_size += sizeof(num_colors);
|
||||
data_size += num_colors * sizeof(RGBColor);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create data buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char *data_buf = new unsigned char[data_size];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in data size |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &data_size, sizeof(data_size));
|
||||
data_ptr += sizeof(data_size);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in zone index |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &zone, sizeof(zone));
|
||||
data_ptr += sizeof(zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in number of colors (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &num_colors, sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in colors |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int color_index = 0; color_index < num_colors; color_index++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in color (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[data_ptr], &zones[zone].colors[color_index], sizeof(zones[zone].colors[color_index]));
|
||||
data_ptr += sizeof(zones[zone].colors[color_index]);
|
||||
}
|
||||
|
||||
return(data_buf);
|
||||
}
|
||||
|
||||
void RGBController::SetZoneColorDescription(unsigned char* data_buf)
|
||||
{
|
||||
unsigned int data_ptr = sizeof(unsigned int);
|
||||
unsigned int zone_idx;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in zone index |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&zone_idx, &data_buf[data_ptr], sizeof(zone_idx));
|
||||
data_ptr += sizeof(zone_idx);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in number of colors (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned short num_colors;
|
||||
memcpy(&num_colors, &data_buf[data_ptr], sizeof(unsigned short));
|
||||
data_ptr += sizeof(unsigned short);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in colors |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int color_index = 0; color_index < num_colors; color_index++)
|
||||
{
|
||||
RGBColor new_color;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in color (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&new_color, &data_buf[data_ptr], sizeof(RGBColor));
|
||||
data_ptr += sizeof(RGBColor);
|
||||
|
||||
zones[zone_idx].colors[color_index] = new_color;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetSingleLEDColorDescription(int led)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Fixed size descrption: |
|
||||
| int: LED index |
|
||||
| RGBColor: LED color |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char *data_buf = new unsigned char[sizeof(int) + sizeof(RGBColor)];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in LED index |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[0], &led, sizeof(int));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in LED color |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&data_buf[sizeof(led)], &colors[led], sizeof(RGBColor));
|
||||
|
||||
return(data_buf);
|
||||
}
|
||||
|
||||
void RGBController::SetSingleLEDColorDescription(unsigned char* data_buf)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Fixed size descrption: |
|
||||
| int: LED index |
|
||||
| RGBColor: LED color |
|
||||
\*---------------------------------------------------------*/
|
||||
int led_idx;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in LED index |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&led_idx, &data_buf[0], sizeof(led_idx));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in LED color |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&colors[led_idx], &data_buf[sizeof(led_idx)], sizeof(RGBColor));
|
||||
}
|
||||
|
||||
void RGBController::SetupColors()
|
||||
@@ -728,6 +1296,34 @@ void RGBController::SetMode(int mode)
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void RGBController::UpdateLEDs()
|
||||
{
|
||||
CallFlag_UpdateLEDs = true;
|
||||
}
|
||||
|
||||
void RGBController::DeviceUpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController::DeviceCallThreadFunction()
|
||||
{
|
||||
CallFlag_UpdateLEDs = false;
|
||||
|
||||
while(DeviceThreadRunning.load() == true)
|
||||
{
|
||||
if(CallFlag_UpdateLEDs.load() == true)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
CallFlag_UpdateLEDs = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string device_type_to_str(device_type type)
|
||||
{
|
||||
switch(type)
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
typedef unsigned int RGBColor;
|
||||
|
||||
@@ -115,6 +117,13 @@ enum
|
||||
|
||||
std::string device_type_to_str(device_type type);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
unsigned int * map;
|
||||
} matrix_map_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* Zone name */
|
||||
@@ -125,6 +134,7 @@ typedef struct
|
||||
unsigned int leds_count; /* Number of LEDs in zone */
|
||||
unsigned int leds_min; /* Minimum number of LEDs */
|
||||
unsigned int leds_max; /* Maximum number of LEDs */
|
||||
matrix_map_type * matrix_map; /* Matrix map pointer */
|
||||
} zone;
|
||||
|
||||
class RGBController
|
||||
@@ -142,7 +152,11 @@ public:
|
||||
device_type type; /* device type */
|
||||
int active_mode = 0;/* active mode */
|
||||
|
||||
virtual ~RGBController() = default;
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController base class constructor |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBController();
|
||||
~RGBController();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Generic functions implemented in RGBController.cpp |
|
||||
@@ -160,6 +174,26 @@ public:
|
||||
unsigned char * GetDeviceDescription();
|
||||
void ReadDeviceDescription(unsigned char* data_buf);
|
||||
|
||||
unsigned char * GetModeDescription(int mode);
|
||||
void SetModeDescription(unsigned char* data_buf);
|
||||
|
||||
unsigned char * GetColorDescription();
|
||||
void SetColorDescription(unsigned char* data_buf);
|
||||
|
||||
unsigned char * GetZoneColorDescription(int zone);
|
||||
void SetZoneColorDescription(unsigned char* data_buf);
|
||||
|
||||
unsigned char * GetSingleLEDColorDescription(int led);
|
||||
void SetSingleLEDColorDescription(unsigned char* data_buf);
|
||||
|
||||
void UpdateLEDs();
|
||||
//void UpdateZoneLEDs(int zone);
|
||||
//void UpdateSingleLED(int led);
|
||||
|
||||
//void UpdateMode();
|
||||
|
||||
void DeviceCallThreadFunction();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Functions to be implemented in device implementation |
|
||||
\*---------------------------------------------------------*/
|
||||
@@ -167,10 +201,19 @@ public:
|
||||
|
||||
virtual void ResizeZone(int zone, int new_size) = 0;
|
||||
|
||||
virtual void UpdateLEDs() = 0;
|
||||
virtual void DeviceUpdateLEDs() = 0;
|
||||
virtual void UpdateZoneLEDs(int zone) = 0;
|
||||
virtual void UpdateSingleLED(int led) = 0;
|
||||
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void UpdateMode() = 0;
|
||||
|
||||
virtual void SetCustomMode() = 0;
|
||||
|
||||
private:
|
||||
std::thread* DeviceCallThread;
|
||||
std::atomic<bool> CallFlag_UpdateLEDs;
|
||||
std::atomic<bool> DeviceThreadRunning;
|
||||
//bool CallFlag_UpdateZoneLEDs = false;
|
||||
//bool CallFlag_UpdateSingleLED = false;
|
||||
//bool CallFlag_UpdateMode = false;
|
||||
};
|
||||
|
||||
@@ -13,9 +13,10 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
|
||||
{
|
||||
wraith = wraith_ptr;
|
||||
|
||||
name = "AMD Wraith Prism";
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
version = wraith->GetFirmwareVersionString();
|
||||
name = "AMD Wraith Prism";
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
description = "AMD Wraith Prism Device";
|
||||
version = wraith->GetFirmwareVersionString();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
@@ -103,6 +104,7 @@ void RGBController_AMDWraithPrism::SetupZones()
|
||||
logo_zone.leds_min = 1;
|
||||
logo_zone.leds_max = 1;
|
||||
logo_zone.leds_count = 1;
|
||||
logo_zone.matrix_map = NULL;
|
||||
zones.push_back(logo_zone);
|
||||
|
||||
zone fan_zone;
|
||||
@@ -111,6 +113,7 @@ void RGBController_AMDWraithPrism::SetupZones()
|
||||
fan_zone.leds_min = 1;
|
||||
fan_zone.leds_max = 1;
|
||||
fan_zone.leds_count = 1;
|
||||
fan_zone.matrix_map = NULL;
|
||||
zones.push_back(fan_zone);
|
||||
|
||||
zone ring_zone;
|
||||
@@ -119,6 +122,7 @@ void RGBController_AMDWraithPrism::SetupZones()
|
||||
ring_zone.leds_min = 1;
|
||||
ring_zone.leds_max = 1;
|
||||
ring_zone.leds_count = 1;
|
||||
ring_zone.matrix_map = NULL;
|
||||
zones.push_back(ring_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -146,7 +150,7 @@ void RGBController_AMDWraithPrism::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateLEDs()
|
||||
void RGBController_AMDWraithPrism::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
@@ -229,5 +233,5 @@ void RGBController_AMDWraithPrism::UpdateMode()
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraCore.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for ROG Aura Core |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AuraCore.h"
|
||||
|
||||
RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura Core";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "ASUS Aura Core Device";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_CORE_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_CORE_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = AURA_CORE_MODE_SPECTRUM_CYCLE;
|
||||
ColorCycle.flags = 0;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetupZones()
|
||||
{
|
||||
zone Keyboard;
|
||||
Keyboard.name = "Keyboard";
|
||||
Keyboard.type = ZONE_TYPE_SINGLE;
|
||||
Keyboard.leds_min = 4;
|
||||
Keyboard.leds_max = 4;
|
||||
Keyboard.leds_count = 4;
|
||||
Keyboard.matrix_map = NULL;
|
||||
zones.push_back(Keyboard);
|
||||
|
||||
for(int led_idx = 0; led_idx < Keyboard.leds_count; led_idx++)
|
||||
{
|
||||
led KeyLED;
|
||||
KeyLED.name = "Keyboard LED ";
|
||||
KeyLED.name.append(std::to_string(led_idx + 1));
|
||||
leds.push_back(KeyLED);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::DeviceUpdateLEDs()
|
||||
{
|
||||
UpdateZoneLEDs(0);
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
for(int led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
UpdateSingleLED(led_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateSingleLED(int led)
|
||||
{
|
||||
aura->SendUpdate
|
||||
(
|
||||
led + 1,
|
||||
modes[active_mode].value,
|
||||
AURA_CORE_SPEED_NORMAL,
|
||||
RGBGetRValue(colors[led]),
|
||||
RGBGetGValue(colors[led]),
|
||||
RGBGetBValue(colors[led])
|
||||
);
|
||||
aura->SendSet();
|
||||
aura->SendApply();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraCore.h |
|
||||
| |
|
||||
| Generic RGB Interface for ROG Aura Core |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AuraCoreController.h"
|
||||
|
||||
class RGBController_AuraCore : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraCore(AuraCoreController* aura_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AuraCoreController* aura;
|
||||
|
||||
};
|
||||
@@ -46,10 +46,11 @@ RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
|
||||
aura_gpu = aura_gpu_ptr;
|
||||
|
||||
|
||||
name = aura_gpu->GetDeviceName();
|
||||
version = "0.00.1";
|
||||
location = aura_gpu->GetDeviceLocation();
|
||||
type = DEVICE_TYPE_GPU;
|
||||
name = aura_gpu->GetDeviceName();
|
||||
type = DEVICE_TYPE_GPU;
|
||||
description = "ASUS Aura GPU Device";
|
||||
version = "0.00.1";
|
||||
location = aura_gpu->GetDeviceLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -109,6 +110,7 @@ void RGBController_AuraGPU::SetupZones()
|
||||
aura_gpu_zone.leds_min = 1;
|
||||
aura_gpu_zone.leds_max = 1;
|
||||
aura_gpu_zone.leds_count = 1;
|
||||
aura_gpu_zone.matrix_map = NULL;
|
||||
zones.push_back(aura_gpu_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -137,7 +139,7 @@ void RGBController_AuraGPU::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::UpdateLEDs()
|
||||
void RGBController_AuraGPU::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
@@ -158,12 +160,12 @@ void RGBController_AuraGPU::UpdateLEDs()
|
||||
|
||||
void RGBController_AuraGPU::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::SetCustomMode()
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ int RGBController_AuraSMBus::GetDeviceMode()
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController_AuraSMBus::UpdateLEDs()
|
||||
void RGBController_AuraSMBus::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
@@ -275,6 +275,8 @@ void RGBController_AuraSMBus::SetupZones()
|
||||
new_zone->type = ZONE_TYPE_SINGLE;
|
||||
}
|
||||
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push new zone to zones vector |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraUSB.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AuraUSB.h"
|
||||
|
||||
RGBController_AuraUSB::RGBController_AuraUSB(AuraUSBController* aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura USB";
|
||||
version = aura->GetDeviceName();
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
description = "ASUS Aura USB Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = AURA_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AURA_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_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 Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AURA_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Flashing.colors_min = 1;
|
||||
Flashing.colors_max = 1;
|
||||
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flashing.colors.resize(1);
|
||||
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_MODE_SPECIFIC_COLOR;
|
||||
ChaseFade.colors_min = 1;
|
||||
ChaseFade.colors_max = 1;
|
||||
ChaseFade.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ChaseFade.colors.resize(1);
|
||||
modes.push_back(ChaseFade);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AURA_MODE_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Chase.colors_min = 1;
|
||||
Chase.colors_max = 1;
|
||||
Chase.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Chase.colors.resize(1);
|
||||
modes.push_back(Chase);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AuraUSB::~RGBController_AuraUSB()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Only set LED count on the first run |
|
||||
\*-------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
zones.resize(aura->GetChannelCount());
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
|
||||
{
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
zones[channel_idx].name = "Aura Channel ";
|
||||
zones[channel_idx].name.append(ch_idx_string);
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[4];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Aura Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
new_led.value = channel_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
zones[channel_idx].matrix_map = NULL;
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
aura->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
aura->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds[led].value;
|
||||
|
||||
aura->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::UpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
for(unsigned int zone_idx; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
if(zones[zone_idx].leds_count > 0)
|
||||
{
|
||||
aura->SetMode(zone_idx, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraUSB.h |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#define AURA_ADDRESSABLE_MAX_LEDS 120
|
||||
|
||||
class RGBController_AuraUSB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraUSB(AuraUSBController* aura_ptr);
|
||||
~RGBController_AuraUSB();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AuraUSBController* aura;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
@@ -0,0 +1,153 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMMP750Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 18th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
|
||||
RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr)
|
||||
{
|
||||
cmmp750 = cmmp_ptr;
|
||||
|
||||
name = cmmp750->GetDeviceName();
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
description = "Cooler Master Mousepad 750";
|
||||
version = "1.0";
|
||||
serial = "";
|
||||
location = cmmp750->GetLocation();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = MP750_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = MP750_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Blink.speed_min = MP750_SPEED_SLOWEST;
|
||||
Blink.speed_max = MP750_SPEED_FASTEST;
|
||||
Blink.color_mode = MODE_COLORS_PER_LED;
|
||||
Blink.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(Blink);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = MP750_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = MP750_SPEED_SLOWEST;
|
||||
Breathing.speed_max = MP750_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = MP750_MODE_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColorCycle.speed_min = MP750_SPEED_SLOWEST;
|
||||
ColorCycle.speed_max = MP750_SPEED_FASTEST;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
ColorCycle.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode BreathCycle;
|
||||
BreathCycle.name = "Breath Cycle";
|
||||
BreathCycle.value = MP750_MODE_BREATH_CYCLE;
|
||||
BreathCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
BreathCycle.speed_min = MP750_SPEED_SLOWEST;
|
||||
BreathCycle.speed_max = MP750_SPEED_FASTEST;
|
||||
BreathCycle.color_mode = MODE_COLORS_NONE;
|
||||
BreathCycle.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(BreathCycle);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CMMP750Controller::~RGBController_CMMP750Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::SetupZones()
|
||||
{
|
||||
zone MP_zone;
|
||||
MP_zone.name = "Mousepad";
|
||||
MP_zone.type = ZONE_TYPE_SINGLE;
|
||||
MP_zone.leds_min = 1;
|
||||
MP_zone.leds_max = 1;
|
||||
MP_zone.leds_count = 1;
|
||||
MP_zone.matrix_map = NULL;
|
||||
zones.push_back(MP_zone);
|
||||
|
||||
led MP_led;
|
||||
MP_led.name = "Mousepad LED";
|
||||
leds.push_back(MP_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
cmmp750->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor color = colors[zone];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
cmmp750->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case MP750_MODE_STATIC:
|
||||
cmmp750->SetMode(MP750_MODE_STATIC, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_BLINK:
|
||||
cmmp750->SetMode(MP750_MODE_BLINK, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_BREATHING:
|
||||
cmmp750->SetMode(MP750_MODE_BREATHING, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_COLOR_CYCLE:
|
||||
cmmp750->SetMode(MP750_MODE_COLOR_CYCLE, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_BREATH_CYCLE:
|
||||
cmmp750->SetMode(MP750_MODE_BREATH_CYCLE, modes[active_mode].speed);
|
||||
break;
|
||||
default:
|
||||
cmmp750->SetMode(MP750_MODE_BREATHING, modes[active_mode].speed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMMP750Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 18th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CMMP750Controller.h"
|
||||
|
||||
class RGBController_CMMP750Controller : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr);
|
||||
~RGBController_CMMP750Controller();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
private:
|
||||
CMMP750Controller* cmmp750;
|
||||
};
|
||||
@@ -196,21 +196,23 @@ void RGBController_CorsairLightingNode::SetupZones()
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| According to some research on Corsair forums, the |
|
||||
| maximum number of LEDs supported by Corsair Link |
|
||||
| devices is 96 |
|
||||
| I did some experimenting and determined that the |
|
||||
| maximum number of LEDs the Corsair Commander Pro |
|
||||
| can support is 200. |
|
||||
\*-------------------------------------------------*/
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = 96;
|
||||
zones[channel_idx].leds_max = 200;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
|
||||
zones[channel_idx].matrix_map = NULL;
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
char led_idx_string[4];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
@@ -237,7 +239,7 @@ void RGBController_CorsairLightingNode::ResizeZone(int zone, int new_size)
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairLightingNode::UpdateLEDs()
|
||||
void RGBController_CorsairLightingNode::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
@@ -266,7 +268,7 @@ void RGBController_CorsairLightingNode::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -9,16 +9,30 @@
|
||||
|
||||
#include "RGBController_CorsairPeripheral.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][23] =
|
||||
{ { 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 },
|
||||
{ 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 },
|
||||
{ 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 },
|
||||
{ 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, NA, NA, NA, NA, 45, 54, 63, NA },
|
||||
{ 4, NA, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 },
|
||||
{ 5, 14, 23, NA, NA, NA, NA, 41, NA, NA, NA, NA, 69, 79, 89, 71, 90, 99, 108, 101, NA, 110, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
"Media Keys"
|
||||
"Keyboard"
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104,
|
||||
7
|
||||
111
|
||||
};
|
||||
|
||||
static const zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX
|
||||
};
|
||||
|
||||
static const char* led_names[] =
|
||||
@@ -134,7 +148,6 @@ static const char* led_names[] =
|
||||
"Key: Right Arrow", //139
|
||||
"Key: Number Pad Enter",//140
|
||||
"Key: Number Pad .", //141
|
||||
"Key: F12"
|
||||
};
|
||||
|
||||
RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr)
|
||||
@@ -172,7 +185,7 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
num_zones = 2;
|
||||
num_zones = 1;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
@@ -191,18 +204,41 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
new_zone.name = zone_names[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];
|
||||
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;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
new_zone.name = "Mousemat Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_min = 15;
|
||||
new_zone.leds_max = 15;
|
||||
new_zone.leds_count = 15;
|
||||
new_zone.matrix_map = NULL;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
new_zone.name = "Mousemat Zone";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 15;
|
||||
new_zone.leds_max = 15;
|
||||
new_zone.leds_count = 15;
|
||||
new_zone.matrix_map = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -241,7 +277,7 @@ void RGBController_CorsairPeripheral::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::UpdateLEDs()
|
||||
void RGBController_CorsairPeripheral::DeviceUpdateLEDs()
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ RGBController_CorsairVengeance::RGBController_CorsairVengeance(CorsairVengeanceC
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = corsair->GetDeviceName();
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "Corsair Vengeance RGB Device";
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
@@ -53,6 +53,7 @@ void RGBController_CorsairVengeance::SetupZones()
|
||||
new_zone.leds_min = corsair->GetLEDCount();
|
||||
new_zone.leds_max = corsair->GetLEDCount();
|
||||
new_zone.leds_count = corsair->GetLEDCount();
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -75,7 +76,7 @@ void RGBController_CorsairVengeance::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::UpdateLEDs()
|
||||
void RGBController_CorsairVengeance::DeviceUpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
@@ -87,12 +88,12 @@ void RGBController_CorsairVengeance::UpdateLEDs()
|
||||
|
||||
void RGBController_CorsairVengeance::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::SetCustomMode()
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ RGBController_CorsairVengeancePro::RGBController_CorsairVengeancePro(CorsairVeng
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = corsair->GetDeviceName();
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "Corsair Vengeance Pro RGB Device";
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
mode ColorShift;
|
||||
ColorShift.name = "Color Shift";
|
||||
@@ -160,6 +160,7 @@ void RGBController_CorsairVengeancePro::SetupZones()
|
||||
new_zone.leds_min = corsair->GetLEDCount();
|
||||
new_zone.leds_max = corsair->GetLEDCount();
|
||||
new_zone.leds_count = corsair->GetLEDCount();
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -183,7 +184,7 @@ void RGBController_CorsairVengeancePro::ResizeZone(int /*zone*/, int /*new_size*
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeancePro::UpdateLEDs()
|
||||
void RGBController_CorsairVengeancePro::DeviceUpdateLEDs()
|
||||
{
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
@@ -199,7 +200,7 @@ void RGBController_CorsairVengeancePro::UpdateLEDs()
|
||||
|
||||
void RGBController_CorsairVengeancePro::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeancePro::UpdateSingleLED(int led)
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,9 +13,10 @@ RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
|
||||
{
|
||||
crucial = crucial_ptr;
|
||||
|
||||
location = crucial->GetDeviceLocation();
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = "Crucial DRAM";
|
||||
name = "Crucial DRAM";
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "Crucial DRAM Device";
|
||||
location = crucial->GetDeviceLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -125,6 +126,7 @@ void RGBController_Crucial::SetupZones()
|
||||
new_zone.leds_min = 8;
|
||||
new_zone.leds_max = 8;
|
||||
new_zone.leds_count = 8;
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -148,7 +150,7 @@ void RGBController_Crucial::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateLEDs()
|
||||
void RGBController_Crucial::DeviceUpdateLEDs()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
@@ -162,12 +164,12 @@ void RGBController_Crucial::UpdateLEDs()
|
||||
|
||||
void RGBController_Crucial::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Crucial::SetCustomMode()
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void RGBController_Dummy::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Dummy::UpdateLEDs()
|
||||
void RGBController_Dummy::DeviceUpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
|
||||
RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
{
|
||||
name = "E1.31 Streaming ACN Device";
|
||||
name = "E1.31 Streaming ACN Device";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "E1.31 Streaming ACN Device";
|
||||
|
||||
devices = device_list;
|
||||
|
||||
@@ -77,6 +79,7 @@ void RGBController_E131::SetupZones()
|
||||
led_zone.leds_min = devices[zone_idx].num_leds;
|
||||
led_zone.leds_max = devices[zone_idx].num_leds;
|
||||
led_zone.leds_count = devices[zone_idx].num_leds;
|
||||
led_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(led_zone);
|
||||
}
|
||||
@@ -107,7 +110,7 @@ void RGBController_E131::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateLEDs()
|
||||
void RGBController_E131::DeviceUpdateLEDs()
|
||||
{
|
||||
int color_idx = 0;
|
||||
|
||||
@@ -170,12 +173,12 @@ void RGBController_E131::UpdateLEDs()
|
||||
|
||||
void RGBController_E131::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::SetCustomMode()
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
RGBController_Faustus::RGBController_Faustus(const std::string& dev_path)
|
||||
{
|
||||
name = "Faustus";
|
||||
description = "ASUS TUF Keyboard Backlight";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
name = "ASUS TUF Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Faustus Device";
|
||||
|
||||
modes.resize(4);
|
||||
modes[0].name = "Static";
|
||||
@@ -68,6 +68,7 @@ void RGBController_Faustus::SetupZones()
|
||||
zones[0].leds_min = 1;
|
||||
zones[0].leds_max = 1;
|
||||
zones[0].leds_count = 1;
|
||||
zones[0].matrix_map = NULL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LED |
|
||||
@@ -85,7 +86,7 @@ void RGBController_Faustus::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateLEDs()
|
||||
void RGBController_Faustus::DeviceUpdateLEDs()
|
||||
{
|
||||
int rv = uint8_t(RGBGetRValue(colors[0]));
|
||||
int gv = uint8_t(RGBGetGValue(colors[0]));
|
||||
@@ -130,12 +131,12 @@ void RGBController_Faustus::UpdateLEDs()
|
||||
|
||||
void RGBController_Faustus::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::SetCustomMode()
|
||||
@@ -145,7 +146,7 @@ void RGBController_Faustus::SetCustomMode()
|
||||
|
||||
void RGBController_Faustus::UpdateMode()
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
|
||||
@@ -35,7 +35,7 @@ class RGBController_Faustus : public RGBController
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
{
|
||||
hue2 = hue2_ptr;
|
||||
|
||||
name = "NZXT Hue 2";
|
||||
name = "NZXT Hue 2";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "NZXT Hue 2 Device";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
@@ -144,6 +144,7 @@ void RGBController_Hue2::SetupZones()
|
||||
new_zone->leds_min = 0;
|
||||
new_zone->leds_max = 40;
|
||||
new_zone->leds_count = hue2->channel_leds[zone_idx];
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
@@ -174,7 +175,7 @@ void RGBController_Hue2::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateLEDs()
|
||||
void RGBController_Hue2::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
@@ -203,7 +204,7 @@ void RGBController_Hue2::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,11 +13,10 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
{
|
||||
hueplus = hueplus_ptr;
|
||||
|
||||
name = "NZXT Hue+";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
location = hueplus->GetLocation();
|
||||
name = "NZXT Hue+";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "NZXT Hue+ Device";
|
||||
location = hueplus->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -190,6 +189,7 @@ void RGBController_HuePlus::SetupZones()
|
||||
zones[zone_idx].type = ZONE_TYPE_LINEAR;
|
||||
zones[zone_idx].leds_min = 0;
|
||||
zones[zone_idx].leds_max = 40;
|
||||
zones[zone_idx].matrix_map = NULL;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
@@ -228,7 +228,7 @@ void RGBController_HuePlus::ResizeZone(int zone, int new_size)
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateLEDs()
|
||||
void RGBController_HuePlus::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
@@ -257,7 +257,7 @@ void RGBController_HuePlus::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == HUE_PLUS_MODE_FIXED)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ RGBController_HyperXDRAM::RGBController_HyperXDRAM(HyperXDRAMController* hyperx_
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
|
||||
name = hyperx->GetDeviceName();
|
||||
location = hyperx->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = hyperx->GetDeviceName();
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "HyperX DRAM Device";
|
||||
location = hyperx->GetDeviceLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -136,6 +136,7 @@ void RGBController_HyperXDRAM::SetupZones()
|
||||
new_zone->leds_min = 5;
|
||||
new_zone->leds_max = 5;
|
||||
new_zone->leds_count = 5;
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
@@ -167,7 +168,7 @@ void RGBController_HyperXDRAM::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_HyperXDRAM::UpdateLEDs()
|
||||
void RGBController_HyperXDRAM::DeviceUpdateLEDs()
|
||||
{
|
||||
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -44,6 +44,17 @@ THREAD keepalive_thread(void *param)
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][23] =
|
||||
{ { 0, NA, 15, 28, 42, 52, NA, 63, 73, 82, 93, NA, 8, 21, 36, 6, 20, 34, 47, NA, NA, NA, NA },
|
||||
{ 1, 16, 29, 43, 53, 64, 74, 83, 94, 9, 22, NA, 37, 7, 35, NA, 58, 68, 78, 50, 61, 71, 80 },
|
||||
{ 2, NA, 17, 30, 44, 54, NA, 65, 75, 84, 95, 10, 23, 38, 88, 99, 48, 59, 69, 49, 60, 70, 91 },
|
||||
{ 3, NA, 18, 31, 45, 55, NA, 66, 76, 85, 96, 11, 24, 39, 26, NA, NA, NA, NA, 90, 101, 51, NA },
|
||||
{ 4, NA, 32, 46, 56, 67, NA, 77, NA, 86, 97, 12, 25, 40, 79, NA, NA, 100, NA, 62, 72, 81, 102 },
|
||||
{ 5, 19, 33, NA, NA, NA, NA, 57, NA, NA, NA, NA, 87, 98, 13, 89, 14, 27, 41, 92, NA, 103, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
@@ -51,6 +62,13 @@ static const char* zone_names[] =
|
||||
"Media Keys"
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
ZONE_TYPE_LINEAR,
|
||||
ZONE_TYPE_SINGLE
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104,
|
||||
@@ -192,8 +210,9 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
|
||||
name = "HyperX RGB Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
name = "HyperX RGB Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "HyperX RGB Keyboard Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -263,10 +282,24 @@ void RGBController_HyperXKeyboard::SetupZones()
|
||||
for(unsigned int zone_idx = 0; zone_idx < 3; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[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];
|
||||
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];
|
||||
@@ -289,7 +322,7 @@ void RGBController_HyperXKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateLEDs()
|
||||
void RGBController_HyperXKeyboard::DeviceUpdateLEDs()
|
||||
{
|
||||
if(active_mode == 0)
|
||||
{
|
||||
@@ -303,12 +336,12 @@ void RGBController_HyperXKeyboard::UpdateLEDs()
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::SetCustomMode()
|
||||
@@ -335,7 +368,7 @@ void RGBController_HyperXKeyboard::KeepaliveThread()
|
||||
{
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SetLEDsDirect(colors);
|
||||
UpdateLEDs();
|
||||
}
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
{
|
||||
strip = ledstrip_ptr;
|
||||
|
||||
name = "LED Strip";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
name = "LED Strip";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "Keyboard Visualizer Arduino LED Strip Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -36,6 +36,7 @@ void RGBController_LEDStrip::SetupZones()
|
||||
led_zone.leds_min = strip->num_leds;
|
||||
led_zone.leds_max = strip->num_leds;
|
||||
led_zone.leds_count = strip->num_leds;
|
||||
led_zone.matrix_map = NULL;
|
||||
zones.push_back(led_zone);
|
||||
|
||||
for(int led_idx = 0; led_idx < strip->num_leds; led_idx++)
|
||||
@@ -57,7 +58,7 @@ void RGBController_LEDStrip::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateLEDs()
|
||||
void RGBController_LEDStrip::DeviceUpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ RGBController_MSI3Zone::RGBController_MSI3Zone(MSI3ZoneController* msi_ptr)
|
||||
{
|
||||
msi = msi_ptr;
|
||||
|
||||
name = "MSI 3-Zone Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
name = "MSI 3-Zone Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "MSI 3-Zone Keyboard Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -42,6 +43,7 @@ void RGBController_MSI3Zone::SetupZones()
|
||||
keyboard_zone.leds_min = 3;
|
||||
keyboard_zone.leds_max = 3;
|
||||
keyboard_zone.leds_count = 3;
|
||||
keyboard_zone.matrix_map = NULL;
|
||||
zones.push_back(keyboard_zone);
|
||||
|
||||
led left_led;
|
||||
@@ -65,6 +67,7 @@ void RGBController_MSI3Zone::SetupZones()
|
||||
aux_zone.leds_min = 1;
|
||||
aux_zone.leds_max = 1;
|
||||
aux_zone.leds_count = 1;
|
||||
aux_zone.matrix_map = NULL;
|
||||
zones.push_back(aux_zone);
|
||||
|
||||
led aux_led;
|
||||
@@ -81,7 +84,7 @@ void RGBController_MSI3Zone::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::UpdateLEDs()
|
||||
void RGBController_MSI3Zone::DeviceUpdateLEDs()
|
||||
{
|
||||
msi->SetLEDs(colors);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_MSIMysticLight.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| MSI Mystic Light USB Driver |
|
||||
| |
|
||||
| T-bond 3/4/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_MSIMysticLight.h"
|
||||
#include <array>
|
||||
|
||||
static const std::array<ZoneDescription, 18> led_zones
|
||||
{
|
||||
ZoneDescription{"JRGB1", J_RGB_1},
|
||||
ZoneDescription{"JRGB2", J_RGB_2},
|
||||
ZoneDescription{"JRAINBOW1", J_RAINBOW_1},
|
||||
ZoneDescription{"JRAINBOW2", J_RAINBOW_2},
|
||||
ZoneDescription{"JPIPE1", J_PIPE_1},
|
||||
ZoneDescription{"JPIPE2", J_PIPE_2},
|
||||
ZoneDescription{"JCORSAIR", J_CORSAIR},
|
||||
ZoneDescription{"JCORSAIR Outer", J_CORSAIR_OUTERLL120},
|
||||
ZoneDescription{"OnboardLED", ON_BOARD_LED},
|
||||
ZoneDescription{"OnboardLED1", ON_BOARD_LED_1},
|
||||
ZoneDescription{"OnboardLED2", ON_BOARD_LED_2},
|
||||
ZoneDescription{"OnboardLED3", ON_BOARD_LED_3},
|
||||
ZoneDescription{"OnboardLED4", ON_BOARD_LED_4},
|
||||
ZoneDescription{"OnboardLED5", ON_BOARD_LED_5},
|
||||
ZoneDescription{"OnboardLED6", ON_BOARD_LED_6},
|
||||
ZoneDescription{"OnboardLED7", ON_BOARD_LED_7},
|
||||
ZoneDescription{"OnboardLED8", ON_BOARD_LED_8},
|
||||
ZoneDescription{"OnboardLED9", ON_BOARD_LED_9},
|
||||
};
|
||||
|
||||
RGBController_MSIMysticLight::RGBController_MSIMysticLight(MSIMysticLightController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "MSI Mystic Light Controller";
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
description = controller->GetDeviceName();
|
||||
version = controller->GetFWVersion();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerial();
|
||||
|
||||
SetupModes();
|
||||
SetupZones();
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
RGBController_MSIMysticLight::~RGBController_MSIMysticLight()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < led_zones.size(); zone_idx++)
|
||||
{
|
||||
ZoneDescription zd = led_zones[zone_idx];
|
||||
zone new_zone;
|
||||
new_zone.name = zd.name;
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
|
||||
new_zone.leds_min = controller->GetZoneMinLedCount(zd.value);
|
||||
new_zone.leds_max = controller->GetZoneMaxLedCount(zd.value);
|
||||
new_zone.leds_count = controller->GetZoneLedCount(zd.value);
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < new_zone.leds_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
|
||||
new_led.name = new_zone.name + " LED ";
|
||||
if(new_zone.leds_count > 1)
|
||||
{
|
||||
new_led.name.append(std::to_string(led_idx + 1));
|
||||
}
|
||||
|
||||
new_led.value = zone_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
ZONE zon = ZoneFromPos(zone);
|
||||
unsigned int max_count = controller->GetZoneMaxLedCount(zon),
|
||||
min_count = controller->GetZoneMinLedCount(zon),
|
||||
new_siz = new_size;
|
||||
new_siz = std::min(std::max(new_siz, min_count), max_count); // std::clamp only from C++17
|
||||
/// TODO: Update LED count
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::DeviceUpdateLEDs()
|
||||
{
|
||||
for(size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
UpdateZoneLEDs(zone_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
for(int led_idx = zones[zone].leds_count - 1; led_idx >= 0; led_idx--)
|
||||
{
|
||||
UpdateLed(zone, led_idx);
|
||||
}
|
||||
controller->Update();
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLed(leds[led].value, led);
|
||||
controller->Update();
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::UpdateMode()
|
||||
{
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::SetupModes()
|
||||
{
|
||||
constexpr unsigned int RANDOM_ONLY = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
constexpr unsigned int COMMON = RANDOM_ONLY | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
|
||||
SetupMode("Off", DISABLE, 0);
|
||||
SetupMode("Static", STATIC, MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR);
|
||||
SetupMode("Breathing", BREATHING, COMMON);
|
||||
SetupMode("Flashing", FLASHING, COMMON);
|
||||
SetupMode("Double flashing", DOUBLE_FLASHING, COMMON);
|
||||
SetupMode("Lightning", LIGHTNING, COMMON);
|
||||
SetupMode("MSI Marquee", MSI_MARQUEE, COMMON);
|
||||
SetupMode("Meteor", METEOR, COMMON);
|
||||
SetupMode("Water drop", WATER_DROP, COMMON);
|
||||
SetupMode("MSI Rainbow", MSI_RAINBOW, RANDOM_ONLY);
|
||||
SetupMode("Pop", POP, COMMON);
|
||||
SetupMode("Rap", RAP, COMMON);
|
||||
SetupMode("Jazz", JAZZ, COMMON);
|
||||
SetupMode("Play", PLAY, COMMON);
|
||||
SetupMode("Movie", MOVIE, COMMON);
|
||||
SetupMode("Color ring", COLOR_RING, COMMON);
|
||||
SetupMode("Planetary", PLANETARY, COMMON);
|
||||
SetupMode("Double meteor", DOUBLE_METEOR, COMMON);
|
||||
SetupMode("Energy", ENERGY, COMMON);
|
||||
SetupMode("Blink", BLINK, COMMON);
|
||||
SetupMode("Clock", CLOCK, COMMON);
|
||||
SetupMode("Color pulse", COLOR_PULSE, COMMON);
|
||||
SetupMode("Color shift", COLOR_SHIFT, COMMON);
|
||||
SetupMode("Color wave", COLOR_WAVE, COMMON);
|
||||
SetupMode("Marquee", MARQUEE, COMMON);
|
||||
SetupMode("Rainbow", RAINBOW, COMMON);
|
||||
SetupMode("Rainbow wave", RAINBOW_WAVE, COMMON);
|
||||
SetupMode("Visor", VISOR, COMMON);
|
||||
SetupMode("JRainbow", JRAINBOW, COMMON);
|
||||
SetupMode("Rainbow flashing", RAINBOW_FLASHING, COMMON);
|
||||
SetupMode("Rainbow double flashing", RAINBOW_DOUBLE_FLASHING, COMMON);
|
||||
SetupMode("Random", RANDOM, COMMON);
|
||||
SetupMode("Fan control", FAN_CONTROL, COMMON);
|
||||
SetupMode("Off 2", DISABLE_2, COMMON);
|
||||
SetupMode("Color ring flashing", COLOR_RING_FLASHING, COMMON);
|
||||
SetupMode("Color ring double flashing", COLOR_RING_DOUBLE_FLASHING, COMMON);
|
||||
SetupMode("Stack", STACK, COMMON);
|
||||
SetupMode("Corsair Que", CORSAIR_QUE, COMMON);
|
||||
SetupMode("Fire", FIRE, COMMON);
|
||||
SetupMode("Lava", LAVA, COMMON);
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::UpdateLed(int zone, int led)
|
||||
{
|
||||
bool random = modes[active_mode].color_mode == MODE_COLORS_RANDOM;
|
||||
unsigned char red = RGBGetRValue(zones[zone].colors[led]);
|
||||
unsigned char grn = RGBGetGValue(zones[zone].colors[led]);
|
||||
unsigned char blu = RGBGetBValue(zones[zone].colors[led]);
|
||||
EFFECT mode = static_cast<EFFECT>(modes[active_mode].value);
|
||||
SPEED speed = static_cast<SPEED>(modes[active_mode].speed);
|
||||
ZONE zon = ZoneFromPos(zone);
|
||||
|
||||
controller->SetMode(zon, mode, speed, BRIGHTNESS::LEVEL_100, random);
|
||||
controller->SetZoneColor(zon, red, grn, blu, red, grn, blu);
|
||||
}
|
||||
|
||||
ZONE RGBController_MSIMysticLight::ZoneFromPos(int zone)
|
||||
{
|
||||
return led_zones[zone].value;
|
||||
}
|
||||
|
||||
void RGBController_MSIMysticLight::SetupMode(const char *name, EFFECT mod, unsigned int flags)
|
||||
{
|
||||
mode Mode;
|
||||
Mode.name = name;
|
||||
Mode.value = mod;
|
||||
Mode.flags = flags;
|
||||
if(flags & MODE_FLAG_HAS_PER_LED_COLOR)
|
||||
{
|
||||
Mode.color_mode = MODE_COLORS_PER_LED;
|
||||
}
|
||||
else
|
||||
{
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
}
|
||||
|
||||
if(flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
Mode.speed = SPEED::MEDIUM;
|
||||
Mode.speed_max = SPEED::HIGH;
|
||||
Mode.speed_min = SPEED::LOW;
|
||||
}
|
||||
|
||||
modes.push_back(Mode);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_MSIMysticLight.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| MSI Mystic Light USB Driver |
|
||||
| |
|
||||
| T-bond 3/4/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "MSIMysticLightController.h"
|
||||
#include <vector>
|
||||
|
||||
class RGBController_MSIMysticLight: public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_MSIMysticLight(MSIMysticLightController* controller_ptr);
|
||||
~RGBController_MSIMysticLight();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
void SetupModes();
|
||||
void UpdateLed(int zone, int led);
|
||||
ZONE ZoneFromPos(int zone);
|
||||
void SetupMode(const char *name, EFFECT mode, unsigned int flags);
|
||||
|
||||
MSIMysticLightController* controller;
|
||||
};
|
||||
@@ -12,10 +12,9 @@ RGBController_MSIRGB::RGBController_MSIRGB(MSIRGBController* msi_ptr)
|
||||
{
|
||||
msi = msi_ptr;
|
||||
|
||||
name = "MSI Motherboard";
|
||||
name = "MSI Motherboard";
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
description = "MSI-RGB Device";
|
||||
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -40,6 +39,7 @@ void RGBController_MSIRGB::SetupZones()
|
||||
msi_zone.leds_min = 1;
|
||||
msi_zone.leds_max = 1;
|
||||
msi_zone.leds_count = 1;
|
||||
msi_zone.matrix_map = NULL;
|
||||
zones.push_back(msi_zone);
|
||||
|
||||
led msi_led;
|
||||
@@ -54,7 +54,7 @@ void RGBController_MSIRGB::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::UpdateLEDs()
|
||||
void RGBController_MSIRGB::DeviceUpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
@@ -66,12 +66,12 @@ void RGBController_MSIRGB::UpdateLEDs()
|
||||
|
||||
void RGBController_MSIRGB::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::SetCustomMode()
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_NZXTKraken.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Kraken |
|
||||
| |
|
||||
| Martin Hartl (inlart) 04/04/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_NZXTKraken.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
RGBController_NZXTKraken::RGBController_NZXTKraken(NZXTKrakenController* nzxtkraken_ptr)
|
||||
{
|
||||
nzxtkraken = nzxtkraken_ptr;
|
||||
|
||||
name = "NZXT Kraken X";
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
description = "NZXT Kraken X42/X52/X62/X72";
|
||||
version = nzxtkraken->GetFirmwareVersion();
|
||||
|
||||
mode Fixed;
|
||||
Fixed.name = "Fixed";
|
||||
Fixed.value = NZXT_KRAKEN_MODE_FIXED;
|
||||
Fixed.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Fixed.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Fixed);
|
||||
|
||||
mode Fading;
|
||||
Fading.name = "Fading";
|
||||
Fading.value = NZXT_KRAKEN_MODE_FADING;
|
||||
Fading.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Fading.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
Fading.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
Fading.colors_min = 2;
|
||||
Fading.colors_max = 8;
|
||||
Fading.speed = NZXT_KRAKEN_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 = NZXT_KRAKEN_MODE_SPECTRUM;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
SpectrumCycle.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
SpectrumCycle.direction = MODE_DIRECTION_RIGHT;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = NZXT_KRAKEN_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Marquee.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
Marquee.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
Marquee.colors_min = 1;
|
||||
Marquee.colors_max = 1;
|
||||
Marquee.speed = NZXT_KRAKEN_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 = NZXT_KRAKEN_MODE_COVER_MARQUEE;
|
||||
CoverMarquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
CoverMarquee.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
CoverMarquee.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
CoverMarquee.colors_min = 1;
|
||||
CoverMarquee.colors_max = 8;
|
||||
CoverMarquee.speed = NZXT_KRAKEN_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 = NZXT_KRAKEN_MODE_ALTERNATING;
|
||||
Alternating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Alternating.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
Alternating.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
Alternating.colors_min = 2;
|
||||
Alternating.colors_max = 2;
|
||||
Alternating.speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
Alternating.direction = MODE_DIRECTION_RIGHT;
|
||||
Alternating.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Alternating.colors.resize(2);
|
||||
modes.push_back(Alternating);
|
||||
|
||||
mode Pulse;
|
||||
Pulse.name = "Pulse";
|
||||
Pulse.value = NZXT_KRAKEN_MODE_PULSE;
|
||||
Pulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Pulse.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
Pulse.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
Pulse.colors_min = 1;
|
||||
Pulse.colors_max = 8;
|
||||
Pulse.speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
Pulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Pulse.colors.resize(1);
|
||||
modes.push_back(Pulse);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = NZXT_KRAKEN_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
Breathing.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 8;
|
||||
Breathing.speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ThaiChi;
|
||||
ThaiChi.name = "Thai Chi";
|
||||
ThaiChi.value = NZXT_KRAKEN_MODE_TAI_CHI;
|
||||
ThaiChi.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
ThaiChi.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
ThaiChi.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
ThaiChi.speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
ThaiChi.colors_min = 2;
|
||||
ThaiChi.colors_max = 2;
|
||||
ThaiChi.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ThaiChi.colors.resize(2);
|
||||
modes.push_back(ThaiChi);
|
||||
|
||||
mode WaterCooler;
|
||||
WaterCooler.name = "Water Cooler";
|
||||
WaterCooler.value = NZXT_KRAKEN_MODE_WATER_COOLER;
|
||||
WaterCooler.flags = MODE_FLAG_HAS_SPEED;
|
||||
WaterCooler.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
WaterCooler.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
WaterCooler.speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
WaterCooler.colors_min = 1;
|
||||
WaterCooler.colors_max = 1;
|
||||
WaterCooler.color_mode = MODE_COLORS_NONE;
|
||||
WaterCooler.colors.resize(1);
|
||||
modes.push_back(WaterCooler);
|
||||
|
||||
mode Loading;
|
||||
Loading.name = "Loading";
|
||||
Loading.value = NZXT_KRAKEN_MODE_LOADING;
|
||||
Loading.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Loading.colors_min = 1;
|
||||
Loading.colors_max = 1;
|
||||
Loading.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Loading.colors.resize(1);
|
||||
modes.push_back(Loading);
|
||||
|
||||
mode Wings;
|
||||
Wings.name = "Wings";
|
||||
Wings.value = NZXT_KRAKEN_MODE_WINGS;
|
||||
Wings.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Wings.speed_min = NZXT_KRAKEN_SPEED_SLOWEST;
|
||||
Wings.speed_max = NZXT_KRAKEN_SPEED_FASTEST;
|
||||
Wings.speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
Wings.colors_min = 1;
|
||||
Wings.colors_max = 1;
|
||||
Wings.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Wings.colors.resize(1);
|
||||
modes.push_back(Wings);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Fixed is the default mode |
|
||||
\*---------------------------------------------------------*/
|
||||
default_mode = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Modes supported by the LOGO LED |
|
||||
\*---------------------------------------------------------*/
|
||||
logo_modes =
|
||||
{
|
||||
NZXT_KRAKEN_MODE_FIXED,
|
||||
NZXT_KRAKEN_MODE_FADING,
|
||||
NZXT_KRAKEN_MODE_SPECTRUM,
|
||||
NZXT_KRAKEN_MODE_BREATHING,
|
||||
NZXT_KRAKEN_MODE_PULSE
|
||||
};
|
||||
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
zone logo_zone;
|
||||
logo_zone.name = "Logo";
|
||||
logo_zone.type = ZONE_TYPE_SINGLE;
|
||||
logo_zone.leds_min = 1;
|
||||
logo_zone.leds_max = 1;
|
||||
logo_zone.leds_count = 1;
|
||||
logo_zone.matrix_map = NULL;
|
||||
zones.push_back(logo_zone);
|
||||
|
||||
zone ring_zone;
|
||||
ring_zone.name = "Ring";
|
||||
ring_zone.type = ZONE_TYPE_LINEAR;
|
||||
ring_zone.leds_min = 8;
|
||||
ring_zone.leds_max = 8;
|
||||
ring_zone.leds_count = 8;
|
||||
ring_zone.matrix_map = NULL;
|
||||
zones.push_back(ring_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
led logo_led;
|
||||
logo_led.name = "Logo LED";
|
||||
leds.push_back(logo_led);
|
||||
|
||||
led ring_led;
|
||||
for(int i = 1; i < 9; i++)
|
||||
{
|
||||
ring_led.name = std::string("Ring LED ") + std::to_string(i);
|
||||
leds.push_back(ring_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
std::vector<std::vector<RGBColor>> RGBController_NZXTKraken::GetColors(int zone, const mode& channel_mode)
|
||||
{
|
||||
std::vector<std::vector<RGBColor>> result;
|
||||
int length = zone < 0 ? leds.size() : zones[zone].leds_count;
|
||||
|
||||
if(channel_mode.color_mode == MODE_COLORS_NONE)
|
||||
{
|
||||
result.push_back(std::vector<RGBColor>());
|
||||
}
|
||||
else if(channel_mode.color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
if(zone < 0)
|
||||
{
|
||||
result.push_back(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<RGBColor> led_colors;
|
||||
for(std::size_t idx = 0; idx < zones[zone].leds_count; ++idx)
|
||||
{
|
||||
led_colors.push_back(zones[zone].colors[idx]);
|
||||
}
|
||||
result.push_back(led_colors);
|
||||
}
|
||||
}
|
||||
else if(channel_mode.color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
for(std::size_t idx = 0; idx < channel_mode.colors.size(); ++idx)
|
||||
{
|
||||
result.push_back(std::vector<RGBColor>(length, channel_mode.colors[idx]));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::UpdateChannel(NZXTKrakenChannel_t channel, int zone, const mode& channel_mode)
|
||||
{
|
||||
bool direction = false;
|
||||
|
||||
if((channel_mode.flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
&&(channel_mode.direction == MODE_DIRECTION_LEFT ))
|
||||
{
|
||||
direction = true;
|
||||
}
|
||||
|
||||
unsigned char speed = NZXT_KRAKEN_SPEED_NORMAL;
|
||||
if(channel_mode.flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
speed = channel_mode.speed;
|
||||
}
|
||||
|
||||
std::vector<std::vector<RGBColor>> update_colors = GetColors(zone, channel_mode);
|
||||
for(std::size_t idx = 0; idx < update_colors.size(); ++idx)
|
||||
{
|
||||
nzxtkraken->UpdateEffect(
|
||||
channel,
|
||||
channel_mode.value,
|
||||
direction,
|
||||
speed,
|
||||
idx,
|
||||
update_colors[idx]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::DeviceUpdateLEDs()
|
||||
{
|
||||
if(logo_modes.find(modes[active_mode].value) == logo_modes.end())
|
||||
{
|
||||
UpdateChannel(NZXT_KRAKEN_CHANNEL_LOGO, 0, modes[default_mode]);
|
||||
UpdateChannel(NZXT_KRAKEN_CHANNEL_RING, 1, modes[active_mode]);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateChannel(NZXT_KRAKEN_CHANNEL_SYNC, -1, modes[active_mode]);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
NZXTKrakenChannel_t channel;
|
||||
mode channel_mode = modes[active_mode];
|
||||
if(zone == 0)
|
||||
{
|
||||
channel = NZXT_KRAKEN_CHANNEL_LOGO;
|
||||
if(logo_modes.find(modes[active_mode].value) == logo_modes.end())
|
||||
{
|
||||
channel_mode = modes[default_mode];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
channel = NZXT_KRAKEN_CHANNEL_RING;
|
||||
}
|
||||
UpdateChannel(channel, zone, channel_mode);
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::UpdateSingleLED(int led)
|
||||
{
|
||||
int zone = (led > 0) ? 1 : 0;
|
||||
UpdateZoneLEDs(zone);
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_NZXTKraken::UpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_NZXTKraken.h |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Kraken |
|
||||
| |
|
||||
| Martin Hartl (inlart) 04/04/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "NZXTKrakenController.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
class RGBController_NZXTKraken : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_NZXTKraken(NZXTKrakenController* nzxtkraken_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
std::vector<std::vector<RGBColor>> GetColors
|
||||
(
|
||||
int zone,
|
||||
const mode& channel_mode
|
||||
);
|
||||
|
||||
void UpdateChannel
|
||||
(
|
||||
NZXTKrakenChannel_t channel,
|
||||
int zone,
|
||||
const mode& channel_mode
|
||||
);
|
||||
|
||||
NZXTKrakenController* nzxtkraken;
|
||||
std::set<unsigned int> logo_modes;
|
||||
int default_mode;
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Network.cpp |
|
||||
| |
|
||||
| Generic RGB Interface Network Class |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "RGBController_Network.h"
|
||||
|
||||
RGBController_Network::RGBController_Network(NetworkClient * client_ptr, unsigned int dev_idx_val)
|
||||
{
|
||||
client = client_ptr;
|
||||
dev_idx = dev_idx_val;
|
||||
}
|
||||
|
||||
void RGBController_Network::SetupZones()
|
||||
{
|
||||
//Don't send anything, this function should only process on host
|
||||
}
|
||||
|
||||
void RGBController_Network::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
client->SendRequest_RGBController_ResizeZone(dev_idx, zone, new_size);
|
||||
}
|
||||
|
||||
void RGBController_Network::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char * data = GetColorDescription();
|
||||
unsigned int size;
|
||||
|
||||
memcpy(&size, &data[0], sizeof(unsigned int));
|
||||
|
||||
client->SendRequest_RGBController_UpdateLEDs(dev_idx, data, size);
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void RGBController_Network::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned char * data = GetZoneColorDescription(zone);
|
||||
unsigned int size;
|
||||
|
||||
memcpy(&size, &data[0], sizeof(unsigned int));
|
||||
|
||||
client->SendRequest_RGBController_UpdateZoneLEDs(dev_idx, data, size);
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void RGBController_Network::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char * data = GetSingleLEDColorDescription(led);
|
||||
|
||||
client->SendRequest_RGBController_UpdateSingleLED(dev_idx, data, sizeof(int) + sizeof(RGBColor));
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void RGBController_Network::SetCustomMode()
|
||||
{
|
||||
client->SendRequest_RGBController_SetCustomMode(dev_idx);
|
||||
}
|
||||
|
||||
void RGBController_Network::UpdateMode()
|
||||
{
|
||||
unsigned char * data = GetModeDescription(active_mode);
|
||||
unsigned int size;
|
||||
|
||||
memcpy(&size, &data[0], sizeof(unsigned int));
|
||||
|
||||
client->SendRequest_RGBController_UpdateMode(dev_idx, data, size);
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Network.h |
|
||||
| |
|
||||
| Generic RGB Interface Network Class |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "NetworkClient.h"
|
||||
|
||||
class RGBController_Network : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Network(NetworkClient * client_ptr, unsigned int dev_idx_val);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
NetworkClient * client;
|
||||
unsigned int dev_idx;
|
||||
};
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
|
||||
void RGBController_OpenRazer::UpdateLEDs()
|
||||
void RGBController_OpenRazer::DeviceUpdateLEDs()
|
||||
{
|
||||
switch(matrix_type)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
output_offset = 0;
|
||||
}
|
||||
|
||||
char output_array[output_array_size];
|
||||
char* output_array = new char[output_array_size];
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
@@ -71,6 +71,8 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
matrix_effect_static.write(output_array, output_array_size);
|
||||
matrix_effect_static.flush();
|
||||
}
|
||||
|
||||
delete[] output_array;
|
||||
}
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
@@ -80,44 +82,23 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
}
|
||||
}
|
||||
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();
|
||||
UpdateMode();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupMatrixDevice(unsigned int rows, unsigned int cols)
|
||||
@@ -170,17 +151,41 @@ void RGBController_OpenRazer::OpenFunctions(std::string dev_path)
|
||||
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_breath.open( dev_path + "/logo_matrix_effect_breath");
|
||||
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_breath.open( dev_path + "/scroll_matrix_effect_breath");
|
||||
scroll_matrix_effect_spectrum.open(dev_path + "/scroll_matrix_effect_spectrum");
|
||||
scroll_matrix_effect_reactive.open(dev_path + "/scroll_matrix_effect_reactive");
|
||||
|
||||
backlight_led_effect.open( dev_path + "/backlight_led_effect");
|
||||
backlight_led_rgb.open( dev_path + "/backlight_led_rgb");
|
||||
backlight_led_state.open( dev_path + "/backlight_led_state");
|
||||
|
||||
logo_led_effect.open( dev_path + "/logo_led_effect");
|
||||
logo_led_rgb.open( dev_path + "/logo_led_rgb");
|
||||
logo_led_state.open( dev_path + "/logo_led_state");
|
||||
|
||||
scroll_led_effect.open( dev_path + "/scroll_led_effect");
|
||||
scroll_led_rgb.open( dev_path + "/scroll_led_rgb");
|
||||
scroll_led_state.open( dev_path + "/scroll_led_state");
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| The Naga Chroma (and possibly others) expose a useless |
|
||||
| matrix_effect_custom interface because they use the matrix_ name |
|
||||
| for the keypad LED. Close this useless interface in this case. |
|
||||
| We can detect this when there is a logo matrix or scroll matrix |
|
||||
| at the same time as matrix_effect_custom. |
|
||||
\*-----------------------------------------------------------------*/
|
||||
if((logo_matrix_effect_none || scroll_matrix_effect_none) && matrix_effect_custom)
|
||||
{
|
||||
matrix_effect_custom.close();
|
||||
matrix_effect_custom.setstate(std::ios::failbit);
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
@@ -250,7 +255,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
modes.push_back(Custom);
|
||||
}
|
||||
|
||||
if(matrix_effect_none)
|
||||
if(matrix_effect_none || logo_matrix_effect_none || scroll_matrix_effect_none || backlight_led_state || logo_led_state || scroll_led_state)
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
@@ -260,7 +265,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
modes.push_back(Off);
|
||||
}
|
||||
|
||||
if(matrix_effect_static)
|
||||
if(matrix_effect_static || logo_matrix_effect_static || scroll_matrix_effect_static || backlight_led_effect || logo_led_effect || scroll_led_effect)
|
||||
{
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
@@ -273,7 +278,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
modes.push_back(Static);
|
||||
}
|
||||
|
||||
if(matrix_effect_breath)
|
||||
if(matrix_effect_breath || logo_matrix_effect_breath || scroll_matrix_effect_breath)
|
||||
{
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
@@ -286,7 +291,33 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
modes.push_back(Breathing);
|
||||
}
|
||||
|
||||
if(matrix_effect_spectrum)
|
||||
if(backlight_led_effect || logo_led_effect || scroll_led_effect)
|
||||
{
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = RAZER_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
}
|
||||
|
||||
if(backlight_led_effect || logo_led_effect || scroll_led_effect)
|
||||
{
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = RAZER_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Flashing.colors_min = 1;
|
||||
Flashing.colors_max = 1;
|
||||
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flashing.colors.resize(1);
|
||||
modes.push_back(Flashing);
|
||||
}
|
||||
|
||||
if(matrix_effect_spectrum || logo_matrix_effect_spectrum || scroll_matrix_effect_spectrum || backlight_led_effect || logo_led_effect || scroll_led_effect)
|
||||
{
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
@@ -307,7 +338,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
modes.push_back(Wave);
|
||||
}
|
||||
|
||||
if(matrix_effect_reactive)
|
||||
if(matrix_effect_reactive || logo_matrix_effect_reactive || scroll_matrix_effect_reactive)
|
||||
{
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
@@ -352,6 +383,29 @@ void RGBController_OpenRazer::SetupZones()
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
|
||||
if(new_zone.type == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
matrix_map_type * new_map = new matrix_map_type;
|
||||
new_zone.matrix_map = new_map;
|
||||
|
||||
new_map->height = device_list[device_index]->zones[zone_id]->rows;
|
||||
new_map->width = device_list[device_index]->zones[zone_id]->cols;
|
||||
|
||||
new_map->map = new unsigned int[new_map->height * new_map->width];
|
||||
|
||||
for(int y = 0; y < new_map->height; y++)
|
||||
{
|
||||
for(int x = 0; x < new_map->width; x++)
|
||||
{
|
||||
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
@@ -383,12 +437,27 @@ void RGBController_OpenRazer::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
active_mode = RAZER_MODE_CUSTOM;
|
||||
/*---------------------------------------------------------*\
|
||||
| If device supports custom mode, it will be mode index 0 |
|
||||
\*---------------------------------------------------------*/
|
||||
if(modes[0].value == RAZER_MODE_CUSTOM)
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| If not, use static mode. Static mode should be mode index|
|
||||
| 1 because Off will be index 0 |
|
||||
\*---------------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateMode()
|
||||
{
|
||||
char update_value[6];
|
||||
char effect_value[1];
|
||||
|
||||
update_value[0] = 1;
|
||||
|
||||
@@ -410,26 +479,26 @@ void RGBController_OpenRazer::UpdateMode()
|
||||
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]);
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].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)
|
||||
switch(modes[active_mode].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]);
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(modes[RAZER_MODE_BREATHING].colors.size() == 2)
|
||||
if(modes[active_mode].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]);
|
||||
update_value[3] = RGBGetRValue(modes[active_mode].colors[1]);
|
||||
update_value[4] = RGBGetGValue(modes[active_mode].colors[1]);
|
||||
update_value[5] = RGBGetBValue(modes[active_mode].colors[1]);
|
||||
|
||||
matrix_effect_breath.write(update_value, 6);
|
||||
matrix_effect_breath.flush();
|
||||
@@ -475,28 +544,387 @@ void RGBController_OpenRazer::UpdateMode()
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
switch(active_mode)
|
||||
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();
|
||||
matrix_effect_custom.write(update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
if(matrix_effect_none)
|
||||
{
|
||||
matrix_effect_none.write(update_value, 1);
|
||||
matrix_effect_none.flush();
|
||||
}
|
||||
|
||||
if(logo_matrix_effect_none)
|
||||
{
|
||||
logo_matrix_effect_none.write(update_value, 1);
|
||||
logo_matrix_effect_none.flush();
|
||||
}
|
||||
|
||||
if(scroll_matrix_effect_none)
|
||||
{
|
||||
scroll_matrix_effect_none.write(update_value, 1);
|
||||
scroll_matrix_effect_none.flush();
|
||||
}
|
||||
|
||||
if(backlight_led_state)
|
||||
{
|
||||
update_value[0] = '0';
|
||||
backlight_led_state.write(update_value, 1);
|
||||
backlight_led_state.flush();
|
||||
}
|
||||
|
||||
if(logo_led_state)
|
||||
{
|
||||
update_value[0] = '0';
|
||||
logo_led_state.write(update_value, 1);
|
||||
logo_led_state.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_state)
|
||||
{
|
||||
update_value[0] = '0';
|
||||
scroll_led_state.write(update_value, 1);
|
||||
scroll_led_state.flush();
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
effect_value[0] = '0';
|
||||
|
||||
if(backlight_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
backlight_led_state.write(update_value, 1);
|
||||
backlight_led_state.flush();
|
||||
}
|
||||
|
||||
if(logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
logo_led_state.write(update_value, 1);
|
||||
logo_led_state.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
scroll_led_state.write(update_value, 1);
|
||||
scroll_led_state.flush();
|
||||
}
|
||||
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(matrix_effect_static)
|
||||
{
|
||||
matrix_effect_static.write(update_value, 3);
|
||||
matrix_effect_static.flush();
|
||||
}
|
||||
|
||||
if(logo_matrix_effect_static)
|
||||
{
|
||||
logo_matrix_effect_static.write(update_value, 3);
|
||||
logo_matrix_effect_static.flush();
|
||||
}
|
||||
|
||||
if(scroll_matrix_effect_static)
|
||||
{
|
||||
scroll_matrix_effect_static.write(update_value, 3);
|
||||
scroll_matrix_effect_static.flush();
|
||||
}
|
||||
|
||||
if(backlight_led_effect && backlight_led_rgb)
|
||||
{
|
||||
backlight_led_rgb.write(update_value, 3);
|
||||
backlight_led_rgb.flush();
|
||||
backlight_led_effect.write(effect_value, 1);
|
||||
backlight_led_effect.flush();
|
||||
}
|
||||
|
||||
if(logo_led_effect && logo_led_rgb)
|
||||
{
|
||||
logo_led_rgb.write(update_value, 3);
|
||||
logo_led_rgb.flush();
|
||||
logo_led_effect.write(effect_value, 1);
|
||||
logo_led_effect.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_effect && scroll_led_rgb)
|
||||
{
|
||||
scroll_led_rgb.write(update_value, 3);
|
||||
scroll_led_rgb.flush();
|
||||
scroll_led_effect.write(effect_value, 1);
|
||||
scroll_led_effect.flush();
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_FLASHING:
|
||||
effect_value[0] = '1';
|
||||
|
||||
if(backlight_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
backlight_led_state.write(update_value, 1);
|
||||
backlight_led_state.flush();
|
||||
}
|
||||
|
||||
if(logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
logo_led_state.write(update_value, 1);
|
||||
logo_led_state.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
scroll_led_state.write(update_value, 1);
|
||||
scroll_led_state.flush();
|
||||
}
|
||||
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(backlight_led_effect && backlight_led_rgb)
|
||||
{
|
||||
backlight_led_rgb.write(update_value, 3);
|
||||
backlight_led_rgb.flush();
|
||||
backlight_led_effect.write(effect_value, 1);
|
||||
backlight_led_effect.flush();
|
||||
}
|
||||
|
||||
if(logo_led_effect && logo_led_rgb)
|
||||
{
|
||||
logo_led_rgb.write(update_value, 3);
|
||||
logo_led_rgb.flush();
|
||||
logo_led_effect.write(effect_value, 1);
|
||||
logo_led_effect.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_effect && scroll_led_rgb)
|
||||
{
|
||||
scroll_led_rgb.write(update_value, 3);
|
||||
scroll_led_rgb.flush();
|
||||
scroll_led_effect.write(effect_value, 1);
|
||||
scroll_led_effect.flush();
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
effect_value[0] = '2';
|
||||
|
||||
switch(modes[active_mode].color_mode)
|
||||
{
|
||||
case MODE_COLORS_MODE_SPECIFIC:
|
||||
if(backlight_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
backlight_led_state.write(update_value, 1);
|
||||
backlight_led_state.flush();
|
||||
}
|
||||
|
||||
if(logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
logo_led_state.write(update_value, 1);
|
||||
logo_led_state.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
scroll_led_state.write(update_value, 1);
|
||||
scroll_led_state.flush();
|
||||
}
|
||||
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(modes[active_mode].colors.size() == 2)
|
||||
{
|
||||
update_value[3] = RGBGetRValue(modes[active_mode].colors[1]);
|
||||
update_value[4] = RGBGetGValue(modes[active_mode].colors[1]);
|
||||
update_value[5] = RGBGetBValue(modes[active_mode].colors[1]);
|
||||
|
||||
if(matrix_effect_breath)
|
||||
{
|
||||
matrix_effect_breath.write(update_value, 6);
|
||||
matrix_effect_breath.flush();
|
||||
}
|
||||
|
||||
if(logo_matrix_effect_breath)
|
||||
{
|
||||
logo_matrix_effect_breath.write(update_value, 6);
|
||||
logo_matrix_effect_breath.flush();
|
||||
}
|
||||
|
||||
if(scroll_matrix_effect_breath)
|
||||
{
|
||||
scroll_matrix_effect_breath.write(update_value, 6);
|
||||
scroll_matrix_effect_breath.flush();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(matrix_effect_breath)
|
||||
{
|
||||
matrix_effect_breath.write(update_value, 3);
|
||||
matrix_effect_breath.flush();
|
||||
}
|
||||
|
||||
if(logo_matrix_effect_breath)
|
||||
{
|
||||
logo_matrix_effect_breath.write(update_value, 3);
|
||||
logo_matrix_effect_breath.flush();
|
||||
}
|
||||
|
||||
if(scroll_matrix_effect_breath)
|
||||
{
|
||||
scroll_matrix_effect_breath.write(update_value, 3);
|
||||
scroll_matrix_effect_breath.flush();
|
||||
}
|
||||
|
||||
if(backlight_led_effect && backlight_led_rgb)
|
||||
{
|
||||
backlight_led_rgb.write(update_value, 3);
|
||||
backlight_led_rgb.flush();
|
||||
backlight_led_effect.write(effect_value, 1);
|
||||
backlight_led_effect.flush();
|
||||
}
|
||||
|
||||
if(logo_led_effect && logo_led_rgb)
|
||||
{
|
||||
logo_led_rgb.write(update_value, 3);
|
||||
logo_led_rgb.flush();
|
||||
logo_led_effect.write(effect_value, 1);
|
||||
logo_led_effect.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_effect && scroll_led_rgb)
|
||||
{
|
||||
scroll_led_rgb.write(update_value, 3);
|
||||
scroll_led_rgb.flush();
|
||||
scroll_led_effect.write(effect_value, 1);
|
||||
scroll_led_effect.flush();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_COLORS_RANDOM:
|
||||
if(matrix_effect_breath)
|
||||
{
|
||||
matrix_effect_breath.write(update_value, 1);
|
||||
matrix_effect_breath.flush();
|
||||
}
|
||||
|
||||
if(logo_matrix_effect_breath)
|
||||
{
|
||||
logo_matrix_effect_breath.write(update_value, 1);
|
||||
logo_matrix_effect_breath.flush();
|
||||
}
|
||||
|
||||
if(scroll_matrix_effect_breath)
|
||||
{
|
||||
scroll_matrix_effect_breath.write(update_value, 1);
|
||||
scroll_matrix_effect_breath.flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
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();
|
||||
effect_value[0] = '4';
|
||||
|
||||
if(backlight_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
backlight_led_state.write(update_value, 1);
|
||||
backlight_led_state.flush();
|
||||
}
|
||||
|
||||
if(logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
logo_led_state.write(update_value, 1);
|
||||
logo_led_state.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
scroll_led_state.write(update_value, 1);
|
||||
scroll_led_state.flush();
|
||||
}
|
||||
|
||||
if(matrix_effect_spectrum)
|
||||
{
|
||||
matrix_effect_spectrum.write(update_value, 1);
|
||||
matrix_effect_spectrum.flush();
|
||||
}
|
||||
|
||||
if(logo_matrix_effect_spectrum)
|
||||
{
|
||||
logo_matrix_effect_spectrum.write(update_value, 1);
|
||||
logo_matrix_effect_spectrum.flush();
|
||||
}
|
||||
|
||||
if(scroll_matrix_effect_spectrum)
|
||||
{
|
||||
scroll_matrix_effect_spectrum.write(update_value, 1);
|
||||
scroll_matrix_effect_spectrum.flush();
|
||||
}
|
||||
|
||||
if(backlight_led_effect)
|
||||
{
|
||||
backlight_led_effect.write(effect_value, 1);
|
||||
backlight_led_effect.flush();
|
||||
}
|
||||
|
||||
if(logo_led_effect)
|
||||
{
|
||||
logo_led_effect.write(effect_value, 1);
|
||||
logo_led_effect.flush();
|
||||
}
|
||||
|
||||
if(scroll_led_effect)
|
||||
{
|
||||
scroll_led_effect.write(effect_value, 1);
|
||||
scroll_led_effect.flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
if(matrix_effect_reactive)
|
||||
{
|
||||
matrix_effect_reactive.write(update_value, 1);
|
||||
matrix_effect_reactive.flush();
|
||||
}
|
||||
|
||||
if(logo_matrix_effect_reactive)
|
||||
{
|
||||
logo_matrix_effect_reactive.write(update_value, 1);
|
||||
logo_matrix_effect_reactive.flush();
|
||||
}
|
||||
|
||||
if(scroll_matrix_effect_reactive)
|
||||
{
|
||||
scroll_matrix_effect_reactive.write(update_value, 1);
|
||||
scroll_matrix_effect_reactive.flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
RAZER_MODE_SPECTRUM_CYCLE,
|
||||
RAZER_MODE_WAVE,
|
||||
RAZER_MODE_REACTIVE,
|
||||
RAZER_MODE_FLASHING,
|
||||
RAZER_NUM_MODES
|
||||
};
|
||||
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
@@ -82,15 +83,26 @@ private:
|
||||
std::ofstream logo_led_brightness;
|
||||
std::ofstream logo_matrix_effect_none;
|
||||
std::ofstream logo_matrix_effect_static;
|
||||
std::ofstream logo_matrix_effect_breath;
|
||||
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_breath;
|
||||
std::ofstream scroll_matrix_effect_spectrum;
|
||||
std::ofstream scroll_matrix_effect_reactive;
|
||||
|
||||
std::ofstream backlight_led_effect;
|
||||
std::ofstream backlight_led_rgb;
|
||||
std::ofstream backlight_led_state;
|
||||
|
||||
std::ofstream logo_led_effect;
|
||||
std::ofstream logo_led_rgb;
|
||||
std::ofstream logo_led_state;
|
||||
|
||||
std::ofstream scroll_led_effect;
|
||||
std::ofstream scroll_led_rgb;
|
||||
std::ofstream scroll_led_state;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/hid.h>
|
||||
|
||||
void RGBController_OpenRazer::UpdateLEDs()
|
||||
void RGBController_OpenRazer::DeviceUpdateLEDs()
|
||||
{
|
||||
switch(matrix_type)
|
||||
{
|
||||
@@ -72,6 +72,8 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
{
|
||||
razer_functions->matrix_effect_static->store(razer_device, NULL, output_array, output_array_size);
|
||||
}
|
||||
|
||||
delete[] output_array;
|
||||
}
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
@@ -80,44 +82,23 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
}
|
||||
}
|
||||
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
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
UpdateMode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupMatrixDevice(device_fn_type* razer_functions, unsigned int rows, unsigned int cols)
|
||||
@@ -222,7 +203,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
|
||||
modes.push_back(Custom);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_none)
|
||||
if(razer_functions->matrix_effect_none || razer_functions->logo_matrix_effect_none || razer_functions->scroll_matrix_effect_none /*|| razer_functions->backlight_led_state*/ || razer_functions->logo_led_state || razer_functions->scroll_led_state)
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
@@ -232,7 +213,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
|
||||
modes.push_back(Off);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_static)
|
||||
if(razer_functions->matrix_effect_static || razer_functions->logo_matrix_effect_static || razer_functions->scroll_matrix_effect_static /*|| razer_functions->backlight_led_effect*/ || razer_functions->logo_led_effect || razer_functions->scroll_led_effect)
|
||||
{
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
@@ -245,7 +226,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
|
||||
modes.push_back(Static);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_breath)
|
||||
if(razer_functions->matrix_effect_breath || razer_functions->logo_matrix_effect_breath || razer_functions->scroll_matrix_effect_breath)
|
||||
{
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
@@ -258,7 +239,33 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
|
||||
modes.push_back(Breathing);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_spectrum)
|
||||
if(/*razer_functions->backlight_led_effect ||*/ razer_functions->logo_led_effect || razer_functions->scroll_led_effect)
|
||||
{
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = RAZER_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
}
|
||||
|
||||
if(/*razer_functions->backlight_led_effect ||*/ razer_functions->logo_led_effect || razer_functions->scroll_led_effect)
|
||||
{
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = RAZER_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Flashing.colors_min = 1;
|
||||
Flashing.colors_max = 1;
|
||||
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flashing.colors.resize(1);
|
||||
modes.push_back(Flashing);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_spectrum || razer_functions->logo_matrix_effect_spectrum || razer_functions->scroll_matrix_effect_spectrum /*|| razer_functions->backlight_led_effect*/ || razer_functions->logo_led_effect || razer_functions->scroll_led_effect)
|
||||
{
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
@@ -279,7 +286,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
|
||||
modes.push_back(Wave);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_reactive)
|
||||
if(razer_functions->matrix_effect_reactive || razer_functions->logo_matrix_effect_reactive || razer_functions->scroll_matrix_effect_reactive)
|
||||
{
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
@@ -325,6 +332,29 @@ void RGBController_OpenRazer::SetupZones()
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
|
||||
if(new_zone.type == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
matrix_map_type * new_map = new matrix_map_type;
|
||||
new_zone.matrix_map = new_map;
|
||||
|
||||
new_map->height = device_list[device_index]->zones[zone_id]->rows;
|
||||
new_map->width = device_list[device_index]->zones[zone_id]->cols;
|
||||
|
||||
new_map->map = new unsigned int[new_map->height * new_map->width];
|
||||
|
||||
for(int y = 0; y < new_map->height; y++)
|
||||
{
|
||||
for(int x = 0; x < new_map->width; x++)
|
||||
{
|
||||
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
@@ -356,12 +386,27 @@ void RGBController_OpenRazer::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
SetMode(RAZER_MODE_CUSTOM);
|
||||
/*---------------------------------------------------------*\
|
||||
| If device supports custom mode, it will be mode index 0 |
|
||||
\*---------------------------------------------------------*/
|
||||
if(modes[0].value == RAZER_MODE_CUSTOM)
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| If not, use static mode. Static mode should be mode index|
|
||||
| 1 because Off will be index 0 |
|
||||
\*---------------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateMode()
|
||||
{
|
||||
char update_value[6];
|
||||
char effect_value[1];
|
||||
|
||||
update_value[0] = 1;
|
||||
|
||||
@@ -381,25 +426,25 @@ void RGBController_OpenRazer::UpdateMode()
|
||||
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]);
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].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)
|
||||
switch(modes[active_mode].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]);
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(modes[RAZER_MODE_BREATHING].colors.size() == 2)
|
||||
if(modes[active_mode].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]);
|
||||
update_value[3] = RGBGetRValue(modes[active_mode].colors[1]);
|
||||
update_value[4] = RGBGetGValue(modes[active_mode].colors[1]);
|
||||
update_value[5] = RGBGetBValue(modes[active_mode].colors[1]);
|
||||
|
||||
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 6);
|
||||
}
|
||||
@@ -439,28 +484,329 @@ void RGBController_OpenRazer::UpdateMode()
|
||||
}
|
||||
}
|
||||
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();
|
||||
razer_functions->matrix_effect_custom->store(razer_device, NULL, update_value, 1);
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
if(razer_functions->matrix_effect_none)
|
||||
{
|
||||
razer_functions->matrix_effect_none->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->logo_matrix_effect_none)
|
||||
{
|
||||
razer_functions->logo_matrix_effect_none->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_matrix_effect_none)
|
||||
{
|
||||
razer_functions->scroll_matrix_effect_none->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
//if(razer_functions->backlight_led_state)
|
||||
//{
|
||||
// update_value[0] = '0';
|
||||
// razer_functions->backlight_led_state->store(razer_device, NULL, update_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_state)
|
||||
{
|
||||
update_value[0] = '0';
|
||||
razer_functions->logo_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_state)
|
||||
{
|
||||
update_value[0] = '0';
|
||||
razer_functions->scroll_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
effect_value[0] = '0';
|
||||
|
||||
//if(razer_functions->backlight_led_state)
|
||||
//{
|
||||
// update_value[0] = '1';
|
||||
// razer_functions->backlight_led_state->store(razer_device, NULL, update_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->logo_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->scroll_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(razer_functions->matrix_effect_static)
|
||||
{
|
||||
razer_functions->matrix_effect_static->store(razer_device, NULL, update_value, 3);
|
||||
}
|
||||
|
||||
if(razer_functions->logo_matrix_effect_static)
|
||||
{
|
||||
razer_functions->logo_matrix_effect_static->store(razer_device, NULL, update_value, 3);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_matrix_effect_static)
|
||||
{
|
||||
razer_functions->scroll_matrix_effect_static->store(razer_device, NULL, update_value, 3);
|
||||
}
|
||||
|
||||
//if(razer_functions->backlight_led_effect && razer_functions->backlight_led_rgb)
|
||||
//{
|
||||
// razer_functions->backlight_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
// razer_functions->backlight_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_effect && razer_functions->logo_led_rgb)
|
||||
{
|
||||
razer_functions->logo_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
razer_functions->logo_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_effect && razer_functions->scroll_led_rgb)
|
||||
{
|
||||
razer_functions->scroll_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
razer_functions->scroll_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_FLASHING:
|
||||
effect_value[0] = '1';
|
||||
|
||||
//if(razer_functions->backlight_led_state)
|
||||
//{
|
||||
// update_value[0] = '1';
|
||||
// razer_functions->backlight_led_state->store(razer_device, NULL, update_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->logo_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->scroll_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
//if(razer_functions->backlight_led_effect && razer_functions->backlight_led_rgb)
|
||||
//{
|
||||
// razer_functions->backlight_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
// razer_functions->backlight_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_effect && razer_functions->logo_led_rgb)
|
||||
{
|
||||
razer_functions->logo_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
razer_functions->logo_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_effect && razer_functions->scroll_led_rgb)
|
||||
{
|
||||
razer_functions->scroll_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
razer_functions->scroll_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
effect_value[0] = '2';
|
||||
|
||||
switch(modes[active_mode].color_mode)
|
||||
{
|
||||
case MODE_COLORS_MODE_SPECIFIC:
|
||||
//if(razer_functions->backlight_led_state)
|
||||
//{
|
||||
// update_value[0] = '1';
|
||||
// razer_functions->backlight_led_state->store(razer_device, NULL, update_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->logo_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->scroll_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
if(modes[active_mode].colors.size() == 2)
|
||||
{
|
||||
update_value[3] = RGBGetRValue(modes[active_mode].colors[1]);
|
||||
update_value[4] = RGBGetGValue(modes[active_mode].colors[1]);
|
||||
update_value[5] = RGBGetBValue(modes[active_mode].colors[1]);
|
||||
|
||||
if(razer_functions->matrix_effect_breath)
|
||||
{
|
||||
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 6);
|
||||
}
|
||||
|
||||
if(razer_functions->logo_matrix_effect_breath)
|
||||
{
|
||||
razer_functions->logo_matrix_effect_breath->store(razer_device, NULL, update_value, 6);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_matrix_effect_breath)
|
||||
{
|
||||
razer_functions->scroll_matrix_effect_breath->store(razer_device, NULL, update_value, 6);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(razer_functions->matrix_effect_breath)
|
||||
{
|
||||
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 3);
|
||||
}
|
||||
|
||||
if(razer_functions->logo_matrix_effect_breath)
|
||||
{
|
||||
razer_functions->logo_matrix_effect_breath->store(razer_device, NULL, update_value, 3);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_matrix_effect_breath)
|
||||
{
|
||||
razer_functions->scroll_matrix_effect_breath->store(razer_device, NULL, update_value, 3);
|
||||
}
|
||||
|
||||
//if(razer_functions->backlight_led_effect && razer_functions->backlight_led_rgb)
|
||||
//{
|
||||
// razer_functions->backlight_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
// razer_functions->backlight_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_effect && razer_functions->logo_led_rgb)
|
||||
{
|
||||
razer_functions->logo_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
razer_functions->logo_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_effect && razer_functions->scroll_led_rgb)
|
||||
{
|
||||
razer_functions->scroll_led_rgb->store(razer_device, NULL, update_value, 3);
|
||||
razer_functions->scroll_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MODE_COLORS_RANDOM:
|
||||
if(razer_functions->matrix_effect_breath)
|
||||
{
|
||||
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->logo_matrix_effect_breath)
|
||||
{
|
||||
razer_functions->logo_matrix_effect_breath->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_matrix_effect_breath)
|
||||
{
|
||||
razer_functions->scroll_matrix_effect_breath->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
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();
|
||||
effect_value[0] = '4';
|
||||
|
||||
//if(razer_functions->backlight_led_state)
|
||||
//{
|
||||
// update_value[0] = '1';
|
||||
// razer_functions->backlight_led_state->store(razer_device, NULL, update_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->logo_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_state)
|
||||
{
|
||||
update_value[0] = '1';
|
||||
razer_functions->scroll_led_state->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->matrix_effect_spectrum)
|
||||
{
|
||||
razer_functions->matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->logo_matrix_effect_spectrum)
|
||||
{
|
||||
razer_functions->logo_matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_matrix_effect_spectrum)
|
||||
{
|
||||
razer_functions->scroll_matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
//if(razer_functions->backlight_led_effect)
|
||||
//{
|
||||
// razer_functions->backlight_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
//}
|
||||
|
||||
if(razer_functions->logo_led_effect)
|
||||
{
|
||||
razer_functions->logo_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_led_effect)
|
||||
{
|
||||
razer_functions->scroll_led_effect->store(razer_device, NULL, effect_value, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
if(razer_functions->matrix_effect_reactive)
|
||||
{
|
||||
razer_functions->matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->logo_matrix_effect_reactive)
|
||||
{
|
||||
razer_functions->logo_matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
|
||||
if(razer_functions->scroll_matrix_effect_reactive)
|
||||
{
|
||||
razer_functions->scroll_matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,35 +17,58 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct device_attribute * device_type;
|
||||
struct device_attribute * device_serial;
|
||||
struct device_attribute * firmware_version;
|
||||
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_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* 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* logo_led_brightness;
|
||||
struct device_attribute* logo_matrix_effect_none;
|
||||
struct device_attribute* logo_matrix_effect_static;
|
||||
struct device_attribute* logo_matrix_effect_breath;
|
||||
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_brightness;
|
||||
struct device_attribute* scroll_matrix_effect_none;
|
||||
struct device_attribute* scroll_matrix_effect_static;
|
||||
struct device_attribute* scroll_matrix_effect_breath;
|
||||
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;
|
||||
struct device_attribute* left_led_brightness;
|
||||
struct device_attribute* left_matrix_effect_none;
|
||||
struct device_attribute* left_matrix_effect_static;
|
||||
struct device_attribute* left_matrix_effect_breath;
|
||||
struct device_attribute* left_matrix_effect_spectrum;
|
||||
struct device_attribute* left_matrix_effect_reactive;
|
||||
struct device_attribute* left_matrix_effect_wave;
|
||||
|
||||
struct device_attribute* right_led_brightness;
|
||||
struct device_attribute* right_matrix_effect_none;
|
||||
struct device_attribute* right_matrix_effect_static;
|
||||
struct device_attribute* right_matrix_effect_breath;
|
||||
struct device_attribute* right_matrix_effect_spectrum;
|
||||
struct device_attribute* right_matrix_effect_reactive;
|
||||
struct device_attribute* right_matrix_effect_wave;
|
||||
|
||||
struct device_attribute* logo_led_effect;
|
||||
struct device_attribute* logo_led_rgb;
|
||||
struct device_attribute* logo_led_state;
|
||||
|
||||
struct device_attribute* scroll_led_effect;
|
||||
struct device_attribute* scroll_led_rgb;
|
||||
struct device_attribute* scroll_led_state;
|
||||
} device_fn_type;
|
||||
|
||||
class RGBController_OpenRazer : public RGBController
|
||||
@@ -60,6 +83,7 @@ public:
|
||||
RAZER_MODE_SPECTRUM_CYCLE,
|
||||
RAZER_MODE_WAVE,
|
||||
RAZER_MODE_REACTIVE,
|
||||
RAZER_MODE_FLASHING,
|
||||
RAZER_NUM_MODES
|
||||
};
|
||||
|
||||
@@ -79,7 +103,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* v
|
||||
{
|
||||
viper = viper_ptr;
|
||||
|
||||
name = viper->GetDeviceName();
|
||||
location = viper->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = viper->GetDeviceName();
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "Patriot Viper Device";
|
||||
location = viper->GetDeviceLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -114,6 +114,7 @@ void RGBController_PatriotViper::SetupZones()
|
||||
new_zone->leds_min = 5;
|
||||
new_zone->leds_max = 5;
|
||||
new_zone->leds_count = 5;
|
||||
new_zone->matrix_map = NULL;
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ void RGBController_PatriotViper::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::UpdateLEDs()
|
||||
void RGBController_PatriotViper::DeviceUpdateLEDs()
|
||||
{
|
||||
if(viper->direct == true)
|
||||
{
|
||||
@@ -167,7 +168,7 @@ void RGBController_PatriotViper::UpdateLEDs()
|
||||
|
||||
void RGBController_PatriotViper::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
UpdateLEDs();
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::UpdateSingleLED(int led)
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user