Moved GB_Fusion2USB calibration & custom layout loading to config file

+ Adding layout for Z390 AORUS MASTER-CF
+ Adding destructor to RGBController_GigabyteRGBFusion2USB.cpp to
'delete controller'

+ Allows custom layout saving to config
+ Custom config will save out to config if not present
+ Layout is enablable and disabled by default
+ Added a lookup map from mapping in config
+ Added a template for the reverse_map for saving to the config
+ Removed the header integers from the config to avoid invalid values
+ Changed internal mapping closer to JSON for ease of lookup
+ Added protection to the led count

+ Added calibration to config
* Disabled execution of calibration until explicitely enabled in config

Commit amended for code style of changes as well as general cleanup of RGB Fusion 2 USB controller by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
Chris 2021-04-15 11:06:04 +10:00 committed by Adam Honse
parent 9b2296b0bc
commit 727fd9efb9
5 changed files with 695 additions and 271 deletions

View file

@ -4,27 +4,59 @@
| Driver for Gigabyte Aorus RGB Fusion 2.0 |
| USB lighting controller |
| |
| jackun 1/8/2020 |
| Author: jackun 1/8/2020 |
| Maintainer: Chris M (Dr_No) |
\*-----------------------------------------*/
#include "GigabyteRGBFusion2USBController.h"
#include <algorithm>
#include <array>
#include <thread>
#include <chrono>
#include "ResourceManager.h"
#include "SettingsManager.h"
/*-------------------------------------------------------------------------*\
| This is stored as a uint32_t in the chip so is trasmitted LSB to MSB |
| Therefore the numbers represent the index where the controller will find |
| respective colour in a regular packet |
\*-------------------------------------------------------------------------*/
static RGBCalibration GigabyteCalibrationsLookup
{
{ "BGR", { 0x00, 0x01, 0x02, 0x00} },
{ "BRG", { 0x01, 0x00, 0x02, 0x00} },
{ "GRB", { 0x02, 0x00, 0x01, 0x00} },
{ "GBR", { 0x00, 0x02, 0x01, 0x00} },
{ "RGB", { 0x02, 0x01, 0x00, 0x00} },
{ "RBG", { 0x01, 0x02, 0x00, 0x00} }
};
static calibration GigabyteBoardCalibration
{
{ "D_LED1", "GRB" },
{ "D_LED2", "GRB" },
{ "Mainboard", "BGR" },
{ "Spare", "BGR" }
};
static LEDCount LedCountToEnum(unsigned int c)
{
if (c <= 32)
if(c <= 32)
{
return(LEDS_32);
if (c <= 64)
}
else if(c <= 64)
{
return(LEDS_64);
if (c <= 256)
}
else if(c <= 256)
{
return(LEDS_256);
if (c <= 512)
}
else if(c <= 512)
{
return(LEDS_512);
return(LEDS_1024);
}
else
{
return(LEDS_1024);
}
}
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name) : dev(handle)
@ -33,19 +65,23 @@ RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char
char text[64] = { 0x00 };
unsigned char buffer[64] = { 0x00 };
if( dev )
if(dev)
{
SetCalibration();
name = mb_name;
// hid report read needs 0x60 packet or it gives IO error
/*---------------------------------------------------------*\
| HID report read needs 0x60 packet or it gives IO error |
\*---------------------------------------------------------*/
SendPacket(0x60, 0x00);
buffer[0] = report_id;
res = hid_get_feature_report(dev, buffer, 64);
if( res > 0 )
buffer[0] = report_id;
res = hid_get_feature_report(dev, buffer, 64);
if(res > 0)
{
report = *reinterpret_cast<IT8297Report*>(buffer);
report = *reinterpret_cast<IT8297Report*>(buffer);
description = std::string(report.str_product, 32);
description.erase(std::find(description.begin(), description.end(), '\0'), description.end());
@ -59,6 +95,7 @@ RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char
D_LED1_count = LedCountToEnum(report.total_leds & 0x0F);
D_LED2_count = LedCountToEnum(report.total_leds & 0xF0);
}
location = path;
EnableBeat(false);
@ -75,61 +112,117 @@ void RGBFusion2USBController::SetMode(int m)
mode = m;
}
// Sets RGB color mapping to LED pins.
// "Custom" RGB packets don't seem to get remapped so use report.byteorderN and do it manually.
// Of course it all depends how we send data to the controller, but bios/rgb fusion 2 itself
// set it up like this.
RGBA RGBFusion2USBController::GetCalibration(std::string rgb_order)
{
/*-------------------------------------------------*\
| Check for RGB order string in calibration table |
| If not found return the "BGR" calibration |
\*-------------------------------------------------*/
if(GigabyteCalibrationsLookup.count(rgb_order))
{
return GigabyteCalibrationsLookup.find(rgb_order)->second;
}
else
{
return GigabyteCalibrationsLookup.find("BGR")->second;
}
}
void RGBFusion2USBController::SetCalibrationBuffer(std::string rgb_order, uint8_t* buffer, uint8_t offset)
{
RGBA rgb_cal;
int raw_size = sizeof(rgb_cal.raw) / sizeof(rgb_cal.raw[0]);
rgb_cal = GetCalibration(rgb_order);
for(int i = 0; i < raw_size; i++)
{
buffer[offset + i] = rgb_cal.raw[i];
}
}
/*---------------------------------------------------------------------------------------------*\
| Sets RGB color mapping to LED pins. |
| "Custom" RGB packets don't seem to get remapped so use report.byteorderN and do it manually. |
| Of course it all depends how we send data to the controller, but bios/rgb fusion 2 itself |
| set it up like this. |
\*---------------------------------------------------------------------------------------------*/
void RGBFusion2USBController::SetCalibration()
{
uint8_t buffer[64] {};
buffer[0] = report_id;
buffer[1] = 0x33;
const std::string detector_name = "Gigabyte RGB Fusion 2 USB";
const std::string json_cal = "Calibration";
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
json device_settings = settings_manager->GetSettings(detector_name);
// D_LED1 WS2812 GRB, 0x00RRGGBB to 0x00GGRRBB
buffer[2] = 0x02; // B
buffer[3] = 0x00; // G
buffer[4] = 0x01; // R
buffer[5] = 0x00;
/*---------------------------------------------------------*\
| Get Layouts from the settings manager |
| If Calibration settings are not found then write them out |
| Calibration will only be executed if it is explicitly |
| enabled by the user |
\*---------------------------------------------------------*/
if(!device_settings.contains(json_cal))
{
device_settings[json_cal]["Enabled"] = false;
device_settings[json_cal]["Data"] = GigabyteBoardCalibration;
// D_LED2 WS2812 GRB
buffer[6] = 0x02;
buffer[7] = 0x00;
buffer[8] = 0x01;
buffer[9] = 0x00;
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
}
else if(device_settings[json_cal]["Enabled"])
{
GigabyteBoardCalibration["D_LED1"] = device_settings[json_cal]["Data"]["D_LED1"];
GigabyteBoardCalibration["D_LED2"] = device_settings[json_cal]["Data"]["D_LED2"];
GigabyteBoardCalibration["Mainboard"] = device_settings[json_cal]["Data"]["Mainboard"];
GigabyteBoardCalibration["Spare"] = device_settings[json_cal]["Data"]["Spare"];
// LED C1/C2 12vGRB, seems pins already connect to LEDs correctly
buffer[10] = 0x00;
buffer[11] = 0x01;
buffer[12] = 0x02;
buffer[13] = 0x00;
uint8_t buffer[64] = { 0x00 };
buffer[0] = report_id;
buffer[1] = 0x33;
// Spare set seen in some Motherboard models
buffer[14] = 0x00;
buffer[15] = 0x01;
buffer[16] = 0x02;
buffer[17] = 0x00;
SetCalibrationBuffer( GigabyteBoardCalibration.find("D_LED1")->second, buffer, 2);
SetCalibrationBuffer( GigabyteBoardCalibration.find("D_LED2")->second, buffer, 6);
SetCalibrationBuffer( GigabyteBoardCalibration.find("Mainboard")->second, buffer, 10);
SetCalibrationBuffer( GigabyteBoardCalibration.find("Spare")->second, buffer, 14);
SendPacket(buffer);
SendPacket(buffer);
}
}
void RGBFusion2USBController::SetLedCount(unsigned int led, unsigned int count)
{
//Check which Digital LED we're setting then send the value of both
( led == HDR_D_LED1 ) ? D_LED1_count = LedCountToEnum(count) : D_LED2_count = LedCountToEnum(count);
/*-----------------------------------------------------------------*\
| Check which Digital LED we're setting then send the value of both |
\*-----------------------------------------------------------------*/
if(led == HDR_D_LED1)
{
D_LED1_count = LedCountToEnum(count);
}
else
{
D_LED2_count = LedCountToEnum(count);
}
SendPacket(0x34, D_LED1_count | (D_LED2_count << 4));
}
bool RGBFusion2USBController::DisableBuiltinEffect(int enable_bit, int mask)
{
if(effect_disabled & enable_bit)
{
return(true);
}
effect_disabled &= ~mask;
effect_disabled |= enable_bit;
int res = SendPacket(0x32, effect_disabled);
// Sometimes effect doesn't apply at first, delay a little and let MCU to react, if this packet is the cause
/*-----------------------------------------------------------------*\
| Sometimes effect doesn't apply at first, delay a little and let |
| MCU react, if this packet is the cause |
\*-----------------------------------------------------------------*/
std::this_thread::sleep_for(std::chrono::milliseconds(50));
return res;
}
@ -174,37 +267,50 @@ void RGBFusion2USBController::SetStripColors
PktRGB pkt;
pkt.Init(hdr, report_id);
// FIXME assuming that LED strips ports are 0x58/0x59 for all boards
uint32_t byteorder = hdr == HDR_D_LED1_RGB ? report.byteorder0 : report.byteorder1;
/*-------------------------------------------------------------------------*\
| FIXME assuming that LED strips ports are 0x58/0x59 for all boards |
\*-------------------------------------------------------------------------*/
uint32_t byteorder;
if(hdr == HDR_D_LED1_RGB)
{
byteorder = report.byteorder0;
}
else
{
byteorder = report.byteorder1;
}
unsigned char bo_r = byteorder >> 16;
unsigned char bo_g = byteorder >> 8;
unsigned char bo_b = byteorder & 0xFF;
unsigned char bo_r = byteorder >> 16;
unsigned char bo_g = byteorder >> 8;
unsigned char bo_b = byteorder & 0xFF;
int res;
int leds_left = num_colors;
int sent_data = 0;
int k = 0;
int leds_in_pkt = sizeof(pkt.s.leds) / sizeof(*pkt.s.leds); /* 19 */
int leds_left = num_colors;
int sent_data = 0;
int k = 0;
int leds_in_pkt = sizeof(pkt.s.leds) / sizeof(*pkt.s.leds); /* 19 */
// other leds stay at whatever the builtin effect was doing at that moment
// if breathing/pulse effect faded out then they stay dark
/*-------------------------------------------------------------------------*\
| Other leds stay at whatever the builtin effect was doing at that moment |
| if breathing/pulse effect faded out then they stay dark |
\*-------------------------------------------------------------------------*/
if(single_led > -1)
{
leds_left = 1;
k = single_led;
sent_data = k * 3;
leds_in_pkt = 1;
leds_left = 1;
k = single_led;
sent_data = k * 3;
leds_in_pkt = 1;
}
while(leds_left > 0)
{
leds_in_pkt = (std::min)(leds_in_pkt, leds_left);
leds_left -= leds_in_pkt;
leds_in_pkt = (std::min)(leds_in_pkt, leds_left);
leds_left -= leds_in_pkt;
pkt.s.bcount = leds_in_pkt * 3;
pkt.s.boffset = sent_data;
sent_data += pkt.s.bcount;
pkt.s.bcount = leds_in_pkt * 3;
pkt.s.boffset = sent_data;
sent_data += pkt.s.bcount;
for(int i = 0; i < leds_in_pkt; i++)
{
@ -220,35 +326,46 @@ void RGBFusion2USBController::SetStripColors
}
res = SendPacket(pkt.buffer);
if(res < 0)
{
return;
}
}
if (hdr == HDR_D_LED1_RGB)
if(hdr == HDR_D_LED1_RGB)
{
DisableBuiltinEffect(0x01, 0x01);
}
else
{
DisableBuiltinEffect(0x02, 0x02);
}
}
static const std::array< std::array<int, 3>, 5> speeds = {
static const std::array< std::array<int, 3>, 5> speeds =
{
{
{1600, 1600, 200},
{1200, 1200, 200},
{800, 800, 200},
{400, 400, 200},
{200, 200, 200},
{1600, 1600, 200},
{1200, 1200, 200},
{800, 800, 200},
{400, 400, 200},
{200, 200, 200},
},
};
void RGBFusion2USBController::SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char r, unsigned char g, unsigned char b)
{
PktEffect pkt;
pkt.Init(led, report_id);
pkt.e.effect_type = mode;
pkt.e.color0 = r << 16 | g << 8 | b;
if (speed < speeds.size()) {
const auto& s = speeds[speed];
pkt.Init(led, report_id);
pkt.e.effect_type = mode;
pkt.e.color0 = r << 16 | g << 8 | b;
if(speed < speeds.size())
{
const std::array<int, 3>& s = speeds[speed];
pkt.e.period0 = s[0];
pkt.e.period1 = s[1];
pkt.e.period2 = s[2];
@ -256,27 +373,42 @@ void RGBFusion2USBController::SetLEDEffect(unsigned int led, int mode, unsigned
switch(mode)
{
case 0: break;
case 1: break; // static
case 2: // breathing
case 3: // blink
if (random)
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
break;
case 4: // color cycle
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
break;
case 0:
break;
// "fake" effects
case 10: // flashing, flashing color cycle
pkt.e.period0 = 200;
pkt.e.period1 = 200;
pkt.e.period2 = 5000 - 1000 * speed; // time between flashing, doesn't seem to be affected by period0/period1
pkt.e.effect_type = 3;
pkt.e.effect_param2 = 2; // flash twice
if (random)
pkt.e.effect_param0 = 7;
break;
// Static
case 1:
break;
// Breathing
case 2:
// Blink
case 3:
if(random)
{
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
}
break;
// Color Cycle
case 4:
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
break;
// "Fake" effects
case 10: // flashing, flashing color cycle
pkt.e.period0 = 200;
pkt.e.period1 = 200;
pkt.e.period2 = 5000 - 1000 * speed; // time between flashing, doesn't seem to be affected by period0/period1
pkt.e.effect_type = 3;
pkt.e.effect_param2 = 2; // flash twice
if (random)
{
pkt.e.effect_param0 = 7;
}
break;
}
SendPacket(pkt.buffer);
@ -290,11 +422,13 @@ bool RGBFusion2USBController::ApplyEffect()
bool RGBFusion2USBController::SendPacket(uint8_t a, uint8_t b, uint8_t c)
{
unsigned char buffer[64] {};
buffer[0] = report_id;
buffer[1] = a;
buffer[2] = b;
buffer[3] = c;
return (SendPacket(buffer) == 64);
return(SendPacket(buffer) == 64);
}
int RGBFusion2USBController::SendPacket(unsigned char* packet)

View file

@ -4,41 +4,67 @@
| Definitions and types for Gigabyte Aorus |
| RGB Fusion 2.0 USB lighting controller |
| |
| jackun 1/8/2020 |
| Author: jackun 1/8/2020 |
| Maintainer: Chris M (Dr_No) |
\*-----------------------------------------*/
#include "RGBController.h"
#include <algorithm>
#include <array>
#include <chrono>
#include <cstring>
#include <hidapi/hidapi.h>
#include <map>
#include <thread>
#pragma once
// LED "headers" 0x20..0x27, As seen on Gigabyte X570 Elite board
const uint8_t HDR_BACK_IO = 0x20;
const uint8_t HDR_CPU = 0x21;
const uint8_t HDR_LED_2 = 0x22;
const uint8_t HDR_PCIE = 0x23;
const uint8_t HDR_LED_C1C2 = 0x24;
const uint8_t HDR_D_LED1 = 0x25;
const uint8_t HDR_D_LED2 = 0x26;
const uint8_t HDR_LED_7 = 0x27;
#define GB_CALIBRATION_SIZE (sizeof(GB_Calibrations) / sizeof(GB_Calibrations[0]))
const uint8_t HDR_D_LED1_RGB = 0x58; // FIXME assuming that it is 0x58 for all boards
/*-------------------------------------------------------------*\
| Standardising LED naming for external config layout |
\*-------------------------------------------------------------*/
const uint8_t LED1 = 0x20;
const uint8_t LED2 = 0x21;
const uint8_t LED3 = 0x22;
const uint8_t LED4 = 0x23;
const uint8_t LED5 = 0x24;
const uint8_t LED6 = 0x25;
const uint8_t LED7 = 0x26;
const uint8_t LED8 = 0x27;
/*-------------------------------------------------------------*\
| LED "headers" 0x20..0x27, As seen on Gigabyte X570 Elite board|
| Internal legacy shorthand naming and possibly depracated |
\*-------------------------------------------------------------*/
const uint8_t HDR_BACK_IO = LED1;
const uint8_t HDR_CPU = LED2;
const uint8_t HDR_LED_2 = LED3;
const uint8_t HDR_PCIE = LED4;
const uint8_t HDR_LED_C1C2 = LED5;
const uint8_t HDR_D_LED1 = LED6;
const uint8_t HDR_D_LED2 = LED7;
const uint8_t HDR_LED_7 = LED8;
/*-------------------------------------------------------------*\
| FIXME assuming that it is 0x58 for all boards |
\*-------------------------------------------------------------*/
const uint8_t HDR_D_LED1_RGB = 0x58;
const uint8_t HDR_D_LED2_RGB = 0x59;
enum EffectType
{
EFFECT_NONE = 0,
EFFECT_STATIC = 1,
EFFECT_PULSE = 2,
EFFECT_BLINKING = 3,
EFFECT_COLORCYCLE = 4,
EFFECT_NONE = 0,
EFFECT_STATIC = 1,
EFFECT_PULSE = 2,
EFFECT_BLINKING = 3,
EFFECT_COLORCYCLE = 4,
// to be continued...
};
enum LEDCount
{
LEDS_32 = 0,
LEDS_32 = 0,
LEDS_64,
LEDS_256,
LEDS_512,
@ -54,6 +80,24 @@ struct LEDs
#pragma pack(push, 1)
struct RGBA
{
union
{
uint8_t raw[4];
struct
{
uint8_t blue;
uint8_t green;
uint8_t red;
uint8_t alpha;
};
};
};
typedef std::map< std::string, RGBA > RGBCalibration;
typedef std::map< std::string, std::string> calibration;
union PktRGB
{
unsigned char buffer[64];
@ -61,7 +105,7 @@ union PktRGB
{
uint8_t report_id;
uint8_t header;
uint16_t boffset; // in bytes, absolute
uint16_t boffset; // In bytes, absolute
uint8_t bcount;
LEDs leds[19];
uint16_t padding0;
@ -88,7 +132,7 @@ union PktEffect
{
uint8_t report_id;
uint8_t header;
uint32_t zone0; // rgb fusion seems to set it to pow(2, header - 0x20)
uint32_t zone0; // RGB Fusion seems to set it to pow(2, header - 0x20)
uint32_t zone1;
uint8_t reserved0;
uint8_t effect_type;
@ -96,9 +140,9 @@ union PktEffect
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 period0; // Fade in
uint16_t period1; // Fade out
uint16_t period2; // Hold
uint16_t period3;
uint8_t effect_param0;
uint8_t effect_param1;
@ -114,24 +158,31 @@ union PktEffect
void Init(int header, uint8_t report_id)
{
memset(buffer, 0, sizeof(buffer));
e.report_id = report_id;
if (header < 8)
e.header = 32 + header; // set as default
e.report_id = report_id;
if(header < 8)
{
e.header = 32 + header; // Set as default
}
else
e.header = header;
e.zone0 = (uint32_t)(1 << (e.header - 32));
e.effect_type = EFFECT_STATIC;
e.max_brightness = 100;
e.min_brightness = 0;
e.color0 = 0x00FF2100; //orange
e.period0 = 1200;
e.period1 = 1200;
e.period2 = 200;
e.period3 = 200;
e.effect_param0 = 0; // ex color count to cycle through (max seems to be 7)
e.effect_param1 = 0;
e.effect_param2 = 1; // ex flash repeat count
e.effect_param3 = 0;
{
e.header = header;
}
e.zone0 = (uint32_t)(1 << (e.header - 32));
e.effect_type = EFFECT_STATIC;
e.max_brightness = 100;
e.min_brightness = 0;
e.color0 = 0x00FF2100; //orange
e.period0 = 1200;
e.period1 = 1200;
e.period2 = 200;
e.period3 = 200;
e.effect_param0 = 0; // ex color count to cycle through (max seems to be 7)
e.effect_param1 = 0;
e.effect_param2 = 1; // ex flash repeat count
e.effect_param3 = 0;
}
};
@ -144,8 +195,8 @@ struct IT8297Report
uint32_t fw_ver;
uint16_t curr_led_count;
uint16_t reserved0;
char str_product[32]; // might be 28 and an extra byteorder3
uint32_t byteorder0; // is little-endian 0x00RRGGBB ?
char str_product[32]; // might be 28 and an extra byteorder3
uint32_t byteorder0; // is little-endian 0x00RRGGBB ?
uint32_t byteorder1;
uint32_t byteorder2;
uint32_t chip_id;
@ -184,6 +235,8 @@ private:
bool EnableBeat(bool enable);
bool SendPacket(uint8_t a, uint8_t b, uint8_t c = 0);
int SendPacket(unsigned char* packet);
RGBA GetCalibration( std::string rgb_order);
void SetCalibrationBuffer(std::string rgb_order, uint8_t* buffer, uint8_t offset);
hid_device* dev;
int mode;

View file

@ -2,6 +2,7 @@
#include "GigabyteRGBFusion2USBController.h"
#include "RGBController_GigabyteRGBFusion2USB.h"
#include "dependencies/dmiinfo.h"
#define DETECTOR_NAME "Gigabyte RGB Fusion 2 USB"
#define IT8297_VID 0x048D
#define IT8297_IFC 0
@ -22,18 +23,18 @@ void DetectGigabyteRGBFusion2USBControllers(hid_device_info* info, const std::st
hid_device* dev = hid_open_path(info->path);
if (dev)
{
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, info->path, MB_info.getMainboard());
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller);
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, info->path, MB_info.getMainboard());
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller, DETECTOR_NAME);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
} /* DetectRGBFusion2USBControllers() */
#ifdef USE_HID_USAGE
REGISTER_HID_DETECTOR_PU("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_UPG, IT8297_U);
REGISTER_HID_DETECTOR_PU("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_UPG, IT8297_U);
REGISTER_HID_DETECTOR_PU(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_UPG, IT8297_U);
REGISTER_HID_DETECTOR_PU(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_UPG, IT8297_U);
#else
REGISTER_HID_DETECTOR_I("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_IFC);
REGISTER_HID_DETECTOR_I("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_IFC);
REGISTER_HID_DETECTOR_I(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_IFC);
REGISTER_HID_DETECTOR_I(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_IFC);
#endif

View file

@ -4,26 +4,84 @@
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 USB Driver |
| |
| jackun 1/8/2020 |
| Author: jackun 1/8/2020 |
| Maintainer: Chris M (Dr_No) |
\*-----------------------------------------*/
#include "RGBController_GigabyteRGBFusion2USB.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include <sstream>
#include <array>
static const MBName MBName2Layout
/*-------------------------------------------------*\
| LedHeaders is a map of the led header addresses |
\*-------------------------------------------------*/
static FwdLedHeaders LedLookup
{
{"B550 AORUS PRO", "STD_ATX"},
{"B550 AORUS ELITE", "STD_ATX"},
{"X570 AORUS ELITE", "STD_ATX"},
{"X570 AORUS ELITE WIFI", "STD_ATX"},
{"X570 AORUS PRO WIFI", "STD_ATX"},
{"X570 AORUS ULTRA", "STD_ATX"},
{"B550I AORUS PRO AX", "ITX"},
{"X570 I AORUS PRO WIFI", "ITX"}
{"LED1", 0x20}, {"LED2", 0x21}, {"LED3", 0x22}, {"LED4", 0x23},
{"LED5", 0x24}, {"LED6", 0x25}, {"LED7", 0x26}, {"LED8", 0x27},
{"D_LED1", 0x58}, {"D_LED2", 0x59},
};
static const KnownLayout knownLayoutsLookup
/*-------------------------------------------------*\
| This is the default knownLayouts structure and |
| will be written into config if it doesn't exist |
\*-------------------------------------------------*/
static MBName MBName2LayoutLookup
{
{"B550 AORUS ELITE", "STD_ATX"},
{"B550 AORUS PRO", "STD_ATX"},
{"B550I AORUS PRO AX", "ITX"},
{"X570 AORUS ELITE", "STD_ATX"},
{"X570 AORUS ELITE WIFI", "STD_ATX"},
{"X570 AORUS PRO WIFI", "STD_ATX"},
{"X570 AORUS ULTRA", "STD_ATX"},
{"X570 I AORUS PRO WIFI", "ITX"},
{"Z390 AORUS MASTER-CF", "MSTR_ATX"}
};
/*-------------------------------------------------*\
| This is the default Custom layout that will be |
| written into config if it doesn't exist |
\*-------------------------------------------------*/
static const KnownLayout HardcodedCustom
{
{
"Custom",
{
{
"Motherboard",
{
{ "Name for Led 1", LED1, 1 },
{ "Name for Led 2", LED2, 1 },
{ "Name for Led 3", LED3, 1 },
{ "Name for Led 4", LED4, 1 },
{ "Name for Led 5", LED5, 1 },
{ "Name for Led 8", LED8, 1 },
}
},
{
"D_LED1 Bottom",
{
{ "Name for LED Strip 1", HDR_D_LED1, 0 },
}
},
{
"D_LED2 Top",
{
{ "Name for LED Strip 2", HDR_D_LED2, 0 },
}
}
}
}
};
/*-------------------------------------------------*\
| KnownLayoutsLookup now needs to be variable to |
| allow for a custom addition from config |
\*-------------------------------------------------*/
static KnownLayout knownLayoutsLookup
{
{
"IT8297BX-GBX570", //Left as a catch all
@ -31,26 +89,26 @@ static const KnownLayout knownLayoutsLookup
{
"Motherboard",
{
{ "Led 1", 0x20, 1 },
{ "Led 2", 0x21, 1 },
{ "Led 3", 0x22, 1 },
{ "Led 4", 0x23, 1 },
{ "Led 5", 0x24, 1 },
{ "Led 6", 0x25, 1 },
{ "Led 7", 0x26, 1 },
{ "Led 8", 0x27, 1 },
{ "Name for Led 1", LED1, 1 },
{ "Name for Led 2", LED2, 1 },
{ "Name for Led 3", LED3, 1 },
{ "Name for Led 4", LED4, 1 },
{ "Name for Led 5", LED5, 1 },
{ "Name for Led 6", LED6, 1 },
{ "Name for Led 7", LED7, 1 },
{ "Name for Led 8", LED8, 1 },
}
},
{
"D_LED1 Bottom",
{
{ "LED Strip 1", HDR_D_LED1, 0 },
{ "Name for LED Strip 1", HDR_D_LED1, 0 },
}
},
{
"D_LED2 Top",
{
{ "LED Strip 2", HDR_D_LED2, 0 },
{ "Name for LED Strip 2", HDR_D_LED2, 0 },
}
}
}
@ -102,87 +160,115 @@ static const KnownLayout knownLayoutsLookup
}
}
},
{
"MSTR_ATX",
{
{
"Digital Headers",
{
{ "D_LED1 / D_LED2", LED6, 0},
}
},
{
"ARGB Strip",
{
{ "Back IO / VRM", LED7, 0},
}
},
{
"Motherboard",
{
{ "XMP Logo", LED2, 1},
{ "Chipset Logo", LED3, 1},
{ "PCIe", LED4, 1},
{ "LED C1/C2", LED5, 1},
}
}
}
},
};
RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr)
RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr, std::string detector)
{
controller = controller_ptr;
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "Gigabyte";
type = DEVICE_TYPE_MOTHERBOARD;
description = controller->GetDeviceDescription();
version = controller->GetFWVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerial();
name = controller->GetDeviceName();
detector_name = detector;
vendor = "Gigabyte";
type = DEVICE_TYPE_MOTHERBOARD;
description = controller->GetDeviceDescription();
version = controller->GetFWVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerial();
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Static;
Static.name = "Static";
Static.value = EFFECT_STATIC;
Static.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.colors_min = 1;
Static.colors_max = 1;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.name = "Static";
Static.value = EFFECT_STATIC;
Static.flags = MODE_FLAG_HAS_BRIGHTNESS | 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 = EFFECT_PULSE;
Breathing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.speed_min = 0;
Breathing.speed_max = 4;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.name = "Breathing";
Breathing.value = EFFECT_PULSE;
Breathing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.speed_min = 0;
Breathing.speed_max = 4;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors.resize(1);
Breathing.speed = 2;
Breathing.speed = 2;
modes.push_back(Breathing);
mode Blinking;
Blinking.name = "Blinking";
Blinking.value = EFFECT_BLINKING;
Blinking.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Blinking.speed_min = 0;
Blinking.speed_max = 4;
Blinking.colors_min = 1;
Blinking.colors_max = 1;
Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC;
Blinking.name = "Blinking";
Blinking.value = EFFECT_BLINKING;
Blinking.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Blinking.speed_min = 0;
Blinking.speed_max = 4;
Blinking.colors_min = 1;
Blinking.colors_max = 1;
Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC;
Blinking.colors.resize(1);
Blinking.speed = 2;
Blinking.speed = 2;
modes.push_back(Blinking);
mode ColorCycle;
ColorCycle.name = "Color Cycle";
ColorCycle.value = EFFECT_COLORCYCLE;
ColorCycle.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
ColorCycle.speed_min = 0;
ColorCycle.speed_max = 4;
ColorCycle.color_mode = MODE_COLORS_NONE;
ColorCycle.speed = 2;
ColorCycle.name = "Color Cycle";
ColorCycle.value = EFFECT_COLORCYCLE;
ColorCycle.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
ColorCycle.speed_min = 0;
ColorCycle.speed_max = 4;
ColorCycle.color_mode = MODE_COLORS_NONE;
ColorCycle.speed = 2;
modes.push_back(ColorCycle);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = 10;
Flashing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Flashing.speed_min = 0;
Flashing.speed_max = 4;
Flashing.colors_min = 1;
Flashing.colors_max = 1;
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flashing.name = "Flashing";
Flashing.value = 10;
Flashing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Flashing.speed_min = 0;
Flashing.speed_max = 4;
Flashing.colors_min = 1;
Flashing.colors_max = 1;
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flashing.colors.resize(1);
Flashing.speed = 2;
Flashing.speed = 2;
modes.push_back(Flashing);
Init_Controller(); //Only processed on first run
Load_Device_Config();
Init_Controller();
SetupZones();
}
@ -191,38 +277,159 @@ RGBController_RGBFusion2USB::~RGBController_RGBFusion2USB()
delete controller;
}
void RGBController_RGBFusion2USB::Load_Device_Config()
{
const std::string SectionLayout = "MotherboardLayouts";
const std::string SectionCustom = "CustomLayout";
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
json device_settings = settings_manager->GetSettings(detector_name);
RvrseLedHeaders ReverseLedLookup = reverse_map(LedLookup);
/*-------------------------------------------------*\
| Get Layouts from the settings manager |
| If MotherboardLayouts is not found then write it |
| to settings |
\*-------------------------------------------------*/
if(!device_settings.contains(SectionLayout))
{
device_settings[SectionLayout] = MBName2LayoutLookup;
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
MBName2Layout = MBName2LayoutLookup;
}
else
{
for(nlohmann::detail::iteration_proxy_value<nlohmann::detail::iter_impl<nlohmann::json>>& it : device_settings[SectionLayout].items())
{
MBName2Layout.insert( std::pair<std::string, std::string>(it.key(), it.value() ));
}
}
/*-------------------------------------------------*\
| Get Custom Layout from the settings manager |
\*-------------------------------------------------*/
layout = HardcodedCustom.find("Custom")->second;
if (!device_settings.contains(SectionCustom))
{
/*---------------------------------------------*\
| If the Custom layout is not found then write |
| it to settings |
\*---------------------------------------------*/
json json_HCL;
for(ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); zl++)
{
std::vector<LedPort> v_lp = zl->second;
json json_zl;
for(std::vector<LedPort>::iterator lp_it = v_lp.begin(); lp_it != v_lp.end(); lp_it++)
{
json json_lp;
json_lp["name"] = lp_it[0].name;
json_lp["header"] = ReverseLedLookup.find(lp_it[0].header)->second;
json_zl.push_back(json_lp);
}
json_HCL.emplace(zl->first, json_zl);
}
device_settings[SectionCustom]["Enabled"] = false;
device_settings[SectionCustom]["Data"] = json_HCL;
settings_manager->SetSettings(detector_name, device_settings);
settings_manager->SaveSettings();
}
else
{
custom_layout = device_settings[SectionCustom]["Enabled"];
/*---------------------------------------------*\
| If the Custom layout is found and enabled |
| then read it in from config |
\*---------------------------------------------*/
if(custom_layout)
{
json json_HCL = device_settings[SectionCustom]["Data"];
layout.clear();
for(nlohmann::detail::iteration_proxy_value<nlohmann::detail::iter_impl<nlohmann::json>>& json_layout_it : json_HCL.items())
{
json json_zl = json_layout_it.value();
std::vector<LedPort> v_lp;
for(json& zl : json_zl)
{
json json_vlp = zl;
LedPort lp;
/*---------------------------------*\
| Initialize the name, header, and |
| count values. Set the D_LED |
| headers LED count to 0 |
\*---------------------------------*/
lp.name = json_vlp["name"].get<std::string>();
lp.header = LedLookup.find(json_vlp["header"].get<std::string>())->second;
lp.count = ((lp.header == LED6) || (lp.header == LED7)) ? 0 : 1;
v_lp.push_back(lp);
}
layout.insert(std::pair<std::string,std::vector<LedPort>>(json_layout_it.key(),v_lp));
}
}
}
}
void RGBController_RGBFusion2USB::Init_Controller()
{
/*---------------------------------------------------------*\
| Look up channel map based on device name |
\*---------------------------------------------------------*/
if ( MBName2Layout.count(controller->GetDeviceName()) ) //Quick way to get a boolean on find()
if (!custom_layout)
{
layout = knownLayoutsLookup.find(MBName2Layout.find(controller->GetDeviceName())->second )->second;
}
else
{
layout = knownLayoutsLookup.find("IT8297BX-GBX570")->second;
/*-----------------------------------------------------*\
| If the layout is custom then it's loaded and ready, |
| otherwise get known layouts |
| This check is a quick way to get a boolean on find() |
\*-----------------------------------------------------*/
if(MBName2Layout.count(controller->GetDeviceName()))
{
layout = knownLayoutsLookup.find(MBName2Layout.find(controller->GetDeviceName())->second )->second;
}
else
{
layout = knownLayoutsLookup.find("IT8297BX-GBX570")->second;
}
}
/*---------------------------------------------------------*\
| 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(ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); zl++)
{
std::vector<LedPort> lp = zl->second;
int LED_count = 0; //We're going to count the leds in the zone
bool boolSingleLED = true; //If all the Ledport.count == 1 then the zone is ZONE_TYPE_SINGLE
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++)
{
int lp_count = lp[lp_idx].count;
boolSingleLED = boolSingleLED && (lp_count == 1); //Is this a single LED zone??
LED_count += lp_count;
/*-------------------------------------------------*\
| Get LED count and check if it is a single LED zone|
\*-------------------------------------------------*/
int lp_count = lp[lp_idx].count;
single_zone = single_zone && (lp_count == 1);
LED_count += lp_count;
}
zones[zone_idx].name = zl->first;
zones[zone_idx].leds_min = (boolSingleLED) ? LED_count : RGBFusion2_Digital_LEDS_Min;
zones[zone_idx].leds_max = (boolSingleLED) ? LED_count : RGBFusion2_Digital_LEDS_Max;
zones[zone_idx].leds_count = (boolSingleLED) ? LED_count : 0; //Digital LEDS will not be set yet
zones[zone_idx].type = (boolSingleLED) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
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++;
}
@ -240,11 +447,11 @@ void RGBController_RGBFusion2USB::SetupZones()
| Set up zones |
\*---------------------------------------------------------*/
int zone_idx = 0;
for(ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); ++zl)
for(ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); zl++)
{
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE); //Calculated for later use
bool single_zone = (zones[zone_idx].type == ZONE_TYPE_SINGLE);
if (!boolSingleLED)
if(!single_zone)
{
controller->SetLedCount(zl->second.at(0).header, zones[zone_idx].leds_count);
controller->DisableBuiltinEffect(0, 0x3);
@ -252,22 +459,23 @@ void RGBController_RGBFusion2USB::SetupZones()
for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
{
led new_led;
led new_led;
if(boolSingleLED)
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 = zl->second.at(0).name;
new_led.name.append(" LED " + std::to_string(lp_idx));
new_led.value = zl->second.at(0).header;
}
leds.push_back(new_led);
}
zone_idx++;
}
@ -361,17 +569,17 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
\*---------------------------------------------------------*/
else
{
if(zones[zone].leds_count) //If the Digital zone has been resized i.e. > 0
if(zones[zone].leds_count)
{
unsigned char hdr = zones[zone].leds->value;
/*---------------------------------------------------------*\
| Direct mode |
| Direct mode addresses a different register |
\*---------------------------------------------------------*/
if(mode_value == 0xFFFF)
{
hdr += RGBFusion2_Digital_Direct_Offset; //Direct mode addresses a different register
controller->DisableBuiltinEffect(1, hdr == HDR_D_LED1_RGB ? 0x01 : 0x02);
hdr += RGBFusion2_Digital_Direct_Offset;
controller->DisableBuiltinEffect(1, ((hdr == HDR_D_LED1_RGB) ? 0x01 : 0x02));
controller->SetStripColors(hdr, zones[zone].colors, zones[zone].leds_count);
}
/*---------------------------------------------------------*\
@ -463,13 +671,19 @@ void RGBController_RGBFusion2USB::DeviceUpdateMode()
int RGBController_RGBFusion2USB::GetLED_Zone(int led_idx)
{
//This may be more useful in the abstract RGBController.cpp
for(size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
int zone_start = zones[zone_idx].start_idx;
int zone_end = zone_start + zones[zone_idx].leds_count - 1;
if( zone_start <= led_idx && zone_end >= led_idx)
return(zone_idx);
int zone_start = zones[zone_idx].start_idx;
int zone_end = zone_start + zones[zone_idx].leds_count - 1;
if((zone_start <= led_idx) && (zone_end >= led_idx))
{
return(zone_idx);
}
}
return -1; // NotFound error?
/*---------------------------------*\
| If zone is not found, return -1 |
\*---------------------------------*/
return(-1);
}

View file

@ -4,7 +4,8 @@
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 USB Driver |
| |
| jackun 1/8/2020 |
| Author: jackun 1/8/2020 |
| Maintainer: Chris M (Dr_No) |
\*-----------------------------------------*/
#pragma once
@ -13,25 +14,41 @@
#include <map>
#include <vector>
#define RGBFusion2_Digital_LEDS_Min 0;
#define RGBFusion2_Digital_LEDS_Max 1024;
#define RGBFusion2_Digital_Direct_Offset (HDR_D_LED1_RGB - HDR_D_LED1);
#define RGBFusion2_Digital_LEDS_Min 0;
#define RGBFusion2_Digital_LEDS_Max 1024;
#define RGBFusion2_Digital_Direct_Offset (HDR_D_LED1_RGB - HDR_D_LED1);
template<typename K, typename V>
static std::map<V, K> reverse_map(const std::map<K, V>& map)
{
std::map<V, K> reversed_map;
for(const std::pair<K, V>& entry : map)
{
reversed_map[entry.second] = entry.first;
}
return reversed_map;
}
typedef std::map< std::string, int > FwdLedHeaders;
typedef std::map< int, std::string > RvrseLedHeaders;
struct LedPort
{
const char* name;
int header;
int count;
std::string name;
int header;
int count;
};
typedef std::map< std::string, std::string > MBName;
typedef std::map< std::string, std::vector<LedPort> > ZoneLeds;
typedef std::map< std::string, ZoneLeds> KnownLayout;
typedef std::map< std::string, std::string > MBName;
typedef std::map< std::string, std::vector<LedPort> > ZoneLeds;
typedef std::map< std::string, ZoneLeds> KnownLayout;
class RGBController_RGBFusion2USB: public RGBController
{
public:
RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr);
RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr, std::string _detector_name);
~RGBController_RGBFusion2USB();
void SetupZones();
@ -46,10 +63,15 @@ public:
void DeviceUpdateMode();
private:
MBName MBName2Layout;
bool custom_layout;
std::string detector_name;
RGBFusion2USBController* controller;
IT8297Report report;
ZoneLeds layout;
void Load_Device_Config();
void Init_Controller();
int GetLED_Zone(int led_idx);
RGBFusion2USBController* controller;
IT8297Report report;
ZoneLeds layout;
};