Refactored Gigabyte Fusion2USB controller

* Refactored RGBController_GigabyteRGBFusion2USBBoards &
RGBController_GigabyteRGBFusion2USBLayouts into single
GigabyteFusion2USB_Devices to align with structure of
RazerDevices and CorsairV2Devices.
* Replaced definition for `gb_fusion2_layout`
* Adjusted code paths to suit new variable structures
* Removed redundant files
This commit is contained in:
Chris M
2025-08-23 22:19:12 +10:00
committed by Adam Honse
parent 7886dc4c14
commit c1d67aa740
10 changed files with 4337 additions and 2809 deletions

View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/*---------------------------------------------------------*\
| Gigabyte_Fusion2_USB_Devices.h |
| |
| Gigabyte Fusion 2 USB Device layouts and |
| and mapping to the device IDs stored on chip |
| |
| megadjc 31 Jul 2025 |
| chrism 29 Aug 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*---------------------------------------------------------*/
#pragma once
#include <map>
#include "RGBController.h"
#define GB_FUSION2_ZONES_MAX 8
/*--------------------------------------------------------*\
| Base LED mappings found on all controllers. |
\*--------------------------------------------------------*/
enum GB_FUSION2_LED_IDX
{
LED1 = 0,
LED2 = 1,
LED3 = 2,
LED4 = 3,
LED5 = 4,
LED6 = 5,
LED7 = 6,
LED8 = 7,
/*--------------------------------------------------------*\
| IT8297/IT5701/IT5702 ARGB Headers |
\*--------------------------------------------------------*/
HDR_D_LED1 = 5,
HDR_D_LED2 = 6,
HDR_D_LED1_ARGB = 0x58,
HDR_D_LED2_ARGB = 0x59,
/*--------------------------------------------------------*\
| Additional LED mappings found on IT5711 controllers. |
\*--------------------------------------------------------*/
LED9 = 8,
LED10 = 9,
LED11 = 10,
/*--------------------------------------------------------*\
| IT5711 additional ARGB Headers. |
\*--------------------------------------------------------*/
HDR_D_LED3 = 7,
HDR_D_LED4 = 8,
HDR_D_LED3_ARGB = 0x62,
HDR_D_LED4_ARGB = 0x63,
};
/*-------------------------------------------------*\
| LED mapping |
\*-------------------------------------------------*/
using FwdLedHeaders = std::map<std::string, GB_FUSION2_LED_IDX>;
using RvrseLedHeaders = std::map<GB_FUSION2_LED_IDX, std::string>;
const FwdLedHeaders LedLookup =
{
{"LED1", LED1 },
{"LED2", LED2 },
{"LED3", LED3 },
{"LED4", LED4 },
{"LED5", LED5 },
{"LED6", LED6 },
{"LED7", LED7 },
{"LED8", LED8 },
{"LED9", LED9 },
{"LED10", LED10 },
{"LED11", LED11 },
{"HDR_D_LED1", HDR_D_LED1 },
{"HDR_D_LED2", HDR_D_LED2 },
{"HDR_D_LED3", HDR_D_LED3 },
{"HDR_D_LED4", HDR_D_LED4 },
/*-------------------------------------------------*\
| The DLED ARGB index is not required for parsing |
\*-------------------------------------------------*/
/*-------------------------------------------------*\
{"HDR_D_LED1_RGB", HDR_D_LED1_ARGB },
{"HDR_D_LED2_RGB", HDR_D_LED2_ARGB },
{"HDR_D_LED3_RGB", HDR_D_LED3_ARGB },
{"HDR_D_LED4_RGB", HDR_D_LED4_ARGB },
\*-------------------------------------------------*/
};
typedef struct
{
GB_FUSION2_LED_IDX idx = LED1;
uint16_t leds_min = 0;
uint16_t leds_max = 0;
std::string name;
} gb_fusion2_zone;
typedef const gb_fusion2_zone* gb_fusion2_layout[GB_FUSION2_ZONES_MAX];
typedef struct
{
gb_fusion2_layout* zones;
uint32_t layout_id;
uint8_t device_num;
std::string name;
} gb_fusion2_device;
/*---------------------------------------------------------------------*\
| These constant values are defined in GigabyteFusion2USB_Devices.cpp |
\*---------------------------------------------------------------------*/
extern const unsigned int GB_FUSION2_DEVICE_COUNT;
extern const gb_fusion2_device** gb_fusion2_device_list;

View File

@@ -57,9 +57,9 @@ static LEDCount LedCountToEnum(unsigned int c)
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char* path, std::string mb_name, uint16_t pid): dev(handle), product_id(pid)
{
name = mb_name;
location = path;
name = mb_name;
location = path;
if(!RefreshHardwareInfo())
{
return;
@@ -85,7 +85,7 @@ bool RGBFusion2USBController::RefreshHardwareInfo()
{
unsigned char buffer[FUSION2_USB_BUFFER_SIZE] = {0};
SendPacket(0x60, 0x00);
SendCCReport(0x60, 0x00);
buffer[0] = report_id;
int res = hid_get_feature_report(dev, buffer, sizeof(buffer));
@@ -95,6 +95,7 @@ bool RGBFusion2USBController::RefreshHardwareInfo()
return false;
}
IT8297Report report;
std::memcpy(&report, buffer, sizeof(IT8297Report));
report_loaded = true;
@@ -106,19 +107,17 @@ bool RGBFusion2USBController::RefreshHardwareInfo()
}
{
char text[32]{};
char text[16]{};
uint32_t fw_ver = ((report.fw_ver & 0x000000FFu) << 24)
| ((report.fw_ver & 0x0000FF00u) << 8)
| ((report.fw_ver & 0x00FF0000u) >> 8)
| ((report.fw_ver & 0xFF000000u) >> 24);
uint8_t b0 = static_cast<uint8_t>((fw_ver >> 24) & 0xFFu);
uint8_t b1 = static_cast<uint8_t>((fw_ver >> 16) & 0xFFu);
uint8_t b2 = static_cast<uint8_t>((fw_ver >> 8) & 0xFFu);
uint8_t b3 = static_cast<uint8_t>( fw_ver & 0xFFu);
std::snprintf(text, sizeof(text), "%u.%u.%u.%u", b0, b1, b2, b3);
std::snprintf(
text,
sizeof(text),
"%u.%u.%u.%u",
(report.fw_ver ) & 0xFF,
(report.fw_ver >> 8) & 0xFF,
(report.fw_ver >> 16) & 0xFF,
(report.fw_ver >> 24) & 0xFF
);
version = text;
std::snprintf(text, sizeof(text), "0x%08X", report.chip_id);
chip_id = text;
@@ -139,12 +138,14 @@ bool RGBFusion2USBController::RefreshHardwareInfo()
if(product_id == 0x5711)
{
unsigned char buffer2[FUSION2_USB_BUFFER_SIZE] = {0};
SendPacket(0x61, 0x00);
SendCCReport(0x61, 0x00);
buffer2[0] = report_id;
int res2 = hid_get_feature_report(dev, buffer2, sizeof(buffer2));
if(res2 >= static_cast<int>(sizeof(IT5711Calibration)))
{
IT5711Calibration cali;
std::memcpy(&cali, buffer2, sizeof(IT5711Calibration));
cali_loaded = true;
@@ -173,25 +174,23 @@ bool RGBFusion2USBController::RefreshHardwareInfo()
return report_loaded;
}
void RGBFusion2USBController::SetMode(int m)
{
mode = m;
}
std::string RGBFusion2USBController::DecodeCalibrationBuffer(uint32_t value) const
{
if(value==0) return "OFF";
std::string out = "OFF";
if(value == 0)
{
return out;
}
uint8_t bo_b = value & 0xFF;
uint8_t bo_g = (value >> 8) & 0xFF;
uint8_t bo_g = (value >> 8 ) & 0xFF;
uint8_t bo_r = (value >> 16) & 0xFF;
bool in_range = (bo_r<3 && bo_g<3 && bo_b<3);
bool distinct = (bo_r!=bo_g && bo_r!=bo_b && bo_g!=bo_b);
bool in_range = (bo_r < 3 && bo_g < 3 && bo_b < 3);
bool distinct = (bo_r != bo_g && bo_r != bo_b && bo_g != bo_b);
if(in_range && distinct)
{
std::string out(3, '?');
out[bo_r] = 'R';
out[bo_g] = 'G';
out[bo_b] = 'B';
@@ -224,7 +223,7 @@ uint32_t RGBFusion2USBController::EncodeCalibrationBuffer(const std::string& rgb
}
const RGBA &rgb_cal = it->second;
return (uint32_t(rgb_cal.raw[0]))
return (uint32_t(rgb_cal.raw[0]))
| (uint32_t(rgb_cal.raw[1]) << 8)
| (uint32_t(rgb_cal.raw[2]) << 16)
| (uint32_t(rgb_cal.raw[3]) << 24);
@@ -268,12 +267,9 @@ EncodedCalibration RGBFusion2USBController::GetCalibration(bool refresh_from_hw)
bool RGBFusion2USBController::SetCalibration(const EncodedCalibration& cal, bool refresh_from_hw)
{
if(refresh_from_hw)
if(refresh_from_hw && !RefreshHardwareInfo())
{
if(!RefreshHardwareInfo())
{
return false;
}
return false;
}
if(EncodeCalibrationBuffer(cal.dled[0]) == cal_data.dled[0]
@@ -290,27 +286,23 @@ bool RGBFusion2USBController::SetCalibration(const EncodedCalibration& cal, bool
return true;
}
CMD_0x33 desired{};
std::memset(&desired, 0, sizeof(desired));
desired.report_id = report_id;
desired.command_id = 0x33;
CMD_0x33 desired;
desired.d_strip_c0 = EncodeCalibrationBuffer(cal.dled[0]);
desired.d_strip_c1 = EncodeCalibrationBuffer(cal.dled[1]);
desired.rgb_cali = EncodeCalibrationBuffer(cal.mainboard);
desired.c_spare0 = EncodeCalibrationBuffer(cal.spare[0]);
desired.c_spare1 = EncodeCalibrationBuffer(cal.spare[1]);
desired.c.d_strip_c0 = EncodeCalibrationBuffer(cal.dled[0]);
desired.c.d_strip_c1 = EncodeCalibrationBuffer(cal.dled[1]);
desired.c.rgb_cali = EncodeCalibrationBuffer(cal.mainboard);
desired.c.c_spare0 = EncodeCalibrationBuffer(cal.spare[0]);
desired.c.c_spare1 = EncodeCalibrationBuffer(cal.spare[1]);
if(product_id == 0x5711)
{
desired.d_strip_c2 = EncodeCalibrationBuffer(cal.dled[2]);
desired.d_strip_c3 = EncodeCalibrationBuffer(cal.dled[3]);
desired.c_spare2 = EncodeCalibrationBuffer(cal.spare[2]);
desired.c_spare3 = EncodeCalibrationBuffer(cal.spare[3]);
desired.c.d_strip_c2 = EncodeCalibrationBuffer(cal.dled[2]);
desired.c.d_strip_c3 = EncodeCalibrationBuffer(cal.dled[3]);
desired.c.c_spare2 = EncodeCalibrationBuffer(cal.spare[2]);
desired.c.c_spare3 = EncodeCalibrationBuffer(cal.spare[3]);
}
std::memset(desired.reserved, 0, sizeof(desired.reserved));
int rc = SendPacket(reinterpret_cast<unsigned char*>(&desired));
int rc = SendPacket(desired.buffer);
if(rc < 0)
{
return false;
@@ -321,18 +313,18 @@ bool RGBFusion2USBController::SetCalibration(const EncodedCalibration& cal, bool
SaveCalState();
std::this_thread::sleep_for(std::chrono::milliseconds(20));
cal_data.dled[0] = desired.d_strip_c0;
cal_data.dled[1] = desired.d_strip_c1;
cal_data.mainboard = desired.rgb_cali;
cal_data.spare[0] = desired.c_spare0;
cal_data.spare[1] = desired.c_spare1;
cal_data.dled[0] = desired.c.d_strip_c0;
cal_data.dled[1] = desired.c.d_strip_c1;
cal_data.mainboard = desired.c.rgb_cali;
cal_data.spare[0] = desired.c.c_spare0;
cal_data.spare[1] = desired.c.c_spare1;
if(product_id == 0x5711)
{
cal_data.dled[2] = desired.d_strip_c2;
cal_data.dled[3] = desired.d_strip_c3;
cal_data.spare[2] = desired.c_spare2;
cal_data.spare[3] = desired.c_spare3;
cal_data.dled[2] = desired.c.d_strip_c2;
cal_data.dled[3] = desired.c.d_strip_c3;
cal_data.spare[2] = desired.c.c_spare2;
cal_data.spare[3] = desired.c.c_spare3;
}
else
{
@@ -347,27 +339,22 @@ bool RGBFusion2USBController::SetCalibration(const EncodedCalibration& cal, bool
void RGBFusion2USBController::SetLedCount(unsigned int c0, unsigned int c1, unsigned int c2, unsigned int c3)
{
new_d1 = LedCountToEnum(c0);
new_d2 = LedCountToEnum(c1);
new_d3 = LedCountToEnum(c2);
new_d4 = LedCountToEnum(c3);
LEDCount new_d1 = LedCountToEnum(c0);
LEDCount new_d2 = LedCountToEnum(c1);
LEDCount new_d3 = LedCountToEnum(c2);
LEDCount new_d4 = LedCountToEnum(c3);
if(new_d1 == D_LED1_count && new_d2 == D_LED2_count && new_d3 == D_LED3_count && new_d4 == D_LED4_count)
{
return;
}
D_LED1_count = new_d1;
D_LED2_count = new_d2;
D_LED3_count = new_d3;
D_LED4_count = new_d4;
D_LED1_count = new_d1;
D_LED2_count = new_d2;
D_LED3_count = new_d3;
D_LED4_count = new_d4;
unsigned char buffer[FUSION2_USB_BUFFER_SIZE] = { 0 };
buffer[0] = report_id;
buffer[1] = 0x34;
buffer[2] = (new_d2 << 4) | new_d1;
buffer[3] = (new_d4 << 4) | new_d3;
SendPacket(buffer);
SendCCReport(0x34, (new_d2 << 4) | new_d1, (new_d4 << 4) | new_d3);
}
/*---------------------------------------------------------*\
@@ -388,15 +375,15 @@ bool RGBFusion2USBController::SetStripBuiltinEffectState(int hdr, bool enable)
{
case LED4:
case HDR_D_LED2:
case HDR_D_LED2_RGB:
case HDR_D_LED2_ARGB:
bitmask = 0x02;
break;
case HDR_D_LED3:
case HDR_D_LED3_RGB:
case HDR_D_LED3_ARGB:
bitmask = 0x08;
break;
case HDR_D_LED4:
case HDR_D_LED4_RGB:
case HDR_D_LED4_ARGB:
bitmask = 0x10;
break;
default:
@@ -416,7 +403,7 @@ bool RGBFusion2USBController::SetStripBuiltinEffectState(int hdr, bool enable)
first_call = false;
effect_disabled = new_effect_disabled;
int res = SendPacket(0x32, effect_disabled);
int res = SendCCReport(0x32, effect_disabled);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
return res;
}
@@ -426,7 +413,7 @@ bool RGBFusion2USBController::SetStripBuiltinEffectState(int hdr, bool enable)
\*---------------------------------------------------------*/
bool RGBFusion2USBController::SaveLEDState(bool e)
{
return SendPacket(0x47, e ? 1 : 0);
return SendCCReport(0x47, e ? 1 : 0);
}
/*---------------------------------------------------------*\
@@ -434,7 +421,7 @@ bool RGBFusion2USBController::SaveLEDState(bool e)
\*---------------------------------------------------------*/
bool RGBFusion2USBController::SaveCalState()
{
return SendPacket(0x5E, 0);
return SendCCReport(0x5E, 0);
}
/*---------------------------------------------------------*\
@@ -442,7 +429,7 @@ bool RGBFusion2USBController::SaveCalState()
\*---------------------------------------------------------*/
bool RGBFusion2USBController::EnableBeat(bool e)
{
return SendPacket(0x31, e ? 1 : 0);
return SendCCReport(0x31, e ? 1 : 0);
}
/*---------------------------------------------------------*\
@@ -450,7 +437,7 @@ bool RGBFusion2USBController::EnableBeat(bool e)
\*---------------------------------------------------------*/
bool RGBFusion2USBController::EnableLampArray(bool enable)
{
return SendPacket(0x48, enable ? 1 : 0);
return SendCCReport(0x48, enable ? 1 : 0);
}
std::string RGBFusion2USBController::GetDeviceName()
@@ -483,7 +470,7 @@ std::string RGBFusion2USBController::GetSerial()
\*---------------------------------------------------------*/
uint16_t RGBFusion2USBController::GetProductID()
{
return (product_id);
return(product_id);
}
/*---------------------------------------------------------*\
@@ -491,7 +478,7 @@ uint16_t RGBFusion2USBController::GetProductID()
\*---------------------------------------------------------*/
uint8_t RGBFusion2USBController::GetDeviceNum()
{
return (device_num);
return(device_num);
}
/*---------------------------------------------------------*\
@@ -505,13 +492,13 @@ void RGBFusion2USBController::SetStripColors(unsigned int hdr, RGBColor* colors,
switch(pkt.s.header)
{
case HDR_D_LED2_RGB:
case HDR_D_LED2_ARGB:
byteorder = cal_data.dled[1];
break;
case HDR_D_LED3_RGB:
case HDR_D_LED3_ARGB:
byteorder = cal_data.dled[2];
break;
case HDR_D_LED4_RGB:
case HDR_D_LED4_ARGB:
byteorder = cal_data.dled[3];
break;
default:
@@ -659,11 +646,11 @@ bool RGBFusion2USBController::ApplyEffect(bool fast_apply)
{
if(product_id == 0x5711)
{
return SendPacket(0x28, 0xFF, 0x07);
return SendCCReport(0x28, 0xFF, 0x07);
}
else
{
return SendPacket(0x28, 0xFF, 0x00);
return SendCCReport(0x28, 0xFF, 0x00);
}
}
@@ -674,11 +661,17 @@ bool RGBFusion2USBController::ApplyEffect(bool fast_apply)
return SendPacket(pkt.buffer);
}
bool RGBFusion2USBController::SendPacket(uint8_t a, uint8_t b, uint8_t c)
bool RGBFusion2USBController::SendCCReport(uint8_t a, uint8_t b, uint8_t c)
{
return(SendReport(report_id, a, b, c));
}
bool RGBFusion2USBController::SendReport(uint8_t id, uint8_t a, uint8_t b, uint8_t c)
{
unsigned char buffer[FUSION2_USB_BUFFER_SIZE] {};
std::memset(buffer, 0, FUSION2_USB_BUFFER_SIZE);
buffer[0] = report_id;
buffer[0] = id;
buffer[1] = a;
buffer[2] = b;
buffer[3] = c;
@@ -698,14 +691,14 @@ void RGBFusion2USBController::ResetController()
{
for(uint8_t reg = 0x20; reg <= 0x27; ++reg)
{
SendPacket(reg, 0x00, 0x00);
SendCCReport(reg, 0x00, 0x00);
}
if(product_id == 0x5711)
{
for(uint8_t reg = 0x90; reg <= 0x92; ++reg)
{
SendPacket(reg, 0x00, 0x00);
SendCCReport(reg, 0x00, 0x00);
}
}
ApplyEffect(true);

View File

@@ -17,44 +17,10 @@
#include <hidapi.h>
#include <map>
#include "RGBController.h"
#include "GigabyteFusion2USB_Devices.h"
#define FUSION2_USB_BUFFER_SIZE 64
/*--------------------------------------------------------*\
| Base LED mappings found on all controllers. |
\*--------------------------------------------------------*/
const uint8_t LED1 = 0;
const uint8_t LED2 = 1;
const uint8_t LED3 = 2;
const uint8_t LED4 = 3;
const uint8_t LED5 = 4;
const uint8_t LED6 = 5;
const uint8_t LED7 = 6;
const uint8_t LED8 = 7;
/*--------------------------------------------------------*\
| IT8297/IT5701/IT5702 ARGB Headers |
\*--------------------------------------------------------*/
const uint8_t HDR_D_LED1 = LED6;
const uint8_t HDR_D_LED2 = LED7;
const uint8_t HDR_D_LED1_RGB = 0x58;
const uint8_t HDR_D_LED2_RGB = 0x59;
/*--------------------------------------------------------*\
| Additional LED mappings found on IT5711 controllers. |
\*--------------------------------------------------------*/
const uint8_t LED9 = 8;
const uint8_t LED10 = 9;
const uint8_t LED11 = 10;
/*--------------------------------------------------------*\
| IT5711 additional ARGB Headers. |
\*--------------------------------------------------------*/
const uint8_t HDR_D_LED3 = LED8;
const uint8_t HDR_D_LED4 = LED9;
const uint8_t HDR_D_LED3_RGB = 0x62;
const uint8_t HDR_D_LED4_RGB = 0x63;
/*---------------------------------------------------------*\
| Effects mode list |
\*---------------------------------------------------------*/
@@ -102,8 +68,8 @@ struct LEDs
\*---------------------------------------------------------*/
struct CalibrationData
{
uint32_t dled[4] = {0};
uint32_t spare[4] = {0};
uint32_t dled[4] = {0, 0, 0, 0};
uint32_t spare[4] = {0, 0, 0, 0};
uint32_t mainboard = 0;
};
@@ -187,16 +153,16 @@ union PktRGB
{
case LED4:
case HDR_D_LED2:
header = HDR_D_LED2_RGB;
header = HDR_D_LED2_ARGB;
break;
case HDR_D_LED3:
header = HDR_D_LED3_RGB;
header = HDR_D_LED3_ARGB;
break;
case HDR_D_LED4:
header = HDR_D_LED4_RGB;
header = HDR_D_LED4_ARGB;
break;
default:
header = HDR_D_LED1_RGB;
header = HDR_D_LED1_ARGB;
break;
}
s.report_id = report_id;
@@ -250,7 +216,7 @@ union PktEffect
void Init(int led, uint8_t report_id, uint16_t pid)
{
memset(e.padding0, 0, sizeof(e.padding0));
memset(buffer, 0, sizeof(buffer));
e.report_id = report_id;
if(led == -1)
@@ -316,20 +282,29 @@ struct IT5711Calibration
/*---------------------------------------------------------*\
| CC33 Set Calibration Struct |
\*---------------------------------------------------------*/
struct CMD_0x33
union CMD_0x33
{
uint8_t report_id;
uint8_t command_id;
uint32_t d_strip_c0;
uint32_t d_strip_c1;
uint32_t rgb_cali;
uint32_t c_spare0;
uint32_t c_spare1;
uint32_t d_strip_c2;
uint32_t d_strip_c3;
uint32_t c_spare2;
uint32_t c_spare3;
uint8_t reserved[25];
unsigned char buffer[FUSION2_USB_BUFFER_SIZE];
struct Calibration
{
uint8_t report_id = 0xCC;
uint8_t command_id = 0x33;
uint32_t d_strip_c0 = 0;
uint32_t d_strip_c1 = 0;
uint32_t rgb_cali = 0;
uint32_t c_spare0 = 0;
uint32_t c_spare1 = 0;
uint32_t d_strip_c2 = 0;
uint32_t d_strip_c3 = 0;
uint32_t c_spare2 = 0;
uint32_t c_spare3 = 0;
uint8_t reserved[25];
} c;
CMD_0x33() : c{}
{
memset(c.reserved, 0, sizeof(c.reserved));
}
};
#pragma pack(pop)
@@ -340,54 +315,51 @@ public:
RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name, uint16_t pid);
~RGBFusion2USBController();
bool RefreshHardwareInfo();
void ResetController();
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, 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);
bool SetStripBuiltinEffectState(int hdr, bool enable);
EncodedCalibration GetCalibration(bool refresh_from_hw = false);
bool SetCalibration(const EncodedCalibration& cal, bool refresh_from_hw);
void SetLedCount(unsigned int c0, unsigned int c1, unsigned int c2, unsigned int c3);
void SetLEDEffect(int led, int mode, unsigned int speed, unsigned char brightness, bool random, uint32_t* color);
bool SetStripBuiltinEffectState(int hdr, bool enable);
void SetStripColors(unsigned int hdr, RGBColor * colors, unsigned int num_colors, int single_led = -1);
EncodedCalibration GetCalibration(bool refresh_from_hw = false);
std::string GetDeviceName();
uint8_t GetDeviceNum();
std::string GetDeviceDescription();
std::string GetDeviceLocation();
std::string GetFWVersion();
uint16_t GetProductID();
std::string GetSerial();
private:
bool SaveLEDState(bool enable);
bool SaveCalState();
std::string DecodeCalibrationBuffer(uint32_t value) const;
bool EnableLampArray(bool enable);
bool EnableBeat(bool enable);
bool SendPacket(uint8_t a, uint8_t b, uint8_t c = 0);
int SendPacket(unsigned char* packet);
uint32_t EncodeCalibrationBuffer(const std::string& rgb_order);
std::string DecodeCalibrationBuffer(uint32_t value) const;
bool RefreshHardwareInfo();
void ResetController();
bool SaveLEDState(bool enable);
bool SaveCalState();
bool SendCCReport(uint8_t a, uint8_t b, uint8_t c = 0);
bool SendReport(uint8_t id, uint8_t a, uint8_t b, uint8_t c = 0);
int SendPacket(unsigned char* packet);
hid_device* dev;
int device_num;
uint16_t product_id;
uint32_t effect_zone_mask = 0;
uint32_t effect_zone_mask = 0;
int mode;
IT8297Report report;
IT5711Calibration cali;
CalibrationData cal_data;
std::string name;
std::string description;
std::string location;
std::string version;
std::string chip_id;
int effect_disabled = 0;
int report_id = 0xCC;
bool report_loaded = false;
bool cali_loaded = false;
LEDCount new_d1;
LEDCount new_d2;
LEDCount new_d3;
LEDCount new_d4;
int effect_disabled = 0;
int report_id = 0xCC;
bool report_loaded = false;
bool cali_loaded = false;
LEDCount D_LED1_count;
LEDCount D_LED2_count;
LEDCount D_LED3_count;

View File

@@ -11,11 +11,10 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "GigabyteFusion2USB_Devices.h"
#include "LogManager.h"
#include "RGBController_GigabyteRGBFusion2USB.h"
#include "RGBController_GigabyteRGBFusion2USBBoards.h"
#include "RGBController_GigabyteRGBFusion2USBLayouts.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
/**------------------------------------------------------------------*\
@name Gigabyte RGB Fusion 2 USB
@@ -29,138 +28,6 @@
Intel mainboards from the x570 and z390 chipsets onwards.
\*-------------------------------------------------------------------*/
/*---------------------------------------------------------*\
| Convert calibration data to JSON |
\*---------------------------------------------------------*/
static nlohmann::json WriteCalJsonFrom(const EncodedCalibration& src, uint16_t pid)
{
nlohmann::json calib_json;
calib_json["HDR_D_LED1"] = src.dled[0];
calib_json["HDR_D_LED2"] = src.dled[1];
if(pid == 0x5711)
{
calib_json["HDR_D_LED3"] = src.dled[2];
calib_json["HDR_D_LED4"] = src.dled[3];
}
calib_json["Mainboard"] = src.mainboard;
calib_json["Spare0"] = src.spare[0];
calib_json["Spare1"] = src.spare[1];
if(pid == 0x5711)
{
calib_json["Spare2"] = src.spare[2];
calib_json["Spare3"] = src.spare[3];
}
return calib_json;
}
/*---------------------------------------------------------*\
| Fill missing JSON calibration keys |
\*---------------------------------------------------------*/
static void FillMissingWith(nlohmann::json& dst, const EncodedCalibration& fb, uint16_t pid)
{
struct SetIfMissing
{
nlohmann::json& dst;
void operator()(const char* key, const std::string& val) const
{
if(!dst.contains(key))
{
dst[key] = val;
}
}
};
SetIfMissing set_if_missing{dst};
set_if_missing("HDR_D_LED1", fb.dled[0]);
set_if_missing("HDR_D_LED2", fb.dled[1]);
if(pid==0x5711)
{
set_if_missing("HDR_D_LED3", fb.dled[2]);
set_if_missing("HDR_D_LED4", fb.dled[3]);
}
set_if_missing("Mainboard", fb.mainboard);
set_if_missing("Spare0", fb.spare[0]);
set_if_missing("Spare1", fb.spare[1]);
if(pid==0x5711)
{
set_if_missing("Spare2", fb.spare[2]);
set_if_missing("Spare3", fb.spare[3]);
}
}
/*---------------------------------------------------------*\
| JSON safe string fetch (calibration) |
\*---------------------------------------------------------*/
static std::string GetOrOff(const nlohmann::json& obj, const char* key)
{
return obj.contains(key) ? obj.at(key).get<std::string>() : std::string("OFF");
}
/*---------------------------------------------------------*\
| Build custom layout in JSON |
\*---------------------------------------------------------*/
static nlohmann::json BuildCustomLayoutJson(const ZoneLeds& src_layout, const RvrseLedHeaders& reverseLookup)
{
nlohmann::json json_HCL;
for(ZoneLeds::const_iterator zl = src_layout.begin(); zl != src_layout.end(); ++zl)
{
const std::string& zone_name = zl->first;
const std::vector<LedPort>& v_lp = zl->second;
nlohmann::json json_zl;
for(std::vector<LedPort>::const_iterator it = v_lp.begin(); it != v_lp.end(); ++it)
{
const LedPort& lp = *it;
nlohmann::json json_lp;
json_lp["name"] = lp.name;
json_lp["header"] = reverseLookup.at(lp.header);
json_lp["count"] = lp.count;
json_zl.push_back(json_lp);
}
json_HCL.emplace(zone_name, json_zl);
}
return json_HCL;
}
/*---------------------------------------------------------*\
| Build custom layout from JSON |
\*---------------------------------------------------------*/
static void LoadCustomLayoutFromJson(const nlohmann::json& json_HCL, const FwdLedHeaders& forwardLookup, ZoneLeds& out_layout)
{
out_layout.clear();
for(nlohmann::json::const_iterator json_layout_it = json_HCL.begin();
json_layout_it != json_HCL.end();
++json_layout_it)
{
const std::string& zone_name = json_layout_it.key();
const nlohmann::json& json_zl = json_layout_it.value();
std::vector<LedPort> v_lp;
for(nlohmann::json::const_iterator zl_it = json_zl.begin();
zl_it != json_zl.end();
++zl_it)
{
const nlohmann::json& zl = *zl_it;
nlohmann::json jv = zl;
LedPort lp;
lp.name = jv["name"].get<std::string>();
lp.header = forwardLookup.at(jv["header"].get<std::string>());
lp.count = jv.contains("count") ? jv["count"].get<int>() : 1;
v_lp.push_back(lp);
}
out_layout.insert(std::pair<std::string, std::vector<LedPort>>(zone_name, v_lp));
}
}
RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr, std::string detector)
{
controller = controller_ptr;
@@ -172,7 +39,6 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
version = controller->GetFWVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerial();
pid = controller->GetProductID();
device_num = controller->GetDeviceNum();
mode Direct;
@@ -334,7 +200,6 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
Wave4.color_mode = MODE_COLORS_NONE;
modes.push_back(Wave4);
Load_Device_Config();
Init_Controller();
SetupZones();
}
@@ -347,7 +212,7 @@ RGBController_RGBFusion2USB::~RGBController_RGBFusion2USB()
/*---------------------------------------------------------*\
| Loads JSON config data |
\*---------------------------------------------------------*/
void RGBController_RGBFusion2USB::Load_Device_Config()
void RGBController_RGBFusion2USB::Init_Controller()
{
const std::string SectionCustom = "CustomLayout";
const std::string SectionCalibration = "Calibration";
@@ -355,40 +220,24 @@ void RGBController_RGBFusion2USB::Load_Device_Config()
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
nlohmann::json device_settings = settings_manager->GetSettings(detector_name);
if(pid == 0x5711)
{
layout = HardcodedCustom_Gen2.find("Custom")->second;
}
else
{
layout = HardcodedCustom_Gen1.find("Custom")->second;
}
/*---------------------------------------------------------*\
| Remove legacy top-level "MotherboardLayouts" |
| Create the custom layout from the generic_device |
\*---------------------------------------------------------*/
if(device_settings.contains("MotherboardLayouts"))
{
device_settings.erase("MotherboardLayouts");
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
}
gb_fusion2_device* layout = const_cast<gb_fusion2_device*>(gb_fusion2_device_list[device_index]);
if(!device_settings.contains(SectionCustom))
{
nlohmann::json json_HCL = BuildCustomLayoutJson(layout, ReverseLedLookup);
device_settings[SectionCustom]["Enabled"] = false;
device_settings[SectionCustom]["Data"] = BuildCustomLayoutJson(layout, ReverseLedLookup);
device_settings[SectionCustom]["Enabled"] = false;
device_settings[SectionCustom]["Data"] = BuildCustomLayoutJson(layout, ReverseLedLookup);
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
}
custom_layout = device_settings[SectionCustom]["Enabled"];
bool custom_layout = device_settings[SectionCustom]["Enabled"];
if(custom_layout)
{
const nlohmann::json json_HCL = device_settings[SectionCustom]["Data"];
LoadCustomLayoutFromJson(json_HCL, LedLookup, layout);
LoadCustomLayoutFromJson(device_settings[SectionCustom]["Data"], LedLookup, layout);
}
EncodedCalibration hw_cal = controller->GetCalibration(false);
@@ -396,7 +245,7 @@ void RGBController_RGBFusion2USB::Load_Device_Config()
if(!device_settings.contains(SectionCalibration))
{
device_settings[SectionCalibration]["Enabled"] = false;
device_settings[SectionCalibration]["Data"] = WriteCalJsonFrom(hw_cal, pid);
device_settings[SectionCalibration]["Data"] = WriteCalJsonFrom(hw_cal);
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
}
@@ -407,18 +256,18 @@ void RGBController_RGBFusion2USB::Load_Device_Config()
if(!cal_sec.contains("Data") || !cal_sec["Data"].is_object())
{
cal_sec["Data"] = WriteCalJsonFrom(hw_cal, pid);
cal_sec["Data"] = WriteCalJsonFrom(hw_cal);
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
}
else
{
nlohmann::json& cdata = cal_sec["Data"];
FillMissingWith(cdata, hw_cal, pid);
FillMissingWith(cdata, hw_cal);
if(!cal_enable)
{
cal_sec["Data"] = WriteCalJsonFrom(hw_cal, pid);
cal_sec["Data"] = WriteCalJsonFrom(hw_cal);
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
}
@@ -429,18 +278,18 @@ void RGBController_RGBFusion2USB::Load_Device_Config()
const nlohmann::json& cdata = cal_sec["Data"];
EncodedCalibration desired;
desired.dled[0] = GetOrOff(cdata, "HDR_D_LED1");
desired.dled[1] = GetOrOff(cdata, "HDR_D_LED2");
desired.mainboard = GetOrOff(cdata, "Mainboard");
desired.spare[0] = GetOrOff(cdata, "Spare0");
desired.spare[1] = GetOrOff(cdata, "Spare1");
desired.dled[0] = GET_JSON_VAL_ELSE_OFF(cdata, "HDR_D_LED1");
desired.dled[1] = GET_JSON_VAL_ELSE_OFF(cdata, "HDR_D_LED2");
desired.mainboard = GET_JSON_VAL_ELSE_OFF(cdata, "Mainboard");
desired.spare[0] = GET_JSON_VAL_ELSE_OFF(cdata, "Spare0");
desired.spare[1] = GET_JSON_VAL_ELSE_OFF(cdata, "Spare1");
if(pid == 0x5711)
if(controller->GetProductID() == 0x5711)
{
desired.dled[2] = GetOrOff(cdata, "HDR_D_LED3");
desired.dled[3] = GetOrOff(cdata, "HDR_D_LED4");
desired.spare[2] = GetOrOff(cdata, "Spare2");
desired.spare[3] = GetOrOff(cdata, "Spare3");
desired.dled[2] = GET_JSON_VAL_ELSE_OFF(cdata, "HDR_D_LED3");
desired.dled[3] = GET_JSON_VAL_ELSE_OFF(cdata, "HDR_D_LED4");
desired.spare[2] = GET_JSON_VAL_ELSE_OFF(cdata, "Spare2");
desired.spare[3] = GET_JSON_VAL_ELSE_OFF(cdata, "Spare3");
}
else
{
@@ -452,110 +301,51 @@ void RGBController_RGBFusion2USB::Load_Device_Config()
controller->SetCalibration(desired, false);
}
}
}
/*---------------------------------------------------------*\
| Loads layout and zone data for controller |
\*---------------------------------------------------------*/
void RGBController_RGBFusion2USB::Init_Controller()
{
/*---------------------------------------------------------*\
| Look up channel map based on device name |
\*---------------------------------------------------------*/
/*---------------------------------------------------------------------*\
| When no match found the first entry (generic_device) will be used |
| otherwise look up channel map based on device name |
\*---------------------------------------------------------------------*/
if(!custom_layout)
{
std::string layout_key;
bool found = false;
switch(pid)
/*-----------------------------------------------------------------*\
| Loop through all known devices to look for a name match |
| NB: Can be switched to device IDs lookup when acpi table |
| is able to be probed accurately |
\*-----------------------------------------------------------------*/
for(unsigned int i = 0; i < GB_FUSION2_DEVICE_COUNT; i++)
{
case 0x5711:
if(MBName2LayoutLookup5711.count(name))
{
layout_key = MBName2LayoutLookup5711.at(name);
found = true;
}
break;
case 0x5702:
if(MBName2LayoutLookup5702.count(name))
{
layout_key = MBName2LayoutLookup5702.at(name);
found = true;
}
break;
case 0x8950:
if(MBName2LayoutLookup8950.count(name))
{
layout_key = MBName2LayoutLookup8950.at(name);
found = true;
}
break;
case 0x8297:
if(MBName2LayoutLookup8297.count(name))
{
layout_key = MBName2LayoutLookup8297.at(name);
found = true;
}
break;
default:
break;
}
if(found)
{
layout = knownLayoutsLookup.at(layout_key);
}
else
{
switch(pid)
if(gb_fusion2_device_list[i]->name == name)
{
case 0x8297:
case 0x8950:
case 0x5702:
layout = knownLayoutsLookup.at("STD_ATX");
break;
default:
layout = knownLayoutsLookup.at("IT5711-Generic");
break;
/*---------------------------------------------------------*\
| Set device ID |
\*---------------------------------------------------------*/
device_index = i;
layout = const_cast<gb_fusion2_device*>(gb_fusion2_device_list[i]);
break;
}
}
}
/*---------------------------------------------------------*\
| Initialize the number of zones from the layout |
\*---------------------------------------------------------*/
zones.resize(layout.size());
/*---------------------------------------------------------*\
| Iterate through layout and process each zone |
\*---------------------------------------------------------*/
int zone_idx = 0;
for(ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); zl++)
for(uint8_t zone_idx = 0; zone_idx < GB_FUSION2_ZONES_MAX; zone_idx++)
{
std::vector<LedPort> lp = zl->second;
int LED_count = 0;
bool single_zone = true;
for(std::size_t lp_idx = 0; lp_idx < lp.size(); lp_idx++)
if(!layout->zones[0][zone_idx])
{
int lp_count = lp[lp_idx].count;
single_zone = single_zone && (lp_count == 1);
LED_count += lp_count;
continue;
}
const gb_fusion2_zone* zone_at_idx = layout->zones[0][zone_idx];
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_count = (single_zone) ? LED_count : 0;
zones[zone_idx].type = (single_zone) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
zones[zone_idx].matrix_map = NULL;
zone_idx++;
zone new_zone;
new_zone.name = zone_at_idx->name;
new_zone.leds_min = zone_at_idx->leds_min;
new_zone.leds_max = zone_at_idx->leds_max;
new_zone.leds_count = new_zone.leds_min;
new_zone.type = (new_zone.leds_min == new_zone.leds_max) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
new_zone.matrix_map = NULL;
zones.emplace_back(new_zone);
}
}
@@ -572,16 +362,19 @@ void RGBController_RGBFusion2USB::SetupZones()
/*---------------------------------------------------------*\
| Set up zones (Fixed so as to not spam the controller) |
\*---------------------------------------------------------*/
int zone_idx = 0;
for (ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); zl++)
for(uint8_t zone_idx = 0; zone_idx < GB_FUSION2_ZONES_MAX; zone_idx++)
{
bool single_zone = (zones[zone_idx].type == ZONE_TYPE_SINGLE);
if (!single_zone)
const gb_fusion2_zone* zone_at_idx = gb_fusion2_device_list[device_index]->zones[0][zone_idx];
if(!zone_at_idx)
{
unsigned char hdr = zl->second.at(0).header;
continue;
}
bool single_zone = (zone_at_idx->leds_min == zone_at_idx->leds_max);
switch (hdr)
if(!single_zone)
{
switch(zone_at_idx->idx)
{
case LED4:
case HDR_D_LED2:
@@ -599,26 +392,20 @@ void RGBController_RGBFusion2USB::SetupZones()
}
}
for (unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led new_led;
if (single_zone)
new_led.name = zone_at_idx->name;
new_led.value = zone_at_idx->idx;
if(!single_zone)
{
new_led.name = zl->second.at(lp_idx).name;
new_led.value = zl->second.at(lp_idx).header;
}
else
{
new_led.name = zl->second.at(0).name;
new_led.name.append(" LED " + std::to_string(lp_idx));
new_led.value = zl->second.at(0).header;
new_led.name.append(" LED " + std::to_string(led_idx));
}
leds.push_back(new_led);
}
zone_idx++;
}
controller->SetLedCount(d1, d2, d3, d4);
@@ -911,3 +698,145 @@ int RGBController_RGBFusion2USB::GetLED_Zone(int led_idx)
\*---------------------------------------------------------*/
return(-1);
}
/*---------------------------------------------------------*\
| Convert calibration data to JSON |
\*---------------------------------------------------------*/
nlohmann::json RGBController_RGBFusion2USB::WriteCalJsonFrom(const EncodedCalibration& src)
{
nlohmann::json calib_json;
calib_json["HDR_D_LED1"] = src.dled[0];
calib_json["HDR_D_LED2"] = src.dled[1];
calib_json["HDR_D_LED3"] = src.dled[2];
calib_json["HDR_D_LED4"] = src.dled[3];
calib_json["Mainboard"] = src.mainboard;
calib_json["Spare0"] = src.spare[0];
calib_json["Spare1"] = src.spare[1];
calib_json["Spare2"] = src.spare[2];
calib_json["Spare3"] = src.spare[3];
return calib_json;
}
/*---------------------------------------------------------*\
| Fill missing JSON calibration keys |
\*---------------------------------------------------------*/
void RGBController_RGBFusion2USB::FillMissingWith(nlohmann::json& dst, const EncodedCalibration& fb)
{
struct SetIfMissing
{
nlohmann::json& dst;
void operator()(const char* key, const std::string& val) const
{
if(!dst.contains(key))
{
dst[key] = val;
}
}
};
SetIfMissing set_if_missing{dst};
set_if_missing("HDR_D_LED1", fb.dled[0]);
set_if_missing("HDR_D_LED2", fb.dled[1]);
set_if_missing("Mainboard", fb.mainboard);
set_if_missing("Spare0", fb.spare[0]);
set_if_missing("Spare1", fb.spare[1]);
if(controller->GetProductID() == 0x5711)
{
set_if_missing("HDR_D_LED3", fb.dled[2]);
set_if_missing("HDR_D_LED4", fb.dled[3]);
set_if_missing("Spare2", fb.spare[2]);
set_if_missing("Spare3", fb.spare[3]);
}
}
/*---------------------------------------------------------*\
| Build custom layout in JSON |
\*---------------------------------------------------------*/
nlohmann::json RGBController_RGBFusion2USB::BuildCustomLayoutJson(
const gb_fusion2_device* layout,
const RvrseLedHeaders& reverseLookup)
{
nlohmann::json json_custom;
for(uint8_t zone_idx = 0; zone_idx < GB_FUSION2_ZONES_MAX; zone_idx++)
{
if(!layout->zones[0][zone_idx])
{
continue;
}
nlohmann::json json_zone;
json_zone["name"] = layout->zones[0][zone_idx]->name;
json_zone["header"] = reverseLookup.at(layout->zones[0][zone_idx]->idx);
json_zone["leds_min"] = layout->zones[0][zone_idx]->leds_min;
json_zone["leds_max"] = layout->zones[0][zone_idx]->leds_max;
json_custom[layout->name].push_back(json_zone);
}
return json_custom;
}
/*---------------------------------------------------------*\
| Build custom layout from JSON |
\*---------------------------------------------------------*/
void RGBController_RGBFusion2USB::LoadCustomLayoutFromJson(
const nlohmann::json& json_custom,
const FwdLedHeaders& forwardLookup,
gb_fusion2_device* layout)
{
for(uint8_t zone_idx = 0; zone_idx < GB_FUSION2_ZONES_MAX; zone_idx++)
{
/*---------------------------------------------------------*\
| Check if there are more JSON objects to parse |
\*---------------------------------------------------------*/
if(json_custom[layout->name].size() <= zone_idx)
{
layout->zones[0][zone_idx] = nullptr;
continue;
}
nlohmann::json json_zone = json_custom[layout->name].at(zone_idx);
gb_fusion2_zone* new_zone = new gb_fusion2_zone();
new_zone->name = json_zone["name"].get<std::string>();
std::string header = json_zone["header"].get<std::string>();
new_zone->idx = forwardLookup.at(header);
if( header == "HDR_D_LED1"
|| header == "HDR_D_LED2"
|| header == "HDR_D_LED3"
|| header == "HDR_D_LED4")
{
new_zone->leds_min = std::max(json_zone["leds_min"].get<int>(), 1);
new_zone->leds_max = std::min(json_zone["leds_max"].get<int>(), 1024);
}
else
{
new_zone->leds_min = 1;
new_zone->leds_max = 1;
}
/*---------------------------------------------------------*\
| Check for valid values from JSON |
\*---------------------------------------------------------*/
if(new_zone->name != ""
&& new_zone->leds_min <= new_zone->leds_max
&& new_zone->idx >= GB_FUSION2_LED_IDX::LED1
&& new_zone->idx <= GB_FUSION2_LED_IDX::LED11)
{
layout->zones[0][zone_idx] = new_zone;
}
else
{
LOG_ERROR("[%s] Error creating zone %d: Validation failed for %s @ index %d (LEDs min %d to %d max)",
controller->GetDeviceName().c_str(),
zone_idx,
new_zone->name.c_str(),
new_zone->idx,
new_zone->leds_min,
new_zone->leds_max);
}
}
}

View File

@@ -15,9 +15,9 @@
#include <map>
#include "RGBController.h"
#include "GigabyteFusion2USB_Devices.h"
#include "GigabyteRGBFusion2USBController.h"
#include "RGBController_GigabyteRGBFusion2USBBoards.h"
#include "RGBController_GigabyteRGBFusion2USBLayouts.h"
#include "SettingsManager.h"
#define RGBFUSION2_DIGITAL_LEDS_MIN 0
#define RGBFUSION2_DIGITAL_LEDS_MAX 1024
@@ -27,6 +27,8 @@
#define RGBFUSION2_SPEED_MID 4
#define RGBFUSION2_SPEED_MAX 0
#define GET_JSON_VAL_ELSE_OFF(obj, key) obj.contains(key) ? obj.at(key).get<std::string>() : std::string("OFF")
template<typename K, typename V>
static std::map<V, K> reverse_map(const std::map<K, V>& map)
{
@@ -46,28 +48,41 @@ public:
RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr, std::string _detector_name);
~RGBController_RGBFusion2USB();
void SetupZones();
void SetupZones();
void ResizeZone(int zone, int new_size);
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceUpdateMode();
private:
MBName MBName2Layout;
bool custom_layout;
std::string detector_name;
RGBFusion2USBController* controller;
int device_num;
ZoneLeds layout;
RGBColor null_color = 0;
uint16_t pid;
/*---------------------------------------------------------*\
| The intial value of device_index should point to the |
| layout for the generic_device |
\*---------------------------------------------------------*/
uint32_t device_index = 0;
void Load_Device_Config();
void Init_Controller();
int GetLED_Zone(int led_idx);
void Init_Controller();
int GetLED_Zone(int led_idx);
nlohmann::json WriteCalJsonFrom(
const EncodedCalibration& src);
void FillMissingWith(
nlohmann::json& dst,
const EncodedCalibration& fb);
nlohmann::json BuildCustomLayoutJson(
const gb_fusion2_device* layout,
const RvrseLedHeaders& reverseLookup);
void LoadCustomLayoutFromJson(
const nlohmann::json& json_custom,
const FwdLedHeaders& forwardLookup,
gb_fusion2_device* layout);
};

View File

@@ -1,315 +0,0 @@
/*---------------------------------------------------------*\
| RGBController_GigabyteRGBFusion2USBBoards.cpp |
| |
| RGBController for Gigabyte Aorus RGB Fusion 2 USB |
| motherboard |
| |
| megadjc 31 Jul 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_GigabyteRGBFusion2USBBoards.h"
/*---------------------------------------------------------*\
| This is a list of known layouts listed by controller |
\*---------------------------------------------------------*/
const MBName MBName2LayoutLookup8297 =
{
{"X570 AORUS ELITE", "STD_ATX" },
{"X570 AORUS ELITE WIFI", "STD_ATX" },
{"X570 AORUS MASTER", "MSTR_ATX_3" },
{"X570 AORUS PRO", "STD_ATX" },
{"X570 AORUS PRO WIFI", "STD_ATX" },
{"X570 AORUS ULTRA", "STD_ATX" },
{"X570 I AORUS PRO WIFI", "B550I-AORUS-PRO-AX" },
{"Z390 AORUS MASTER-CF", "MSTR_ATX" },
};
const MBName MBName2LayoutLookup8950 =
{
{"H810M GAMING WIFI6", "H810M" },
{"H810M H", "H810M" },
{"H810M S2H", "H810M" },
};
const MBName MBName2LayoutLookup5702 =
{
{"A620I AX", "B650-C-V2" },
{"A620M C", "B650-D2H" },
{"A620M D2H", "B650-D2H" },
{"A620M DS3H", "A620M-H" },
{"A620M GAMING X", "A620M-H" },
{"A620M GAMING X AX", "A620M-H" },
{"A620M H", "A620M-H" },
{"A620M S2H", "B650-C-V2" },
{"B550 AORUS ELITE", "STD_ATX" },
{"B550 AORUS ELITE AX V2", "B550-AORUS-ELITE" },
{"B550 AORUS PRO", "STD_ATX" },
{"B550I AORUS PRO AX", "B550I-AORUS-PRO-AX" },
{"B650 AERO G", "X670-ELITE" },
{"B650 AORUS ELITE", "B650-ELITE" },
{"B650 AORUS ELITE AX", "B650-ELITE" },
{"B650 AORUS ELITE AX ICE", "B650-ELITE-V2" },
{"B650 AORUS ELITE AX V2", "B650-ELITE-V2" },
{"B650 AORUS ELITE V2", "B650-ELITE-V2" },
{"B650 AORUS PRO AX", "B650-PRO" },
{"B650 EAGLE", "B650-Eagle-AX" },
{"B650 EAGLE AX", "B650-Eagle-AX" },
{"B650 GAMING X", "B650-PRO" },
{"B650 GAMING X AX", "B650-PRO" },
{"B650 GAMING X AX V2", "B650-PRO" },
{"B650 GAMING X V2", "B650-PRO" },
{"B650 UD AC", "B650-UD" },
{"B650 UD AX", "B650-UD" },
{"B650E AORUS ELITE X AX ICE", "B650-ELITE-V2" },
{"B650E AORUS MASTER", "MSTR_ATX_2" },
{"B650E AORUS PRO X USB4", "B650-USB4" },
{"B650E AORUS TACHYON", "B650-TACH" },
{"B650I AORUS ULTRA", "B650-D2H" },
{"B650I AX", "B650-C-V2" },
{"B650M AORUS ELITE", "B650-ELITE" },
{"B650M AORUS ELITE AX", "B650-ELITE" },
{"B650M AORUS ELITE AX ICE", "B650-ELITE" },
{"B650M AORUS PRO", "B650-ELITE" },
{"B650M AORUS PRO AX", "B650-ELITE" },
{"B650M C V2", "B650-C-V2" },
{"B650M C V3", "B650-C-V2" },
{"B650M D2H", "B650-D2H" },
{"B650M D2HP", "B650M-DS3H" },
{"B650M D3HP", "B650M-DS3H" },
{"B650M D3HP AX", "B650M-DS3H" },
{"B650M DS3H", "B650M-DS3H" },
{"B650M GAMING PLUS WIFI", "B650M-DS3H" },
{"B650M GAMING WIFI", "B650M-DS3H" },
{"B650M GAMING WIFI6", "B650M-DS3H" },
{"B650M GAMING X AX", "B650M-DS3H" },
{"B650M H", "B650-D2H" },
{"B650M K", "B650M-DS3H" },
{"B650M S2H", "B650-D2H" },
{"B760 AORUS ELITE", "Z790-S-DDR4" },
{"B760 AORUS ELITE AX", "Z790-S-DDR4" },
{"B760 AORUS MASTER DDR4", "Z690-ELITE" },
{"B760 DS3H", "Z790-S-DDR4" },
{"B760 DS3H AC", "Z790-S-DDR4" },
{"B760 DS3H AC DDR4", "Z790-S-DDR4" },
{"B760 DS3H AX", "Z790-S-DDR4" },
{"B760 DS3H AX DDR4", "Z790-S-DDR4" },
{"B760 DS3H AX V2", "Z790-S-DDR4" },
{"B760 DS3H DDR4", "Z790-S-DDR4" },
{"B760 GAMING X", "Z790-S-DDR4" },
{"B760 GAMING X AX", "Z790-S-DDR4" },
{"B760 GAMING X AX DDR4", "Z790-S-DDR4" },
{"B760 GAMING X DDR4", "Z790-S-DDR4" },
{"B760I AORUS PRO", "B550I-AORUS-PRO-AX" },
{"B760I AORUS PRO DDR4", "B550I-AORUS-PRO-AX" },
{"B760M AORUS ELITE", "Z790-XTRM" },
{"B760M AORUS ELITE AX", "Z790-XTRM" },
{"B760M AORUS ELITE AX DDR4", "Z790-XTRM" },
{"B760M AORUS ELITE DDR4", "Z790-XTRM" },
{"B760M AORUS ELITE X AX", "B760M-EXAX" },
{"B760M AORUS PRO", "Z790-XTRM" },
{"B760M AORUS PRO AX", "Z790-XTRM" },
{"B760M AORUS PRO AX DDR4", "Z790-XTRM" },
{"B760M AORUS PRO DDR4", "Z790-XTRM" },
{"B760M C", "Z790-S-DDR4" },
{"B760M C V2", "Z790-S-DDR4" },
{"B760M D2H", "B760M-D2H" },
{"B760M D2H DDR4", "B760M-D2H" },
{"B760M D3H", "B760M-D2H" },
{"B760M D3H DDR4", "B760M-D2H" },
{"B760M D3HP", "B760M-D2H" },
{"B760M D3HP DDR4", "B760M-D2H" },
{"B760M D3HP WIFI6", "B760M-D2H" },
{"B760M DS3H", "B760M-D2H" },
{"B760M DS3H AX", "B760M-D2H" },
{"B760M DS3H AX DDR4", "B760M-D2H" },
{"B760M DS3H DDR4", "B760M-D2H" },
{"B760M DS3H GEN 5", "B760M-DS3H-DR-G5" },
{"B760M G AX", "B760M-GAX" },
{"B760M GAMING", "B760M-GAX" },
{"B760M GAMING AC", "B760M-GAX" },
{"B760M GAMING AC DDR4", "B760M-D2H" },
{"B760M GAMING DDR4", "B760M-D2H" },
{"B760M GAMING PLUS WIFI DDR4", "B760M-D2H" },
{"B760M GAMING WIFI", "B760M-GAX" },
{"B760M GAMING WIFI PLUS", "B760M-GAX" },
{"B760M GAMING X", "Z790-S-DDR4" },
{"B760M GAMING X AX", "Z790-S-DDR4" },
{"B760M GAMING X AX DDR4", "Z790-S-DDR4" },
{"B760M GAMING X DDR4", "Z790-S-DDR4" },
{"B760M POWER", "B760M-D2H" },
{"B760M POWER DDR4", "B760M-D2H" },
{"H610M D3H DDR4", "B860I-Pro" },
{"H610M D3H WIFI DDR4", "B860I-Pro" },
{"H610M GAMING WIFI DDR4", "B860I-Pro" },
{"TRX50 AERO D", "TRX50-AERO-D" },
{"X570S AERO G", "X670-ELITE" },
{"X570S AORUS ELITE", "X570S-ELITE" },
{"X570S AORUS ELITE AX", "X570S-ELITE" },
{"X570S AORUS MASTER", "X570S-A-MSTR" },
{"X570S AORUS PRO AX", "X570S-PRO-AX" },
{"X570S GAMING X", "X570S-ELITE" },
{"X570S UD", "X670-ELITE" },
{"X570SI AORUS PRO AX", "B550I-AORUS-PRO-AX" },
{"X670 AORUS ELITE AX", "X670-ELITE" },
{"X670 GAMING X AX", "X670-ELITE" },
{"X670 GAMING X AX V2", "B650-Eagle-AX" },
{"X670E AORUS MASTER", "MSTR_ATX_2" },
{"X670E AORUS PRO X", "X670-A-PRO-X" },
{"X670E AORUS XTREME", "MSTR_ATX_2" },
{"Z690 AORUS ELITE", "Z690-ELITE" },
{"Z690 AORUS ELITE AX", "Z690-ELITE" },
{"Z690 AORUS ELITE AX DDR4", "Z690-ELITE" },
{"Z690 AORUS ELITE DDR4", "Z690-ELITE" },
{"Z790 AERO G", "Z790-S-DDR4" },
{"Z790 AORUS ELITE", "Z790-ELITE" },
{"Z790 AORUS ELITE AX", "Z790-ELITE" },
{"Z790 AORUS ELITE AX DDR4", "Z790-ELITE" },
{"Z790 AORUS ELITE AX ICE", "Z790-ELITE" },
{"Z790 AORUS ELITE AX-W", "Z790-ELITE" },
{"Z790 AORUS ELITE DDR4", "Z790-ELITE" },
{"Z790 AORUS ELITE X", "TRX50-AERO-D" },
{"Z790 AORUS ELITE X AX", "TRX50-AERO-D" },
{"Z790 AORUS ELITE X WIFI7", "TRX50-AERO-D" },
{"Z790 AORUS MASTER", "Z790-MSTR" },
{"Z790 AORUS MASTER X", "Z790-MSTR-X" },
{"Z790 AORUS PRO X", "Z790-PRO-X" },
{"Z790 AORUS PRO X WIFI7", "Z790-PRO-X" },
{"Z790 AORUS TACHYON", "Z790-XTRM" },
{"Z790 AORUS TACHYON X", "Z790-MSTR-X" },
{"Z790 AORUS XTREME", "Z790-XTRM" },
{"Z790 AORUS XTREME X", "Z790-XTRM-X" },
{"Z790 AORUS XTREME X ICE", "Z790-XTRM-X" },
{"Z790 D", "Z790-D" },
{"Z790 D AC", "Z790-D" },
{"Z790 D AX", "Z790-D" },
{"Z790 D WIFI", "Z790-D" },
{"Z790 EAGLE", "Z790-D" },
{"Z790 EAGLE AX", "Z790-D" },
{"Z790 GAMING PLUS AX", "Z790-S-DDR4" },
{"Z790 GAMING X", "Z790-S-DDR4" },
{"Z790 GAMING X AX", "Z790-S-DDR4" },
{"Z790 S DDR4", "Z790-S-DDR4" },
{"Z790 S WIFI DDR4", "Z790-S-DDR4" },
{"Z790 UD", "Z790-D" },
{"Z790 UD AC", "Z790-D" },
{"Z790 UD AX", "Z790-D" },
{"Z790I AORUS ULTRA", "B550I-AORUS-PRO-AX" },
{"Z790M AORUS ELITE", "Z790-ELITE" },
{"Z790M AORUS ELITE AX", "Z790-ELITE" },
{"Z790M AORUS ELITE AX ICE", "Z790-ELITE" },
};
const MBName MBName2LayoutLookup5711 =
{
{"A620I AX", "B650-D2H" },
{"A620M DS3H", "B650M-DS3H" },
{"A620M GAMING X", "B650M-DS3H" },
{"A620M GAMING X AX", "B650M-DS3H" },
{"A620M H", "B650M-DS3H" },
{"A620M S2H", "B650M-DS3H" },
{"B650E AORUS STEALTH ICE", "B650E-AORUS-STEALTH" },
{"B760 DS3H GEN5", "B840M-DS3H" },
{"B760 DS3H WIFI6E GEN5", "B840M-DS3H" },
{"B760 GAMING X DDR4 GEN5", "B840M-DS3H" },
{"B760 GAMING X GEN5", "B840M-DS3H" },
{"B760 GAMING X WIFI6 GEN5", "B840M-DS3H" },
{"B760M AORUS ELITE DDR4 GEN5", "X870-WIFI7" },
{"B760M AORUS ELITE GEN5", "X870-WIFI7" },
{"B760M AORUS ELITE WIFI6 DDR4 GEN5", "X870-WIFI7" },
{"B760M AORUS ELITE WIFI6 GEN5", "X870-WIFI7" },
{"B760M C V3", "B850-EGL-WIFI6" },
{"B760M DS3H DDR4 GEN 5", "B760M-DS3H-DR-G5" },
{"B760M DS3H WIFI6E DDR4 GEN 5", "B760M-DS3H-DR-G5" },
{"B760M GAMING WIFI6 PLUS GEN5", "B760M-DS3H-DR-G5" },
{"B760M GAMING WIFI6E GEN 5", "B760M-DS3H-DR-G5" },
{"B760M GAMING X DDR4 GEN5", "B850-AI-TOP" },
{"B760M GAMING X GEN5", "B850-AI-TOP" },
{"B760M GAMING X WIFI6E DDR4 GEN5", "B850-AI-TOP" },
{"B760M GAMING X WIFI6E GEN5", "B850-AI-TOP" },
{"B840M AORUS ELITE WIFI6E", "B840M-WIFI6E" },
{"B840M D2H", "B840M-DS3H" },
{"B840M DS3H", "B840M-DS3H" },
{"B840M EAGLE WIFI6", "B840M-DS3H" },
{"B850 AI Top", "B850-AI-TOP" },
{"B850 AORUS ELITE WIFI7", "X870-WIFI7" },
{"B850 AORUS ELITE WIFI7 ICE", "X870-WIFI7" },
{"B850 EAGLE ICE", "B850-EGL-WIFI6" },
{"B850 EAGLE WIFI6E", "B850-EGL-WIFI6" },
{"B850 EAGLE WIFI7 ICE", "B850-EGL-WIFI6" },
{"B850 GAMING WIFI6", "B850-EGL-WIFI6" },
{"B850 GAMING X WIFI6E", "B850-GMX-WIFI6" },
{"B850I AORUS PRO", "X870I-PRO" },
{"B850M AORUS ELITE", "B850-GMX-WIFI6" },
{"B850M AORUS ELITE WIFI6E", "B850-GMX-WIFI6" },
{"B850M AORUS ELITE WIFI6E ICE", "B850-GMX-WIFI6" },
{"B850M AORUS PRO WIFI7", "Z890-WIFI7" },
{"B850M D3HP", "X870I-PRO" },
{"B850M DS3H", "B850-EGL-WIFI6" },
{"B850M DS3H ICE", "B850-EGL-WIFI6" },
{"B850M EAGLE WIFI6E", "B850-EGL-WIFI6" },
{"B850M EAGLE WIFI6E ICE", "B850-EGL-WIFI6" },
{"B850M FORCE", "B850-EGL-WIFI6" },
{"B850M FORCE WIFI6E", "B850-EGL-WIFI6" },
{"B850M GAMING X WIFI6E", "B850-GMX-WIFI6" },
{"B860 AORUS ELITE WIFI7 ICE", "B860-WIFI7" },
{"B860 DS3H", "B860-DS3H" },
{"B860 DS3H WIFI6E", "B860-DS3H" },
{"B860 EAGLE WIFI6E", "B860-EGL-WIFI6" },
{"B860 GAMING X WIFI6E", "B860-DS3H" },
{"B860I AORUS PRO ICE", "B860I-Pro" },
{"B860M AORUS ELITE", "B860-WIFI7" },
{"B860M AORUS ELITE WIFI6E", "B860-WIFI7" },
{"B860M AORUS ELITE WIFI6E ICE", "B860-WIFI7" },
{"B860M AORUS PRO WIFI7", "B860-WIFI7" },
{"B860M D2H", "B860M-D2H" },
{"B860M EAGLE", "B860-EGL-P-WIFI6" },
{"B860M EAGLE DS3H", "B860-EGL-P-WIFI6" },
{"B860M EAGLE DS3H WIFI6E", "B860-EGL-P-WIFI6" },
{"B860M EAGLE PLUS WIFI6E", "B860-EGL-P-WIFI6" },
{"B860M EAGLE WIFI6", "B860-EGL-P-WIFI6" },
{"B860M EAGLE WIFI6 V2", "B860-EGL-P-WIFI6" },
{"B860M GAMING WIFI6", "B860M-D2H" },
{"B860M GAMING X", "B860-EGL-P-WIFI6" },
{"B860M GAMING X WIFI6E", "B860-EGL-P-WIFI6" },
{"B860M POWER", "B860-EGL-P-WIFI6" },
{"TRX50 AI TOP", "TRX50-A-TP" },
{"W790 AI TOP", "B850-AI-TOP" },
{"W880 AI TOP", "B850-AI-TOP" },
{"X870 AORUS ELITE WIFI7", "X870-WIFI7" },
{"X870 AORUS ELITE WIFI7 ICE", "X870-WIFI7" },
{"X870 EAGLE WIFI7", "X870-WIFI7" },
{"X870 GAMING WIFI6", "X870-WIFI7" },
{"X870 GAMING X WIFI", "X870-WIFI7" },
{"X870E AORUS ELITE WIFI7", "X870E-WIFI7" },
{"X870E AORUS ELITE WIFI7 ICE", "X870E-WIFI7" },
{"X870E AORUS MASTER", "X870E-MSTR" },
{"X870E AORUS PRO", "X870E-PRO" },
{"X870E AORUS PRO ICE", "X870E-PRO" },
{"X870E AORUS XTREME AI TOP", "X870E-XTRM-AI-TOP" },
{"X870I AORUS PRO", "X870I-PRO" },
{"X870I AORUS PRO ICE", "X870I-PRO" },
{"Z890 AERO D", "B850-AI-TOP" },
{"Z890 AERO G", "B850-AI-TOP" },
{"Z890 AI TOP", "B850-AI-TOP" },
{"Z890 AORUS ELITE WIFI7", "Z890-WIFI7" },
{"Z890 AORUS ELITE WIFI7 ICE", "Z890-WIFI7" },
{"Z890 AORUS ELITE X ICE", "Z890-WIFI7" },
{"Z890 AORUS MASTER", "Z890-MSTR" },
{"Z890 AORUS MASTER AI TOP", "Z890-MSTR-AI-TOP" },
{"Z890 AORUS PRO ICE", "Z890-WIFI7" },
{"Z890 AORUS TACHYON ICE", "B850-AI-TOP" },
{"Z890 AORUS XTREME AI TOP", "Z890-XTRM-AI-TOP" },
{"Z890 EAGLE", "Z890-WIFI7" },
{"Z890 EAGLE WIFI7", "Z890-WIFI7" },
{"Z890 GAMING X WIFI7", "Z890-WIFI7" },
{"Z890 UD WIFI6E", "B850-AI-TOP" },
{"Z890I AORUS ULTRA", "Z890-A-ULTRA" },
{"Z890M AORUS ELITE WIFI7", "Z890-WIFI7" },
{"Z890M AORUS ELITE WIFI7 ICE", "Z890-WIFI7" },
{"Z890M GAMING X", "X870I-PRO" },
};

View File

@@ -1,25 +0,0 @@
/*---------------------------------------------------------*\
| RGBController_GigabyteRGBFusion2USBBoards.h |
| |
| RGBController for Gigabyte Aorus RGB Fusion 2 USB |
| motherboard |
| |
| megadjc 31 Jul 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <map>
#include <string>
using MBName = std::map<std::string, std::string>;
extern const MBName MBName2LayoutLookup8297;
extern const MBName MBName2LayoutLookup8950;
extern const MBName MBName2LayoutLookup5702;
extern const MBName MBName2LayoutLookup5711;

View File

@@ -1,36 +0,0 @@
/*---------------------------------------------------------*\
| RGBController_GigabyteRGBFusion2USBLayouts.h |
| |
| RGBController for Gigabyte Aorus RGB Fusion 2 USB |
| motherboard |
| |
| megadjc 31 Jul 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <map>
#include <string>
#include <vector>
/* LED port definition */
struct LedPort
{
std::string name;
int header;
int count;
};
/* Type aliases */
using FwdLedHeaders = std::map<std::string, int>;
using RvrseLedHeaders = std::map<int, std::string>;
using ZoneLeds = std::map<std::string, std::vector<LedPort>>;
using KnownLayout = std::map<std::string, ZoneLeds>;
extern const KnownLayout HardcodedCustom_Gen1;
extern const KnownLayout HardcodedCustom_Gen2;
extern const KnownLayout knownLayoutsLookup;
extern const FwdLedHeaders LedLookup;