AsusAuraCore: Support Asus ROG Strix GA15DH.

Commits squashed and amended for code style by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
git 2021-01-21 23:07:11 -05:00 committed by Adam Honse
parent 5ce9ddc40a
commit 4110335e30
5 changed files with 600 additions and 87 deletions

View file

@ -10,10 +10,21 @@
#include "AsusAuraCoreController.h"
#include <cstring>
#define AURA_CORE_MAX_MESSAGE_SIZE 64
AuraCoreController::AuraCoreController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
dev = dev_handle;
location = path;
aura_device.aura_type = AURA_CORE_DEVICE_UNKNOWN;
aura_device.buff_size = 0;
aura_device.report_id = 0x5D;
aura_device.num_leds = 4;
aura_device.supports_direct = false;
IdentifyDevice();
Handshake();
}
AuraCoreController::~AuraCoreController()
@ -42,26 +53,29 @@ void AuraCoreController::SendBrightness
unsigned char brightness
)
{
unsigned char usb_buf[17];
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
{
/*-----------------------------------------------------*\
| 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;
/*-----------------------------------------------------*\
| 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);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
}
}
void AuraCoreController::SendUpdate
@ -69,60 +83,280 @@ void AuraCoreController::SendUpdate
unsigned char zone,
unsigned char mode,
unsigned char speed,
unsigned char dir,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
unsigned char usb_buf[17];
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
{
if(aura_device.aura_type == AURA_CORE_DEVICE_KEYBOARD)
{
zone += 1;
}
/*-----------------------------------------------------*\
| 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;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, 17);
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = aura_device.report_id;
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;
usb_buf[0x08] = dir;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
}
}
void AuraCoreController::SendSet()
{
unsigned char usb_buf[17];
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
{
/*-----------------------------------------------------*\
| 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;
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = aura_device.report_id;
usb_buf[0x01] = AURA_CORE_COMMAND_SET;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, 17);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
}
}
void AuraCoreController::SendApply()
{
unsigned char usb_buf[17];
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
{
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = aura_device.report_id;
usb_buf[0x01] = AURA_CORE_COMMAND_APPLY;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
}
}
void AuraCoreController::InitDirectMode()
{
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
unsigned char msg_num = 0;
int led_count = aura_device.num_leds;
if(aura_device.supports_direct)
{
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = aura_device.report_id;
usb_buf[0x01] = AURA_CORE_COMMAND_DIRECT;
usb_buf[0x02] = 0xD0;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
while(led_count > 0)
{
/*-----------------------------------------------------*\
| Set up second message packet |
\*-----------------------------------------------------*/
usb_buf[0x03] = 0x01;
usb_buf[0x04] = 0x02;
usb_buf[0x05] = 0x00;
usb_buf[0x06] = msg_num++;
usb_buf[0x07] = (led_count > aura_device.max_leds_per_message) ? aura_device.max_leds_per_message : led_count;
usb_buf[0x08] = 0x00;
/*-----------------------------------------------------*\
| Send packet 2 |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
led_count -= aura_device.max_leds_per_message;
}
}
}
void AuraCoreController::UpdateDirect(std::vector<AuraColor>& color_set)
{
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
unsigned char msg_num = 0;
unsigned char color_index = 0;
unsigned char set_count = 0;
int led_count = aura_device.num_leds;
if(aura_device.supports_direct)
{
while(led_count > 0)
{
unsigned char msg_index = 0x09;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = aura_device.report_id;
usb_buf[0x01] = AURA_CORE_COMMAND_DIRECT;
usb_buf[0x02] = 0xD0;
usb_buf[0x03] = 0x01;
usb_buf[0x04] = 0x02;
usb_buf[0x05] = 0x00;
usb_buf[0x06] = msg_num++;
usb_buf[0x07] = (led_count > aura_device.max_leds_per_message) ? aura_device.max_leds_per_message : led_count;
usb_buf[0x08] = 0x00;
set_count = 0;
while( (msg_index < sizeof(usb_buf) ) &&
(led_count > 0 ) &&
(set_count < aura_device.max_leds_per_message) )
{
if(color_index < color_set.size())
{
usb_buf[msg_index++] = color_set[color_index].red;
usb_buf[msg_index++] = color_set[color_index].green;
usb_buf[msg_index++] = color_set[color_index].blue;
}
else
{
usb_buf[msg_index++] = 0;
usb_buf[msg_index++] = 0;
usb_buf[msg_index++] = 0;
}
led_count--;
color_index++;
set_count++;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
}
}
}
void AuraCoreController::IdentifyDevice()
{
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
int num_bytes = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| First, attempt to read the report from the Keyboard |
\*-----------------------------------------------------*/
usb_buf[0x00] = aura_device.report_id;
num_bytes = hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Currently, there is no need to attempt to read the |
| returned data. If the device responded,to the report,|
| we're good. |
\*-----------------------------------------------------*/
if(num_bytes > 0)
{
aura_device.aura_type = AURA_CORE_DEVICE_KEYBOARD;
aura_device.buff_size = 17;
aura_device.report_id = 0x5D;
aura_device.num_leds = 4;
aura_device.supports_direct = false;
}
else if(num_bytes == -1)
{
/*-------------------------------------------------*\
| First, attempt to read the report from the |
| Keyboard |
\*-------------------------------------------------*/
usb_buf[0] = 0x5E;
num_bytes = hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
if(num_bytes > 0)
{
/*---------------------------------------------*\
| Currently, there is no need to attempt to |
| read the returned data. If the device |
| responded,to the report, we're good. |
\*---------------------------------------------*/
aura_device.aura_type = AURA_CORE_DEVICE_GA15DH;
aura_device.buff_size = 64;
aura_device.report_id = 0x5E;
aura_device.num_leds = 20;
aura_device.max_leds_per_message = 16;
aura_device.supports_direct = true;
}
}
}
void AuraCoreController::Handshake()
{
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
if(aura_device.aura_type == AURA_CORE_DEVICE_GA15DH)
{
usb_buf[0] = 0x5E;
SendIdString();
hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
SendQuery();
hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
}
}
void AuraCoreController::SendIdString()
{
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
const char id[] = "ASUS Tech.Inc.";
/*-----------------------------------------------------*\
| Zero out buffer |
@ -132,11 +366,40 @@ void AuraCoreController::SendApply()
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x5D;
usb_buf[0x01] = AURA_CORE_COMMAND_APPLY;
usb_buf[0x00] = aura_device.report_id;
/*-----------------------------------------------------*\
| Copy in string data |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x01], id, sizeof(id));
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, 17);
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
}
void AuraCoreController::SendQuery()
{
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = aura_device.report_id;
usb_buf[0x01] = 0x05;
usb_buf[0x02] = 0x20;
usb_buf[0x03] = 0x31;
usb_buf[0x04] = 0x00;
usb_buf[0x05] = 0x10;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
}

View file

@ -14,11 +14,24 @@
#pragma once
enum AuraCoreDeviceType
{
AURA_CORE_DEVICE_UNKNOWN = 0,
AURA_CORE_DEVICE_KEYBOARD = 1,
AURA_CORE_DEVICE_GA15DH = 2
};
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 */
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 */
AURA_CORE_MODE_RAINBOW = 3, /* Rainbow mode */
AURA_CORE_MODE_STROBE = 10, /* Strobe mode */
AURA_CORE_MODE_COMET = 11, /* Comet mode */
AURA_CORE_MODE_FLASHNDASH = 12, /* Flash & Dash mode */
AURA_CORE_MODE_IRRADIATION = 17, /* Irradiation mode */
AURA_CORE_MODE_DIRECT = 255 /* Not a real mode - but need a way to differentiate */
};
enum
@ -27,6 +40,7 @@ enum
AURA_CORE_COMMAND_SET = 0xB5, /* Set command */
AURA_CORE_COMMAND_APPLY = 0xB4, /* Apply command */
AURA_CORE_COMMAND_BRIGHTNESS = 0xBA, /* Brightness command */
AURA_CORE_COMMAND_DIRECT = 0xBC /* Set LEDs directly */
};
enum
@ -45,9 +59,28 @@ enum
AURA_CORE_SPEED_FAST = 0xF5, /* Fastest speed */
};
struct AuraDeviceDescriptor
{
AuraCoreDeviceType aura_type;
unsigned char buff_size;
unsigned char report_id;
unsigned char num_leds;
unsigned char max_leds_per_message;
bool supports_direct;
};
struct AuraColor
{
unsigned char red;
unsigned char green;
unsigned char blue;
};
class AuraCoreController
{
public:
AuraDeviceDescriptor aura_device;
AuraCoreController(hid_device* dev_handle, const char* path);
~AuraCoreController();
@ -64,6 +97,7 @@ public:
unsigned char zone,
unsigned char mode,
unsigned char speed,
unsigned char dir,
unsigned char red,
unsigned char green,
unsigned char blue
@ -73,8 +107,17 @@ public:
void SendApply();
void InitDirectMode();
void UpdateDirect(std::vector<AuraColor>& color_set);
private:
hid_device* dev;
std::string location;
void IdentifyDevice();
void Handshake();
void SendIdString();
void SendQuery();
};

View file

@ -19,10 +19,13 @@ void DetectAsusAuraCoreControllers(hid_device_info* info, const std::string&)
hid_device* dev = hid_open_path(info->path);
if( dev )
{
AuraCoreController* controller = new AuraCoreController(dev, info->path);
AuraCoreController* controller = new AuraCoreController(dev, info->path);
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);
if(rgb_controller->type != DEVICE_TYPE_UNKNOWN)
{
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -10,14 +10,33 @@
RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
{
aura = aura_ptr;
aura = aura_ptr;
name = "ASUS Aura Core";
name = "ASUS Aura Core Device";
vendor = "ASUS";
location = aura->GetDeviceLocation();
serial = aura->GetSerialString();
description = "ASUS Aura Core Device";
type = DEVICE_TYPE_UNKNOWN;
if(aura->aura_device.aura_type == AURA_CORE_DEVICE_KEYBOARD)
{
SetupKeyboard();
}
else if(aura->aura_device.aura_type == AURA_CORE_DEVICE_GA15DH)
{
SetupGA15DH();
}
SetupZones();
}
void RGBController_AuraCore::SetupKeyboard()
{
name = "ASUS Aura Keyboard";
vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD;
description = "ASUS Aura Core Device";
location = aura->GetDeviceLocation();
serial = aura->GetSerialString();
mode Static;
Static.name = "Static";
@ -39,8 +58,102 @@ RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
ColorCycle.flags = 0;
ColorCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(ColorCycle);
}
SetupZones();
void RGBController_AuraCore::SetupGA15DH()
{
name = "ASUS Aura GA15DH";
vendor = "ASUS";
type = DEVICE_TYPE_LEDSTRIP;
description = "ASUS Aura Core Device";
mode Static;
Static.name = "Static";
Static.value = AURA_CORE_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_CORE_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
Breathing.speed_min = AURA_CORE_SPEED_SLOW;
Breathing.speed_max = AURA_CORE_SPEED_FAST;
Breathing.speed = AURA_CORE_SPEED_NORMAL;
Breathing.colors_min = 1;
Breathing.colors_max = 2;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors.resize(2);
modes.push_back(Breathing);
mode ColorCycle;
ColorCycle.name = "Color Cycle";
ColorCycle.value = AURA_CORE_MODE_SPECTRUM_CYCLE;
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
ColorCycle.speed_min = AURA_CORE_SPEED_SLOW;
ColorCycle.speed_max = AURA_CORE_SPEED_FAST;
ColorCycle.speed = AURA_CORE_SPEED_NORMAL;
ColorCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(ColorCycle);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = AURA_CORE_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
Rainbow.speed_min = AURA_CORE_SPEED_SLOW;
Rainbow.speed_max = AURA_CORE_SPEED_FAST;
Rainbow.speed = AURA_CORE_SPEED_NORMAL;
Rainbow.direction = MODE_DIRECTION_RIGHT;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
mode Strobe;
Strobe.name = "Strobe";
Strobe.value = AURA_CORE_MODE_STROBE;
Strobe.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Strobe.colors_min = 1;
Strobe.colors_max = 1;
Strobe.color_mode = MODE_COLORS_MODE_SPECIFIC;
Strobe.colors.resize(1);
modes.push_back(Strobe);
mode Comet;
Comet.name = "Comet";
Comet.value = AURA_CORE_MODE_COMET;
Comet.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Comet.colors_min = 1;
Comet.colors_max = 1;
Comet.color_mode = MODE_COLORS_MODE_SPECIFIC;
Comet.colors.resize(1);
modes.push_back(Comet);
mode Flash;
Flash.name = "Flash & Dash";
Flash.value = AURA_CORE_MODE_FLASHNDASH;
Flash.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Flash.colors_min = 1;
Flash.colors_max = 1;
Flash.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flash.colors.resize(1);
modes.push_back(Flash);
mode Irradiation;
Irradiation.name = "Irradiation";
Irradiation.value = AURA_CORE_MODE_IRRADIATION;
Irradiation.flags = 0;
Irradiation.color_mode = MODE_COLORS_NONE;
modes.push_back(Irradiation);
mode Direct;
Static.name = "Direct";
Static.value = AURA_CORE_MODE_DIRECT;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
}
RGBController_AuraCore::~RGBController_AuraCore()
@ -50,19 +163,37 @@ RGBController_AuraCore::~RGBController_AuraCore()
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);
zone auraZone;
for(unsigned int led_idx = 0; led_idx < Keyboard.leds_count; led_idx++)
if(aura->aura_device.aura_type == AURA_CORE_DEVICE_KEYBOARD)
{
auraZone.name = "Keyboard";
auraZone.type = ZONE_TYPE_SINGLE;
auraZone.leds_min = 4;
auraZone.leds_max = 4;
auraZone.leds_count = 4;
auraZone.matrix_map = NULL;
}
else if(aura->aura_device.aura_type == AURA_CORE_DEVICE_GA15DH)
{
auraZone.name = "GA15DH";
auraZone.type = ZONE_TYPE_LINEAR;
auraZone.leds_min = 20;
auraZone.leds_max = 20;
auraZone.leds_count = 20;
auraZone.matrix_map = NULL;
}
else
{
auraZone.leds_count = 0;
}
zones.push_back(auraZone);
for(unsigned int led_idx = 0; led_idx < auraZone.leds_count; led_idx++)
{
led KeyLED;
KeyLED.name = "Keyboard LED ";
KeyLED.name = auraZone.name + " ";
KeyLED.name.append(std::to_string(led_idx + 1));
leds.push_back(KeyLED);
}
@ -84,23 +215,88 @@ void RGBController_AuraCore::DeviceUpdateLEDs()
void RGBController_AuraCore::UpdateZoneLEDs(int /*zone*/)
{
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
{
UpdateSingleLED(led_idx);
std::vector<AuraColor> aura_colors;
std::vector<RGBColor>& color_set = colors;
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
color_set = modes[active_mode].colors;
}
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
{
AuraColor new_color;
new_color.red = RGBGetRValue(color_set[led_idx]);
new_color.green = RGBGetGValue(color_set[led_idx]);
new_color.blue = RGBGetBValue(color_set[led_idx]);
aura_colors.push_back(new_color);
}
aura->UpdateDirect(aura_colors);
}
else if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
{
UpdateSingleLED(led_idx);
}
}
else
{
UpdateSingleLED(0);
}
}
void RGBController_AuraCore::UpdateSingleLED(int led)
{
unsigned char speed = 0xFF;
unsigned char red = 0;
unsigned char green = 0;
unsigned char blue = 0;
unsigned char dir = 0;
mode& curr_mode = modes[active_mode];
if(curr_mode.color_mode == MODE_COLORS_PER_LED)
{
red = RGBGetRValue(colors[led]);
green = RGBGetGValue(colors[led]);
blue = RGBGetBValue(colors[led]);
}
else if(curr_mode.color_mode == MODE_COLORS_MODE_SPECIFIC)
{
red = RGBGetRValue(curr_mode.colors[led]);
green = RGBGetGValue(curr_mode.colors[led]);
blue = RGBGetBValue(curr_mode.colors[led]);
}
if(curr_mode.flags & MODE_FLAG_HAS_SPEED)
{
speed = curr_mode.speed;
}
if(curr_mode.flags & MODE_FLAG_HAS_DIRECTION_LR)
{
if(curr_mode.direction == MODE_DIRECTION_RIGHT)
{
dir = 1;
}
}
aura->SendUpdate
(
led + 1,
modes[active_mode].value,
AURA_CORE_SPEED_NORMAL,
RGBGetRValue(colors[led]),
RGBGetGValue(colors[led]),
RGBGetBValue(colors[led])
led,
curr_mode.value,
speed,
dir,
red,
green,
blue
);
aura->SendSet();
aura->SendApply();
}
@ -112,5 +308,12 @@ void RGBController_AuraCore::SetCustomMode()
void RGBController_AuraCore::DeviceUpdateMode()
{
DeviceUpdateLEDs();
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
{
aura->InitDirectMode();
}
else
{
DeviceUpdateLEDs();
}
}

View file

@ -17,6 +17,8 @@ public:
RGBController_AuraCore(AuraCoreController* aura_ptr);
~RGBController_AuraCore();
void SetupKeyboard();
void SetupGA15DH();
void SetupZones();
void ResizeZone(int zone, int new_size);
@ -30,5 +32,4 @@ public:
private:
AuraCoreController* aura;
};