From 503ad362565708e2a335a7cc7eb2a4e7735109c7 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Mon, 18 Aug 2025 19:46:00 +0000 Subject: [PATCH] Merge rework of IT8297, IT5702, IT5711 driver code. Adds new controller IT82950. --- .../GigabyteRGBFusion2USBController.cpp | 790 ++++--- .../GigabyteRGBFusion2USBController.h | 344 ++- .../GigabyteRGBFusion2USBControllerDetect.cpp | 16 +- .../RGBController_GigabyteRGBFusion2USB.cpp | 1242 +++++------ .../RGBController_GigabyteRGBFusion2USB.h | 22 +- ...Controller_GigabyteRGBFusion2USBBoards.cpp | 315 +++ ...GBController_GigabyteRGBFusion2USBBoards.h | 26 + ...ontroller_GigabyteRGBFusion2USBLayouts.cpp | 1935 +++++++++++++++++ ...BController_GigabyteRGBFusion2USBLayouts.h | 36 + 9 files changed, 3598 insertions(+), 1128 deletions(-) create mode 100644 Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.cpp create mode 100644 Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.h create mode 100644 Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.cpp create mode 100644 Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.h diff --git a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp index 24b6a3ef..5f5f552f 100644 --- a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp @@ -4,6 +4,7 @@ | Driver for Gigabyte Aorus RGB Fusion 2 USB motherboard | | | | jackun 08 Jan 2020 | +| megadjc 31 Jul 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-only | @@ -14,6 +15,7 @@ #include "SettingsManager.h" /*-------------------------------------------------------------------------*\ +| Low level RGB value conversion table | | 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 | @@ -28,14 +30,9 @@ static RGBCalibration GigabyteCalibrationsLookup { "RBG", {{{0x01, 0x02, 0x00, 0x00}}}} }; -static calibration GigabyteBoardCalibration -{ - { "D_LED1", "GRB" }, - { "D_LED2/D_LED3", "GRB" }, - { "Mainboard", "BGR" }, - { "Spare", "BGR" } -}; - +/*---------------------------------------------------------*\ +| Converts LED counts to divisions in hardware | +\*---------------------------------------------------------*/ static LEDCount LedCountToEnum(unsigned int c) { if(c <= 32) @@ -60,49 +57,21 @@ 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) +RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char* path, std::string mb_name, uint16_t pid): dev(handle), product_id(pid) { - int res = 0; - char text[64] = { 0x00 }; - unsigned char buffer[64] = { 0x00 }; - - if(dev) + name = mb_name; + location = path; + + if(!RefreshHardwareInfo()) { - SetCalibration(); - - name = mb_name; - - /*---------------------------------------------------------*\ - | 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) - { - report = *reinterpret_cast(buffer); - - description = std::string(report.str_product, 32); - description.erase(std::find(description.begin(), description.end(), '\0'), description.end()); - - snprintf(text, 11, "0x%08X", report.fw_ver); - version = text; - - snprintf(text, 11, "0x%08X", report.chip_id); - chip_id = text; - - D_LED1_count = LedCountToEnum(report.curr_led_count_low & 0x0F); - D_LED2_count = LedCountToEnum((report.curr_led_count_low >> 4) & 0x0F); - D_LED3_count = LedCountToEnum(report.curr_led_count_high & 0x0F); - } - - location = path; - - ResetController(pid); - EnableBeat(false); + return; } + if(report.support_cmd_flag >= 0x02) + { + EnableLampArray(false); + } + ResetController(); + EnableBeat(false); } RGBFusion2USBController::~RGBFusion2USBController() @@ -110,141 +79,382 @@ RGBFusion2USBController::~RGBFusion2USBController() hid_close(dev); } +/*---------------------------------------------------------*\ +| Read configuration data from hardware. | +| Returns false if read fails. | +\*---------------------------------------------------------*/ +bool RGBFusion2USBController::RefreshHardwareInfo() +{ + unsigned char buffer[64] = {0}; + + SendPacket(0x60, 0x00); + buffer[0] = report_id; + int res = hid_get_feature_report(dev, buffer, sizeof(buffer)); + + if(res < static_cast(sizeof(IT8297Report))) + { + report_loaded = false; + return false; + } + + std::memcpy(&report, buffer, sizeof(IT8297Report)); + report_loaded = true; + + description = std::string(report.str_product, 28); + if(std::string::iterator nul = std::find(description.begin(), description.end(), '\0'); + nul != description.end()) + { + description.erase(nul, description.end()); + } + + { + char text[32]{}; + + 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((fw_ver >> 24) & 0xFFu); + uint8_t b1 = static_cast((fw_ver >> 16) & 0xFFu); + uint8_t b2 = static_cast((fw_ver >> 8) & 0xFFu); + uint8_t b3 = static_cast( fw_ver & 0xFFu); + + std::snprintf(text, sizeof(text), "%u.%u.%u.%u", b0, b1, b2, b3); + version = text; + std::snprintf(text, sizeof(text), "0x%08X", report.chip_id); + chip_id = text; + } + + D_LED1_count = LedCountToEnum(report.curr_led_count_low & 0x0F); + D_LED2_count = LedCountToEnum((report.curr_led_count_low >> 4) & 0x0F); + D_LED3_count = LedCountToEnum(report.curr_led_count_high & 0x0F); + D_LED4_count = LedCountToEnum((report.curr_led_count_high >> 4) & 0x0F); + + cal_data.dled[0] = report.cal_strip0; + cal_data.dled[1] = report.cal_strip1; + cal_data.mainboard = report.rgb_cali; + cal_data.spare[0] = report.cal_spare0; + cal_data.spare[1] = report.cal_spare1; + + cali_loaded = false; + if(product_id == 0x5711) + { + unsigned char buffer2[64] = {0}; + SendPacket(0x61, 0x00); + buffer2[0] = report_id; + int res2 = hid_get_feature_report(dev, buffer2, sizeof(buffer2)); + + if(res2 >= static_cast(sizeof(IT5711Calibration))) + { + std::memcpy(&cali, buffer2, sizeof(IT5711Calibration)); + cali_loaded = true; + + cal_data.dled[2] = cali.cal_strip2; + cal_data.dled[3] = cali.cal_strip3; + cal_data.spare[2] = cali.cal_spare2; + cal_data.spare[3] = cali.cal_spare3; + } + else + { + cal_data.dled[2] = 0; + cal_data.dled[3] = 0; + cal_data.spare[2] = 0; + cal_data.spare[3] = 0; + cali_loaded = false; + } + } + else + { + cal_data.dled[2] = 0; + cal_data.dled[3] = 0; + cal_data.spare[2] = 0; + cal_data.spare[3] = 0; + } + + return report_loaded; +} + void RGBFusion2USBController::SetMode(int m) { mode = m; } -RGBA RGBFusion2USBController::GetCalibration(std::string rgb_order) +std::string RGBFusion2USBController::DecodeCalibrationBuffer(uint32_t value) const { - /*-------------------------------------------------*\ - | Check for RGB order string in calibration table | - | If not found return the "BGR" calibration | - \*-------------------------------------------------*/ - if(GigabyteCalibrationsLookup.count(rgb_order)) + if(value==0) return "OFF"; + + uint8_t bo_b = value & 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); + + if(in_range && distinct) { - return GigabyteCalibrationsLookup.find(rgb_order)->second; + std::string out(3, '?'); + out[bo_r] = 'R'; + out[bo_g] = 'G'; + out[bo_b] = 'B'; + return out; + } + + return "BAD"; +} + +uint32_t RGBFusion2USBController::EncodeCalibrationBuffer(const std::string& rgb_order) +{ + if(rgb_order.empty()) + { + return 0u; + } + + std::string key = rgb_order; + std::transform(key.begin(), key.end(), key.begin(), + [](unsigned char c){ return char(std::toupper(c)); }); + + if(key=="OFF" || key=="0") + { + return 0u; + } + + RGBCalibration::const_iterator it = GigabyteCalibrationsLookup.find(key); + if(it == GigabyteCalibrationsLookup.end()) + { + return 0u; + } + + const RGBA &rgb_cal = it->second; + 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); +} + + +EncodedCalibration RGBFusion2USBController::GetCalibration(bool refresh_from_hw) +{ + if(refresh_from_hw || !report_loaded || (product_id == 0x5711 && !cali_loaded)) + { + if(!RefreshHardwareInfo()) + { + return EncodedCalibration{}; + } + } + + EncodedCalibration out{}; + out.dled[0] = DecodeCalibrationBuffer(cal_data.dled[0]); + out.dled[1] = DecodeCalibrationBuffer(cal_data.dled[1]); + out.spare[0] = DecodeCalibrationBuffer(cal_data.spare[0]); + out.spare[1] = DecodeCalibrationBuffer(cal_data.spare[1]); + out.mainboard = DecodeCalibrationBuffer(cal_data.mainboard); + + if(product_id == 0x5711) + { + out.dled[2] = DecodeCalibrationBuffer(cal_data.dled[2]); + out.dled[3] = DecodeCalibrationBuffer(cal_data.dled[3]); + out.spare[2] = DecodeCalibrationBuffer(cal_data.spare[2]); + out.spare[3] = DecodeCalibrationBuffer(cal_data.spare[3]); } else { - return GigabyteCalibrationsLookup.find("BGR")->second; + out.dled[2] = "OFF"; + out.dled[3] = "OFF"; + out.spare[2] = "OFF"; + out.spare[3] = "OFF"; } + + return out; } -void RGBFusion2USBController::SetCalibrationBuffer(std::string rgb_order, uint8_t* buffer, uint8_t offset) +bool RGBFusion2USBController::SetCalibration(const EncodedCalibration& cal, bool refresh_from_hw) { - 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++) + if(refresh_from_hw) { - buffer[offset + i] = rgb_cal.raw[i]; + if(!RefreshHardwareInfo()) + { + return false; + } } + + if(EncodeCalibrationBuffer(cal.dled[0]) == cal_data.dled[0] + && EncodeCalibrationBuffer(cal.dled[1]) == cal_data.dled[1] + && EncodeCalibrationBuffer(cal.mainboard) == cal_data.mainboard + && EncodeCalibrationBuffer(cal.spare[0]) == cal_data.spare[0] + && EncodeCalibrationBuffer(cal.spare[1]) == cal_data.spare[1] + && (product_id != 0x5711 + || (EncodeCalibrationBuffer(cal.dled[2]) == cal_data.dled[2] + && EncodeCalibrationBuffer(cal.dled[3]) == cal_data.dled[3] + && EncodeCalibrationBuffer(cal.spare[2]) == cal_data.spare[2] + && EncodeCalibrationBuffer(cal.spare[3]) == cal_data.spare[3]))) + { + return true; + } + + CMD_0x33 desired{}; + std::memset(&desired, 0, sizeof(desired)); + desired.report_id = report_id; + desired.command_id = 0x33; + + 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]); + + 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]); + } + + std::memset(desired.reserved, 0, sizeof(desired.reserved)); + int rc = SendPacket(reinterpret_cast(&desired)); + if(rc < 0) + { + return false; + } + + ResetController(); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + 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; + + 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; + } + else + { + cal_data.dled[2] = 0u; + cal_data.dled[3] = 0u; + cal_data.spare[2] = 0u; + cal_data.spare[3] = 0u; + } + + return true; } -/*---------------------------------------------------------------------------------------------*\ -| 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() +void RGBFusion2USBController::SetLedCount(unsigned int c0, unsigned int c1, unsigned int c2, unsigned int c3) { - 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); + new_d1 = LedCountToEnum(c0); + new_d2 = LedCountToEnum(c1); + new_d3 = LedCountToEnum(c2); + new_d4 = LedCountToEnum(c3); - /*---------------------------------------------------------*\ - | 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 | - | *Note IT5711 calibration is only partially functional. | - | *Use Calibration at your own risk. | - \*---------------------------------------------------------*/ - if(!device_settings.contains(json_cal)) + if(new_d1 == D_LED1_count && new_d2 == D_LED2_count && new_d3 == D_LED3_count && new_d4 == D_LED4_count) { - device_settings[json_cal]["Enabled"] = false; - device_settings[json_cal]["Data"] = GigabyteBoardCalibration; - - settings_manager->SetSettings(detector_name, device_settings); - settings_manager->SaveSettings(); + return; } - else if(device_settings[json_cal]["Enabled"]) - { - GigabyteBoardCalibration["D_LED1"] = device_settings[json_cal]["Data"]["D_LED1"]; - GigabyteBoardCalibration["D_LED2/D_LED3"] = device_settings[json_cal]["Data"]["D_LED2/D_LED3"]; - GigabyteBoardCalibration["Mainboard"] = device_settings[json_cal]["Data"]["Mainboard"]; - GigabyteBoardCalibration["Spare"] = device_settings[json_cal]["Data"]["Spare"]; - uint8_t buffer[64] = { 0x00 }; - buffer[0] = report_id; - buffer[1] = 0x33; + D_LED1_count = new_d1; + D_LED2_count = new_d2; + D_LED3_count = new_d3; + D_LED4_count = new_d4; - SetCalibrationBuffer(GigabyteBoardCalibration["D_LED1"], buffer, 2); - SetCalibrationBuffer(GigabyteBoardCalibration["D_LED2/D_LED3"], buffer, 6); - SetCalibrationBuffer(GigabyteBoardCalibration["Mainboard"], buffer, 10); - SetCalibrationBuffer(GigabyteBoardCalibration["Spare"], buffer, 14); - - SendPacket(buffer); - } -} - -void RGBFusion2USBController::SetLedCount(unsigned int led, unsigned int count) -{ - /*-----------------------------------------------------------------*\ - | Check which Digital LED we're setting then send the value of each | - \*-----------------------------------------------------------------*/ - if(led == HDR_D_LED1) - { - D_LED1_count = LedCountToEnum(count); - } - else if(led == HDR_D_LED2) - { - D_LED2_count = LedCountToEnum(count); - } - else if(led == HDR_D_LED3) - { - D_LED3_count = LedCountToEnum(count); - } unsigned char buffer[64] = { 0 }; - buffer[0] = report_id; // 0xCC - buffer[1] = 0x34; // CC34 command - buffer[2] = (D_LED2_count << 4) | D_LED1_count; - buffer[3] = D_LED3_count; - - SendPacket(buffer); // Send full HID feature report + buffer[0] = report_id; + buffer[1] = 0x34; + buffer[2] = (new_d2 << 4) | new_d1; + buffer[3] = (new_d4 << 4) | new_d3; + SendPacket(buffer); } -bool RGBFusion2USBController::DisableBuiltinEffect(int enable_bit, int mask) +/*---------------------------------------------------------*\ +| Switch ARGB header mode (single/addressable) | +\*---------------------------------------------------------*/ +bool RGBFusion2USBController::SetStripBuiltinEffectState(int hdr, bool enable) { - if(effect_disabled & enable_bit) + static bool first_call = true; + int bitmask = 0; + + if(hdr == -1) { - return(true); + bitmask = 0x01 | 0x02 | 0x08 | 0x10; + } + else + { + switch(hdr) + { + case LED4: + case HDR_D_LED2: + case HDR_D_LED2_RGB: + bitmask = 0x02; + break; + case HDR_D_LED3: + case HDR_D_LED3_RGB: + bitmask = 0x08; + break; + case HDR_D_LED4: + case HDR_D_LED4_RGB: + bitmask = 0x10; + break; + default: + bitmask = 0x01; + break; + } } - effect_disabled &= ~mask; - effect_disabled |= enable_bit; + int new_effect_disabled = enable + ? (effect_disabled & ~bitmask) + : (effect_disabled | bitmask); + if(!first_call && new_effect_disabled == effect_disabled) + { + return true; + } + + first_call = false; + effect_disabled = new_effect_disabled; int res = SendPacket(0x32, effect_disabled); - - /*-----------------------------------------------------------------*\ - | 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; } +/*---------------------------------------------------------*\ +| Persist LED config data | +\*---------------------------------------------------------*/ +bool RGBFusion2USBController::SaveLEDState(bool e) +{ + return SendPacket(0x47, e ? 1 : 0); +} + +/*---------------------------------------------------------*\ +| Persist calibration | +\*---------------------------------------------------------*/ +bool RGBFusion2USBController::SaveCalState() +{ + return SendPacket(0x5E, 0); +} + +/*---------------------------------------------------------*\ +| Set beat mode (hardware audio sync mode) | +\*---------------------------------------------------------*/ bool RGBFusion2USBController::EnableBeat(bool e) { return SendPacket(0x31, e ? 1 : 0); } +/*---------------------------------------------------------*\ +| Set Lamp Array mode (MSDL) | +\*---------------------------------------------------------*/ +bool RGBFusion2USBController::EnableLampArray(bool enable) +{ + return SendPacket(0x48, enable ? 1 : 0); +} + std::string RGBFusion2USBController::GetDeviceName() { return(name); @@ -270,30 +480,45 @@ std::string RGBFusion2USBController::GetSerial() return(chip_id); } -void RGBFusion2USBController::SetStripColors - ( - unsigned int hdr, - RGBColor * colors, - unsigned int num_colors, - int single_led - ) +/*---------------------------------------------------------*\ +| PID (controller feature support) | +\*---------------------------------------------------------*/ +uint16_t RGBFusion2USBController::GetProductID() +{ + return (product_id); +} + +/*---------------------------------------------------------*\ +| Low level controller number (multi-controller) | +\*---------------------------------------------------------*/ +uint8_t RGBFusion2USBController::GetDeviceNum() +{ + return (device_num); +} + +/*---------------------------------------------------------*\ +| Set ARGB strips (addressable) | +\*---------------------------------------------------------*/ +void RGBFusion2USBController::SetStripColors(unsigned int hdr, RGBColor* colors, unsigned int num_colors, int single_led) { PktRGB pkt; pkt.Init(hdr, report_id); - - /*------------------------------------------------------------------------------------*\ - | byte order is correct for it5711 though there is more work to do. | - | For IT5711 defaults to byteorder1/2 for LED strips (Current Behavior is Functional) | - \*------------------------------------------------------------------------------------*/ uint32_t byteorder; - if(hdr == HDR_D_LED1_RGB) + switch(pkt.s.header) { - byteorder = report.byteorder1; - } - else - { - byteorder = report.byteorder2; + case HDR_D_LED2_RGB: + byteorder = cal_data.dled[1]; + break; + case HDR_D_LED3_RGB: + byteorder = cal_data.dled[2]; + break; + case HDR_D_LED4_RGB: + byteorder = cal_data.dled[3]; + break; + default: + byteorder = cal_data.dled[0]; + break; } unsigned char bo_r = byteorder >> 16; @@ -306,10 +531,6 @@ void RGBFusion2USBController::SetStripColors 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 | - \*-------------------------------------------------------------------------*/ if(single_led > -1) { leds_left = 1; @@ -347,140 +568,123 @@ void RGBFusion2USBController::SetStripColors return; } } - - if(hdr == HDR_D_LED1_RGB) - { - DisableBuiltinEffect(0x01, 0x01); - } - else if(hdr == HDR_D_LED2_RGB) - { - DisableBuiltinEffect(0x02, 0x02); - } - else if(hdr == HDR_D_LED3_RGB) - { - DisableBuiltinEffect(0x08, 0x08); - } } -static const std::array< std::array, 5> speeds = -{ - { - {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, unsigned char brightness, bool random, unsigned char r, unsigned char g, unsigned char b) +/*---------------------------------------------------------*\ +| Set hardware effects (single) | +| Note: Effects paramters match that of gigabyte software. | +| -(2)Gigabyte breathe ranges are 400-1000ms in 100ms steps | +| and 1000-1600ms in 200ms steps | +| -(3)Gigabyte flash ranges are 600-2400ms in 200ms steps | +| -(4)Gigabyte color cycle ranges are 300-2400ms for period0| +| and 100-2200ms for period1 in 100ms steps. | +| the follow this trend between 300-1100/100-1000ms | +| then jump to 2400ms and 2200ms respective on speed 9. | +| -(6)Gigabyte Wave ranges are 30-300ms in steps following | +| the following formula. 2.5(s+1)^2 + 2.5(s+1) + 25. | +| -(15)Gigabyte dflash ranges are 800-2600ms in 200ms steps | +| -(3)(15)flash and dflash parameters were combined. | +\*---------------------------------------------------------*/ +void RGBFusion2USBController::SetLEDEffect(int led, int mode, unsigned int speed, unsigned char brightness, bool random, unsigned char r, unsigned char g, unsigned char b) { PktEffect pkt; - - pkt.Init(led, report_id); - /*-------------------------------------------------------------------------*\ - | Add handling for different parts of the controller | - | IT8297, IT5702, and IT5711 seems to only support 5 levels of brightness | - \*-------------------------------------------------------------------------*/ - if(led >= 0x20 && led <= 0x27) + pkt.Init(led, report_id, product_id); + if(led == -1) { - pkt.e.zone0 = static_cast(1 << (led - 0x20)); + effect_zone_mask = pkt.e.zone0; } - else if(led >= 0x90 && led <= 0x92) + else if((effect_zone_mask & pkt.e.zone0) == 0) { - pkt.e.zone0 = static_cast(1 << (led - 0x90)); + effect_zone_mask |= pkt.e.zone0; } - - pkt.e.effect_type = mode; - pkt.e.color0 = r << 16 | g << 8 | b; - - /*--------------------------------------------------------------------*\ - | Adjust brightness for 0x20-0x27 and 0x90-0x92 | - | Brightness values supported are as follows: | - | 0xFF = Max Brightness | - | 0xB3 = -1 Brightness | - | 0x80 = -2 Brightness | - | 0x4D = -3 Brightness | - | 0x1a = -4 Brightness | - | 0x00 = Min Brightness | - \*--------------------------------------------------------------------*/ - if(brightness == 0) - pkt.e.max_brightness = 0x00; - else if(brightness == 1) - pkt.e.max_brightness = 0x1A; - else if(brightness == 2) - pkt.e.max_brightness = 0x4D; - else if(brightness == 3) - pkt.e.max_brightness = 0x80; - else if(brightness == 4) - pkt.e.max_brightness = 0xB3; - else - pkt.e.max_brightness = 0xFF; + pkt.e.max_brightness = brightness; + pkt.e.effect_type = mode; + pkt.e.color0 = r << 16 | g << 8 | b; switch(mode) { - case 0: // Direct - case 1: // Static zero out other effect parameters (IT5711 needs this) - pkt.e.period0 = 0; - pkt.e.period1 = 0; - pkt.e.period2 = 0; - pkt.e.period3 = 0; - pkt.e.effect_param0 = 0; - pkt.e.effect_param1 = 0; - pkt.e.effect_param2 = 0; - pkt.e.effect_param3 = 0; - break; - - case 2: //Breathing - case 3: //Blink - case 4: // Color Cycle - if(speed < speeds.size()) - { - const std::array& s = speeds[speed]; - - pkt.e.period0 = s[0]; - pkt.e.period1 = s[1]; - pkt.e.period2 = s[2]; - } - - if(random) - { - 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 - + case 2: + pkt.e.period0 = pkt.e.period1 = (speed <= 6) ? (400 + speed * 100) : (1000 + (speed - 6) * 200); + pkt.e.period2 = 200; if(random) { pkt.e.effect_param0 = 7; } break; - } - /*----------------------------------------*\ - | Adjust offset formatting for 0x90-0x92 | - \*----------------------------------------*/ - if(led >= 0x90 && led <= 0x92) - { - pkt.buffer[1] = led; - pkt.buffer[2] = 0x00; - pkt.buffer[3] = 1 << (led - 0x90); + case 15: + pkt.e.effect_type = 3; + pkt.e.effect_param1 = 1; + pkt.e.effect_param2 = 2; + case 3: + pkt.e.period0 = 100; + pkt.e.period1 = 100; + pkt.e.period2 = (speed * 200) + 700; + if(random) + { + pkt.e.effect_param0 = 7; + } + break; + case 4: + pkt.e.period0 = (speed * 100 + 300) + (speed > 8 ? 1300 * (speed - 8) : 0); + pkt.e.period1 = pkt.e.period0 -200; + pkt.e.effect_param0 = 7; + break; + case 6: + pkt.e.period0 = ((speed + 1)^2 + (speed + 1) + 10) * 5 / 2; + pkt.e.effect_param0 = 7; + pkt.e.effect_param1 = 1; + break; + case 8: + pkt.e.period0 = 100; + pkt.e.effect_param0 = 1; + pkt.e.effect_param1 = 5; + break; + case 9: + pkt.e.period0 = 1200; + pkt.e.period1 = 100; + pkt.e.period2 = 360; + pkt.e.period3 = 1200; + break; + case 10: + pkt.e.period0 = 200; + pkt.e.effect_param0 = 7; + break; + case 11: + pkt.e.period0 = 840; + pkt.e.period1 = 20; + pkt.e.period2 = 200; + pkt.e.period3 = 840; + break; + case 12: + pkt.e.period0 = 200; + pkt.e.effect_param0 = 7; + break; } SendPacket(pkt.buffer); } -/*--------------------------------------------------*\ -| IT8297 and IT5702 seem happy with sending 0x28FF | -| IT5711 needs 0x28FF07 to work properly (?) | -\*--------------------------------------------------*/ -bool RGBFusion2USBController::ApplyEffect() + +/*---------------------------------------------------------*\ +| Apply hardware effects (single) | +\*---------------------------------------------------------*/ +bool RGBFusion2USBController::ApplyEffect(bool fast_apply) { - return SendPacket(0x28, 0xFF, 0x07); + if(fast_apply) + { + if(product_id == 0x5711) + { + return SendPacket(0x28, 0xFF, 0x07); + } + else + { + return SendPacket(0x28, 0xFF, 0x00); + } + } + + PktEffectApply pkt = {}; + pkt.a.zone_sel0 = effect_zone_mask; + + effect_zone_mask = 0; + return SendPacket(pkt.buffer()); } bool RGBFusion2USBController::SendPacket(uint8_t a, uint8_t b, uint8_t c) @@ -500,28 +704,22 @@ int RGBFusion2USBController::SendPacket(unsigned char* packet) return hid_send_feature_report(dev, packet, 64); } -/*-----------------------------------------------------------------------------------------*\ -| Init routine to zero out all registers before setting up the controllers. | -| This is required to prevent weird behaviors due to an inconsistent controller state. | -\*-----------------------------------------------------------------------------------------*/ -void RGBFusion2USBController::ResetController(uint16_t pid) +/*---------------------------------------------------------*\ +| Reset controller parameters | +\*---------------------------------------------------------*/ +void RGBFusion2USBController::ResetController() { for(uint8_t reg = 0x20; reg <= 0x27; ++reg) - SendPacket(reg, 0x00, 0x00); - - SendPacket(0x32, 0x00, 0x00); - SendPacket(0x34, 0x00, 0x00); - - if(pid == 0x5711) { - for(uint8_t reg = 0x90; reg <= 0x92; ++reg) - SendPacket(reg, 0x00, 0x00); + SendPacket(reg, 0x00, 0x00); } - SendPacket(0x28, 0xFF, 0x07); -} - -uint16_t RGBFusion2USBController::GetProductID() const -{ - return product_id; + if(product_id == 0x5711) + { + for(uint8_t reg = 0x90; reg <= 0x92; ++reg) + { + SendPacket(reg, 0x00, 0x00); + } + } + ApplyEffect(true); } \ No newline at end of file diff --git a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h index b81cac12..127024a9 100644 --- a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h +++ b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h @@ -4,6 +4,7 @@ | Driver for Gigabyte Aorus RGB Fusion 2 USB motherboard | | | | jackun 08 Jan 2020 | +| megadjc 31 Jul 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-only | @@ -20,50 +21,44 @@ #include #include "RGBController.h" -#define GB_CALIBRATION_SIZE (sizeof(GB_Calibrations) / sizeof(GB_Calibrations[0])) +/*--------------------------------------------------------*\ +| 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; -/*-------------------------------------------------------------*\ -| 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 deprecated | -\*-------------------------------------------------------------*/ -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; +/*--------------------------------------------------------*\ +| IT8297/IT5701/IT5702 ARGB Headers | +\*--------------------------------------------------------*/ const uint8_t HDR_D_LED1 = LED6; const uint8_t HDR_D_LED2 = LED7; -const uint8_t HDR_LED_7 = LED8; - -/*-------------------------------------------------------------*\ -| IT8297/IT5702 ARGB Headers | -\*-------------------------------------------------------------*/ const uint8_t HDR_D_LED1_RGB = 0x58; const uint8_t HDR_D_LED2_RGB = 0x59; -/*-------------------------------------------------------------*\ -| 0x62 & 0x90-92 found on the new IT5711 controller chip | -\*-------------------------------------------------------------*/ -const uint8_t LED9 = 0x90; -const uint8_t LED10 = 0x91; -const uint8_t LED11 = 0x92; -const uint8_t HDR_D_LED3_RGB = 0x62; -/*------------------------------------------*\ -|Defines new mapping for third argb header | -\*------------------------------------------*/ -const uint8_t HDR_D_LED3 = LED8; +/*--------------------------------------------------------*\ +| 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 | +\*---------------------------------------------------------*/ enum EffectType { EFFECT_NONE = 0, @@ -71,9 +66,19 @@ enum EffectType EFFECT_PULSE = 2, EFFECT_BLINKING = 3, EFFECT_COLORCYCLE = 4, + EFFECT_WAVE = 6, + EFFECT_RANDOM = 8, + EFFECT_WAVE1 = 9, + EFFECT_WAVE2 = 10, + EFFECT_WAVE3 = 11, + EFFECT_WAVE4 = 12, + EFFECT_DFLASH = 15, // to be continued... }; +/*---------------------------------------------------------*\ +| Low level strip length divisions | +\*---------------------------------------------------------*/ enum LEDCount { LEDS_32 = 0, @@ -83,6 +88,9 @@ enum LEDCount LEDS_1024, }; +/*---------------------------------------------------------*\ +| Defines the RGB led data structure. | +\*---------------------------------------------------------*/ struct LEDs { uint8_t r; @@ -90,8 +98,62 @@ struct LEDs uint8_t b; }; +/*---------------------------------------------------------*\ +| Defines structure for low level calibration data. | +\*---------------------------------------------------------*/ +struct CalibrationData +{ + uint32_t dled[4] = {0}; + uint32_t spare[4] = {0}; + uint32_t mainboard = 0; +}; + +/*---------------------------------------------------------*\ +| Defines structure for high level calibration data. | +\*---------------------------------------------------------*/ +struct EncodedCalibration +{ + std::string dled[4]; + std::string spare[4]; + std::string mainboard; +}; + #pragma pack(push, 1) +/*---------------------------------------------------------*\ +| Packet structure for applying effects | +\*---------------------------------------------------------*/ +struct ApplyEffects +{ + uint8_t report_id; + uint8_t command_id; + uint32_t zone_sel0; + uint32_t zone_sel1; + uint8_t padding[54]; + + ApplyEffects() + { + report_id = 0xCC; + command_id = 0x28; + zone_sel0 = 0; + zone_sel1 = 0; + std::memset(padding, 0, sizeof(padding)); + } +}; + +struct PktEffectApply +{ + ApplyEffects a; + + uint8_t* buffer() + { + return reinterpret_cast(&a); + } +}; + +/*---------------------------------------------------------*\ +| Single LED Calibration struct | +\*---------------------------------------------------------*/ struct RGBA { union @@ -110,6 +172,9 @@ struct RGBA typedef std::map< std::string, RGBA > RGBCalibration; typedef std::map< std::string, std::string> calibration; +/*---------------------------------------------------------*\ +| Packet structure for ARGB headers (addressable) | +\*---------------------------------------------------------*/ union PktRGB { unsigned char buffer[64]; @@ -117,7 +182,7 @@ union PktRGB { uint8_t report_id; uint8_t header; - uint16_t boffset; // In bytes, absolute + uint16_t boffset; uint8_t bcount; LEDs leds[19]; uint16_t padding0; @@ -129,6 +194,22 @@ union PktRGB void Init(uint8_t header, uint8_t report_id) { + switch(header) + { + case LED4: + case HDR_D_LED2: + header = HDR_D_LED2_RGB; + break; + case HDR_D_LED3: + header = HDR_D_LED3_RGB; + break; + case HDR_D_LED4: + header = HDR_D_LED4_RGB; + break; + default: + header = HDR_D_LED1_RGB; + break; + } s.report_id = report_id; s.header = header; s.boffset = 0; @@ -137,6 +218,17 @@ union PktRGB } }; +/*---------------------------------------------------------*\ +| Packet structure for hardware effects | +| Default values for Hardware Effects mode. | +| Old init values. | +| (All values 0 unless otherwise noted below) | +| e.color0 = 0x00FF2100; //orange | +| e.period1 = 1200; | +| e.period2 = 200; | +| e.period3 = 200; | +| e.effect_param2 = 1; | +\*---------------------------------------------------------*/ union PktEffect { unsigned char buffer[64]; @@ -144,7 +236,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 sets it to pow(2, led) uint32_t zone1; uint8_t reserved0; uint8_t effect_type; @@ -167,65 +259,100 @@ union PktEffect { } - void Init(int header, uint8_t report_id) + void Init(int led, uint8_t report_id, uint16_t pid) { memset(buffer, 0, sizeof(buffer)); e.report_id = report_id; - - if(header < 8) + if(led == -1) { - e.header = 32 + header; // Set as default + e.zone0 = (pid == 0x5711) ? 0x07FF : 0xFF; + e.header = 0x20; + } + else if(led < 8) + { + e.zone0 = 1U << led; + e.header = 0x20 + led; + } + else if(led < 11) + { + e.zone0 = 1U << led; + e.header = 0x90 + (led - 8); } else { - e.header = header; + e.zone0 = 0; + e.header = 0; } - - e.zone0 = (uint32_t)(1 << (e.header - 32)); e.effect_type = EFFECT_STATIC; e.max_brightness = 255; e.min_brightness = 0; - e.color0 = 0x00FF2100; //orange + e.color0 = 0; e.period0 = 0; //Rising Timer - Needs to be 0 for "Direct" - e.period1 = 1200; - e.period2 = 200; - e.period3 = 200; + e.period1 = 0; + e.period2 = 0; + e.period3 = 0; e.effect_param0 = 0; // ex color count to cycle through (max seems to be 7) e.effect_param1 = 0; - e.effect_param2 = 1; // ex flash repeat count + e.effect_param2 = 0; // ex flash repeat count e.effect_param3 = 0; } }; -/*--------------------------------------------------------------------------------------*\ -| Definitions for Initial controller response struct. | -| curr_led_count_high and curr_led_count_low contain the numbers of leds in each header. | -| Byte orders are little endian little-endian 0x00RRGGBB? | -| byteorder0 is location of "Spare" calibration location. | -| byteorder1 is location of "D_LED1" calibration location. | -| byteorder2 is location of "D_LED2/D_LED3" calibration location. | -| byteorder3 is location of "Mainboard" calibration location. | -| byteorder4 is location of fifth calibration location. | -| *Note that the calibration locations aren't fully understood yet for the IT5711. | -\*--------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------*\ +| Basic Controller Init Struct | +\*---------------------------------------------------------*/ struct IT8297Report { - uint8_t report_id; - uint8_t product; - uint8_t device_num; - uint8_t total_leds; + uint8_t report_id; + uint8_t product; + uint8_t device_num; + uint8_t strip_detect; uint32_t fw_ver; - uint8_t curr_led_count_high; - uint8_t curr_led_count_low; - uint16_t reserved0; - char str_product[28]; - uint32_t byteorder0; - uint32_t byteorder1; - uint32_t byteorder2; - uint32_t byteorder3; + uint8_t curr_led_count_high; + uint8_t curr_led_count_low; + uint8_t strip_ctrl_length1; + uint8_t support_cmd_flag; + char str_product[28]; + uint32_t cal_spare0; + uint32_t cal_strip0; + uint32_t cal_strip1; + uint32_t rgb_cali; uint32_t chip_id; - uint32_t byteorder4; + uint32_t cal_spare1; +}; + +/*---------------------------------------------------------*\ +| CC61 Calibration Struct (For IT5711) | +\*---------------------------------------------------------*/ +struct IT5711Calibration +{ + uint8_t report_id; + uint8_t reserved[3]; + uint32_t cal_strip2; + uint32_t cal_strip3; + uint32_t cal_spare2; + uint32_t cal_spare3; + uint8_t padding[44]; +}; + +/*---------------------------------------------------------*\ +| CC33 Set Calibration Struct | +\*---------------------------------------------------------*/ +struct 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]; }; #pragma pack(pop) @@ -236,39 +363,41 @@ public: RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name, uint16_t pid); ~RGBFusion2USBController(); - void SetStripColors - ( - unsigned int hdr, - RGBColor * colors, - unsigned int num_colors, - int single_led = -1 - ); - - void ResetController(uint16_t pid); - uint16_t GetProductID() const; - void SetLEDEffect(unsigned int led, int mode, unsigned int speed, unsigned char brightness, bool random, unsigned char red, unsigned char green, unsigned char blue); - void SetLedCount(unsigned int led, unsigned int count); - void SetMode(int mode); - bool ApplyEffect(); - bool DisableBuiltinEffect(int enable_bit, int mask); - void SetCalibration(); - std::string GetDeviceName(); - std::string GetDeviceDescription(); - std::string GetDeviceLocation(); - std::string GetFWVersion(); - std::string GetSerial(); + 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, unsigned char red, unsigned char green, unsigned char blue); + 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); + std::string GetDeviceName(); + std::string GetDeviceDescription(); + std::string GetDeviceLocation(); + std::string GetFWVersion(); + std::string GetSerial(); 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); - + bool SaveLEDState(bool enable); + bool SaveCalState(); + 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; hid_device* dev; + int device_num; uint16_t product_id; + uint32_t effect_zone_mask = 0; int mode; IT8297Report report; + IT5711Calibration cali; + CalibrationData cal_data; std::string name; std::string description; std::string location; @@ -276,7 +405,14 @@ private: 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; LEDCount D_LED1_count; LEDCount D_LED2_count; - LEDCount D_LED3_count; //Third ARGB header count + LEDCount D_LED3_count; + LEDCount D_LED4_count; }; \ No newline at end of file diff --git a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp index 06855c96..f0c3ecf3 100644 --- a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp @@ -5,6 +5,7 @@ | motherboard | | | | jackun 08 Jan 2020 | +| megadjc 31 Jul 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-only | @@ -22,14 +23,9 @@ #define IT8297_U 0xCC #define IT8297_UPG 0xFF89 -/******************************************************************************************\ -* * -* DetectGigabyteRGBFusion2USBControllers * -* * -* Detect GigabyteRGB Fusion 2 devices that use IT8297 RGB controller * -* * -\******************************************************************************************/ - +/*---------------------------------------------------------*\ +| Detector for Gigabyte RGB Fusion USB controllers | +\*---------------------------------------------------------*/ void DetectGigabyteRGBFusion2USBControllers(hid_device_info* info, const std::string&) { DMIInfo MB_info; @@ -42,14 +38,16 @@ void DetectGigabyteRGBFusion2USBControllers(hid_device_info* info, const std::st // Constructor sets the name ResourceManager::get()->RegisterRGBController(rgb_controller); } -} /* DetectRGBFusion2USBControllers() */ +} #ifdef USE_HID_USAGE REGISTER_HID_DETECTOR_PU(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_UPG, IT8297_U); +REGISTER_HID_DETECTOR_PU(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8950, IT8297_UPG, IT8297_U); REGISTER_HID_DETECTOR_PU(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_UPG, IT8297_U); REGISTER_HID_DETECTOR_PU(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5711, IT8297_UPG, IT8297_U); #else REGISTER_HID_DETECTOR_I(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_IFC); +REGISTER_HID_DETECTOR_I(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8950, IT8297_IFC); REGISTER_HID_DETECTOR_I(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_IFC); REGISTER_HID_DETECTOR_I(DETECTOR_NAME, DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5711, IT8297_IFC); #endif diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp index 2a58bee3..18e84f03 100644 --- a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp @@ -5,6 +5,7 @@ | motherboard | | | | jackun 08 Jan 2020 | +| megadjc 31 Jul 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-only | @@ -13,529 +14,11 @@ #include #include #include "RGBController_GigabyteRGBFusion2USB.h" +#include "RGBController_GigabyteRGBFusion2USBBoards.h" +#include "RGBController_GigabyteRGBFusion2USBLayouts.h" #include "ResourceManager.h" #include "SettingsManager.h" -/*-------------------------------------------------*\ -| LedHeaders is a map of the led header addresses | -\*-------------------------------------------------*/ -static FwdLedHeaders LedLookup -{ - {"LED1", 0x20}, {"LED2", 0x21}, {"LED3", 0x22}, {"LED4", 0x23}, - {"LED5", 0x24}, {"LED6", 0x25}, {"LED7", 0x26}, {"LED8", 0x27}, - {"D_LED1", 0x58}, {"D_LED2", 0x59}, {"D_LED3", 0x62}, {"LED9", 0x90}, - {"LED10", 0x91}, {"LED11", 0x92}, -}; - -/*-------------------------------------------------*\ -| 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" }, - {"B650 EAGLE AX", "B650-Eagle-AX" }, - {"B650E AORUS STEALTH", "B650E-AORUS-STEALTH" }, - {"B650E AORUS STEALTH ICE", "B650E-AORUS-STEALTH" }, - {"B650M DS3H", "B650M-DS3H" }, - {"B850 AORUS ELITE WIFI7", "X870-WIFI7" }, - {"B850 AORUS ELITE WIFI7 ICE", "X870-WIFI7" }, - {"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", "ITX" }, - {"X670E AORUS MASTER", "MSTR_ATX_2" }, - {"X870 AORUS ELITE WIFI7", "X870-WIFI7" }, - {"X870 AORUS ELITE WIFI7 ICE", "X870-WIFI7" }, - {"X870E AORUS ELITE WIFI7", "X870E-WIFI7" }, - {"X870E AORUS ELITE WIFI7 ICE", "X870E-WIFI7" }, - {"X870E AORUS PRO", "X870E-PRO" }, - {"X870E AORUS PRO ICE", "X870E-PRO" }, - {"Z390 AORUS MASTER-CF", "MSTR_ATX" }, - {"Z890 AORUS ELITE WIFI7", "Z890-WIFI7" }, - {"Z890 AORUS ELITE WIFI7 ICE", "Z890-WIFI7" } -}; - -/*-------------------------------------------------*\ -| This is the default Custom layout that will be | -| written into config if it doesn't exist | -\*-------------------------------------------------*/ -static const KnownLayout HardcodedCustom_Gen1 -{ - { - "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 }, - } - } - } - } -}; - -static const KnownLayout HardcodedCustom_Gen2 -{ - { - "Custom", - { - { - "Motherboard", - { - { "0x20", LED1, 1 }, //This one should apply everything globally (testing needed). - { "0x21", LED2, 1 }, - { "0x22", LED3, 1 }, //Confirmed accent Lighting for X870 Aorus Elite Boards. - { "0x23", LED4, 1 }, - { "0x24", LED5, 1 }, //should be LED_C on most if not all models. - { "0x90", LED9, 1 }, - { "0x91", LED10, 1 },//Should be logo on pro models. - { "0x92", LED11, 1 },//Should be accent on pro models. - } - }, - { - "ARGB V2.3", - { - { "ARGB V2.3", HDR_D_LED3, 0 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, -}; - - -/*-------------------------------------------------*\ -| KnownLayoutsLookup now needs to be variable to | -| allow for a custom addition from config | -\*-------------------------------------------------*/ -static KnownLayout knownLayoutsLookup -{ - { - "STD_ATX", - { - { - "Motherboard", - { - { "Back I/O", HDR_BACK_IO, 1 }, - { "CPU Header", HDR_CPU, 1 }, - { "PCIe", HDR_PCIE, 1 }, - { "LED C1/C2", HDR_LED_C1C2, 1 }, - } - }, - { - "D_LED1 Bottom", - { - { "D_LED1 Bottom", HDR_D_LED1, 0 }, - } - }, - { - "D_LED2 Top", - { - { "D_LED2 Top", HDR_D_LED2, 0 }, - } - } - } - }, - { - "ITX", - { - { - "Motherboard", - { - { "LED Group0", HDR_BACK_IO, 1 }, - { "LED Group1", HDR_CPU, 1 }, - { "LED Group2", HDR_LED_2, 1 }, - { "LED Group3", HDR_PCIE, 1 }, - { "LED C1/C2", HDR_LED_C1C2, 1 }, - } - }, - { - "D_LED1", - { - { "D_LED1", HDR_D_LED1, 0 }, - } - } - } - }, - { - "B650-Eagle-AX", - { - { - "Motherboard", - { - { "LED_C", LED5, 1 }, - } - }, - { - "ARGB V2.3", - { - { "ARGB V2.3", HDR_D_LED3, 0 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, - { - "B650E-AORUS-STEALTH", - { - { - "Motherboard", - { - { "Logo", LED10, 1 }, - { "Accent", LED11, 1 }, - { "LED C", LED5, 1 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, - { - "B650M-DS3H", - { - { - "Motherboard", - { - { "LED_C", LED5, 1 }, - } - }, - { - "D_LED1", - { - { "D_LED1", HDR_D_LED1, 0 }, - } - }, - { - "D_LED2", - { - { "D_LED2", HDR_D_LED1, 0 }, - } - } - } - }, - { - "X870-WIFI7", - { - { - "Motherboard", - { - { "Accent", LED3, 1 }, - { "LED C", LED5, 1 }, - } - }, - { - "ARGB V2.3", - { - { "ARGB V2.3", HDR_D_LED3, 0 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, - { - "X870E-WIFI7", - { - { - "Motherboard", - { - { "Accent", LED11, 1 }, - { "LED C", LED5, 1 }, - } - }, - { - "ARGB V2.3", - { - { "ARGB V2.3", HDR_D_LED3, 0 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, - { - "X870E-PRO", - { - { - "Motherboard", - { - { "Logo", LED10, 1 }, - { "Accent", LED11, 1 }, - { "LED C", LED5, 1 }, - } - }, - { - "ARGB V2.3", - { - { "ARGB V2.3", HDR_D_LED3, 0 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, - { - "MSTR_ATX_2", - { - { - "D_LED1 Bottom", - { - { "D_LED1 Bottom", HDR_D_LED2, 0 }, - } - }, - { - "D_LED2 Top", - { - { "D_LED2 Top", HDR_D_LED1, 0 }, - } - }, - { - "Motherboard", - { - { "LED C1", LED2, 1 }, - { "LED C2", LED5, 1 }, - { "CPU Header", LED3, 1 }, - { "Cover Left", LED4, 1 }, - { "Cover Right", LED1, 1 }, - } - } - } - }, - { - "MSTR_ATX_3", - { - { - "Digital Headers", - { - { "D_LED1 / D_LED2", HDR_D_LED1, 0 }, - } - }, - { - "ARGB Strip", - { - { "LED C1/C2", LED5, 1 }, - } - }, - { - "Motherboard", - { - { "Aorus Logo", LED7, 1 }, - { "ESS Logo", LED4, 1 }, - } - } - } - }, - { - "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 }, - } - } - } - }, - { - "Z890-WIFI7", - { - { - "Motherboard", - { - { "Logo", LED10, 1 }, - { "Accent", LED3, 1 }, - { "LED C", LED5, 1 }, - } - }, - { - "ARGB V2.3", - { - { "ARGB V2.3", HDR_D_LED3, 0 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, - { - "IT5711-Generic", - { - { - "Motherboard", - { - { "0x20", LED1, 1 }, - { "Ox21", LED2, 1 }, - { "0x22", LED3, 1 }, - { "0x23", LED4, 1 }, - { "0x24", LED5, 1 }, - { "0x90", LED9, 1 }, - { "0x91", LED10, 1 }, - { "0x92", LED11, 1 }, - } - }, - { - "ARGB V2.3", - { - { "ARGB V2.3", HDR_D_LED3, 0 }, - } - }, - { - "ARGB V2.1", - { - { "ARGB V2.1", HDR_D_LED1, 0 }, - } - }, - { - "ARGB V2.2", - { - { "ARGB V2.2", HDR_D_LED2, 0 }, - } - } - } - }, - { - "IT8297BX-GBX570", - { - { - "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 6", LED6, 1 }, - { "Name for Led 7", LED7, 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 }, - } - } - } - } -}; - - /**------------------------------------------------------------------*\ @name Gigabyte RGB Fusion 2 USB @category Motherboard @@ -548,10 +31,141 @@ static KnownLayout knownLayoutsLookup 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("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& v_lp = zl->second; + + nlohmann::json json_zl; + for(std::vector::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 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(); + lp.header = forwardLookup.at(jv["header"].get()); + lp.count = jv.contains("count") ? jv["count"].get() : 1; + + v_lp.push_back(lp); + } + + out_layout.insert(std::pair>(zone_name, v_lp)); + } +} + RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr, std::string detector) { controller = controller_ptr; - name = controller->GetDeviceName(); detector_name = detector; vendor = "Gigabyte"; @@ -560,6 +174,8 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController version = controller->GetFWVersion(); location = controller->GetDeviceLocation(); serial = controller->GetSerial(); + pid = controller->GetProductID(); + device_num = controller->GetDeviceNum(); mode Direct; Direct.name = "Direct"; @@ -583,16 +199,17 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController 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.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; - Breathing.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; - Breathing.brightness = RGBFUSION2_BRIGHTNESS_MAX; - Breathing.speed_min = 0; - Breathing.speed_max = 4; + Breathing.brightness_max = 100; // Set 100 max due to controller quirks + Breathing.brightness = 100; // Match default to above + Breathing.speed_min = 9; + Breathing.speed_max = 0; + Breathing.speed = 4; Breathing.colors_min = 1; Breathing.colors_max = 1; Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC; @@ -601,14 +218,15 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController modes.push_back(Breathing); mode Blinking; - Blinking.name = "Blinking"; + Blinking.name = "Flashing"; 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.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; Blinking.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; Blinking.brightness = RGBFUSION2_BRIGHTNESS_MAX; - Blinking.speed_min = 0; - Blinking.speed_max = 4; + Blinking.speed_min = 9; + Blinking.speed_max = 0; + Blinking.speed = 4; Blinking.colors_min = 1; Blinking.colors_max = 1; Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC; @@ -623,21 +241,23 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController ColorCycle.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; ColorCycle.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; ColorCycle.brightness = RGBFUSION2_BRIGHTNESS_MAX; - ColorCycle.speed_min = 0; - ColorCycle.speed_max = 4; + ColorCycle.speed_min = 9; + ColorCycle.speed_max = 0; + ColorCycle.speed = 4; ColorCycle.color_mode = MODE_COLORS_NONE; ColorCycle.speed = 2; modes.push_back(ColorCycle); mode Flashing; - Flashing.name = "Flashing"; - Flashing.value = 10; + Flashing.name = "Double Flash"; + Flashing.value = EFFECT_DFLASH; Flashing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; Flashing.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; Flashing.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; Flashing.brightness = RGBFUSION2_BRIGHTNESS_MAX; - Flashing.speed_min = 0; - Flashing.speed_max = 4; + Flashing.speed_min = 9; + Flashing.speed_max = 0; + Flashing.speed = 4; Flashing.colors_min = 1; Flashing.colors_max = 1; Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC; @@ -645,6 +265,83 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController Flashing.speed = 2; modes.push_back(Flashing); + + mode Wave; + Wave.name = "Wave"; + Wave.value = EFFECT_WAVE; + Wave.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED; + Wave.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; + Wave.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; + Wave.brightness = RGBFUSION2_BRIGHTNESS_MAX; + Wave.speed_min = 9; + Wave.speed_max = 0; + Wave.speed = 4; + Wave.colors_min = 0; + Wave.colors_max = 0; + Wave.color_mode = MODE_COLORS_NONE; + modes.push_back(Wave); + + mode Random; + Random.name = "Random"; + Random.value = EFFECT_RANDOM; + Random.flags = MODE_FLAG_HAS_BRIGHTNESS; + Random.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; + Random.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; + Random.brightness = RGBFUSION2_BRIGHTNESS_MAX; + Random.colors_min = 0; + Random.colors_max = 0; + Random.color_mode = MODE_COLORS_NONE; + modes.push_back(Random); + + + mode Wave1; + Wave1.name = "Wave 1"; + Wave1.value = EFFECT_WAVE1; + Wave1.flags = MODE_FLAG_HAS_BRIGHTNESS; + Wave1.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; + Wave1.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; + Wave1.brightness = RGBFUSION2_BRIGHTNESS_MAX; + Wave1.colors_min = 0; + Wave1.colors_max = 0; + Wave1.color_mode = MODE_COLORS_NONE; + modes.push_back(Wave1); + + mode Wave2; + Wave2.name = "Wave 2"; + Wave2.value = EFFECT_WAVE2; + Wave2.flags = MODE_FLAG_HAS_BRIGHTNESS; + Wave2.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; + Wave2.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; + Wave2.brightness = RGBFUSION2_BRIGHTNESS_MAX; + Wave2.colors_min = 0; + Wave2.colors_max = 0; + Wave2.color_mode = MODE_COLORS_NONE; + modes.push_back(Wave2); + + mode Wave3; + Wave3.name = "Wave 3"; + Wave3.value = EFFECT_WAVE3; + Wave3.flags = MODE_FLAG_HAS_BRIGHTNESS; + Wave3.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; + Wave3.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; + Wave3.brightness = RGBFUSION2_BRIGHTNESS_MAX; + Wave3.colors_min = 0; + Wave3.colors_max = 0; + Wave3.color_mode = MODE_COLORS_NONE; + modes.push_back(Wave3); + + mode Wave4; + Wave4.name = "Wave 4"; + Wave4.value = EFFECT_WAVE4; + Wave4.flags = MODE_FLAG_HAS_BRIGHTNESS; + Wave4.brightness_min = RGBFUSION2_BRIGHTNESS_MIN; + Wave4.brightness_max = RGBFUSION2_BRIGHTNESS_MAX; + Wave4.brightness = RGBFUSION2_BRIGHTNESS_MAX; + Wave4.colors_min = 0; + Wave4.colors_max = 0; + Wave4.color_mode = MODE_COLORS_NONE; + modes.push_back(Wave4); + Load_Device_Config(); Init_Controller(); SetupZones(); @@ -655,39 +352,16 @@ RGBController_RGBFusion2USB::~RGBController_RGBFusion2USB() delete controller; } +/*---------------------------------------------------------*\ +| Loads JSON config data | +\*---------------------------------------------------------*/ 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(const nlohmann::detail::iteration_proxy_value>& it : device_settings[SectionLayout].items()) - { - MBName2Layout.insert( std::pair(it.key(), it.value() )); - } - } - - /*-------------------------------------------------*\ - | Get Custom Layout from the settings manager. | - | Selects appropriate layout based on controller. | - \*-------------------------------------------------*/ - uint16_t pid = controller->GetProductID(); + const std::string SectionCustom = "CustomLayout"; + const std::string SectionCalibration = "Calibration"; + RvrseLedHeaders ReverseLedLookup = reverse_map(LedLookup); + SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); + nlohmann::json device_settings = settings_manager->GetSettings(detector_name); if(pid == 0x5711) { @@ -698,78 +372,99 @@ void RGBController_RGBFusion2USB::Load_Device_Config() layout = HardcodedCustom_Gen1.find("Custom")->second; } - if (!device_settings.contains(SectionCustom)) + /*---------------------------------------------------------*\ + | Remove legacy top-level "MotherboardLayouts" | + \*---------------------------------------------------------*/ + if(device_settings.contains("MotherboardLayouts")) { - /*---------------------------------------------*\ - | 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 v_lp = zl->second; - json json_zl; - - for(std::vector::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.erase("MotherboardLayouts"); + settings_manager->SetSettings(detector_name, device_settings); + settings_manager->SaveSettings(); + } + if(!device_settings.contains(SectionCustom)) + { + nlohmann::json json_HCL = BuildCustomLayoutJson(layout, ReverseLedLookup); device_settings[SectionCustom]["Enabled"] = false; - device_settings[SectionCustom]["Data"] = json_HCL; + device_settings[SectionCustom]["Data"] = BuildCustomLayoutJson(layout, ReverseLedLookup); + settings_manager->SetSettings(detector_name, device_settings); + settings_manager->SaveSettings(); + } + + custom_layout = device_settings[SectionCustom]["Enabled"]; + + if(custom_layout) + { + const nlohmann::json json_HCL = device_settings[SectionCustom]["Data"]; + LoadCustomLayoutFromJson(json_HCL, LedLookup, layout); + } + + EncodedCalibration hw_cal = controller->GetCalibration(false); + + if(!device_settings.contains(SectionCalibration)) + { + device_settings[SectionCalibration]["Enabled"] = false; + device_settings[SectionCalibration]["Data"] = WriteCalJsonFrom(hw_cal, pid); settings_manager->SetSettings(detector_name, device_settings); settings_manager->SaveSettings(); } else { - custom_layout = device_settings[SectionCustom]["Enabled"]; + nlohmann::json& cal_sec = device_settings[SectionCalibration]; + bool cal_enable = cal_sec.value("Enabled", false); - /*---------------------------------------------*\ - | If the Custom layout is found and enabled | - | then read it in from config | - \*---------------------------------------------*/ - if(custom_layout) + if(!cal_sec.contains("Data") || !cal_sec["Data"].is_object()) { - json json_HCL = device_settings[SectionCustom]["Data"]; - layout.clear(); + cal_sec["Data"] = WriteCalJsonFrom(hw_cal, pid); + settings_manager->SetSettings(detector_name, device_settings); + settings_manager->SaveSettings(); + } + else + { + nlohmann::json& cdata = cal_sec["Data"]; + FillMissingWith(cdata, hw_cal, pid); - for(const nlohmann::detail::iteration_proxy_value>& json_layout_it : json_HCL.items()) + if(!cal_enable) { - json json_zl = json_layout_it.value(); - std::vector 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(); - lp.header = LedLookup.find(json_vlp["header"].get())->second; - if(lp.header == HDR_D_LED1 || lp.header == HDR_D_LED2 || lp.header == HDR_D_LED3) - lp.count = 0; - else - lp.count = 1; - v_lp.push_back(lp); - } - - layout.insert(std::pair>(json_layout_it.key(),v_lp)); + cal_sec["Data"] = WriteCalJsonFrom(hw_cal, pid); + settings_manager->SetSettings(detector_name, device_settings); + settings_manager->SaveSettings(); } } + + if(cal_enable) + { + 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"); + + if(pid == 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"); + } + else + { + desired.dled[2] = "OFF"; + desired.dled[3] = "OFF"; + desired.spare[2] = "OFF"; + desired.spare[3] = "OFF"; + } + controller->SetCalibration(desired, false); + } } } +/*---------------------------------------------------------*\ +| Loads layout and zone data for controller | +\*---------------------------------------------------------*/ void RGBController_RGBFusion2USB::Init_Controller() { /*---------------------------------------------------------*\ @@ -777,33 +472,64 @@ void RGBController_RGBFusion2USB::Init_Controller() \*---------------------------------------------------------*/ if(!custom_layout) { - /*-----------------------------------------------------*\ - | 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())) + std::string layout_key; + + bool found = false; + + switch(pid) { - layout = knownLayoutsLookup.find(MBName2Layout.find(controller->GetDeviceName())->second )->second; + 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 { - uint16_t pid = controller->GetProductID(); - std::string fallback_layout; - switch(pid) { - case 0x5711: - fallback_layout = "IT5711-Generic"; - break; - case 0x5702: - fallback_layout = "STD_ATX"; - break; case 0x8297: - fallback_layout = "STD_ATX"; + case 0x8950: + case 0x5702: + layout = knownLayoutsLookup.at("STD_ATX"); break; + default: - fallback_layout = "IT5711-Generic"; // safest default + layout = knownLayoutsLookup.at("IT5711-Generic"); break; } } @@ -826,9 +552,6 @@ void RGBController_RGBFusion2USB::Init_Controller() for(std::size_t lp_idx = 0; lp_idx < lp.size(); lp_idx++) { - /*-------------------------------------------------*\ - | 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; @@ -846,31 +569,49 @@ void RGBController_RGBFusion2USB::Init_Controller() void RGBController_RGBFusion2USB::SetupZones() { - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*---------------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*---------------------------------------------------------*/ leds.clear(); colors.clear(); + unsigned int d1 = 0, d2 = 0, d3 = 0, d4 = 0; + /*---------------------------------------------------------*\ - | Set up zones | + | 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 (ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); zl++) { bool single_zone = (zones[zone_idx].type == ZONE_TYPE_SINGLE); - if(!single_zone) + if (!single_zone) { - controller->SetLedCount(zl->second.at(0).header, zones[zone_idx].leds_count); - controller->DisableBuiltinEffect(0, 0x3); + unsigned char hdr = zl->second.at(0).header; + + switch (hdr) + { + case LED4: + case HDR_D_LED2: + d2 = zones[zone_idx].leds_count; + break; + case HDR_D_LED3: + d3 = zones[zone_idx].leds_count; + break; + case HDR_D_LED4: + d4 = zones[zone_idx].leds_count; + break; + default: + d1 = zones[zone_idx].leds_count; + break; + } } - for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++) + for (unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++) { led new_led; - if(single_zone) + if (single_zone) { new_led.name = zl->second.at(lp_idx).name; new_led.value = zl->second.at(lp_idx).header; @@ -888,6 +629,8 @@ void RGBController_RGBFusion2USB::SetupZones() zone_idx++; } + controller->SetLedCount(d1, d2, d3, d4); + controller->SetStripBuiltinEffectState(-1, false); SetupColors(); } @@ -908,10 +651,110 @@ void RGBController_RGBFusion2USB::ResizeZone(int zone, int new_size) void RGBController_RGBFusion2USB::DeviceUpdateLEDs() { + int mode_value = (modes[active_mode].value); + bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM); + + /*---------------------------------------------------------*\ + | If Wave 1-4 then use special sequence. | + \*---------------------------------------------------------*/ + if(mode_value == 6 || (mode_value >= 9 && mode_value <= 12)) + { + controller->SetStripBuiltinEffectState(-1, true); + controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, 0, 0, 0); + controller->ApplyEffect(); + controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, 0, 0, 0); + controller->ApplyEffect(); + return; + } + for(int zone_idx = 0; zone_idx < (int)zones.size(); zone_idx++) { - UpdateZoneLEDs(zone_idx); + mode_value = modes[active_mode].value; + if(zones[zone_idx].type == ZONE_TYPE_SINGLE) + { + unsigned char red = 0; + unsigned char grn = 0; + unsigned char blu = 0; + + for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { + mode_value = modes[active_mode].value; + + /*---------------------------------------------------------*\ + | Motherboard LEDs always use effect mode, so use static for| + | direct mode but get colors from zone | + \*---------------------------------------------------------*/ + if(mode_value == 0xFFFF) + { + red = RGBGetRValue(zones[zone_idx].colors[led_idx]); + grn = RGBGetGValue(zones[zone_idx].colors[led_idx]); + blu = RGBGetBValue(zones[zone_idx].colors[led_idx]); + + mode_value = EFFECT_STATIC; + } + /*---------------------------------------------------------*\ + | If the mode uses mode-specific color, get color from mode | + \*---------------------------------------------------------*/ + else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) + { + red = RGBGetRValue(modes[active_mode].colors[0]); + grn = RGBGetGValue(modes[active_mode].colors[0]); + blu = RGBGetBValue(modes[active_mode].colors[0]); + } + + /*---------------------------------------------------------*\ + | Apply the mode and color to the zone | + \*---------------------------------------------------------*/ + controller->SetLEDEffect(zones[zone_idx].leds[led_idx].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); + } + } + /*---------------------------------------------------------*\ + | Set strip LEDs | + \*---------------------------------------------------------*/ + else + { + if(zones[zone_idx].leds && zones[zone_idx].leds_count) + { + unsigned char hdr = zones[zone_idx].leds->value; + + /*---------------------------------------------------------*\ + | Direct mode addresses a different register | + \*---------------------------------------------------------*/ + if(mode_value == 0xFFFF) + { + controller->SetStripBuiltinEffectState(hdr, false); + controller->SetStripColors(hdr, zones[zone_idx].colors, zones[zone_idx].leds_count); + } + + /*---------------------------------------------------------*\ + | Effect mode | + \*---------------------------------------------------------*/ + else + { + unsigned char red = 0; + unsigned char grn = 0; + unsigned char blu = 0; + + /*---------------------------------------------------------*\ + | If mode has mode specific color, load color from mode | + \*---------------------------------------------------------*/ + if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) + { + red = RGBGetRValue(modes[active_mode].colors[0]); + grn = RGBGetGValue(modes[active_mode].colors[0]); + blu = RGBGetBValue(modes[active_mode].colors[0]); + } + + /*---------------------------------------------------------*\ + | Apply hardware effects to LED strips | + \*---------------------------------------------------------*/ + controller->SetStripBuiltinEffectState(hdr, true); + controller->SetLEDEffect(hdr, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); + } + } + } } + controller->ApplyEffect(); } void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) @@ -920,7 +763,20 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) | Get mode parameters | \*---------------------------------------------------------*/ int mode_value = (modes[active_mode].value); - bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM || mode_value == EFFECT_COLORCYCLE); + bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM); + + /*---------------------------------------------------------*\ + | If Wave 1-4 then use special sequence. | + \*---------------------------------------------------------*/ + if(mode_value == 6 || (mode_value >= 9 && mode_value <= 12)) + { + controller->SetStripBuiltinEffectState(-1, true); + controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, 0, 0, 0); + controller->ApplyEffect(); + controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, 0, 0, 0); + controller->ApplyEffect(); + return; + } /*---------------------------------------------------------*\ | Set motherboard LEDs | @@ -933,15 +789,11 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) for(std::size_t led_idx = 0; led_idx < zones[zone].leds_count; led_idx++) { - /*---------------------------------------------------------*\ - | Initialize mode value | - \*---------------------------------------------------------*/ - mode_value = modes[active_mode].value; - /*---------------------------------------------------------*\ - | Motherboard LEDs always use effect mode, so use static for| - | direct mode but get colors from zone | - \*---------------------------------------------------------*/ + /*------------------------------------------------------------*\ + | Motherboard LEDs always use effect mode, so use static for | + | direct mode but get colors from zone | + \*------------------------------------------------------------*/ if(mode_value == 0xFFFF) { red = RGBGetRValue(zones[zone].colors[led_idx]); @@ -950,6 +802,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) mode_value = EFFECT_STATIC; } + /*---------------------------------------------------------*\ | If the mode uses mode-specific color, get color from mode | \*---------------------------------------------------------*/ @@ -964,16 +817,16 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) | Apply the mode and color to the zone | \*---------------------------------------------------------*/ controller->SetLEDEffect(zones[zone].leds[led_idx].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); + controller->ApplyEffect(); } - - controller->ApplyEffect(); } + /*---------------------------------------------------------*\ | Set strip LEDs | \*---------------------------------------------------------*/ else { - if(zones[zone].leds_count) + if(zones[zone].leds && zones[zone].leds_count) { unsigned char hdr = zones[zone].leds->value; @@ -982,27 +835,10 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) \*---------------------------------------------------------*/ if(mode_value == 0xFFFF) { - //Updated: Proper RGB register mapping for each header - switch(hdr) - { - case HDR_D_LED1: - hdr = HDR_D_LED1_RGB; - controller->DisableBuiltinEffect(1, 0x01); - break; - case HDR_D_LED2: - hdr = HDR_D_LED2_RGB; - controller->DisableBuiltinEffect(1, 0x02); - break; - case HDR_D_LED3: - hdr = HDR_D_LED3_RGB; - controller->DisableBuiltinEffect(1, 0x08); - break; - default: - break; - } - + controller->SetStripBuiltinEffectState(hdr, false); controller->SetStripColors(hdr, zones[zone].colors, zones[zone].leds_count); } + /*---------------------------------------------------------*\ | Effect mode | \*---------------------------------------------------------*/ @@ -1025,22 +861,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) /*---------------------------------------------------------*\ | Apply built-in effects to LED strips | \*---------------------------------------------------------*/ - - switch(hdr) - { - case HDR_D_LED1: - controller->DisableBuiltinEffect(0, 0x01); - break; - case HDR_D_LED2: - controller->DisableBuiltinEffect(0, 0x02); - break; - case HDR_D_LED3: - controller->DisableBuiltinEffect(0, 0x08); - break; - default: - break; - } - + controller->SetStripBuiltinEffectState(hdr, true); controller->SetLEDEffect(hdr, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); controller->ApplyEffect(); } @@ -1055,6 +876,19 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led) \*---------------------------------------------------------*/ bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM); int mode_value = (modes[active_mode].value); + + /*---------------------------------------------------------*\ + | If Wave 1-4 then use special sequence. | + \*---------------------------------------------------------*/ + if(mode_value == 6 || (mode_value >= 9 && mode_value <= 12)) + { + controller->SetStripBuiltinEffectState(-1, true); + controller->SetLEDEffect(-1, 1, 0, 0xFF, 0, 0, 0, 0); + controller->ApplyEffect(); + controller->SetLEDEffect( 2, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, 0, 0, 0); + controller->ApplyEffect(); + return; + } unsigned int zone_idx = GetLED_Zone(led); /*---------------------------------------------------------*\ @@ -1078,6 +912,7 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led) mode_value = EFFECT_STATIC; } + /*---------------------------------------------------------*\ | If the mode uses mode-specific color, get color from mode | \*---------------------------------------------------------*/ @@ -1091,6 +926,7 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led) controller->SetLEDEffect(leds[led].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); controller->ApplyEffect(); } + /*---------------------------------------------------------*\ | Set strip LEDs | \*---------------------------------------------------------*/ @@ -1118,8 +954,8 @@ int RGBController_RGBFusion2USB::GetLED_Zone(int led_idx) } } - /*---------------------------------*\ - | If zone is not found, return -1 | - \*---------------------------------*/ + /*---------------------------------------------------------*\ + | If zone is not found, return -1 | + \*---------------------------------------------------------*/ return(-1); } \ No newline at end of file diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h index c148a657..fb541a10 100644 --- a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h @@ -5,6 +5,7 @@ | motherboard | | | | jackun 08 Jan 2020 | +| megadjc 31 Jul 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-only | @@ -16,11 +17,13 @@ #include #include "RGBController.h" #include "GigabyteRGBFusion2USBController.h" +#include "RGBController_GigabyteRGBFusion2USBBoards.h" +#include "RGBController_GigabyteRGBFusion2USBLayouts.h" #define RGBFusion2_Digital_LEDS_Min 0; #define RGBFusion2_Digital_LEDS_Max 1024; #define RGBFUSION2_BRIGHTNESS_MIN 0; -#define RGBFUSION2_BRIGHTNESS_MAX 5; +#define RGBFUSION2_BRIGHTNESS_MAX 255; template static std::map reverse_map(const std::map& map) @@ -35,20 +38,6 @@ static std::map reverse_map(const std::map& map) return reversed_map; } -typedef std::map< std::string, int > FwdLedHeaders; -typedef std::map< int, std::string > RvrseLedHeaders; - -struct LedPort -{ - std::string name; - int header; - int count; -}; - -typedef std::map< std::string, std::string > MBName; -typedef std::map< std::string, std::vector > ZoneLeds; -typedef std::map< std::string, ZoneLeds> KnownLayout; - class RGBController_RGBFusion2USB: public RGBController { public: @@ -72,7 +61,8 @@ private: RGBFusion2USBController* controller; ZoneLeds layout; - + uint16_t pid; + int device_num; void Load_Device_Config(); void Init_Controller(); int GetLED_Zone(int led_idx); diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.cpp b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.cpp new file mode 100644 index 00000000..095bccaa --- /dev/null +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.cpp @@ -0,0 +1,315 @@ + +/*---------------------------------------------------------*\ +| 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-only | +\*---------------------------------------------------------*/ + +#include "RGBController_GigabyteRGBFusion2USBBoards.h" +#include "GigabyteRGBFusion2USBController.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 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" }, +}; \ No newline at end of file diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.h b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.h new file mode 100644 index 00000000..5ee7a1ac --- /dev/null +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBBoards.h @@ -0,0 +1,26 @@ +/*---------------------------------------------------------*\ +| 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-only | +\*---------------------------------------------------------*/ + +#pragma once + +#include +#include +#include + +using MBName = std::map; + +extern const MBName MBName2LayoutLookup8297; +extern const MBName MBName2LayoutLookup8950; +extern const MBName MBName2LayoutLookup5702; +extern const MBName MBName2LayoutLookup5711; + + diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.cpp b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.cpp new file mode 100644 index 00000000..3cbe4870 --- /dev/null +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.cpp @@ -0,0 +1,1935 @@ +/*---------------------------------------------------------*\ +| RGBController_GigabyteRGBFusion2USBLayouts.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-only | +\*---------------------------------------------------------*/ + +#include "RGBController_GigabyteRGBFusion2USBLayouts.h" +#include "GigabyteRGBFusion2USBController.h" + +/*-------------------------------------------------*\ +| LedHeaders is a map of the led header addresses | +\*-------------------------------------------------*/ +const FwdLedHeaders LedLookup = +{ + {"LED1", 0}, + {"LED2", 1}, + {"LED3", 2}, + {"LED4", 3}, + {"LED5", 4}, + {"LED6", 5}, + {"LED7", 6}, + {"LED8", 7}, + {"LED9", 8}, + {"LED10", 9}, + {"LED11", 10}, + {"HDR_D_LED1", 5}, + {"HDR_D_LED2", 6}, + {"HDR_D_LED3", 7}, + {"HDR_D_LED4", 8}, + {"HDR_D_LED1_RGB", 0x58}, + {"HDR_D_LED2_RGB", 0x59}, + {"HDR_D_LED3_RGB", 0x62}, + {"HDR_D_LED4_RGB", 0x63}, +}; + +/*-------------------------------------------------*\ +| These are the default Custom layouts that will | +| be written into config if they doesn't exist | +\*-------------------------------------------------*/ +const KnownLayout HardcodedCustom_Gen1 = +{ + { + "Custom", + { + { + "D_LED2 Top", + { + { "Name for LED Strip 2", HDR_D_LED2, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "Name for LED Strip 1", HDR_D_LED1, 0 }, + } + }, + { + "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 }, + } + } + } + } +}; + +const KnownLayout HardcodedCustom_Gen2 = +{ + { + "Custom", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "ARGB_V2_4", + { + { "ARGB_V2_4", HDR_D_LED4, 0 }, + } + }, + { + "Motherboard", + { + { "0x20", LED1, 1 }, + { "0x21", LED2, 1 }, + { "0x22", LED3, 1 }, + { "0x23", LED4, 1 }, + { "0x90", LED9, 1 }, + { "0x91", LED10, 1 }, + { "0x92", LED11, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, +}; + + +/*-------------------------------------------------*\ +| KnownLayoutsLookup contains zone mapping data | +| for each motherboard. | +\*-------------------------------------------------*/ +const KnownLayout knownLayoutsLookup = +{ + { + "STD_ATX", + { + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Back I/O", LED1, 1 }, + { "PCIe", LED4, 1 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED2, 1 }, + { "LED_C1/C2", LED5, 1 }, + } + } + } + }, + { + "A620M-H", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED2, 1 }, + } + } + } + }, + { + "B550I-AORUS-PRO-AX", + { + { + "D_LED", + { + { "D_LED", HDR_D_LED1, 0 }, + } + }, + { + "Motherboard", + { + { "Top LED", LED1, 1 }, + { "Top Middle LED", LED2, 1 }, + { "Bottom Middle LED", LED3, 1 }, + { "Bottom LED", LED4, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B650-C-V2", + { + { + "D_LED", + { + { "D_LED", HDR_D_LED1, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED2, 1 }, + } + } + } + }, + { + "B650-D2H", + { + { + "D_LED", + { + { "D_LED", HDR_D_LED1, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B650-Eagle-AX", + { + { + "ARGB_V2_1/V2.3", + { + { "ARGB_V2_1/V2.3", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B650-ELITE", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED4, 1 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "B650-ELITE-V2", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED4, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B650-PRO", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "B650-UD", + { + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED1, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B650E-AORUS-STEALTH", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED11, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B650-TACH", + { + { + "D_LED", + { + { "D_LED", HDR_D_LED1, 0 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C", LED2, 1 }, + } + } + } + }, + { + "B650-USB4", + { + { + "ARGB_V2_1/V2.3", + { + { "ARGB_V2_1/V2.3", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + { "Cover Left", LED4, 1 }, + { "Cover Right", LED1, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B650M-DS3H", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B760M-D2H", + { + { + "D_LED", + { + { "D_LED", HDR_D_LED1, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED4, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED2, 1 }, + } + } + } + }, + { + "B760M-EXAX", + { + { + "ARGB_V2_1/V2.3", + { + { "ARGB_V2_1/V2.3", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Top Logo", LED4, 1 }, + { "Top Middle Logo", LED3, 1 }, + { "Bottom Middle Logo", LED2, 1 }, + { "Bottom Logo", LED1, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B760M-GAX", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED2, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED2, 1 }, + } + } + } + }, + { + "B760M-DS3H-DR-G5", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED1, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B840M-WIFI6E", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B840M-DS3H", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B850-AI-TOP", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B850-EGL-WIFI6", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B850-GMX-WIFI6", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B860-DS3H", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B860-EGL-WIFI6", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B860-EGL-P-WIFI6", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED1, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B860-WIFI7", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "B860I-Pro", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + } + } + }, + { + "H810M", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", LED3, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", LED4, 0 }, + } + }, + } + }, + { + "MSTR_ATX", + { + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Back IO / VRM", LED7, 0 }, + { "Chipset Logo", LED3, 1 }, + { "PCIe", LED4, 1 }, + { "XMP Logo", LED2, 1 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1/C2", LED5, 1 }, + } + } + } + }, + { + "MSTR_ATX_2", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Cover Left", LED4, 1 }, + { "Cover Right", LED1, 1 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "MSTR_ATX_3", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Aorus Logo", LED7, 1 }, + { "ESS Logo", LED4, 1 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1/C2", LED5, 1 }, + } + } + } + }, + { + "TRX50-AERO-D", + { + { + "ARGB_V2_1/V2.3", + { + { "ARGB_V2_1/V2.3", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "TRX50-A-TP", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "X570S-ELITE", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Top Right Accents", LED4, 1 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "X570S-A-MSTR", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED1, 1 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "X570S-PRO-AX", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED1, 1 }, + { "ESS Logo", LED4, 1 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "X670-ELITE", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strips", + { + { "CPU Header", LED3, 1 }, + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "X670-A-PRO-X", + { + { + "D_LED2 Top", + { + { "D_LED2 Top", HDR_D_LED1, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "D_LED1 Bottom", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Cover Left", LED4, 1 }, + { "Cover Right", LED1, 1 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "X870-WIFI7", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "X870E-WIFI7", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED11, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + }, + } + }, + { + "X870E-PRO", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED11, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "X870E-MSTR", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "ARGB_V2_4", + { + { "ARGB_V2_4", HDR_D_LED4, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED11, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "X870E-XTRM-AI-TOP", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED11, 1 }, + { "Logo", LED10, 1 }, + { "Wifi Antenna Accent", LED9, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "X870I-PRO", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z690-ELITE", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Top Right Accent", LED3, 1 }, + { "Middle Right Accent", LED4, 1 }, + { "Logo", LED1, 1 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "Z790-D", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + } + } + }, + { + "Z790-PRO-X", + { + { + "ARGB_V2_1/ARGB V 2.3", + { + { "ARGB_V2_1/ARGB V 2.3", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED1, 1 }, + { "Logo 2", LED4, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z790-MSTR", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED1, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z790-MSTR-X", + { + { + "ARGB_V2_1/V2.3", + { + { "ARGB_V2_1/V2.3", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED1, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z790-ELITE", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED3, 1 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "Z790-S-DDR4", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "Z790-XTRM", + { + { + "D_LED1", + { + { "D_LED1", HDR_D_LED1, 0 }, + } + }, + { + "D_LED2", + { + { "D_LED2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1", LED2, 1 }, + { "LED_C2", LED5, 1 }, + } + } + } + }, + { + "Z790-XTRM-X", + { + { + "ARGB_V2_1/V2.3", + { + { "ARGB_V2_1/V2.3", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + } + }, + { + "12V RGB Strips", + { + { "LED_C1", LED5, 1 }, + { "LED_C2", LED4, 1 }, + { "LED_C3", LED2, 1 }, + } + } + } + }, + { + "Z890-WIFI7", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z890-MSTR", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "ARGB_V2_4", + { + { "ARGB_V2_4", HDR_D_LED4, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED3, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z890-MSTR-AI-TOP", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "ARGB_V2_4", + { + { "ARGB_V2_4", HDR_D_LED4, 0 }, + } + }, + { + "Motherboard", + { + { "Accent", LED11, 1 }, + { "Logo", LED10, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z890-XTRM-AI-TOP", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "ARGB_V2_4", + { + { "ARGB_V2_4", HDR_D_LED4, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED10, 1 }, + { "WIFI Antenna Accent", LED11, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "Z890-A-ULTRA", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "Motherboard", + { + { "Logo", LED10, 1 }, + } + } + } + }, + { + "IT5711-Generic", + { + { + "ARGB_V2_1", + { + { "ARGB_V2_1", HDR_D_LED1, 0 }, + } + }, + { + "ARGB_V2_2", + { + { "ARGB_V2_2", HDR_D_LED2, 0 }, + } + }, + { + "ARGB_V2_3", + { + { "ARGB_V2_3", HDR_D_LED3, 0 }, + } + }, + { + "ARGB_V2_4", + { + { "ARGB_V2_4", HDR_D_LED4, 0 }, + } + }, + { + "Motherboard", + { + { "0x20", LED1, 1 }, + { "Ox21", LED2, 1 }, + { "0x22", LED3, 1 }, + { "0x23", LED4, 1 }, + { "0x90", LED9, 1 }, + { "0x91", LED10, 1 }, + { "0x92", LED11, 1 }, + } + }, + { + "12V RGB Strip", + { + { "LED_C", LED5, 1 }, + } + } + } + }, + { + "IT8297BX-GBX570", + { + { + "D_LED2 Top", + { + { "Name for LED Strip 2", HDR_D_LED2, 0 }, + } + }, + { + "D_LED1 Bottom", + { + { "Name for LED Strip 1", HDR_D_LED1, 0 }, + } + }, + { + "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 6", LED6, 1 }, + { "Name for Led 7", LED7, 1 }, + { "Name for Led 8", LED8, 1 }, + } + } + } + } +}; \ No newline at end of file diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.h b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.h new file mode 100644 index 00000000..19607598 --- /dev/null +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USBLayouts.h @@ -0,0 +1,36 @@ +/*---------------------------------------------------------*\ +| 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-only | +\*---------------------------------------------------------*/ + +#pragma once + +#include +#include +#include + +/* LED port definition */ +struct LedPort +{ + std::string name; + int header; + int count; +}; + +/* Type aliases */ +using FwdLedHeaders = std::map; +using RvrseLedHeaders = std::map; +using ZoneLeds = std::map>; +using KnownLayout = std::map; + +extern const KnownLayout HardcodedCustom_Gen1; +extern const KnownLayout HardcodedCustom_Gen2; +extern const KnownLayout knownLayoutsLookup; +extern const FwdLedHeaders LedLookup; \ No newline at end of file