Changed Gigabyte Fusion 2 controller

* Removed warnings
* Refactored RGBFusion2USBController::SetLEDEffect() to improve readability
* Tidied up Mode declarations
* Other changes for style and formatting
This commit is contained in:
Chris 2025-08-20 22:33:28 +10:00 committed by Adam Honse
parent ca84bad1fc
commit fbb7d16039
8 changed files with 257 additions and 337 deletions

View file

@ -11,8 +11,6 @@
\*---------------------------------------------------------*/
#include "GigabyteRGBFusion2USBController.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
/*-------------------------------------------------------------------------*\
| Low level RGB value conversion table |
@ -85,7 +83,7 @@ RGBFusion2USBController::~RGBFusion2USBController()
\*---------------------------------------------------------*/
bool RGBFusion2USBController::RefreshHardwareInfo()
{
unsigned char buffer[64] = {0};
unsigned char buffer[FUSION2_USB_BUFFER_SIZE] = {0};
SendPacket(0x60, 0x00);
buffer[0] = report_id;
@ -140,7 +138,7 @@ bool RGBFusion2USBController::RefreshHardwareInfo()
cali_loaded = false;
if(product_id == 0x5711)
{
unsigned char buffer2[64] = {0};
unsigned char buffer2[FUSION2_USB_BUFFER_SIZE] = {0};
SendPacket(0x61, 0x00);
buffer2[0] = report_id;
int res2 = hid_get_feature_report(dev, buffer2, sizeof(buffer2));
@ -364,7 +362,7 @@ void RGBFusion2USBController::SetLedCount(unsigned int c0, unsigned int c1, unsi
D_LED3_count = new_d3;
D_LED4_count = new_d4;
unsigned char buffer[64] = { 0 };
unsigned char buffer[FUSION2_USB_BUFFER_SIZE] = { 0 };
buffer[0] = report_id;
buffer[1] = 0x34;
buffer[2] = (new_d2 << 4) | new_d1;
@ -551,13 +549,11 @@ void RGBFusion2USBController::SetStripColors(unsigned int hdr, RGBColor* colors,
for(int i = 0; i < leds_in_pkt; i++)
{
RGBColor color = colors[k];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
uint8_t offset = (i * 3) + 5;
pkt.buffer[5 + i * 3 + bo_r] = red;
pkt.buffer[5 + i * 3 + bo_g] = grn;
pkt.buffer[5 + i * 3 + bo_b] = blu;
pkt.buffer[offset + bo_r] = RGBGetRValue(color);
pkt.buffer[offset + bo_g] = RGBGetGValue(color);
pkt.buffer[offset + bo_b] = RGBGetBValue(color);
k++;
}
@ -585,7 +581,7 @@ void RGBFusion2USBController::SetStripColors(unsigned int hdr, RGBColor* colors,
| -(15)Gigabyte dflash ranges are 800-2600ms in 200ms steps |
| -(3)(15)flash and dflash parameters were combined. |
\*---------------------------------------------------------*/
void RGBFusion2USBController::SetLEDEffect(int led, int mode, unsigned int speed, unsigned char brightness, bool random, unsigned char r, unsigned char g, unsigned char b)
void RGBFusion2USBController::SetLEDEffect(int led, int mode, unsigned int speed, unsigned char brightness, bool random, uint32_t* color)
{
PktEffect pkt;
pkt.Init(led, report_id, product_id);
@ -599,66 +595,57 @@ void RGBFusion2USBController::SetLEDEffect(int led, int mode, unsigned int speed
}
pkt.e.max_brightness = brightness;
pkt.e.effect_type = mode;
pkt.e.color0 = r << 16 | g << 8 | b;
pkt.e.effect_param0 = random ? 7 : 0;
pkt.e.color0 = RGBToBGRColor(*color);
switch(mode)
{
case 2:
pkt.e.period0 = pkt.e.period1 = (speed <= 6) ? (400 + speed * 100) : (1000 + (speed - 6) * 200);
case EFFECT_PULSE:
pkt.e.period0 = (speed <= 6) ? (400 + speed * 100) : (1000 + (speed - 6) * 200);
pkt.e.period1 = pkt.e.period0;
pkt.e.period2 = 200;
if(random)
{
pkt.e.effect_param0 = 7;
}
break;
case 15:
case EFFECT_DFLASH:
pkt.e.effect_type = 3;
pkt.e.effect_param1 = 1;
pkt.e.effect_param2 = 2;
case 3:
case EFFECT_BLINKING:
pkt.e.period0 = 100;
pkt.e.period1 = 100;
pkt.e.period2 = (speed * 200) + 700;
if(random)
{
pkt.e.effect_param0 = 7;
}
break;
case 4:
case EFFECT_COLORCYCLE:
pkt.e.period0 = (speed * 100 + 300) + (speed > 8 ? 1300 * (speed - 8) : 0);
pkt.e.period1 = pkt.e.period0 -200;
pkt.e.effect_param0 = 7;
break;
case 6:
pkt.e.period0 = ((speed + 1)^2 + (speed + 1) + 10) * 5 / 2;
case EFFECT_WAVE:
pkt.e.period0 = (((speed + 1)^2) + (speed + 1) + 10) * 5 / 2;
pkt.e.effect_param0 = 7;
pkt.e.effect_param1 = 1;
break;
case 8:
case EFFECT_RANDOM:
pkt.e.period0 = 100;
pkt.e.effect_param0 = 1;
pkt.e.effect_param1 = 5;
break;
case 9:
case EFFECT_WAVE1:
pkt.e.period0 = 1200;
pkt.e.period1 = 100;
pkt.e.period2 = 360;
pkt.e.period3 = 1200;
break;
case 10:
case EFFECT_WAVE2:
case EFFECT_WAVE4:
pkt.e.period0 = 200;
pkt.e.effect_param0 = 7;
break;
case 11:
case EFFECT_WAVE3:
pkt.e.period0 = 840;
pkt.e.period1 = 20;
pkt.e.period2 = 200;
pkt.e.period3 = 840;
break;
case 12:
pkt.e.period0 = 200;
pkt.e.effect_param0 = 7;
break;
}
SendPacket(pkt.buffer);
}
@ -684,24 +671,24 @@ bool RGBFusion2USBController::ApplyEffect(bool fast_apply)
pkt.a.zone_sel0 = effect_zone_mask;
effect_zone_mask = 0;
return SendPacket(pkt.buffer());
return SendPacket(pkt.buffer);
}
bool RGBFusion2USBController::SendPacket(uint8_t a, uint8_t b, uint8_t c)
{
unsigned char buffer[64] {};
unsigned char buffer[FUSION2_USB_BUFFER_SIZE] {};
buffer[0] = report_id;
buffer[1] = a;
buffer[2] = b;
buffer[3] = c;
return(SendPacket(buffer) == 64);
return(SendPacket(buffer) == FUSION2_USB_BUFFER_SIZE);
}
int RGBFusion2USBController::SendPacket(unsigned char* packet)
{
return hid_send_feature_report(dev, packet, 64);
return hid_send_feature_report(dev, packet, FUSION2_USB_BUFFER_SIZE);
}
/*---------------------------------------------------------*\

View file

@ -13,14 +13,13 @@
#pragma once
#include <algorithm>
#include <array>
#include <chrono>
#include <cstring>
#include <map>
#include <thread>
#include <hidapi.h>
#include <map>
#include "RGBController.h"
#define FUSION2_USB_BUFFER_SIZE 64
/*--------------------------------------------------------*\
| Base LED mappings found on all controllers. |
\*--------------------------------------------------------*/
@ -123,31 +122,21 @@ struct EncodedCalibration
/*---------------------------------------------------------*\
| Packet structure for applying effects |
\*---------------------------------------------------------*/
struct ApplyEffects
union PktEffectApply
{
uint8_t report_id;
uint8_t command_id;
uint32_t zone_sel0;
uint32_t zone_sel1;
unsigned char buffer[FUSION2_USB_BUFFER_SIZE];
struct apply_data
{
uint8_t report_id = 0xCC;
uint8_t command_id = 0x28;
uint32_t zone_sel0 = 0;
uint32_t zone_sel1 = 0;
uint8_t padding[54];
} a;
ApplyEffects()
PktEffectApply() : a {}
{
report_id = 0xCC;
command_id = 0x28;
zone_sel0 = 0;
zone_sel1 = 0;
std::memset(padding, 0, sizeof(padding));
}
};
struct PktEffectApply
{
ApplyEffects a;
uint8_t* buffer()
{
return reinterpret_cast<uint8_t*>(&a);
std::memset(a.padding, 0, sizeof(a.padding));
}
};
@ -177,7 +166,7 @@ typedef std::map< std::string, std::string> calibration;
\*---------------------------------------------------------*/
union PktRGB
{
unsigned char buffer[64];
unsigned char buffer[FUSION2_USB_BUFFER_SIZE];
struct RGBData
{
uint8_t report_id;
@ -231,27 +220,27 @@ union PktRGB
\*---------------------------------------------------------*/
union PktEffect
{
unsigned char buffer[64];
unsigned char buffer[FUSION2_USB_BUFFER_SIZE];
struct Effect
{
uint8_t report_id;
uint8_t header;
uint32_t zone0; // RGB Fusion sets it to pow(2, led)
uint32_t zone1;
uint8_t reserved0;
uint8_t effect_type;
uint8_t max_brightness;
uint8_t min_brightness;
uint32_t color0;
uint32_t color1;
uint16_t period0; // Fade in
uint16_t period1; // Fade out
uint16_t period2; // Hold
uint16_t period3;
uint8_t effect_param0;
uint8_t effect_param1;
uint8_t effect_param2;
uint8_t effect_param3;
uint8_t report_id = 0;
uint8_t header = 0;
uint32_t zone0 = 0; // RGB Fusion sets it to pow(2, led)
uint32_t zone1 = 0;
uint8_t reserved0 = 0;
uint8_t effect_type = EFFECT_STATIC;
uint8_t max_brightness = 255;
uint8_t min_brightness = 0;
uint32_t color0 = 0;
uint32_t color1 = 0;
uint16_t period0 = 0; // Fade in - Rising Timer - Needs to be 0 for "Direct"
uint16_t period1 = 0; // Fade out
uint16_t period2 = 0; // Hold
uint16_t period3 = 0;
uint8_t effect_param0 = 0; // ex color count to cycle through (max seems to be 7)
uint8_t effect_param1 = 0;
uint8_t effect_param2 = 0; // ex flash repeat count
uint8_t effect_param3 = 0;
uint8_t padding0[30];
} e;
@ -261,7 +250,7 @@ union PktEffect
void Init(int led, uint8_t report_id, uint16_t pid)
{
memset(buffer, 0, sizeof(buffer));
memset(e.padding0, 0, sizeof(e.padding0));
e.report_id = report_id;
if(led == -1)
@ -284,18 +273,6 @@ union PktEffect
e.zone0 = 0;
e.header = 0;
}
e.effect_type = EFFECT_STATIC;
e.max_brightness = 255;
e.min_brightness = 0;
e.color0 = 0;
e.period0 = 0; //Rising Timer - Needs to be 0 for "Direct"
e.period1 = 0;
e.period2 = 0;
e.period3 = 0;
e.effect_param0 = 0; // ex color count to cycle through (max seems to be 7)
e.effect_param1 = 0;
e.effect_param2 = 0; // ex flash repeat count
e.effect_param3 = 0;
}
};
@ -368,7 +345,7 @@ public:
uint16_t GetProductID();
uint8_t GetDeviceNum();
void SetStripColors(unsigned int hdr, RGBColor * colors, unsigned int num_colors, int single_led = -1);
void SetLEDEffect(int led, int mode, unsigned int speed, unsigned char brightness, bool random, unsigned char red, unsigned char green, unsigned char blue);
void SetLEDEffect(int led, int mode, unsigned int speed, unsigned char brightness, bool random, uint32_t* color);
void SetLedCount(unsigned int c0, unsigned int c1, unsigned int c2, unsigned int c3);
void SetMode(int mode);
bool ApplyEffect(bool batch_commit = false);

View file

@ -11,8 +11,6 @@
| SPDX-License-Identifier: GPL-2.0-only |
\*---------------------------------------------------------*/
#include <array>
#include <sstream>
#include "RGBController_GigabyteRGBFusion2USB.h"
#include "RGBController_GigabyteRGBFusion2USBBoards.h"
#include "RGBController_GigabyteRGBFusion2USBLayouts.h"
@ -206,15 +204,14 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
Breathing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.brightness_min = RGBFUSION2_BRIGHTNESS_MIN;
Breathing.brightness_max = 100; // Set 100 max due to controller quirks
Breathing.brightness = 100; // Match default to above
Breathing.speed_min = 9;
Breathing.speed_max = 0;
Breathing.speed = 4;
Breathing.brightness = Breathing.brightness_max;
Breathing.speed_min = RGBFUSION2_SPEED_MIN;
Breathing.speed_max = RGBFUSION2_SPEED_MAX;
Breathing.speed = RGBFUSION2_SPEED_MID;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors.resize(1);
Breathing.speed = 2;
modes.push_back(Breathing);
mode Blinking;
@ -224,14 +221,13 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
Blinking.brightness_min = RGBFUSION2_BRIGHTNESS_MIN;
Blinking.brightness_max = RGBFUSION2_BRIGHTNESS_MAX;
Blinking.brightness = RGBFUSION2_BRIGHTNESS_MAX;
Blinking.speed_min = 9;
Blinking.speed_max = 0;
Blinking.speed = 4;
Blinking.speed_min = RGBFUSION2_SPEED_MIN;
Blinking.speed_max = RGBFUSION2_SPEED_MAX;
Blinking.speed = RGBFUSION2_SPEED_MID;
Blinking.colors_min = 1;
Blinking.colors_max = 1;
Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC;
Blinking.colors.resize(1);
Blinking.speed = 2;
modes.push_back(Blinking);
mode ColorCycle;
@ -241,11 +237,10 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
ColorCycle.brightness_min = RGBFUSION2_BRIGHTNESS_MIN;
ColorCycle.brightness_max = RGBFUSION2_BRIGHTNESS_MAX;
ColorCycle.brightness = RGBFUSION2_BRIGHTNESS_MAX;
ColorCycle.speed_min = 9;
ColorCycle.speed_max = 0;
ColorCycle.speed = 4;
ColorCycle.speed_min = RGBFUSION2_SPEED_MIN;
ColorCycle.speed_max = RGBFUSION2_SPEED_MAX;
ColorCycle.speed = RGBFUSION2_SPEED_MID;
ColorCycle.color_mode = MODE_COLORS_NONE;
ColorCycle.speed = 2;
modes.push_back(ColorCycle);
mode Flashing;
@ -255,17 +250,15 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
Flashing.brightness_min = RGBFUSION2_BRIGHTNESS_MIN;
Flashing.brightness_max = RGBFUSION2_BRIGHTNESS_MAX;
Flashing.brightness = RGBFUSION2_BRIGHTNESS_MAX;
Flashing.speed_min = 9;
Flashing.speed_max = 0;
Flashing.speed = 4;
Flashing.speed_min = RGBFUSION2_SPEED_MIN;
Flashing.speed_max = RGBFUSION2_SPEED_MAX;
Flashing.speed = RGBFUSION2_SPEED_MID;
Flashing.colors_min = 1;
Flashing.colors_max = 1;
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flashing.colors.resize(1);
Flashing.speed = 2;
modes.push_back(Flashing);
mode Wave;
Wave.name = "Wave";
Wave.value = EFFECT_WAVE;
@ -273,9 +266,9 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
Wave.brightness_min = RGBFUSION2_BRIGHTNESS_MIN;
Wave.brightness_max = RGBFUSION2_BRIGHTNESS_MAX;
Wave.brightness = RGBFUSION2_BRIGHTNESS_MAX;
Wave.speed_min = 9;
Wave.speed_max = 0;
Wave.speed = 4;
Wave.speed_min = RGBFUSION2_SPEED_MIN;
Wave.speed_max = RGBFUSION2_SPEED_MAX;
Wave.speed = RGBFUSION2_SPEED_MID;
Wave.colors_min = 0;
Wave.colors_max = 0;
Wave.color_mode = MODE_COLORS_NONE;
@ -293,7 +286,6 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
Random.color_mode = MODE_COLORS_NONE;
modes.push_back(Random);
mode Wave1;
Wave1.name = "Wave 1";
Wave1.value = EFFECT_WAVE1;
@ -558,8 +550,8 @@ void RGBController_RGBFusion2USB::Init_Controller()
}
zones[zone_idx].name = zl->first;
zones[zone_idx].leds_min = (single_zone) ? LED_count : RGBFusion2_Digital_LEDS_Min;
zones[zone_idx].leds_max = (single_zone) ? LED_count : RGBFusion2_Digital_LEDS_Max;
zones[zone_idx].leds_min = (single_zone) ? LED_count : RGBFUSION2_DIGITAL_LEDS_MIN;
zones[zone_idx].leds_max = (single_zone) ? LED_count : RGBFUSION2_DIGITAL_LEDS_MAX;
zones[zone_idx].leds_count = (single_zone) ? LED_count : 0;
zones[zone_idx].type = (single_zone) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
zones[zone_idx].matrix_map = NULL;
@ -653,6 +645,7 @@ void RGBController_RGBFusion2USB::DeviceUpdateLEDs()
{
int mode_value = (modes[active_mode].value);
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
uint32_t* color = &null_color;
/*---------------------------------------------------------*\
| If Wave 1-4 then use special sequence. |
@ -660,36 +653,26 @@ void RGBController_RGBFusion2USB::DeviceUpdateLEDs()
if(mode_value == 6 || (mode_value >= 9 && mode_value <= 12))
{
controller->SetStripBuiltinEffectState(-1, true);
controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, 0, 0, 0);
controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, color);
controller->ApplyEffect();
controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, 0, 0, 0);
controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
controller->ApplyEffect();
return;
}
for(int zone_idx = 0; zone_idx < (int)zones.size(); zone_idx++)
{
mode_value = modes[active_mode].value;
if(zones[zone_idx].type == ZONE_TYPE_SINGLE)
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
mode_value = modes[active_mode].value;
/*---------------------------------------------------------*\
| Motherboard LEDs always use effect mode, so use static for|
| direct mode but get colors from zone |
\*---------------------------------------------------------*/
if(mode_value == 0xFFFF)
{
red = RGBGetRValue(zones[zone_idx].colors[led_idx]);
grn = RGBGetGValue(zones[zone_idx].colors[led_idx]);
blu = RGBGetBValue(zones[zone_idx].colors[led_idx]);
color = &zones[zone_idx].colors[led_idx];
mode_value = EFFECT_STATIC;
}
/*---------------------------------------------------------*\
@ -697,15 +680,13 @@ void RGBController_RGBFusion2USB::DeviceUpdateLEDs()
\*---------------------------------------------------------*/
else 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]);
color = &modes[active_mode].colors[0];
}
/*---------------------------------------------------------*\
| Apply the mode and color to the zone |
\*---------------------------------------------------------*/
controller->SetLEDEffect(zones[zone_idx].leds[led_idx].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu);
controller->SetLEDEffect(zones[zone_idx].leds[led_idx].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
}
}
/*---------------------------------------------------------*\
@ -731,25 +712,19 @@ void RGBController_RGBFusion2USB::DeviceUpdateLEDs()
\*---------------------------------------------------------*/
else
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
/*---------------------------------------------------------*\
| If mode has mode specific color, load color from mode |
\*---------------------------------------------------------*/
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]);
color = &modes[active_mode].colors[0];
}
/*---------------------------------------------------------*\
| Apply hardware effects to LED strips |
\*---------------------------------------------------------*/
controller->SetStripBuiltinEffectState(hdr, true);
controller->SetLEDEffect(hdr, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu);
controller->SetLEDEffect(hdr, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
}
}
}
@ -764,6 +739,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
\*---------------------------------------------------------*/
int mode_value = (modes[active_mode].value);
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
uint32_t* color = &null_color;
/*---------------------------------------------------------*\
| If Wave 1-4 then use special sequence. |
@ -771,9 +747,9 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
if(mode_value == 6 || (mode_value >= 9 && mode_value <= 12))
{
controller->SetStripBuiltinEffectState(-1, true);
controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, 0, 0, 0);
controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, color);
controller->ApplyEffect();
controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, 0, 0, 0);
controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
controller->ApplyEffect();
return;
}
@ -783,23 +759,15 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
\*---------------------------------------------------------*/
if(zones[zone].type == ZONE_TYPE_SINGLE)
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
for(std::size_t led_idx = 0; led_idx < zones[zone].leds_count; led_idx++)
{
/*------------------------------------------------------------*\
| Motherboard LEDs always use effect mode, so use static for |
| direct mode but get colors from zone |
\*------------------------------------------------------------*/
if(mode_value == 0xFFFF)
{
red = RGBGetRValue(zones[zone].colors[led_idx]);
grn = RGBGetGValue(zones[zone].colors[led_idx]);
blu = RGBGetBValue(zones[zone].colors[led_idx]);
color = &zones[zone].colors[led_idx];
mode_value = EFFECT_STATIC;
}
@ -808,15 +776,13 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
\*---------------------------------------------------------*/
else 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]);
color = &modes[active_mode].colors[0];
}
/*---------------------------------------------------------*\
| Apply the mode and color to the zone |
\*---------------------------------------------------------*/
controller->SetLEDEffect(zones[zone].leds[led_idx].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu);
controller->SetLEDEffect(zones[zone].leds[led_idx].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
controller->ApplyEffect();
}
}
@ -844,25 +810,19 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
\*---------------------------------------------------------*/
else
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
/*---------------------------------------------------------*\
| If mode has mode specific color, load color from mode |
\*---------------------------------------------------------*/
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]);
color = &modes[active_mode].colors[0];
}
/*---------------------------------------------------------*\
| Apply built-in effects to LED strips |
\*---------------------------------------------------------*/
controller->SetStripBuiltinEffectState(hdr, true);
controller->SetLEDEffect(hdr, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu);
controller->SetLEDEffect(hdr, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
controller->ApplyEffect();
}
}
@ -874,8 +834,9 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led)
/*---------------------------------------------------------*\
| Get mode parameters |
\*---------------------------------------------------------*/
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
int mode_value = (modes[active_mode].value);
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
uint32_t* color = &null_color;
/*---------------------------------------------------------*\
| If Wave 1-4 then use special sequence. |
@ -883,9 +844,9 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led)
if(mode_value == 6 || (mode_value >= 9 && mode_value <= 12))
{
controller->SetStripBuiltinEffectState(-1, true);
controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, 0, 0, 0);
controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, color);
controller->ApplyEffect();
controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, 0, 0, 0);
controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
controller->ApplyEffect();
return;
}
@ -896,20 +857,13 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led)
\*---------------------------------------------------------*/
if(zones[zone_idx].type == ZONE_TYPE_SINGLE)
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
/*---------------------------------------------------------*\
| Motherboard LEDs always use effect mode, so use static for|
| direct mode but get colors from zone |
\*---------------------------------------------------------*/
if(mode_value == 0xFFFF)
{
red = RGBGetRValue(colors[led]);
grn = RGBGetGValue(colors[led]);
blu = RGBGetBValue(colors[led]);
color = &colors[led];
mode_value = EFFECT_STATIC;
}
@ -918,12 +872,10 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led)
\*---------------------------------------------------------*/
else 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]);
color = &modes[active_mode].colors[0];
}
controller->SetLEDEffect(leds[led].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu);
controller->SetLEDEffect(leds[led].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, color);
controller->ApplyEffect();
}

View file

@ -14,16 +14,18 @@
#pragma once
#include <map>
#include <vector>
#include "RGBController.h"
#include "GigabyteRGBFusion2USBController.h"
#include "RGBController_GigabyteRGBFusion2USBBoards.h"
#include "RGBController_GigabyteRGBFusion2USBLayouts.h"
#define RGBFusion2_Digital_LEDS_Min 0;
#define RGBFusion2_Digital_LEDS_Max 1024;
#define RGBFUSION2_BRIGHTNESS_MIN 0;
#define RGBFUSION2_BRIGHTNESS_MAX 255;
#define RGBFUSION2_DIGITAL_LEDS_MIN 0
#define RGBFUSION2_DIGITAL_LEDS_MAX 1024
#define RGBFUSION2_BRIGHTNESS_MIN 0
#define RGBFUSION2_BRIGHTNESS_MAX 255
#define RGBFUSION2_SPEED_MIN 9
#define RGBFUSION2_SPEED_MID 4
#define RGBFUSION2_SPEED_MAX 0
template<typename K, typename V>
static std::map<V, K> reverse_map(const std::map<K, V>& map)
@ -60,9 +62,11 @@ private:
std::string detector_name;
RGBFusion2USBController* controller;
ZoneLeds layout;
uint16_t pid;
int device_num;
ZoneLeds layout;
RGBColor null_color = 0;
uint16_t pid;
void Load_Device_Config();
void Init_Controller();
int GetLED_Zone(int led_idx);

View file

@ -12,7 +12,6 @@
\*---------------------------------------------------------*/
#include "RGBController_GigabyteRGBFusion2USBBoards.h"
#include "GigabyteRGBFusion2USBController.h"
/*---------------------------------------------------------*\
| This is a list of known layouts listed by controller |

View file

@ -14,7 +14,6 @@
#include <map>
#include <string>
#include <vector>
using MBName = std::map<std::string, std::string>;

View file

@ -30,6 +30,8 @@ typedef unsigned int RGBColor;
#define ToRGBColor(r, g, b) ((RGBColor)((b << 16) | (g << 8) | (r)))
#define RGBToBGRColor(rgb) ((rgb & 0xFF) << 16 | (rgb & 0xFF00) | (rgb & 0xFF0000) >> 16)
/*------------------------------------------------------------------*\
| Mode Flags |
\*------------------------------------------------------------------*/