Code cleanup, mostly updating name of controller pointer in RGBController classes for consistency

This commit is contained in:
Adam Honse 2022-01-17 19:27:50 -06:00
parent e7f4b9f921
commit 7d34e27019
20 changed files with 837 additions and 841 deletions

View file

@ -20,7 +20,7 @@ void DetectAMDWraithPrismControllers(hid_device_info* info, const std::string&)
hid_device* dev = hid_open_path(info->path);
if( dev )
{
AMDWraithPrismController* controller = new AMDWraithPrismController(dev, info->path);
AMDWraithPrismController* controller = new AMDWraithPrismController(dev, info->path);
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);

View file

@ -9,21 +9,21 @@
#include "RGBController_AMDWraithPrism.h"
RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr)
RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismController* controller_ptr)
{
wraith = wraith_ptr;
controller = controller_ptr;
name = "AMD Wraith Prism";
vendor = "Cooler Master";
type = DEVICE_TYPE_COOLER;
description = "AMD Wraith Prism Device";
version = wraith->GetFirmwareVersionString();
location = wraith->GetLocationString();
version = controller->GetFirmwareVersionString();
location = controller->GetLocationString();
/*-----------------------------------------------------*\
| Don't use HID serial string, it is inconsistent on my |
| Wraith Prism |
\*-----------------------------------------------------*/
serial = "";//wraith->GetSerialString();
serial = "";//controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
@ -118,7 +118,7 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
{
delete wraith;
delete controller;
}
void RGBController_AMDWraithPrism::SetupZones()
@ -183,17 +183,17 @@ void RGBController_AMDWraithPrism::DeviceUpdateLEDs()
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
wraith->SetLogoColor(red, grn, blu);
controller->SetLogoColor(red, grn, blu);
red = RGBGetRValue(colors[1]);
grn = RGBGetGValue(colors[1]);
blu = RGBGetBValue(colors[1]);
wraith->SetFanColor(red, grn, blu);
controller->SetFanColor(red, grn, blu);
red = RGBGetRValue(colors[2]);
grn = RGBGetGValue(colors[2]);
blu = RGBGetBValue(colors[2]);
wraith->SetRingColor(red, grn, blu);
controller->SetRingColor(red, grn, blu);
}
void RGBController_AMDWraithPrism::UpdateZoneLEDs(int zone)
@ -205,15 +205,15 @@ void RGBController_AMDWraithPrism::UpdateZoneLEDs(int zone)
if(zone == 0)
{
wraith->SetLogoColor(red, grn, blu);
controller->SetLogoColor(red, grn, blu);
}
else if(zone == 1)
{
wraith->SetFanColor(red, grn, blu);
controller->SetFanColor(red, grn, blu);
}
else if(zone == 2)
{
wraith->SetRingColor(red, grn, blu);
controller->SetRingColor(red, grn, blu);
}
}
@ -231,36 +231,36 @@ void RGBController_AMDWraithPrism::DeviceUpdateMode()
{
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
wraith->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction, random);
controller->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction, random);
switch(modes[active_mode].value)
{
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE:
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
break;
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW:
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE:
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, (modes[active_mode].brightness >> 1), random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, (modes[active_mode].brightness >> 1), random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, (modes[active_mode].brightness >> 1), random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, (modes[active_mode].brightness >> 1), random);
break;
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING:
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].brightness, random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].brightness, random);
break;
default:
if(random)
{
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
}
else
{
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].brightness, random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].brightness, random);
}
break;
}

View file

@ -1,33 +1,33 @@
/*-----------------------------------------*\
| RGBController_AMDWraithPrism.h |
| |
| Generic RGB Interface for AMD Wraith |
| Prism |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AMDWraithPrismController.h"
class RGBController_AMDWraithPrism : public RGBController
{
public:
RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr);
~RGBController_AMDWraithPrism();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AMDWraithPrismController* wraith;
};
/*-----------------------------------------*\
| RGBController_AMDWraithPrism.h |
| |
| Generic RGB Interface for AMD Wraith |
| Prism |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AMDWraithPrismController.h"
class RGBController_AMDWraithPrism : public RGBController
{
public:
RGBController_AMDWraithPrism(AMDWraithPrismController* controller_ptr);
~RGBController_AMDWraithPrism();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AMDWraithPrismController* controller;
};

View file

@ -47,10 +47,7 @@ bool TestForPolychromeSMBusController(i2c_smbus_interface* bus, unsigned char ad
void DetectPolychromeSMBusControllers(std::vector<i2c_smbus_interface*>& busses)
{
PolychromeController* new_polychrome;
RGBController_Polychrome* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
for(unsigned int bus = 0; bus < busses.size(); bus++)
{
IF_MOBO_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
{
@ -58,21 +55,21 @@ void DetectPolychromeSMBusControllers(std::vector<i2c_smbus_interface*>& busses)
{
LOG_DEBUG(SMBUS_CHECK_DEVICE_MESSAGE_EN, ASROCK_DETECTOR_NAME, bus, VENDOR_NAME, SMBUS_ADDRESS);
// Check for Polychrome controller at 0x6A
if (TestForPolychromeSMBusController(busses[bus], SMBUS_ADDRESS))
if(TestForPolychromeSMBusController(busses[bus], SMBUS_ADDRESS))
{
LOG_DEBUG("[%s] Detected a device at address %02X, testing for a known controller", ASROCK_DETECTOR_NAME, SMBUS_ADDRESS);
new_polychrome = new PolychromeController(busses[bus], SMBUS_ADDRESS);
PolychromeController* controller = new PolychromeController(busses[bus], SMBUS_ADDRESS);
if(new_polychrome->GetASRockType() != ASROCK_TYPE_UNKNOWN)
if(controller->GetASRockType() != ASROCK_TYPE_UNKNOWN)
{
LOG_DEBUG("[%s] Found a known Polychrome device", ASROCK_DETECTOR_NAME);
new_controller = new RGBController_Polychrome(new_polychrome);
ResourceManager::get()->RegisterRGBController(new_controller);
RGBController_Polychrome* rgb_controller = new RGBController_Polychrome(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
else
{
LOG_DEBUG("[%s] Not a Polychrome device or unknown type", ASROCK_DETECTOR_NAME);
delete new_polychrome;
delete controller;
}
}
else

View file

@ -32,17 +32,17 @@ static const char* polychrome_v2_zone_names[] =
"Addressable Header"
};
RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychrome_ptr)
RGBController_Polychrome::RGBController_Polychrome(PolychromeController* controller_ptr)
{
polychrome = polychrome_ptr;
controller = controller_ptr;
name = polychrome->GetDeviceName();
name = controller->GetDeviceName();
vendor = "ASRock";
version = polychrome->GetFirmwareVersion();
version = controller->GetFirmwareVersion();
type = DEVICE_TYPE_MOTHERBOARD;
location = polychrome->GetDeviceLocation();
location = controller->GetDeviceLocation();
switch(polychrome->GetASRockType())
switch(controller->GetASRockType())
{
case ASROCK_TYPE_ASRLED:
{
@ -416,12 +416,12 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
RGBController_Polychrome::~RGBController_Polychrome()
{
delete polychrome;
delete controller;
}
void RGBController_Polychrome::SetupZones()
{
switch(polychrome->GetASRockType())
switch(controller->GetASRockType())
{
/*---------------------------------------------------------*\
| ASR LED motherboards only have a single zone/LED |
@ -477,14 +477,14 @@ void RGBController_Polychrome::SetupZones()
\*---------------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < POLYCHROME_ZONE_COUNT; zone_idx++)
{
if(polychrome->zone_led_count[zone_idx] > 0)
if(controller->zone_led_count[zone_idx] > 0)
{
zone* new_zone = new zone();
/*---------------------------------------------------------*\
| Set zone name to channel name |
\*---------------------------------------------------------*/
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
if(controller->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
{
new_zone->name = polychrome_v1_zone_names[zone_idx];
}
@ -501,9 +501,9 @@ void RGBController_Polychrome::SetupZones()
}
else
{
new_zone->leds_min = polychrome->zone_led_count[zone_idx];
new_zone->leds_max = polychrome->zone_led_count[zone_idx];
new_zone->leds_count = polychrome->zone_led_count[zone_idx];
new_zone->leds_min = controller->zone_led_count[zone_idx];
new_zone->leds_max = controller->zone_led_count[zone_idx];
new_zone->leds_count = controller->zone_led_count[zone_idx];
}
if(new_zone->leds_count > 1)
@ -530,16 +530,16 @@ void RGBController_Polychrome::SetupZones()
\*---------------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < POLYCHROME_ZONE_COUNT; zone_idx++)
{
if(polychrome->zone_led_count[zone_idx] > 0)
if(controller->zone_led_count[zone_idx] > 0)
{
for(unsigned int led_idx = 0; led_idx < polychrome->zone_led_count[zone_idx]; led_idx++)
for(unsigned int led_idx = 0; led_idx < controller->zone_led_count[zone_idx]; led_idx++)
{
/*---------------------------------------------------------*\
| Each zone only has one LED |
\*---------------------------------------------------------*/
led* new_led = new led();
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
if(controller->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
{
new_led->name = polychrome_v1_zone_names[zone_idx];
}
@ -551,7 +551,7 @@ void RGBController_Polychrome::SetupZones()
new_led->name.append(" " + std::to_string(led_idx + 1));
new_led->value = 0;
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
if(controller->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
{
new_led->value = zone_idx;
}
@ -616,7 +616,7 @@ void RGBController_Polychrome::UpdateSingleLED(int led)
led = leds[led].value;
}
polychrome->SetColorsAndSpeed(led, red, grn, blu);
controller->SetColorsAndSpeed(led, red, grn, blu);
}
void RGBController_Polychrome::SetCustomMode()
@ -626,16 +626,16 @@ void RGBController_Polychrome::SetCustomMode()
void RGBController_Polychrome::DeviceUpdateMode()
{
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
if(controller->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
{
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
{
polychrome->SetMode(led_idx, modes[active_mode].value, modes[active_mode].speed);
controller->SetMode(led_idx, modes[active_mode].value, modes[active_mode].speed);
}
}
else
{
polychrome->SetMode(0, modes[active_mode].value, modes[active_mode].speed);
controller->SetMode(0, modes[active_mode].value, modes[active_mode].speed);
}
DeviceUpdateLEDs();

View file

@ -1,34 +1,34 @@
/*-----------------------------------------*\
| RGBController_ASRockPolychromeSMBus.h |
| |
| Generic RGB Interface for OpenRGB |
| ASRock ASR LED and Polychrome RGB Driver |
| |
| Adam Honse (CalcProgrammer1) 12/15/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "ASRockPolychromeSMBusController.h"
class RGBController_Polychrome : public RGBController
{
public:
RGBController_Polychrome(PolychromeController* polychrome_ptr);
~RGBController_Polychrome();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
PolychromeController* polychrome;
};
/*-----------------------------------------*\
| RGBController_ASRockPolychromeSMBus.h |
| |
| Generic RGB Interface for OpenRGB |
| ASRock ASR LED and Polychrome RGB Driver |
| |
| Adam Honse (CalcProgrammer1) 12/15/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "ASRockPolychromeSMBusController.h"
class RGBController_Polychrome : public RGBController
{
public:
RGBController_Polychrome(PolychromeController* controller_ptr);
~RGBController_Polychrome();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
PolychromeController* controller;
};

View file

@ -13,15 +13,15 @@
#define ASROCK_USB_MAX_ZONES 8
#define ASROCK_ADDRESSABLE_MAX_LEDS 100
RGBController_PolychromeUSB::RGBController_PolychromeUSB(PolychromeUSBController* polychrome_ptr)
RGBController_PolychromeUSB::RGBController_PolychromeUSB(PolychromeUSBController* controller_ptr)
{
polychrome = polychrome_ptr;
controller = controller_ptr;
name = polychrome->GetDeviceName();
name = controller->GetDeviceName();
description = "ASRock Polychrome USB Device";
vendor = "ASRock";
type = DEVICE_TYPE_MOTHERBOARD;
location = polychrome->GetDeviceLocation();
location = controller->GetDeviceLocation();
mode Off;
Off.name = "Off";
@ -176,14 +176,14 @@ void RGBController_PolychromeUSB::SetupZones()
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(polychrome->GetChannelCount());
zones.resize(controller->GetChannelCount());
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
{
PolychromeDeviceInfo device_info = polychrome->GetPolychromeDevices()[channel_idx];
PolychromeDeviceInfo device_info = controller->GetPolychromeDevices()[channel_idx];
zones[channel_idx].type = ZONE_TYPE_LINEAR;
@ -226,7 +226,7 @@ void RGBController_PolychromeUSB::SetupZones()
{
unsigned char led = (unsigned char)leds[led_idx].value;
colors[led_idx] = polychrome->GetZoneConfig(led).color; // TODO Get addressable instead of zone idx
colors[led_idx] = controller->GetZoneConfig(led).color; // TODO Get addressable instead of zone idx
}
/*---------------------------------------------------------*\
@ -236,7 +236,7 @@ void RGBController_PolychromeUSB::SetupZones()
for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
{
PolychromeZoneInfo zoneinfo;
zoneinfo = polychrome->GetZoneConfig(channel_idx);
zoneinfo = controller->GetZoneConfig(channel_idx);
zones_info.push_back(zoneinfo);
}
@ -273,7 +273,7 @@ void RGBController_PolychromeUSB::DeviceUpdateLEDs()
set_mode = active_mode;
}
polychrome->WriteZone(zone_idx, set_mode, zones_info[zone_idx].speed, zones[zone_idx].colors[0], false);
controller->WriteZone(zone_idx, set_mode, zones_info[zone_idx].speed, zones[zone_idx].colors[0], false);
}
}
@ -286,7 +286,7 @@ void RGBController_PolychromeUSB::UpdateZoneLEDs(int zone)
set_mode = active_mode;
}
polychrome->WriteZone(zone, set_mode, zones_info[zone].speed, zones[zone].colors[0], false);
controller->WriteZone(zone, set_mode, zones_info[zone].speed, zones[zone].colors[0], false);
}
void RGBController_PolychromeUSB::UpdateSingleLED(int led)
@ -299,14 +299,14 @@ void RGBController_PolychromeUSB::UpdateSingleLED(int led)
set_mode = active_mode;
}
polychrome->WriteZone(channel, set_mode, zones_info[channel].speed, zones[channel].colors[0], false);
controller->WriteZone(channel, set_mode, zones_info[channel].speed, zones[channel].colors[0], false);
}
unsigned char RGBController_PolychromeUSB::GetDeviceMode(unsigned char zone)
{
int dev_mode;
dev_mode = polychrome->GetZoneConfig(zone).mode;
dev_mode = controller->GetZoneConfig(zone).mode;
active_mode = dev_mode;
return(active_mode);
@ -332,7 +332,7 @@ void RGBController_PolychromeUSB::DeviceUpdateMode()
set_mode = active_mode;
}
polychrome->WriteZone(zone_idx, set_mode, zones_info[zone_idx].speed, zones[zone_idx].colors[0], false);
controller->WriteZone(zone_idx, set_mode, zones_info[zone_idx].speed, zones[zone_idx].colors[0], false);
}
}
}

View file

@ -15,7 +15,7 @@
class RGBController_PolychromeUSB : public RGBController
{
public:
RGBController_PolychromeUSB(PolychromeUSBController* polychrome_ptr);
RGBController_PolychromeUSB(PolychromeUSBController* controller_ptr);
void SetupZones();
@ -30,7 +30,7 @@ public:
private:
bool initializedMode;
PolychromeUSBController* polychrome;
PolychromeUSBController* controller;
std::vector<PolychromeZoneInfo> zones_info;
unsigned char GetDeviceMode(unsigned char zone);

View file

@ -12,17 +12,17 @@
#include <thread>
#include <chrono>
RGBController_Alienware::RGBController_Alienware(AlienwareController* alienware_ptr)
RGBController_Alienware::RGBController_Alienware(AlienwareController* controller_ptr)
{
alienware = alienware_ptr;
controller = controller_ptr;
name = alienware->GetDeviceName();
name = controller->GetDeviceName();
vendor = "Alienware";
type = DEVICE_TYPE_KEYBOARD;
description = "Alienware USB Device";
location = alienware->GetDeviceLocation();
serial = alienware->GetSerialString();
version = alienware->GetFirmwareVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
version = controller->GetFirmwareVersion();
mode Color;
Color.name = "Static";
@ -56,7 +56,7 @@ RGBController_Alienware::RGBController_Alienware(AlienwareController* alienware_
Morph.value = ALIENWARE_MODE_MORPH;
Morph.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
Morph.color_mode = MODE_COLORS_MODE_SPECIFIC;
Morph.colors_min = 2 * alienware->GetZoneCount();
Morph.colors_min = 2 * controller->GetZoneCount();
Morph.colors_max = Morph.colors_min;
Morph.colors.resize(Morph.colors_max);
Morph.speed_min = ALIENWARE_TEMPO_MIN;
@ -110,7 +110,7 @@ RGBController_Alienware::RGBController_Alienware(AlienwareController* alienware_
SetupZones();
alienware->UpdateDim();
controller->UpdateDim();
}
void RGBController_Alienware::SetupZones()
@ -118,9 +118,9 @@ void RGBController_Alienware::SetupZones()
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
std::vector<const char*> zone_names = alienware->GetZoneNames();
std::vector<const char*> zone_names = controller->GetZoneNames();
for(unsigned int zone_idx = 0; zone_idx < alienware->GetZoneCount(); zone_idx++)
for(unsigned int zone_idx = 0; zone_idx < controller->GetZoneCount(); zone_idx++)
{
zone new_zone;
@ -217,43 +217,43 @@ void RGBController_Alienware::DeviceUpdateMode()
\*-------------------------------------------------*/
uint16_t period = 0x07d0;
alienware->SetMode(zone_idx, current_mode.value);
controller->SetMode(zone_idx, current_mode.value);
switch(current_mode_idx)
{
case ALIENWARE_MODE_COLOR:
alienware->SetPeriod(zone_idx, period);
alienware->SetColor( zone_idx, colors[current_zone.start_idx]);
alienware->SetTempo( zone_idx, ALIENWARE_TEMPO_MAX);
alienware->SetDim( zone_idx, modes[current_mode_idx].brightness);
controller->SetPeriod(zone_idx, period);
controller->SetColor( zone_idx, colors[current_zone.start_idx]);
controller->SetTempo( zone_idx, ALIENWARE_TEMPO_MAX);
controller->SetDim( zone_idx, modes[current_mode_idx].brightness);
break;
case ALIENWARE_MODE_PULSE:
alienware->SetPeriod(zone_idx, period);
alienware->SetColor( zone_idx, colors[current_zone.start_idx]);
alienware->SetTempo( zone_idx, current_mode.speed);
alienware->SetDim( zone_idx, modes[current_mode_idx].brightness);
controller->SetPeriod(zone_idx, period);
controller->SetColor( zone_idx, colors[current_zone.start_idx]);
controller->SetTempo( zone_idx, current_mode.speed);
controller->SetDim( zone_idx, modes[current_mode_idx].brightness);
break;
case ALIENWARE_MODE_MORPH:
alienware->SetPeriod(zone_idx, period);
alienware->SetColor( zone_idx, current_mode.colors[zone_idx * 2], current_mode.colors[(zone_idx * 2) + 1]);
alienware->SetTempo( zone_idx, current_mode.speed);
alienware->SetDim( zone_idx, modes[current_mode_idx].brightness);
controller->SetPeriod(zone_idx, period);
controller->SetColor( zone_idx, current_mode.colors[zone_idx * 2], current_mode.colors[(zone_idx * 2) + 1]);
controller->SetTempo( zone_idx, current_mode.speed);
controller->SetDim( zone_idx, modes[current_mode_idx].brightness);
break;
case ALIENWARE_MODE_SPECTRUM:
case ALIENWARE_MODE_RAINBOW:
alienware->SetPeriod(zone_idx, ALIENWARE_DURATION_SPECTRUM);
alienware->SetTempo( zone_idx, current_mode.speed);
alienware->SetDim( zone_idx, modes[current_mode_idx].brightness);
controller->SetPeriod(zone_idx, ALIENWARE_DURATION_SPECTRUM);
controller->SetTempo( zone_idx, current_mode.speed);
controller->SetDim( zone_idx, modes[current_mode_idx].brightness);
break;
case ALIENWARE_MODE_BREATHING:
alienware->SetPeriod(zone_idx, period);
alienware->SetColor( zone_idx, colors[current_zone.start_idx], 0x0);
alienware->SetTempo( zone_idx, current_mode.speed);
alienware->SetDim( zone_idx, modes[current_mode_idx].brightness);
controller->SetPeriod(zone_idx, period);
controller->SetColor( zone_idx, colors[current_zone.start_idx], 0x0);
controller->SetTempo( zone_idx, current_mode.speed);
controller->SetDim( zone_idx, modes[current_mode_idx].brightness);
break;
}
}
@ -262,7 +262,7 @@ void RGBController_Alienware::DeviceUpdateMode()
| Due to rate-limiting, this can take more than one |
| second to execute |
\*-----------------------------------------------------*/
alienware->UpdateController();
controller->UpdateController();
/*-----------------------------------------------------*\
| Re-run update if there's anything that's changed from |

View file

@ -17,7 +17,7 @@
class RGBController_Alienware : public RGBController
{
public:
RGBController_Alienware(AlienwareController* alienware_ptr);
RGBController_Alienware(AlienwareController* controller_ptr);
void SetupZones();
@ -32,6 +32,6 @@ public:
void SetCustomMode();
private:
AlienwareController* alienware;
AlienwareController* controller;
std::chrono::steady_clock::time_point last_packet_ts;
};

View file

@ -157,16 +157,16 @@ static const led_type led_names[] =
{ "Logo", ALIENWARE_AW510K_ZONE_DIRECT_LOGO, 0x07 }
};
RGBController_AlienwareAW510K::RGBController_AlienwareAW510K(AlienwareAW510KController* alienware_ptr)
RGBController_AlienwareAW510K::RGBController_AlienwareAW510K(AlienwareAW510KController* controller_ptr)
{
alienware = alienware_ptr;
controller = controller_ptr;
name = "Alienware AW510K Keyboard Device";
vendor = "Alienware";
type = DEVICE_TYPE_KEYBOARD;
description = "Alienware AW510K Keyboard Device";
location = alienware->GetDeviceLocation();
serial = alienware->GetSerialString();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct_Per_LED;
Direct_Per_LED.name = "Direct";
@ -274,7 +274,7 @@ RGBController_AlienwareAW510K::~RGBController_AlienwareAW510K()
}
}
delete alienware;
delete controller;
}
void RGBController_AlienwareAW510K::SetupZones()
@ -349,10 +349,10 @@ void RGBController_AlienwareAW510K::DeviceUpdateLEDs()
{
SelectedKeys key;
key.idx = (unsigned char)leds[led_idx].value;
key.red = RGBGetRValue(colors[led_idx]);
key.green = RGBGetGValue(colors[led_idx]);
key.blue = RGBGetBValue(colors[led_idx]);
key.idx = (unsigned char)leds[led_idx].value;
key.red = RGBGetRValue(colors[led_idx]);
key.green = RGBGetGValue(colors[led_idx]);
key.blue = RGBGetBValue(colors[led_idx]);
frame_buf_keys.push_back(key);
}
@ -360,22 +360,22 @@ void RGBController_AlienwareAW510K::DeviceUpdateLEDs()
{
SelectedKeys key;
key.idx = (unsigned char)leds[led_idx].value;
key.red = RGBGetRValue(colors[led_idx]);
key.green = RGBGetGValue(colors[led_idx]);
key.blue = RGBGetBValue(colors[led_idx]);
key.idx = (unsigned char)leds[led_idx].value;
key.red = RGBGetRValue(colors[led_idx]);
key.green = RGBGetGValue(colors[led_idx]);
key.blue = RGBGetBValue(colors[led_idx]);
frame_buf_keys.push_back(key);
}
}
alienware->SendInitialize();
alienware->SendfeatureReport(0x05, 0x01, 0x51, 0x00);
alienware->SendCommit();
controller->SendInitialize();
controller->SendfeatureReport(0x05, 0x01, 0x51, 0x00);
controller->SendCommit();
if(frame_buf_keys.size() > 0)
{
alienware->SendDirectOn(frame_buf_keys);
controller->SendDirectOn(frame_buf_keys);
}
std::copy(new_colors.begin(), new_colors.end(),current_colors.begin());
@ -383,12 +383,12 @@ void RGBController_AlienwareAW510K::DeviceUpdateLEDs()
void RGBController_AlienwareAW510K::UpdateZoneLEDs(int zone)
{
alienware->SetDirect((unsigned char) zone, RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
controller->SetDirect((unsigned char) zone, RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
}
void RGBController_AlienwareAW510K::UpdateSingleLED(int led)
{
alienware->UpdateSingleLED(leds[led].value, RGBGetRValue(colors[led]), RGBGetGValue(colors[led]), RGBGetBValue(colors[led]));
controller->UpdateSingleLED(leds[led].value, RGBGetRValue(colors[led]), RGBGetGValue(colors[led]), RGBGetBValue(colors[led]));
}
void RGBController_AlienwareAW510K::SetCustomMode()
@ -404,7 +404,7 @@ void RGBController_AlienwareAW510K::DeviceUpdateMode()
return;
}
alienware->SendfeatureReport(0x05, 0x01, 0x51, 0x00);
controller->SendfeatureReport(0x05, 0x01, 0x51, 0x00);
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
@ -427,7 +427,7 @@ void RGBController_AlienwareAW510K::DeviceUpdateMode()
unsigned char grn2 = RGBGetGValue(modes[active_mode].colors[1]);
unsigned char blu2 = RGBGetBValue(modes[active_mode].colors[1]);
alienware->SetMorphMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu, red2, grn2, blu2);
controller->SetMorphMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu, red2, grn2, blu2);
}
break;
@ -435,7 +435,7 @@ void RGBController_AlienwareAW510K::DeviceUpdateMode()
/*-------------------------------------------------------------*\
| Spectrum only set mode, speed and colorMode |
\*-------------------------------------------------------------*/
alienware->SetMode(modes[active_mode].value, modes[active_mode].speed, 0x00, ALIENWARE_AW510K_RANBOW_COLOR_MODE, 0x00, 0x00, 0x00);
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, 0x00, ALIENWARE_AW510K_RANBOW_COLOR_MODE, 0x00, 0x00, 0x00);
break;
case ALIENWARE_AW510K_MODE_SINGLE_WAVE:
@ -444,7 +444,7 @@ void RGBController_AlienwareAW510K::DeviceUpdateMode()
\*-------------------------------------------------------------*/
{
int waveDirection = GetAW520K_WaveDirection(modes[active_mode].direction);
alienware->SetMode(modes[active_mode].value, modes[active_mode].speed, waveDirection, ALIENWARE_AW510K_SINGLE_COLOR_MODE, red, grn, blu);
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, waveDirection, ALIENWARE_AW510K_SINGLE_COLOR_MODE, red, grn, blu);
}
break;
@ -454,13 +454,13 @@ void RGBController_AlienwareAW510K::DeviceUpdateMode()
\*-------------------------------------------------------------*/
{
int waveDirection = GetAW520K_WaveDirection(modes[active_mode].direction);
alienware->SetMode(modes[active_mode].value, modes[active_mode].speed, waveDirection, ALIENWARE_AW510K_RANBOW_COLOR_MODE, 0x00, 0x00, 0x00);
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, waveDirection, ALIENWARE_AW510K_RANBOW_COLOR_MODE, 0x00, 0x00, 0x00);
}
break;
default:
alienware->SetMode(modes[active_mode].value, modes[active_mode].speed, 0x00, ALIENWARE_AW510K_SINGLE_COLOR_MODE, red, grn, blu);
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, 0x00, ALIENWARE_AW510K_SINGLE_COLOR_MODE, red, grn, blu);
break;
}
}

View file

@ -15,7 +15,7 @@
class RGBController_AlienwareAW510K : public RGBController
{
public:
RGBController_AlienwareAW510K(AlienwareAW510KController* alienware_ptr);
RGBController_AlienwareAW510K(AlienwareAW510KController* controller_ptr);
~RGBController_AlienwareAW510K();
void SetupZones();
@ -30,6 +30,6 @@ public:
void DeviceUpdateMode();
private:
AlienwareAW510KController* alienware;
AlienwareAW510KController* controller;
std::vector<RGBColor> current_colors;
};

View file

@ -107,16 +107,16 @@ static const led_type led_names[] =
{ "Key: Right Control", 60 },
};
RGBController_AnnePro2::RGBController_AnnePro2(AnnePro2Controller* annepro2_ptr)
RGBController_AnnePro2::RGBController_AnnePro2(AnnePro2Controller* controller_ptr)
{
annepro2 = annepro2_ptr;
controller = controller_ptr;
name = "Anne Pro 2";
vendor = "Obinslab";
type = DEVICE_TYPE_KEYBOARD;
description = "Obinslab Anne Pro 2 Device";
location = annepro2->GetDeviceLocation();
serial = annepro2->GetSerialString();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
@ -130,7 +130,7 @@ RGBController_AnnePro2::RGBController_AnnePro2(AnnePro2Controller* annepro2_ptr)
RGBController_AnnePro2::~RGBController_AnnePro2()
{
delete annepro2;
delete controller;
}
void RGBController_AnnePro2::SetupZones()
@ -211,7 +211,7 @@ void RGBController_AnnePro2::DeviceUpdateLEDs()
led_real_idx++;
}
annepro2->SendDirect(frame_buf_length, frame_buf);
controller->SendDirect(frame_buf_length, frame_buf);
}
void RGBController_AnnePro2::UpdateZoneLEDs(int /*zone*/)

View file

@ -14,7 +14,7 @@
class RGBController_AnnePro2 : public RGBController
{
public:
RGBController_AnnePro2(AnnePro2Controller* annepro2_ptr);
RGBController_AnnePro2(AnnePro2Controller* controller_ptr);
~RGBController_AnnePro2();
void SetupZones();
@ -28,5 +28,5 @@ public:
void DeviceUpdateMode();
private:
AnnePro2Controller* annepro2;
AnnePro2Controller* controller;
};

View file

@ -1,34 +1,38 @@
#include "Detector.h"
#include "AsusAuraCoreController.h"
#include "RGBController.h"
#include "RGBController_AsusAuraCore.h"
#include <hidapi/hidapi.h>
#define AURA_CORE_VID 0x0B05
/******************************************************************************************\
* *
* DetectAuraCoreControllers *
* *
* Tests the USB address to see if an Asus ROG Aura Core controller exists there *
* *
\******************************************************************************************/
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);
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
// Constructor sets the name
if(rgb_controller->type != DEVICE_TYPE_UNKNOWN)
{
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1854);
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1866);
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1869);
#include "Detector.h"
#include "AsusAuraCoreController.h"
#include "RGBController.h"
#include "RGBController_AsusAuraCore.h"
#include <hidapi/hidapi.h>
#define AURA_CORE_VID 0x0B05
/******************************************************************************************\
* *
* DetectAuraCoreControllers *
* *
* Tests the USB address to see if an Asus ROG Aura Core controller exists there *
* *
\******************************************************************************************/
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);
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
// Constructor sets the name
if(rgb_controller->type != DEVICE_TYPE_UNKNOWN)
{
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
else
{
delete rgb_controller;
}
}
}
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1854);
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1866);
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1869);

View file

@ -1,319 +1,319 @@
/*-----------------------------------------*\
| RGBController_AsusAuraCore.cpp |
| |
| Generic RGB Interface for ROG Aura Core |
| |
| Adam Honse (CalcProgrammer1) 4/17/2020 |
\*-----------------------------------------*/
#include "RGBController_AsusAuraCore.h"
RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
{
aura = aura_ptr;
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";
mode Static;
Static.name = "Static";
Static.value = AURA_CORE_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_CORE_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.color_mode = MODE_COLORS_PER_LED;
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);
}
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()
{
delete aura;
}
void RGBController_AuraCore::SetupZones()
{
zone auraZone;
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 = auraZone.name + " ";
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*/)
{
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
{
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,
curr_mode.value,
speed,
dir,
red,
green,
blue
);
aura->SendSet();
aura->SendApply();
}
void RGBController_AuraCore::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraCore::DeviceUpdateMode()
{
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
{
aura->InitDirectMode();
}
else
{
DeviceUpdateLEDs();
}
}
/*-----------------------------------------*\
| RGBController_AsusAuraCore.cpp |
| |
| Generic RGB Interface for ROG Aura Core |
| |
| Adam Honse (CalcProgrammer1) 4/17/2020 |
\*-----------------------------------------*/
#include "RGBController_AsusAuraCore.h"
RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* controller_ptr)
{
controller = controller_ptr;
name = "ASUS Aura Core Device";
vendor = "ASUS";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
description = "ASUS Aura Core Device";
type = DEVICE_TYPE_UNKNOWN;
if(controller->aura_device.aura_type == AURA_CORE_DEVICE_KEYBOARD)
{
SetupKeyboard();
}
else if(controller->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";
mode Static;
Static.name = "Static";
Static.value = AURA_CORE_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_CORE_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.color_mode = MODE_COLORS_PER_LED;
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);
}
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()
{
delete controller;
}
void RGBController_AuraCore::SetupZones()
{
zone auraZone;
if(controller->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(controller->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 = auraZone.name + " ";
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*/)
{
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
{
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);
}
controller->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;
}
}
controller->SendUpdate
(
led,
curr_mode.value,
speed,
dir,
red,
green,
blue
);
controller->SendSet();
controller->SendApply();
}
void RGBController_AuraCore::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraCore::DeviceUpdateMode()
{
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
{
controller->InitDirectMode();
}
else
{
DeviceUpdateLEDs();
}
}

View file

@ -1,35 +1,35 @@
/*-----------------------------------------*\
| RGBController_AsusAuraCore.h |
| |
| Generic RGB Interface for ROG Aura Core |
| |
| Adam Honse (CalcProgrammer1) 4/17/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusAuraCoreController.h"
class RGBController_AuraCore : public RGBController
{
public:
RGBController_AuraCore(AuraCoreController* aura_ptr);
~RGBController_AuraCore();
void SetupKeyboard();
void SetupGA15DH();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AuraCoreController* aura;
};
/*-----------------------------------------*\
| RGBController_AsusAuraCore.h |
| |
| Generic RGB Interface for ROG Aura Core |
| |
| Adam Honse (CalcProgrammer1) 4/17/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusAuraCoreController.h"
class RGBController_AuraCore : public RGBController
{
public:
RGBController_AuraCore(AuraCoreController* controller_ptr);
~RGBController_AuraCore();
void SetupKeyboard();
void SetupGA15DH();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AuraCoreController* controller;
};

View file

@ -116,10 +116,7 @@ bool TestForAsusAuraGPUController(i2c_smbus_interface* bus, unsigned char addres
void DetectAsusAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses)
{
AuraGPUController* new_aura_gpu;
RGBController_AuraGPU* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
for(unsigned int bus = 0; bus < busses.size(); bus++)
{
for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++)
{
@ -129,12 +126,13 @@ void DetectAsusAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses)
busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device)
{
LOG_DEBUG(GPU_DETECT_MESSAGE, ASUSGPU_CONTROLLER_NAME, bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name );
if (TestForAsusAuraGPUController(busses[bus], device_list[dev_idx].controller_address))
if(TestForAsusAuraGPUController(busses[bus], device_list[dev_idx].controller_address))
{
new_aura_gpu = new AuraGPUController(busses[bus], device_list[dev_idx].controller_address);
new_controller = new RGBController_AuraGPU(new_aura_gpu);
new_controller->name = device_list[dev_idx].name;
ResourceManager::get()->RegisterRGBController(new_controller);
AuraGPUController* controller = new AuraGPUController(busses[bus], device_list[dev_idx].controller_address);
RGBController_AuraGPU* rgb_controller = new RGBController_AuraGPU(controller);
rgb_controller->name = device_list[dev_idx].name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -1,204 +1,201 @@
/*-----------------------------------------*\
| RGBController_AsusAuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "RGBController_AsusAuraGPU.h"
int RGBController_AuraGPU::GetDeviceMode()
{
int dev_mode = aura_gpu->AuraGPURegisterRead(AURA_GPU_REG_MODE);
int color_mode = MODE_COLORS_PER_LED;
if(dev_mode == AURA_GPU_MODE_STATIC)
{
if (aura_gpu->direct)
{
dev_mode = AURA_GPU_MODE_DIRECT;
}
}
switch(dev_mode)
{
case AURA_GPU_MODE_OFF:
case AURA_GPU_MODE_SPECTRUM_CYCLE:
color_mode = MODE_COLORS_NONE;
break;
}
for(std::size_t mode = 0; mode < modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
active_mode = mode;
modes[mode].color_mode = color_mode;
}
}
return(active_mode);
}
RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
{
aura_gpu = aura_gpu_ptr;
name = aura_gpu->GetDeviceName();
vendor = "ASUS";
type = DEVICE_TYPE_GPU;
description = "ASUS Aura GPU Device";
version = "0.00.1";
location = aura_gpu->GetDeviceLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = AURA_GPU_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_GPU_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Static;
Static.name = "Static";
Static.value = AURA_GPU_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AURA_GPU_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing);
mode Spectrum_Cycle;
Spectrum_Cycle.name = "Spectrum Cycle";
Spectrum_Cycle.value = AURA_GPU_MODE_SPECTRUM_CYCLE;
Spectrum_Cycle.flags = 0;
Spectrum_Cycle.color_mode = MODE_COLORS_NONE;
modes.push_back(Spectrum_Cycle);
SetupZones();
active_mode = GetDeviceMode();
}
RGBController_AuraGPU::~RGBController_AuraGPU()
{
delete aura_gpu;
}
void RGBController_AuraGPU::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zone aura_gpu_zone;
aura_gpu_zone.name = "GPU";
aura_gpu_zone.type = ZONE_TYPE_SINGLE;
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);
/*---------------------------------------------------------*\
| Set up LED |
\*---------------------------------------------------------*/
led aura_gpu_led;
aura_gpu_led.name = "GPU";
leds.push_back(aura_gpu_led);
SetupColors();
/*---------------------------------------------------------*\
| Initialize color |
\*---------------------------------------------------------*/
unsigned char red = aura_gpu->GetLEDRed();
unsigned char grn = aura_gpu->GetLEDGreen();
unsigned char blu = aura_gpu->GetLEDBlue();
colors[0] = ToRGBColor(red, grn, blu);
}
void RGBController_AuraGPU::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AuraGPU::DeviceUpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
aura_gpu->SetLEDColorsDirect(red, grn, blu);
}
else
{
aura_gpu->SetLEDColorsEffect(red, grn, blu);
}
}
}
void RGBController_AuraGPU::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AuraGPU::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AuraGPU::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraGPU::DeviceUpdateMode()
{
int new_mode = modes[active_mode].value;
aura_gpu->direct = false;
switch(new_mode)
{
// Set all LEDs to 0 and Mode to static as a workaround for the non existing Off Mode
case AURA_GPU_MODE_OFF:
aura_gpu->SetLEDColorsEffect(0, 0, 0);
new_mode = AURA_GPU_MODE_STATIC;
break;
// Direct mode is done by switching to Static and not applying color changes
case AURA_GPU_MODE_DIRECT:
aura_gpu->direct = true;
new_mode = AURA_GPU_MODE_STATIC;
break;
}
aura_gpu->SetMode(new_mode);
}
/*-----------------------------------------*\
| RGBController_AsusAuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "RGBController_AsusAuraGPU.h"
int RGBController_AuraGPU::GetDeviceMode()
{
int dev_mode = controller->AuraGPURegisterRead(AURA_GPU_REG_MODE);
int color_mode = MODE_COLORS_PER_LED;
if(dev_mode == AURA_GPU_MODE_STATIC)
{
if (controller->direct)
{
dev_mode = AURA_GPU_MODE_DIRECT;
}
}
switch(dev_mode)
{
case AURA_GPU_MODE_OFF:
case AURA_GPU_MODE_SPECTRUM_CYCLE:
color_mode = MODE_COLORS_NONE;
break;
}
for(std::size_t mode = 0; mode < modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
active_mode = mode;
modes[mode].color_mode = color_mode;
}
}
return(active_mode);
}
RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * controller_ptr)
{
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "ASUS";
type = DEVICE_TYPE_GPU;
description = "ASUS Aura GPU Device";
location = controller->GetDeviceLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = AURA_GPU_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_GPU_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Static;
Static.name = "Static";
Static.value = AURA_GPU_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AURA_GPU_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing);
mode Spectrum_Cycle;
Spectrum_Cycle.name = "Spectrum Cycle";
Spectrum_Cycle.value = AURA_GPU_MODE_SPECTRUM_CYCLE;
Spectrum_Cycle.flags = 0;
Spectrum_Cycle.color_mode = MODE_COLORS_NONE;
modes.push_back(Spectrum_Cycle);
SetupZones();
active_mode = GetDeviceMode();
}
RGBController_AuraGPU::~RGBController_AuraGPU()
{
delete controller;
}
void RGBController_AuraGPU::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zone aura_gpu_zone;
aura_gpu_zone.name = "GPU";
aura_gpu_zone.type = ZONE_TYPE_SINGLE;
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);
/*---------------------------------------------------------*\
| Set up LED |
\*---------------------------------------------------------*/
led aura_gpu_led;
aura_gpu_led.name = "GPU";
leds.push_back(aura_gpu_led);
SetupColors();
/*---------------------------------------------------------*\
| Initialize color |
\*---------------------------------------------------------*/
unsigned char red = controller->GetLEDRed();
unsigned char grn = controller->GetLEDGreen();
unsigned char blu = controller->GetLEDBlue();
colors[0] = ToRGBColor(red, grn, blu);
}
void RGBController_AuraGPU::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AuraGPU::DeviceUpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
controller->SetLEDColorsDirect(red, grn, blu);
}
else
{
controller->SetLEDColorsEffect(red, grn, blu);
}
}
}
void RGBController_AuraGPU::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AuraGPU::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AuraGPU::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraGPU::DeviceUpdateMode()
{
int new_mode = modes[active_mode].value;
controller->direct = false;
switch(new_mode)
{
// Set all LEDs to 0 and Mode to static as a workaround for the non existing Off Mode
case AURA_GPU_MODE_OFF:
controller->SetLEDColorsEffect(0, 0, 0);
new_mode = AURA_GPU_MODE_STATIC;
break;
// Direct mode is done by switching to Static and not applying color changes
case AURA_GPU_MODE_DIRECT:
controller->direct = true;
new_mode = AURA_GPU_MODE_STATIC;
break;
}
controller->SetMode(new_mode);
}

View file

@ -1,35 +1,35 @@
/*-----------------------------------------*\
| RGBController_AsusAuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusAuraGPUController.h"
class RGBController_AuraGPU : public RGBController
{
public:
RGBController_AuraGPU(AuraGPUController* aura_gpu_ptr);
~RGBController_AuraGPU();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AuraGPUController* aura_gpu;
int GetDeviceMode();
};
/*-----------------------------------------*\
| RGBController_AsusAuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusAuraGPUController.h"
class RGBController_AuraGPU : public RGBController
{
public:
RGBController_AuraGPU(AuraGPUController* controller_ptr);
~RGBController_AuraGPU();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AuraGPUController* controller;
int GetDeviceMode();
};