diff --git a/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp b/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp index df7ef6c0..1feac1b3 100644 --- a/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp +++ b/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp @@ -70,10 +70,7 @@ bool TestForGalaxGPUController(i2c_smbus_interface* bus, unsigned char address) void DetectGalaxGPUControllers(std::vector &busses) { - GalaxGPUController* new_GalaxGPU; - RGBController_GalaxGPU* new_controller; - - for (unsigned int bus = 0; bus < busses.size(); bus++) + for(unsigned int bus = 0; bus < busses.size(); bus++) { // Check for GALAX controller at 0x23 for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++) @@ -84,12 +81,14 @@ void DetectGalaxGPUControllers(std::vector &busses) busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device) { LOG_DEBUG(GPU_DETECT_MESSAGE, "Galax GPU", bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name ); - if (TestForGalaxGPUController(busses[bus], 0x23)) + + if(TestForGalaxGPUController(busses[bus], 0x23)) { - new_GalaxGPU = new GalaxGPUController(busses[bus], 0x23); - new_controller = new RGBController_GalaxGPU(new_GalaxGPU); - new_controller->name = device_list[dev_idx].name; - ResourceManager::get()->RegisterRGBController(new_controller); + GalaxGPUController* controller = new GalaxGPUController(busses[bus], 0x23); + RGBController_GalaxGPU* rgb_controller = new RGBController_GalaxGPU(controller); + rgb_controller->name = device_list[dev_idx].name; + + ResourceManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/GalaxGPUController/RGBController_GalaxGPU.cpp b/Controllers/GalaxGPUController/RGBController_GalaxGPU.cpp index 81c5528d..b7caa9fd 100644 --- a/Controllers/GalaxGPUController/RGBController_GalaxGPU.cpp +++ b/Controllers/GalaxGPUController/RGBController_GalaxGPU.cpp @@ -1,171 +1,170 @@ -/*-----------------------------------------*\ -| RGBController_GalaxGPU.cpp | -| | -| Driver for Galax / KFA2 RGB on GPUs | -| | -| Niels Westphal (crashniels) 12.07.2020 | -\*-----------------------------------------*/ - -#include "RGBController_GalaxGPU.h" - -int RGBController_GalaxGPU::GetDeviceMode() -{ - int modereg1 = galax_gpu->GalaxGPURegisterRead(GALAX_MODE_REGISTER_1); - int modereg2 = galax_gpu->GalaxGPURegisterRead(GALAX_MODE_REGISTER_2); - - if (modereg1 == GALAX_MODE_STATIC_VALUE_1 && modereg2 == GALAX_MODE_STATIC_VALUE_2) - { - active_mode = 1; - modes[active_mode].color_mode = MODE_COLORS_PER_LED; - } - - if (modereg1 == GALAX_MODE_BREATHING_VALUE_1 && modereg2 == GALAX_MODE_BREATHING_VALUE_2) - { - active_mode = 2; - modes[active_mode].color_mode = MODE_COLORS_PER_LED; - } - - if (modereg1 == GALAX_MODE_RAINBOW_VALUE_1 && modereg2 == GALAX_MODE_RAINBOW_VALUE_2) - { - active_mode = 3; - modes[active_mode].color_mode = MODE_COLORS_NONE; - } - - if (modereg1 == GALAX_MODE_CYCLE_BREATHING_VALUE_1 && modereg2 == GALAX_MODE_CYCLE_BREATHING_VALUE_2) - { - active_mode = 4; - modes[active_mode].color_mode = MODE_COLORS_NONE; - } - - return(active_mode); -} - -RGBController_GalaxGPU::RGBController_GalaxGPU(GalaxGPUController * galax_gpu_ptr) -{ - galax_gpu = galax_gpu_ptr; - - name = galax_gpu->GetDeviceName(); - vendor = "GALAX"; - type = DEVICE_TYPE_GPU; - description = "GALAX / KFA2 RTX GPU"; - version = "1.0"; - location = galax_gpu->GetDeviceLocation(); - - mode Direct; - Direct.name = "Direct"; - Direct.value = 1; - Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Direct.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Direct); - - mode Breathing; - Breathing.name = "Breathing"; - Breathing.value = 2; - Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Breathing.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Breathing); - - mode Rainbow; - Rainbow.name = "Rainbow"; - Rainbow.value = 3; - Rainbow.flags = 0; - Rainbow.color_mode = MODE_COLORS_NONE; - modes.push_back(Rainbow); - - mode Cycle_Breathing; - Cycle_Breathing.name = "Cycle Breathing"; - Cycle_Breathing.value = 4; - Cycle_Breathing.flags = 0; - Cycle_Breathing.color_mode = MODE_COLORS_NONE; - modes.push_back(Cycle_Breathing); - - SetupZones(); - - active_mode = GetDeviceMode(); -} - -RGBController_GalaxGPU::~RGBController_GalaxGPU() -{ - delete galax_gpu; -} - -void RGBController_GalaxGPU::SetupZones() -{ - /*---------------------------------------------------------*\ - | Set up zone | - \*---------------------------------------------------------*/ - zone galax_gpu_zone; - galax_gpu_zone.name = "GPU"; - galax_gpu_zone.type = ZONE_TYPE_SINGLE; - galax_gpu_zone.leds_min = 1; - galax_gpu_zone.leds_max = 1; - galax_gpu_zone.leds_count = 1; - galax_gpu_zone.matrix_map = NULL; - zones.push_back(galax_gpu_zone); - - /*---------------------------------------------------------*\ - | Set up LED | - \*---------------------------------------------------------*/ - led galax_gpu_led; - galax_gpu_led.name = "GPU"; - leds.push_back(galax_gpu_led); - - SetupColors(); - - /*---------------------------------------------------------*\ - | Initialize color | - \*---------------------------------------------------------*/ - unsigned char red = galax_gpu->GetLEDRed(); - unsigned char grn = galax_gpu->GetLEDGreen(); - unsigned char blu = galax_gpu->GetLEDBlue(); - - colors[0] = ToRGBColor(red, grn, blu); -} - -void RGBController_GalaxGPU::ResizeZone(int /*zone*/, int /*new_size*/) -{ - /*---------------------------------------------------------*\ - | This device does not support resizing zones | - \*---------------------------------------------------------*/ -} - -void RGBController_GalaxGPU::DeviceUpdateLEDs() -{ - for(std::size_t led = 0; led < colors.size(); led++) - { - unsigned char red = RGBGetRValue(colors[led]); - unsigned char grn = RGBGetGValue(colors[led]); - unsigned char blu = RGBGetBValue(colors[led]); - - if (GetMode() == 1) - { - galax_gpu->SetLEDColorsDirect(red, grn, blu); - } - else - { - galax_gpu->SetLEDColorsEffect(red, grn, blu); - } - } -} - -void RGBController_GalaxGPU::UpdateZoneLEDs(int /*zone*/) -{ - DeviceUpdateLEDs(); -} - -void RGBController_GalaxGPU::UpdateSingleLED(int /*led*/) -{ - DeviceUpdateLEDs(); -} - -void RGBController_GalaxGPU::SetCustomMode() -{ - active_mode = 1; -} - -void RGBController_GalaxGPU::DeviceUpdateMode() -{ - int new_mode = modes[active_mode].value; - - galax_gpu->SetMode(new_mode); -} +/*-----------------------------------------*\ +| RGBController_GalaxGPU.cpp | +| | +| Driver for Galax / KFA2 RGB on GPUs | +| | +| Niels Westphal (crashniels) 12.07.2020 | +\*-----------------------------------------*/ + +#include "RGBController_GalaxGPU.h" + +int RGBController_GalaxGPU::GetDeviceMode() +{ + int modereg1 = controller->GalaxGPURegisterRead(GALAX_MODE_REGISTER_1); + int modereg2 = controller->GalaxGPURegisterRead(GALAX_MODE_REGISTER_2); + + if(modereg1 == GALAX_MODE_STATIC_VALUE_1 && modereg2 == GALAX_MODE_STATIC_VALUE_2) + { + active_mode = 1; + modes[active_mode].color_mode = MODE_COLORS_PER_LED; + } + + if(modereg1 == GALAX_MODE_BREATHING_VALUE_1 && modereg2 == GALAX_MODE_BREATHING_VALUE_2) + { + active_mode = 2; + modes[active_mode].color_mode = MODE_COLORS_PER_LED; + } + + if(modereg1 == GALAX_MODE_RAINBOW_VALUE_1 && modereg2 == GALAX_MODE_RAINBOW_VALUE_2) + { + active_mode = 3; + modes[active_mode].color_mode = MODE_COLORS_NONE; + } + + if(modereg1 == GALAX_MODE_CYCLE_BREATHING_VALUE_1 && modereg2 == GALAX_MODE_CYCLE_BREATHING_VALUE_2) + { + active_mode = 4; + modes[active_mode].color_mode = MODE_COLORS_NONE; + } + + return(active_mode); +} + +RGBController_GalaxGPU::RGBController_GalaxGPU(GalaxGPUController* controller_ptr) +{ + controller = controller_ptr; + + name = controller->GetDeviceName(); + vendor = "GALAX"; + type = DEVICE_TYPE_GPU; + description = "GALAX / KFA2 RTX GPU"; + location = controller->GetDeviceLocation(); + + mode Direct; + Direct.name = "Direct"; + Direct.value = 1; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Direct); + + mode Breathing; + Breathing.name = "Breathing"; + Breathing.value = 2; + Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Breathing.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Breathing); + + mode Rainbow; + Rainbow.name = "Rainbow"; + Rainbow.value = 3; + Rainbow.flags = 0; + Rainbow.color_mode = MODE_COLORS_NONE; + modes.push_back(Rainbow); + + mode Cycle_Breathing; + Cycle_Breathing.name = "Cycle Breathing"; + Cycle_Breathing.value = 4; + Cycle_Breathing.flags = 0; + Cycle_Breathing.color_mode = MODE_COLORS_NONE; + modes.push_back(Cycle_Breathing); + + SetupZones(); + + active_mode = GetDeviceMode(); +} + +RGBController_GalaxGPU::~RGBController_GalaxGPU() +{ + delete controller; +} + +void RGBController_GalaxGPU::SetupZones() +{ + /*---------------------------------------------------------*\ + | Set up zone | + \*---------------------------------------------------------*/ + zone galax_gpu_zone; + galax_gpu_zone.name = "GPU"; + galax_gpu_zone.type = ZONE_TYPE_SINGLE; + galax_gpu_zone.leds_min = 1; + galax_gpu_zone.leds_max = 1; + galax_gpu_zone.leds_count = 1; + galax_gpu_zone.matrix_map = NULL; + zones.push_back(galax_gpu_zone); + + /*---------------------------------------------------------*\ + | Set up LED | + \*---------------------------------------------------------*/ + led galax_gpu_led; + galax_gpu_led.name = "GPU"; + leds.push_back(galax_gpu_led); + + SetupColors(); + + /*---------------------------------------------------------*\ + | Initialize color | + \*---------------------------------------------------------*/ + unsigned char red = controller->GetLEDRed(); + unsigned char grn = controller->GetLEDGreen(); + unsigned char blu = controller->GetLEDBlue(); + + colors[0] = ToRGBColor(red, grn, blu); +} + +void RGBController_GalaxGPU::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ +} + +void RGBController_GalaxGPU::DeviceUpdateLEDs() +{ + for(std::size_t led = 0; led < colors.size(); led++) + { + unsigned char red = RGBGetRValue(colors[led]); + unsigned char grn = RGBGetGValue(colors[led]); + unsigned char blu = RGBGetBValue(colors[led]); + + if(GetMode() == 1) + { + controller->SetLEDColorsDirect(red, grn, blu); + } + else + { + controller->SetLEDColorsEffect(red, grn, blu); + } + } +} + +void RGBController_GalaxGPU::UpdateZoneLEDs(int /*zone*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_GalaxGPU::UpdateSingleLED(int /*led*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_GalaxGPU::SetCustomMode() +{ + active_mode = 1; +} + +void RGBController_GalaxGPU::DeviceUpdateMode() +{ + int new_mode = modes[active_mode].value; + + controller->SetMode(new_mode); +} diff --git a/Controllers/GalaxGPUController/RGBController_GalaxGPU.h b/Controllers/GalaxGPUController/RGBController_GalaxGPU.h index f1fe992d..105a6dbd 100644 --- a/Controllers/GalaxGPUController/RGBController_GalaxGPU.h +++ b/Controllers/GalaxGPUController/RGBController_GalaxGPU.h @@ -1,35 +1,35 @@ -/*-----------------------------------------*\ -| RGBController_GalaxGPU.h | -| | -| Driver for Galax / KFA2 RGB on GPUs | -| | -| Niels Westphal (crashniels) 12.07.2020 | -\*-----------------------------------------*/ - -#pragma once - -#include "RGBController.h" -#include "GalaxGPUController.h" - -class RGBController_GalaxGPU : public RGBController -{ -public: - RGBController_GalaxGPU(GalaxGPUController* galax_gpu_ptr); - ~RGBController_GalaxGPU(); - - void SetupZones(); - - void ResizeZone(int zone, int new_size); - - void DeviceUpdateLEDs(); - void UpdateZoneLEDs(int zone); - void UpdateSingleLED(int led); - - void SetCustomMode(); - void DeviceUpdateMode(); - -private: - GalaxGPUController* galax_gpu; - - int GetDeviceMode(); -}; +/*-----------------------------------------*\ +| RGBController_GalaxGPU.h | +| | +| Driver for Galax / KFA2 RGB on GPUs | +| | +| Niels Westphal (crashniels) 12.07.2020 | +\*-----------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include "GalaxGPUController.h" + +class RGBController_GalaxGPU : public RGBController +{ +public: + RGBController_GalaxGPU(GalaxGPUController* controller_ptr); + ~RGBController_GalaxGPU(); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void SetCustomMode(); + void DeviceUpdateMode(); + +private: + GalaxGPUController* controller; + + int GetDeviceMode(); +}; diff --git a/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp b/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp index 55e6314a..76037f1d 100644 --- a/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp +++ b/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp @@ -1,37 +1,39 @@ -#include "Detector.h" -#include "RGBController.h" -#include "ATC800Controller.h" -#include "RGBController_AorusATC800.h" -#include - -/*-----------------------------------------------------*\ -| Vendor ID | -\*-----------------------------------------------------*/ -#define HOLTEK_VID 0x1044 - -/*-----------------------------------------------------*\ -| Controller product ids | -\*-----------------------------------------------------*/ -#define ATC_800_CONTROLLER_PID 0x7A42 - -/******************************************************************************************\ -* * -* DetectAorusCPUCoolerControllers * -* * -* Tests the USB address to see if a Aorus RGB CPU Cooler exists there. * -* * -\******************************************************************************************/ - -void DetectGigabyteAorusCPUCoolerControllers(hid_device_info* info, const std::string& name) -{ - hid_device* dev = hid_open_path(info->path); - if(dev) - { - ATC800Controller* controller = new ATC800Controller(dev, info->path); - RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller); - rgb_controller->name = name; - ResourceManager::get()->RegisterRGBController(rgb_controller); - } -} - -REGISTER_HID_DETECTOR_IPU("Aorus CPU Coolers", DetectGigabyteAorusCPUCoolerControllers, HOLTEK_VID, ATC_800_CONTROLLER_PID, 0, 0xFF01, 1); +#include "Detector.h" +#include "RGBController.h" +#include "ATC800Controller.h" +#include "RGBController_AorusATC800.h" +#include + +/*-----------------------------------------------------*\ +| Vendor ID | +\*-----------------------------------------------------*/ +#define HOLTEK_VID 0x1044 + +/*-----------------------------------------------------*\ +| Controller product ids | +\*-----------------------------------------------------*/ +#define ATC_800_CONTROLLER_PID 0x7A42 + +/******************************************************************************************\ +* * +* DetectAorusCPUCoolerControllers * +* * +* Tests the USB address to see if a Aorus RGB CPU Cooler exists there. * +* * +\******************************************************************************************/ + +void DetectGigabyteAorusCPUCoolerControllers(hid_device_info* info, const std::string& name) +{ + hid_device* dev = hid_open_path(info->path); + + if(dev) + { + ATC800Controller* controller = new ATC800Controller(dev, info->path); + RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller); + rgb_controller->name = name; + + ResourceManager::get()->RegisterRGBController(rgb_controller); + } +} + +REGISTER_HID_DETECTOR_IPU("Aorus CPU Coolers", DetectGigabyteAorusCPUCoolerControllers, HOLTEK_VID, ATC_800_CONTROLLER_PID, 0, 0xFF01, 1); diff --git a/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.cpp b/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.cpp index 1b4ed0e5..ad237271 100644 --- a/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.cpp +++ b/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.cpp @@ -1,150 +1,150 @@ -/*-----------------------------------------*\ -| RGBController_AorusATC800.cpp | -| | -| Generic RGB Interface Aorus ATC800 CPU | -| Cooler | -| | -| Felipe Cavalcanti 08/13/2020 | -\*-----------------------------------------*/ - -#include "RGBController_AorusATC800.h" - -RGBController_AorusATC800::RGBController_AorusATC800(ATC800Controller* cooler_ptr) -{ - cooler = cooler_ptr; - - name = "Aorus ATC800 CPU Cooler"; - vendor = "Gigabyte"; - type = DEVICE_TYPE_COOLER; - description = "Aorus ATC800 CPU Cooler"; - location = cooler->GetDeviceLocation(); - serial = cooler->GetSerialString(); - - mode Static; - Static.name = "Static"; - Static.value = AORUS_ATC800_MODE_STATIC; - Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Static.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Static); - - mode Off; - Off.name = "Off"; - Off.value = AORUS_ATC800_MODE_OFF; - Off.flags = 0; - Off.color_mode = MODE_COLORS_NONE; - modes.push_back(Off); - - mode Flashing; - Flashing.name = "Flashing"; - Flashing.value = AORUS_ATC800_MODE_FLASHING; - Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; - Flashing.color_mode = MODE_COLORS_PER_LED; - Flashing.speed_min = AORUS_ATC800_SPEED_SLOWEST; - Flashing.speed_max = AORUS_ATC800_SPEED_FASTEST; - Flashing.speed = AORUS_ATC800_SPEED_NORMAL; - modes.push_back(Flashing); - - mode DoubleFlashing; - DoubleFlashing.name = "Double Flashing"; - DoubleFlashing.value = AORUS_ATC800_MODE_DOUBLE_FLASH; - DoubleFlashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; - DoubleFlashing.color_mode = MODE_COLORS_PER_LED; - DoubleFlashing.speed_min = AORUS_ATC800_SPEED_SLOWEST; - DoubleFlashing.speed_max = AORUS_ATC800_SPEED_FASTEST; - DoubleFlashing.speed = AORUS_ATC800_SPEED_NORMAL; - modes.push_back(DoubleFlashing); - - mode Pulsing; - Pulsing.name = "Pulsing"; - Pulsing.value = AORUS_ATC800_MODE_PULSE; - Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; - Pulsing.color_mode = MODE_COLORS_PER_LED; - Pulsing.speed_min = AORUS_ATC800_SPEED_SLOWEST; - Pulsing.speed_max = AORUS_ATC800_SPEED_FASTEST; - Pulsing.speed = AORUS_ATC800_SPEED_NORMAL; - modes.push_back(Pulsing); - - SetupZones(); -} - -RGBController_AorusATC800::~RGBController_AorusATC800() -{ - delete cooler; -} - -void RGBController_AorusATC800::SetupZones() -{ - zone atc800_cpu_fans_zone; - atc800_cpu_fans_zone.name = "Fan"; - atc800_cpu_fans_zone.type = ZONE_TYPE_SINGLE; - atc800_cpu_fans_zone.leds_min = 1; - atc800_cpu_fans_zone.leds_max = 1; - atc800_cpu_fans_zone.leds_count = 1; - atc800_cpu_fans_zone.matrix_map = NULL; - zones.push_back(atc800_cpu_fans_zone); - - led atc800_fan_led; - atc800_fan_led.name = "Fan"; - leds.push_back(atc800_fan_led); - - zone atc800_top_zone; - atc800_top_zone.name = "Top"; - atc800_top_zone.type = ZONE_TYPE_SINGLE; - atc800_top_zone.leds_min = 1; - atc800_top_zone.leds_max = 1; - atc800_top_zone.leds_count = 1; - atc800_top_zone.matrix_map = NULL; - zones.push_back(atc800_top_zone); - - led atc800_top_led; - atc800_top_led.name = "Top"; - leds.push_back(atc800_top_led); - - SetupColors(); -} - -void RGBController_AorusATC800::ResizeZone(int /*zone*/, int /*new_size*/) -{ - /*---------------------------------------------------------*\ - | This device does not support resizing zones | - \*---------------------------------------------------------*/ -} - -void RGBController_AorusATC800::DeviceUpdateLEDs() -{ - UpdateZoneLEDs(0); - UpdateZoneLEDs(1); -} - -void RGBController_AorusATC800::UpdateZoneLEDs(int zone) -{ - unsigned char mode = modes[active_mode].value; - unsigned char red = RGBGetRValue(colors[zone]); - unsigned char grn = RGBGetGValue(colors[zone]); - unsigned char blu = RGBGetBValue(colors[zone]); - - if (mode == AORUS_ATC800_MODE_OFF) - { - mode = 1; - red = 0; - grn = 0; - blu = 0; - } - - cooler->SendCoolerMode(mode, modes[active_mode].speed, zone, red, grn, blu); -} - -void RGBController_AorusATC800::UpdateSingleLED(int led) -{ - UpdateZoneLEDs(led); -} - -void RGBController_AorusATC800::SetCustomMode() -{ - -} - -void RGBController_AorusATC800::DeviceUpdateMode() -{ - DeviceUpdateLEDs(); -} +/*-----------------------------------------*\ +| RGBController_AorusATC800.cpp | +| | +| Generic RGB Interface Aorus ATC800 CPU | +| Cooler | +| | +| Felipe Cavalcanti 08/13/2020 | +\*-----------------------------------------*/ + +#include "RGBController_AorusATC800.h" + +RGBController_AorusATC800::RGBController_AorusATC800(ATC800Controller* controller_ptr) +{ + controller = controller_ptr; + + name = "Aorus ATC800 CPU Cooler"; + vendor = "Gigabyte"; + type = DEVICE_TYPE_COOLER; + description = "Aorus ATC800 CPU Cooler"; + location = controller->GetDeviceLocation(); + serial = controller->GetSerialString(); + + mode Static; + Static.name = "Static"; + Static.value = AORUS_ATC800_MODE_STATIC; + Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Static.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Static); + + mode Off; + Off.name = "Off"; + Off.value = AORUS_ATC800_MODE_OFF; + Off.flags = 0; + Off.color_mode = MODE_COLORS_NONE; + modes.push_back(Off); + + mode Flashing; + Flashing.name = "Flashing"; + Flashing.value = AORUS_ATC800_MODE_FLASHING; + Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; + Flashing.color_mode = MODE_COLORS_PER_LED; + Flashing.speed_min = AORUS_ATC800_SPEED_SLOWEST; + Flashing.speed_max = AORUS_ATC800_SPEED_FASTEST; + Flashing.speed = AORUS_ATC800_SPEED_NORMAL; + modes.push_back(Flashing); + + mode DoubleFlashing; + DoubleFlashing.name = "Double Flashing"; + DoubleFlashing.value = AORUS_ATC800_MODE_DOUBLE_FLASH; + DoubleFlashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; + DoubleFlashing.color_mode = MODE_COLORS_PER_LED; + DoubleFlashing.speed_min = AORUS_ATC800_SPEED_SLOWEST; + DoubleFlashing.speed_max = AORUS_ATC800_SPEED_FASTEST; + DoubleFlashing.speed = AORUS_ATC800_SPEED_NORMAL; + modes.push_back(DoubleFlashing); + + mode Pulsing; + Pulsing.name = "Pulsing"; + Pulsing.value = AORUS_ATC800_MODE_PULSE; + Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; + Pulsing.color_mode = MODE_COLORS_PER_LED; + Pulsing.speed_min = AORUS_ATC800_SPEED_SLOWEST; + Pulsing.speed_max = AORUS_ATC800_SPEED_FASTEST; + Pulsing.speed = AORUS_ATC800_SPEED_NORMAL; + modes.push_back(Pulsing); + + SetupZones(); +} + +RGBController_AorusATC800::~RGBController_AorusATC800() +{ + delete controller; +} + +void RGBController_AorusATC800::SetupZones() +{ + zone atc800_cpu_fans_zone; + atc800_cpu_fans_zone.name = "Fan"; + atc800_cpu_fans_zone.type = ZONE_TYPE_SINGLE; + atc800_cpu_fans_zone.leds_min = 1; + atc800_cpu_fans_zone.leds_max = 1; + atc800_cpu_fans_zone.leds_count = 1; + atc800_cpu_fans_zone.matrix_map = NULL; + zones.push_back(atc800_cpu_fans_zone); + + led atc800_fan_led; + atc800_fan_led.name = "Fan"; + leds.push_back(atc800_fan_led); + + zone atc800_top_zone; + atc800_top_zone.name = "Top"; + atc800_top_zone.type = ZONE_TYPE_SINGLE; + atc800_top_zone.leds_min = 1; + atc800_top_zone.leds_max = 1; + atc800_top_zone.leds_count = 1; + atc800_top_zone.matrix_map = NULL; + zones.push_back(atc800_top_zone); + + led atc800_top_led; + atc800_top_led.name = "Top"; + leds.push_back(atc800_top_led); + + SetupColors(); +} + +void RGBController_AorusATC800::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ +} + +void RGBController_AorusATC800::DeviceUpdateLEDs() +{ + UpdateZoneLEDs(0); + UpdateZoneLEDs(1); +} + +void RGBController_AorusATC800::UpdateZoneLEDs(int zone) +{ + unsigned char mode = modes[active_mode].value; + unsigned char red = RGBGetRValue(colors[zone]); + unsigned char grn = RGBGetGValue(colors[zone]); + unsigned char blu = RGBGetBValue(colors[zone]); + + if(mode == AORUS_ATC800_MODE_OFF) + { + mode = 1; + red = 0; + grn = 0; + blu = 0; + } + + controller->SendCoolerMode(mode, modes[active_mode].speed, zone, red, grn, blu); +} + +void RGBController_AorusATC800::UpdateSingleLED(int led) +{ + UpdateZoneLEDs(led); +} + +void RGBController_AorusATC800::SetCustomMode() +{ + +} + +void RGBController_AorusATC800::DeviceUpdateMode() +{ + DeviceUpdateLEDs(); +} diff --git a/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.h b/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.h index 3b953841..91f647ea 100644 --- a/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.h +++ b/Controllers/GigabyteAorusCPUCoolerController/RGBController_AorusATC800.h @@ -1,33 +1,33 @@ -/*-----------------------------------------*\ -| RGBController_AorusATC800.h | -| | -| Generic RGB Interface for Aorus ATC 800 | -| CPU Cooler | -| | -| Felipe Cavalcanti 08/13/2020 | -\*-----------------------------------------*/ - -#pragma once -#include "RGBController.h" -#include "ATC800Controller.h" - -class RGBController_AorusATC800 : public RGBController -{ -public: - RGBController_AorusATC800(ATC800Controller* logitech_ptr); - ~RGBController_AorusATC800(); - - void SetupZones(); - - void ResizeZone(int zone, int new_size); - - void DeviceUpdateLEDs(); - void UpdateZoneLEDs(int zone); - void UpdateSingleLED(int led); - - void SetCustomMode(); - void DeviceUpdateMode(); - -private: - ATC800Controller* cooler; -}; +/*-----------------------------------------*\ +| RGBController_AorusATC800.h | +| | +| Generic RGB Interface for Aorus ATC 800 | +| CPU Cooler | +| | +| Felipe Cavalcanti 08/13/2020 | +\*-----------------------------------------*/ + +#pragma once +#include "RGBController.h" +#include "ATC800Controller.h" + +class RGBController_AorusATC800 : public RGBController +{ +public: + RGBController_AorusATC800(ATC800Controller* controller_ptr); + ~RGBController_AorusATC800(); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void SetCustomMode(); + void DeviceUpdateMode(); + +private: + ATC800Controller* controller; +}; diff --git a/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp b/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp index 52dcd415..cad19dd3 100644 --- a/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp @@ -1,75 +1,73 @@ -#include "Detector.h" -#include "GigabyteRGBFusion2DRAMController.h" -#include "RGBController.h" -#include "RGBController_GigabyteRGBFusion2DRAM.h" -#include "i2c_smbus.h" -#include "pci_ids.h" -#include -#include -#include -#include - -/******************************************************************************************\ -* * -* TestForGigabyteRGBFusion2DRAMController * -* * -* Tests the given address to see if an RGB 2 Fusion DRAMcontroller exists there. * -* First does a quick write to test for a response * -* * -\******************************************************************************************/ - -bool TestForGigabyteRGBFusion2DRAMController(i2c_smbus_interface* bus, unsigned char address) -{ - bool pass = false; - - int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); - if (res >= 0) - { - pass = true; - - // res = bus->i2c_smbus_read_byte_data(address, 0xF2); - - // if (res != 0xC4) - // { - // pass = false; - // } - } - - return(pass); - -} /* TestForGigabyteRGBFusion2DRAMController() */ - -/***********************************************************************************************\ -* * -* DetectGigabyteRGBFusion2DRAMControllers * -* * -* Detect Gigabyte RGB Fusion 2 controllers on the enumerated I2C buses at address 0x67. * -* * -* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected * -* dev - I2C address of RGB Fusion device * -* * -\***********************************************************************************************/ - -void DetectGigabyteRGBFusion2DRAMControllers(std::vector& busses) -{ - RGBFusion2DRAMController* new_rgb_fusion; - RGBController_RGBFusion2DRAM* new_controller; - - for (unsigned int bus = 0; bus < busses.size(); bus++) - { - IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) - { - // Check for RGB Fusion 2 DRAM controller at 0x67 - if (TestForGigabyteRGBFusion2DRAMController(busses[bus], 0x67)) - { - new_rgb_fusion = new RGBFusion2DRAMController(busses[bus], 0x67); - new_controller = new RGBController_RGBFusion2DRAM(new_rgb_fusion); - ResourceManager::get()->RegisterRGBController(new_controller); - } - } - } - -} /* DetectGigabyteRGBFusion2DRAMControllers() */ - -// This detector is disabled as proper detection isn't implemented -//REGISTER_I2C_DETECTOR("Gigabyte RGB Fusion 2 DRAM", DetectGigabyteRGBFusion2DRAMControllers); +#include "Detector.h" +#include "GigabyteRGBFusion2DRAMController.h" +#include "RGBController.h" +#include "RGBController_GigabyteRGBFusion2DRAM.h" +#include "i2c_smbus.h" +#include "pci_ids.h" +#include +#include +#include +#include + +/******************************************************************************************\ +* * +* TestForGigabyteRGBFusion2DRAMController * +* * +* Tests the given address to see if an RGB 2 Fusion DRAMcontroller exists there. * +* First does a quick write to test for a response * +* * +\******************************************************************************************/ + +bool TestForGigabyteRGBFusion2DRAMController(i2c_smbus_interface* bus, unsigned char address) +{ + bool pass = false; + + int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); + if (res >= 0) + { + pass = true; + + // res = bus->i2c_smbus_read_byte_data(address, 0xF2); + + // if (res != 0xC4) + // { + // pass = false; + // } + } + + return(pass); + +} /* TestForGigabyteRGBFusion2DRAMController() */ + +/***********************************************************************************************\ +* * +* DetectGigabyteRGBFusion2DRAMControllers * +* * +* Detect Gigabyte RGB Fusion 2 controllers on the enumerated I2C buses at address 0x67. * +* * +* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected * +* dev - I2C address of RGB Fusion device * +* * +\***********************************************************************************************/ + +void DetectGigabyteRGBFusion2DRAMControllers(std::vector& busses) +{ + for(unsigned int bus = 0; bus < busses.size(); bus++) + { + IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) + { + // Check for RGB Fusion 2 DRAM controller at 0x67 + if(TestForGigabyteRGBFusion2DRAMController(busses[bus], 0x67)) + { + RGBFusion2DRAMController* controller = new RGBFusion2DRAMController(busses[bus], 0x67); + RGBController_RGBFusion2DRAM* rgb_controller = new RGBController_RGBFusion2DRAM(controller); + + ResourceManager::get()->RegisterRGBController(rgb_controller); + } + } + } + +} /* DetectGigabyteRGBFusion2DRAMControllers() */ + +// This detector is disabled as proper detection isn't implemented +//REGISTER_I2C_DETECTOR("Gigabyte RGB Fusion 2 DRAM", DetectGigabyteRGBFusion2DRAMControllers); diff --git a/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.cpp b/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.cpp index 54e176c2..f64e58f6 100644 --- a/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.cpp +++ b/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.cpp @@ -1,105 +1,105 @@ -/*-----------------------------------------*\ -| GigabyteRGBController_RGBFusion2DRAM.cpp | -| | -| Generic RGB Interface for OpenRGB | -| Gigabyte RGB Fusion 2 DRAM Driver | -| | -| Adam Honse (CalcProgrammer1) 6/7/2020 | -\*-----------------------------------------*/ - -#include "RGBController_GigabyteRGBFusion2DRAM.h" - -RGBController_RGBFusion2DRAM::RGBController_RGBFusion2DRAM(RGBFusion2DRAMController* rgb_fusion_ptr) -{ - rgb_fusion = rgb_fusion_ptr; - - name = "RGB Fusion 2 DRAM"; - vendor = "Gigabyte"; - description = "RGB Fusion 2 DRAM Device"; - location = rgb_fusion->GetDeviceLocation(); - - type = DEVICE_TYPE_DRAM; - - mode Static; - Static.name = "Static"; - Static.value = 1; - Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Static.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Static); - - SetupZones(); -} - -RGBController_RGBFusion2DRAM::~RGBController_RGBFusion2DRAM() -{ - delete rgb_fusion; -} - -void RGBController_RGBFusion2DRAM::SetupZones() -{ - /*---------------------------------------------------------*\ - | Search through all LEDs and create zones for each channel | - | type | - \*---------------------------------------------------------*/ - zone* new_zone = new zone(); - - // Set zone name to channel name - new_zone->name = "DRAM Zone"; - new_zone->leds_min = 1; - new_zone->leds_max = 1; - new_zone->leds_count = 1; - - // Push new zone to zones vector - zones.push_back(*new_zone); - - led* new_led = new led(); - new_led->name = "DRAM LED"; - - // Push new LED to LEDs vector - leds.push_back(*new_led); - - SetupColors(); -} - -void RGBController_RGBFusion2DRAM::ResizeZone(int /*zone*/, int /*new_size*/) -{ - /*---------------------------------------------------------*\ - | This device does not support resizing zones | - \*---------------------------------------------------------*/ -} - -void RGBController_RGBFusion2DRAM::DeviceUpdateLEDs() -{ - RGBColor color = colors[0]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); - - int mode = modes[active_mode].value; - unsigned int speed = modes[active_mode].speed; - - rgb_fusion->SetLEDEffect(0, mode, speed, red, grn, blu); - - rgb_fusion->Apply(); -} - -void RGBController_RGBFusion2DRAM::UpdateZoneLEDs(int /*zone*/) -{ - UpdateLEDs(); -} - -void RGBController_RGBFusion2DRAM::UpdateSingleLED(int /*led*/) -{ - UpdateLEDs(); -} - -void RGBController_RGBFusion2DRAM::SetCustomMode() -{ - -} - -void RGBController_RGBFusion2DRAM::DeviceUpdateMode() -{ - -} - +/*-----------------------------------------*\ +| GigabyteRGBController_RGBFusion2DRAM.cpp | +| | +| Generic RGB Interface for OpenRGB | +| Gigabyte RGB Fusion 2 DRAM Driver | +| | +| Adam Honse (CalcProgrammer1) 6/7/2020 | +\*-----------------------------------------*/ + +#include "RGBController_GigabyteRGBFusion2DRAM.h" + +RGBController_RGBFusion2DRAM::RGBController_RGBFusion2DRAM(RGBFusion2DRAMController* controller_ptr) +{ + controller = controller_ptr; + + name = "RGB Fusion 2 DRAM"; + vendor = "Gigabyte"; + description = "RGB Fusion 2 DRAM Device"; + location = controller->GetDeviceLocation(); + + type = DEVICE_TYPE_DRAM; + + mode Static; + Static.name = "Static"; + Static.value = 1; + Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Static.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Static); + + SetupZones(); +} + +RGBController_RGBFusion2DRAM::~RGBController_RGBFusion2DRAM() +{ + delete controller; +} + +void RGBController_RGBFusion2DRAM::SetupZones() +{ + /*---------------------------------------------------------*\ + | Search through all LEDs and create zones for each channel | + | type | + \*---------------------------------------------------------*/ + zone* new_zone = new zone(); + + // Set zone name to channel name + new_zone->name = "DRAM Zone"; + new_zone->leds_min = 1; + new_zone->leds_max = 1; + new_zone->leds_count = 1; + + // Push new zone to zones vector + zones.push_back(*new_zone); + + led* new_led = new led(); + new_led->name = "DRAM LED"; + + // Push new LED to LEDs vector + leds.push_back(*new_led); + + SetupColors(); +} + +void RGBController_RGBFusion2DRAM::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ +} + +void RGBController_RGBFusion2DRAM::DeviceUpdateLEDs() +{ + RGBColor color = colors[0]; + unsigned char red = RGBGetRValue(color); + unsigned char grn = RGBGetGValue(color); + unsigned char blu = RGBGetBValue(color); + + int mode = modes[active_mode].value; + unsigned int speed = modes[active_mode].speed; + + controller->SetLEDEffect(0, mode, speed, red, grn, blu); + + controller->Apply(); +} + +void RGBController_RGBFusion2DRAM::UpdateZoneLEDs(int /*zone*/) +{ + UpdateLEDs(); +} + +void RGBController_RGBFusion2DRAM::UpdateSingleLED(int /*led*/) +{ + UpdateLEDs(); +} + +void RGBController_RGBFusion2DRAM::SetCustomMode() +{ + +} + +void RGBController_RGBFusion2DRAM::DeviceUpdateMode() +{ + +} + diff --git a/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.h b/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.h index 5b097bbe..6781f571 100644 --- a/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.h +++ b/Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.h @@ -1,34 +1,34 @@ -/*-----------------------------------------*\ -| RGBController_GigabyteRGBFusion2DRAM.h | -| | -| Generic RGB Interface for OpenRGB | -| Gigabyte RGB Fusion 2 DRAM Driver | -| | -| Adam Honse (CalcProgrammer1) 6/7/2020 | -\*-----------------------------------------*/ - -#pragma once - -#include "RGBController.h" -#include "GigabyteRGBFusion2DRAMController.h" - -class RGBController_RGBFusion2DRAM : public RGBController -{ -public: - RGBController_RGBFusion2DRAM(RGBFusion2DRAMController* rgb_fusion_ptr); - ~RGBController_RGBFusion2DRAM(); - - void SetupZones(); - - void ResizeZone(int zone, int new_size); - - void DeviceUpdateLEDs(); - void UpdateZoneLEDs(int zone); - void UpdateSingleLED(int led); - - void SetCustomMode(); - void DeviceUpdateMode(); - -private: - RGBFusion2DRAMController* rgb_fusion; -}; +/*-----------------------------------------*\ +| RGBController_GigabyteRGBFusion2DRAM.h | +| | +| Generic RGB Interface for OpenRGB | +| Gigabyte RGB Fusion 2 DRAM Driver | +| | +| Adam Honse (CalcProgrammer1) 6/7/2020 | +\*-----------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include "GigabyteRGBFusion2DRAMController.h" + +class RGBController_RGBFusion2DRAM : public RGBController +{ +public: + RGBController_RGBFusion2DRAM(RGBFusion2DRAMController* controller_ptr); + ~RGBController_RGBFusion2DRAM(); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void SetCustomMode(); + void DeviceUpdateMode(); + +private: + RGBFusion2DRAMController* controller; +}; diff --git a/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp b/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp index 006a0ce5..d3db222b 100644 --- a/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp @@ -99,14 +99,14 @@ void DetectGigabyteRGBFusion2GPUControllers(std::vector& b busses[bus]->pci_subsystem_vendor == device_list[dev_idx].pci_subsystem_vendor && busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device) { - LOG_DEBUG(GPU_DETECT_MESSAGE, GIGABYTEGPU_CONTROLLER_NAME2, bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name ); + LOG_DEBUG(GPU_DETECT_MESSAGE, GIGABYTEGPU_CONTROLLER_NAME2, bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name); + // Check for RGB Fusion2 controller if(TestForGigabyteRGBFusion2GPUController(busses[bus], device_list[dev_idx].controller_address)) { RGBFusion2GPUController* controller = new RGBFusion2GPUController(busses[bus], device_list[dev_idx].controller_address); RGBController_RGBFusion2GPU* rgb_controller = new RGBController_RGBFusion2GPU(controller); - - rgb_controller->name = device_list[dev_idx].name; + rgb_controller->name = device_list[dev_idx].name; ResourceManager::get()->RegisterRGBController(rgb_controller); } diff --git a/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp b/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp index 772c6956..44895375 100644 --- a/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp @@ -80,8 +80,6 @@ bool TestForGigabyteRGBFusion2SMBusController(i2c_smbus_interface* bus, unsigned void DetectGigabyteRGBFusion2SMBusControllers(std::vector& busses) { - RGBFusion2SMBusController* new_rgb_fusion; - RGBController_RGBFusion2SMBus* new_controller; SettingsManager* set_man = ResourceManager::get()->GetSettingsManager(); json device_settings; @@ -93,7 +91,7 @@ void DetectGigabyteRGBFusion2SMBusControllers(std::vector& \*-------------------------------------------------*/ device_settings = set_man->GetSettings(DETECTOR_NAME); - if (!device_settings.contains("SupportedDevices")) + if(!device_settings.contains("SupportedDevices")) { //If supported devices is not found then write it to settings device_settings["SupportedDevices"] = rgb_fusion_2_smbus_motherboards; @@ -113,7 +111,7 @@ void DetectGigabyteRGBFusion2SMBusControllers(std::vector& if(found) { - for (unsigned int bus = 0; bus < busses.size(); bus++) + for(unsigned int bus = 0; bus < busses.size(); bus++) { IF_MOBO_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) { @@ -122,15 +120,18 @@ void DetectGigabyteRGBFusion2SMBusControllers(std::vector& // TODO - Is this necessary? Or an artifact of my own system? // Skip dmcd devices std::string device_name = std::string(busses[bus]->device_name); - if (device_name.find("dmdc") == std::string::npos) + + if(device_name.find("dmdc") == std::string::npos) { LOG_DEBUG(SMBUS_CHECK_DEVICE_MESSAGE_EN, DETECTOR_NAME, bus, VENDOR_NAME, SMBUS_ADDRESS); + // Check for RGB Fusion 2 controller at 0x68 - if (TestForGigabyteRGBFusion2SMBusController(busses[bus], SMBUS_ADDRESS)) + if(TestForGigabyteRGBFusion2SMBusController(busses[bus], SMBUS_ADDRESS)) { - new_rgb_fusion = new RGBFusion2SMBusController(busses[bus], SMBUS_ADDRESS, dmi.getMainboard() ); - new_controller = new RGBController_RGBFusion2SMBus(new_rgb_fusion); - ResourceManager::get()->RegisterRGBController(new_controller); + RGBFusion2SMBusController* controller = new RGBFusion2SMBusController(busses[bus], SMBUS_ADDRESS, dmi.getMainboard() ); + RGBController_RGBFusion2SMBus* rgb_controller = new RGBController_RGBFusion2SMBus(controller); + + ResourceManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.cpp b/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.cpp index 0fc875ad..493cf084 100644 --- a/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.cpp +++ b/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.cpp @@ -37,14 +37,14 @@ static const char* rgb_fusion_zone_names[] = "???" }; -RGBController_RGBFusion2SMBus::RGBController_RGBFusion2SMBus(RGBFusion2SMBusController* rgb_fusion_ptr) +RGBController_RGBFusion2SMBus::RGBController_RGBFusion2SMBus(RGBFusion2SMBusController* controller_ptr) { - rgb_fusion = rgb_fusion_ptr; + controller = controller_ptr; - name = rgb_fusion->GetDeviceName(); + name = controller->GetDeviceName(); vendor = "Gigabyte"; description = "RGB Fusion 2 SMBus"; - location = rgb_fusion->GetDeviceLocation(); + location = controller->GetDeviceLocation(); type = DEVICE_TYPE_MOTHERBOARD; @@ -189,7 +189,7 @@ RGBController_RGBFusion2SMBus::RGBController_RGBFusion2SMBus(RGBFusion2SMBusCont RGBController_RGBFusion2SMBus::~RGBController_RGBFusion2SMBus() { - delete rgb_fusion; + delete controller; } void RGBController_RGBFusion2SMBus::SetupZones() @@ -198,7 +198,7 @@ void RGBController_RGBFusion2SMBus::SetupZones() | Search through all LEDs and create zones for each channel | | type | \*---------------------------------------------------------*/ - for(unsigned int zone_idx = 0; zone_idx < rgb_fusion->GetLEDCount(); zone_idx++) + for(unsigned int zone_idx = 0; zone_idx < controller->GetLEDCount(); zone_idx++) { zone* new_zone = new zone(); @@ -214,7 +214,7 @@ void RGBController_RGBFusion2SMBus::SetupZones() for(unsigned int led_idx = 0; led_idx < zones.size(); led_idx++) { - led* new_led = new led(); + led* new_led = new led(); // Set LED name to channel name new_led->name = rgb_fusion_zone_names[led_idx]; @@ -237,19 +237,19 @@ void RGBController_RGBFusion2SMBus::DeviceUpdateLEDs() { for (std::size_t led = 0; led < colors.size(); led++) { - RGBColor color = colors[led]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); + RGBColor color = colors[led]; + unsigned char red = RGBGetRValue(color); + unsigned char grn = RGBGetGValue(color); + unsigned char blu = RGBGetBValue(color); - int mode = modes[active_mode].value; - unsigned int speed = modes[active_mode].speed; + int mode = modes[active_mode].value; + unsigned int speed = modes[active_mode].speed; unsigned int brightness = modes[active_mode].brightness; - rgb_fusion->SetLEDEffect(led, mode, brightness, speed, red, grn, blu); + controller->SetLEDEffect(led, mode, brightness, speed, red, grn, blu); } - rgb_fusion->Apply(); + controller->Apply(); } void RGBController_RGBFusion2SMBus::UpdateZoneLEDs(int zone) @@ -259,12 +259,12 @@ void RGBController_RGBFusion2SMBus::UpdateZoneLEDs(int zone) unsigned char grn = RGBGetGValue(color); unsigned char blu = RGBGetBValue(color); - int mode = modes[active_mode].value; - unsigned int speed = modes[active_mode].speed; + int mode = modes[active_mode].value; + unsigned int speed = modes[active_mode].speed; unsigned int brightness = modes[active_mode].brightness; - rgb_fusion->SetLEDEffect(zone, mode, brightness, speed, red, grn, blu); - rgb_fusion->Apply(); + controller->SetLEDEffect(zone, mode, brightness, speed, red, grn, blu); + controller->Apply(); } void RGBController_RGBFusion2SMBus::UpdateSingleLED(int led) diff --git a/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.h b/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.h index 3ca521ce..3bf6c672 100644 --- a/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.h +++ b/Controllers/GigabyteRGBFusion2SMBusController/RGBController_GigabyteRGBFusion2SMBus.h @@ -1,37 +1,37 @@ - -/*-----------------------------------------*\ -| RGBController_GigabyteRGBFusion2SMBus.h | -| | -| Generic RGB Interface for OpenRGB | -| Gigabyte RGB Fusion 2 SMBUS Driver | -| | -| Matt Harper (5/5/2020) | -\*-----------------------------------------*/ - -#pragma once - -#include "RGBController.h" -#include "GigabyteRGBFusion2SMBusController.h" - -class RGBController_RGBFusion2SMBus : public RGBController -{ -public: - RGBController_RGBFusion2SMBus(RGBFusion2SMBusController* rgb_fusion_ptr); - ~RGBController_RGBFusion2SMBus(); - - void SetupZones(); - - void ResizeZone(int zone, int new_size); - - void DeviceUpdateLEDs(); - void UpdateZoneLEDs(int zone); - void UpdateSingleLED(int led); - - void SetCustomMode(); - void DeviceUpdateMode(); - -private: - RGBFusion2SMBusController* rgb_fusion; - - int GetDeviceMode(); -}; + +/*-----------------------------------------*\ +| RGBController_GigabyteRGBFusion2SMBus.h | +| | +| Generic RGB Interface for OpenRGB | +| Gigabyte RGB Fusion 2 SMBUS Driver | +| | +| Matt Harper (5/5/2020) | +\*-----------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include "GigabyteRGBFusion2SMBusController.h" + +class RGBController_RGBFusion2SMBus : public RGBController +{ +public: + RGBController_RGBFusion2SMBus(RGBFusion2SMBusController* controller_ptr); + ~RGBController_RGBFusion2SMBus(); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void SetCustomMode(); + void DeviceUpdateMode(); + +private: + RGBFusion2SMBusController* controller; + + int GetDeviceMode(); +}; diff --git a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp index b5ba92a8..5eaba8a7 100644 --- a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp @@ -1,40 +1,41 @@ -#include "Detector.h" -#include "GigabyteRGBFusion2USBController.h" -#include "RGBController_GigabyteRGBFusion2USB.h" -#include "dependencies/dmiinfo.h" -#define DETECTOR_NAME "Gigabyte RGB Fusion 2 USB" - -#define IT8297_VID 0x048D -#define IT8297_IFC 0 -#define IT8297_U 0xCC -#define IT8297_UPG 0xFF89 - -/******************************************************************************************\ -* * -* DetectGigabyteRGBFusion2USBControllers * -* * -* Detect GigabyteRGB Fusion 2 devices that use IT8297 RGB controller * -* * -\******************************************************************************************/ - -void DetectGigabyteRGBFusion2USBControllers(hid_device_info* info, const std::string&) -{ - DMIInfo MB_info; - hid_device* dev = hid_open_path(info->path); - if (dev) - { - RGBFusion2USBController * controller = new RGBFusion2USBController(dev, info->path, MB_info.getMainboard()); - RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller, DETECTOR_NAME); - // 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, 0x5702, 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, 0x5702, IT8297_IFC); -#endif - +#include "Detector.h" +#include "GigabyteRGBFusion2USBController.h" +#include "RGBController_GigabyteRGBFusion2USB.h" +#include "dependencies/dmiinfo.h" +#define DETECTOR_NAME "Gigabyte RGB Fusion 2 USB" + +#define IT8297_VID 0x048D +#define IT8297_IFC 0 +#define IT8297_U 0xCC +#define IT8297_UPG 0xFF89 + +/******************************************************************************************\ +* * +* DetectGigabyteRGBFusion2USBControllers * +* * +* Detect GigabyteRGB Fusion 2 devices that use IT8297 RGB controller * +* * +\******************************************************************************************/ + +void DetectGigabyteRGBFusion2USBControllers(hid_device_info* info, const std::string&) +{ + DMIInfo MB_info; + hid_device* dev = hid_open_path(info->path); + + if(dev) + { + RGBFusion2USBController* controller = new RGBFusion2USBController(dev, info->path, MB_info.getMainboard()); + RGBController_RGBFusion2USB* rgb_controller = new RGBController_RGBFusion2USB(controller, DETECTOR_NAME); + // 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, 0x5702, 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, 0x5702, IT8297_IFC); +#endif + diff --git a/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp b/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp index 787fbe9b..3b18b62d 100644 --- a/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp @@ -57,22 +57,21 @@ bool TestForGigabyteRGBFusionController(i2c_smbus_interface* bus, unsigned char void DetectGigabyteRGBFusionControllers(std::vector& busses) { - RGBFusionController* new_rgb_fusion; - RGBController_RGBFusion* new_controller; - - for (unsigned int bus = 0; bus < busses.size(); bus++) + for(unsigned int bus = 0; bus < busses.size(); bus++) { IF_MOBO_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) { if(busses[bus]->pci_subsystem_vendor == GIGABYTE_SUB_VEN) { LOG_DEBUG(SMBUS_CHECK_DEVICE_MESSAGE_EN, DETECTOR_NAME, bus, VENDOR_NAME, SMBUS_ADDRESS); + // Check for RGB Fusion controller at 0x28 - if (TestForGigabyteRGBFusionController(busses[bus], SMBUS_ADDRESS)) + if(TestForGigabyteRGBFusionController(busses[bus], SMBUS_ADDRESS)) { - new_rgb_fusion = new RGBFusionController(busses[bus], SMBUS_ADDRESS); - new_controller = new RGBController_RGBFusion(new_rgb_fusion); - ResourceManager::get()->RegisterRGBController(new_controller); + RGBFusionController* controller = new RGBFusionController(busses[bus], SMBUS_ADDRESS); + RGBController_RGBFusion* rgb_controller = new RGBController_RGBFusion(controller); + + ResourceManager::get()->RegisterRGBController(rgb_controller); } } else diff --git a/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.cpp b/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.cpp index 1e052f92..10314cf2 100644 --- a/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.cpp +++ b/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.cpp @@ -1,168 +1,167 @@ -/*-----------------------------------------*\ -| RGBController_GigabyteRGBFusion.cpp | -| | -| Generic RGB Interface for OpenRGB | -| Gigabyte RGB Fusion Driver | -| | -| Adam Honse (CalcProgrammer1) 12/11/2019 | -\*-----------------------------------------*/ - -#include "RGBController_GigabyteRGBFusion.h" - -static const char* rgb_fusion_zone_names[] = -{ - "Motherboard", - "RGB Header" -}; - -RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion_ptr) -{ - rgb_fusion = rgb_fusion_ptr; - - name = rgb_fusion->GetDeviceName(); - vendor = "Gigabyte"; - description = "RGB Fusion 1.0"; - location = rgb_fusion->GetDeviceLocation(); - - type = DEVICE_TYPE_MOTHERBOARD; - - mode Direct; - Direct.name = "Direct"; - Direct.value = RGB_FUSION_MODE_STATIC; - Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Direct.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Direct); - - mode Breathing; - Breathing.name = "Breathing"; - Breathing.value = RGB_FUSION_MODE_BREATHING; - Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; - Breathing.speed_min = RGB_FUSION_SPEED_SLOW; - Breathing.speed_max = RGB_FUSION_SPEED_FAST; - Breathing.speed = RGB_FUSION_SPEED_NORMAL; - Breathing.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Breathing); - - mode Flashing; - Flashing.name = "Flashing"; - Flashing.value = RGB_FUSION_MODE_FLASHING; - Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; - Flashing.speed_min = RGB_FUSION_SPEED_SLOW; - Flashing.speed_max = RGB_FUSION_SPEED_FAST; - Flashing.speed = RGB_FUSION_SPEED_NORMAL; - Flashing.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Flashing); - - SetupZones(); - - // Initialize active mode - active_mode = GetDeviceMode(); -} - -RGBController_RGBFusion::~RGBController_RGBFusion() -{ - delete rgb_fusion; -} - -void RGBController_RGBFusion::SetupZones() -{ - /*---------------------------------------------------------*\ - | Search through all LEDs and create zones for each channel | - | type | - \*---------------------------------------------------------*/ - for(unsigned int zone_idx = 0; zone_idx < rgb_fusion->GetLEDCount(); zone_idx++) - { - zone* new_zone = new zone(); - - /*---------------------------------------------------------*\ - | Set zone name to channel name | - \*---------------------------------------------------------*/ - new_zone->name = rgb_fusion_zone_names[zone_idx]; - new_zone->leds_min = 1; - new_zone->leds_max = 1; - new_zone->leds_count = 1; - new_zone->matrix_map = NULL; - - /*---------------------------------------------------------*\ - | Push new zone to zones vector | - \*---------------------------------------------------------*/ - zones.push_back(*new_zone); - } - - for(unsigned int led_idx = 0; led_idx < zones.size(); led_idx++) - { - led* new_led = new led(); - - /*---------------------------------------------------------*\ - | Set LED name to channel name | - \*---------------------------------------------------------*/ - new_led->name = rgb_fusion_zone_names[led_idx]; - - /*---------------------------------------------------------*\ - | Push new LED to LEDs vector | - \*---------------------------------------------------------*/ - leds.push_back(*new_led); - } - - SetupColors(); -} - -void RGBController_RGBFusion::ResizeZone(int /*zone*/, int /*new_size*/) -{ - /*---------------------------------------------------------*\ - | This device does not support resizing zones | - \*---------------------------------------------------------*/ -} - -void RGBController_RGBFusion::DeviceUpdateLEDs() -{ - for (std::size_t led = 0; led < colors.size(); led++) - { - RGBColor color = colors[led]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); - - rgb_fusion->SetLEDColor(led, red, grn, blu); - } -} - -void RGBController_RGBFusion::UpdateZoneLEDs(int zone) -{ - RGBColor color = colors[zone]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); - - rgb_fusion->SetLEDColor(zone, red, grn, blu); -} - -void RGBController_RGBFusion::UpdateSingleLED(int led) -{ - UpdateZoneLEDs(led); -} - -int RGBController_RGBFusion::GetDeviceMode() -{ - int dev_mode = rgb_fusion->GetMode(); - - for(std::size_t mode = 0; mode < modes.size(); mode++) - { - if(modes[mode].value == dev_mode) - { - return(mode); - } - } - - return(0); -} - -void RGBController_RGBFusion::SetCustomMode() -{ - active_mode = 0; -} - -void RGBController_RGBFusion::DeviceUpdateMode() -{ - rgb_fusion->SetMode(modes[active_mode].value, modes[active_mode].speed); -} +/*-----------------------------------------*\ +| RGBController_GigabyteRGBFusion.cpp | +| | +| Generic RGB Interface for OpenRGB | +| Gigabyte RGB Fusion Driver | +| | +| Adam Honse (CalcProgrammer1) 12/11/2019 | +\*-----------------------------------------*/ + +#include "RGBController_GigabyteRGBFusion.h" + +static const char* rgb_fusion_zone_names[] = +{ + "Motherboard", + "RGB Header" +}; + +RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* controller_ptr) +{ + controller = controller_ptr; + + name = controller->GetDeviceName(); + vendor = "Gigabyte"; + description = "RGB Fusion 1.0"; + location = controller->GetDeviceLocation(); + type = DEVICE_TYPE_MOTHERBOARD; + + mode Direct; + Direct.name = "Direct"; + Direct.value = RGB_FUSION_MODE_STATIC; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Direct); + + mode Breathing; + Breathing.name = "Breathing"; + Breathing.value = RGB_FUSION_MODE_BREATHING; + Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; + Breathing.speed_min = RGB_FUSION_SPEED_SLOW; + Breathing.speed_max = RGB_FUSION_SPEED_FAST; + Breathing.speed = RGB_FUSION_SPEED_NORMAL; + Breathing.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Breathing); + + mode Flashing; + Flashing.name = "Flashing"; + Flashing.value = RGB_FUSION_MODE_FLASHING; + Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; + Flashing.speed_min = RGB_FUSION_SPEED_SLOW; + Flashing.speed_max = RGB_FUSION_SPEED_FAST; + Flashing.speed = RGB_FUSION_SPEED_NORMAL; + Flashing.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Flashing); + + SetupZones(); + + // Initialize active mode + active_mode = GetDeviceMode(); +} + +RGBController_RGBFusion::~RGBController_RGBFusion() +{ + delete controller; +} + +void RGBController_RGBFusion::SetupZones() +{ + /*---------------------------------------------------------*\ + | Search through all LEDs and create zones for each channel | + | type | + \*---------------------------------------------------------*/ + for(unsigned int zone_idx = 0; zone_idx < controller->GetLEDCount(); zone_idx++) + { + zone* new_zone = new zone(); + + /*---------------------------------------------------------*\ + | Set zone name to channel name | + \*---------------------------------------------------------*/ + new_zone->name = rgb_fusion_zone_names[zone_idx]; + new_zone->leds_min = 1; + new_zone->leds_max = 1; + new_zone->leds_count = 1; + new_zone->matrix_map = NULL; + + /*---------------------------------------------------------*\ + | Push new zone to zones vector | + \*---------------------------------------------------------*/ + zones.push_back(*new_zone); + } + + for(unsigned int led_idx = 0; led_idx < zones.size(); led_idx++) + { + led* new_led = new led(); + + /*---------------------------------------------------------*\ + | Set LED name to channel name | + \*---------------------------------------------------------*/ + new_led->name = rgb_fusion_zone_names[led_idx]; + + /*---------------------------------------------------------*\ + | Push new LED to LEDs vector | + \*---------------------------------------------------------*/ + leds.push_back(*new_led); + } + + SetupColors(); +} + +void RGBController_RGBFusion::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ +} + +void RGBController_RGBFusion::DeviceUpdateLEDs() +{ + for (std::size_t led = 0; led < colors.size(); led++) + { + RGBColor color = colors[led]; + unsigned char red = RGBGetRValue(color); + unsigned char grn = RGBGetGValue(color); + unsigned char blu = RGBGetBValue(color); + + controller->SetLEDColor(led, red, grn, blu); + } +} + +void RGBController_RGBFusion::UpdateZoneLEDs(int zone) +{ + RGBColor color = colors[zone]; + unsigned char red = RGBGetRValue(color); + unsigned char grn = RGBGetGValue(color); + unsigned char blu = RGBGetBValue(color); + + controller->SetLEDColor(zone, red, grn, blu); +} + +void RGBController_RGBFusion::UpdateSingleLED(int led) +{ + UpdateZoneLEDs(led); +} + +int RGBController_RGBFusion::GetDeviceMode() +{ + int dev_mode = controller->GetMode(); + + for(std::size_t mode = 0; mode < modes.size(); mode++) + { + if(modes[mode].value == dev_mode) + { + return(mode); + } + } + + return(0); +} + +void RGBController_RGBFusion::SetCustomMode() +{ + active_mode = 0; +} + +void RGBController_RGBFusion::DeviceUpdateMode() +{ + controller->SetMode(modes[active_mode].value, modes[active_mode].speed); +} diff --git a/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.h b/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.h index 54a4beb8..25051488 100644 --- a/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.h +++ b/Controllers/GigabyteRGBFusionController/RGBController_GigabyteRGBFusion.h @@ -1,36 +1,36 @@ -/*-----------------------------------------*\ -| RGBController_GigabyteRGBFusion.h | -| | -| Generic RGB Interface for OpenRGB | -| Gigabyte RGB Fusion Driver | -| | -| Adam Honse (CalcProgrammer1) 12/11/2019 | -\*-----------------------------------------*/ - -#pragma once - -#include "RGBController.h" -#include "GigabyteRGBFusionController.h" - -class RGBController_RGBFusion : public RGBController -{ -public: - RGBController_RGBFusion(RGBFusionController* rgb_fusion_ptr); - ~RGBController_RGBFusion(); - - void SetupZones(); - - void ResizeZone(int zone, int new_size); - - void DeviceUpdateLEDs(); - void UpdateZoneLEDs(int zone); - void UpdateSingleLED(int led); - - void SetCustomMode(); - void DeviceUpdateMode(); - -private: - RGBFusionController* rgb_fusion; - - int GetDeviceMode(); -}; +/*-----------------------------------------*\ +| RGBController_GigabyteRGBFusion.h | +| | +| Generic RGB Interface for OpenRGB | +| Gigabyte RGB Fusion Driver | +| | +| Adam Honse (CalcProgrammer1) 12/11/2019 | +\*-----------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include "GigabyteRGBFusionController.h" + +class RGBController_RGBFusion : public RGBController +{ +public: + RGBController_RGBFusion(RGBFusionController* controller_ptr); + ~RGBController_RGBFusion(); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void SetCustomMode(); + void DeviceUpdateMode(); + +private: + RGBFusionController* controller; + + int GetDeviceMode(); +}; diff --git a/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp b/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp index c3429797..641f3dd0 100644 --- a/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp @@ -150,10 +150,7 @@ bool TestForGigabyteRGBFusionGPUController(i2c_smbus_interface* bus, unsigned ch void DetectGigabyteRGBFusionGPUControllers(std::vector& busses) { - RGBFusionGPUController* new_rgb_fusion; - RGBController_RGBFusionGPU* new_controller; - - for (unsigned int bus = 0; bus < busses.size(); bus++) + for(unsigned int bus = 0; bus < busses.size(); bus++) { for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++) { @@ -162,14 +159,16 @@ void DetectGigabyteRGBFusionGPUControllers(std::vector& bu busses[bus]->pci_subsystem_vendor == device_list[dev_idx].pci_subsystem_vendor && busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device) { - LOG_DEBUG(GPU_DETECT_MESSAGE, GIGABYTEGPU_CONTROLLER_NAME, bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name ); + LOG_DEBUG(GPU_DETECT_MESSAGE, GIGABYTEGPU_CONTROLLER_NAME, bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name); + // Check for RGB Fusion controller - if (TestForGigabyteRGBFusionGPUController(busses[bus], device_list[dev_idx].controller_address)) + if(TestForGigabyteRGBFusionGPUController(busses[bus], device_list[dev_idx].controller_address)) { - new_rgb_fusion = new RGBFusionGPUController(busses[bus], device_list[dev_idx].controller_address); - new_controller = new RGBController_RGBFusionGPU(new_rgb_fusion); - new_controller->name = device_list[dev_idx].name; - ResourceManager::get()->RegisterRGBController(new_controller); + RGBFusionGPUController* controller = new RGBFusionGPUController(busses[bus], device_list[dev_idx].controller_address); + RGBController_RGBFusionGPU* rgb_controller = new RGBController_RGBFusionGPU(controller); + rgb_controller->name = device_list[dev_idx].name; + + ResourceManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.cpp b/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.cpp index 96eab039..d0f7fc26 100644 --- a/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.cpp +++ b/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.cpp @@ -9,16 +9,15 @@ #include "RGBController_GigabyteRGBFusionGPU.h" -RGBController_RGBFusionGPU::RGBController_RGBFusionGPU(RGBFusionGPUController* rgb_fusion_ptr) +RGBController_RGBFusionGPU::RGBController_RGBFusionGPU(RGBFusionGPUController* controller_ptr) { - rgb_fusion = rgb_fusion_ptr; + controller = controller_ptr; name = "Gigabyte GPU"; vendor = "Gigabyte"; description = "RGB Fusion GPU"; - location = rgb_fusion->GetDeviceLocation(); - - type = DEVICE_TYPE_GPU; + location = controller->GetDeviceLocation(); + type = DEVICE_TYPE_GPU; mode Direct; Direct.name = "Direct"; @@ -100,7 +99,7 @@ RGBController_RGBFusionGPU::RGBController_RGBFusionGPU(RGBFusionGPUController* r RGBController_RGBFusionGPU::~RGBController_RGBFusionGPU() { - delete rgb_fusion; + delete controller; } void RGBController_RGBFusionGPU::SetupZones() @@ -109,8 +108,8 @@ void RGBController_RGBFusionGPU::SetupZones() | This device only has one LED, so create a single zone and | | LED for it | \*---------------------------------------------------------*/ - zone* new_zone = new zone(); - led* new_led = new led(); + zone* new_zone = new zone(); + led* new_led = new led(); new_zone->name = "GPU Zone"; new_zone->type = ZONE_TYPE_SINGLE; @@ -144,7 +143,7 @@ void RGBController_RGBFusionGPU::DeviceUpdateLEDs() unsigned char grn = RGBGetGValue(color); unsigned char blu = RGBGetBValue(color); - rgb_fusion->SetColor(red, grn, blu); + controller->SetColor(red, grn, blu); } void RGBController_RGBFusionGPU::UpdateZoneLEDs(int /*zone*/) @@ -164,11 +163,11 @@ void RGBController_RGBFusionGPU::SetCustomMode() void RGBController_RGBFusionGPU::DeviceUpdateMode() { - rgb_fusion->SetMode((unsigned char)modes[(unsigned int)active_mode].value, (unsigned char)modes[(unsigned int)active_mode].speed, (unsigned char)modes[(unsigned int)active_mode].brightness); + controller->SetMode((unsigned char)modes[(unsigned int)active_mode].value, (unsigned char)modes[(unsigned int)active_mode].speed, (unsigned char)modes[(unsigned int)active_mode].brightness); } void RGBController_RGBFusionGPU::DeviceSaveMode() { DeviceUpdateMode(); - rgb_fusion->Save(); + controller->Save(); } \ No newline at end of file diff --git a/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.h b/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.h index 346f6298..5cc76448 100644 --- a/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.h +++ b/Controllers/GigabyteRGBFusionGPUController/RGBController_GigabyteRGBFusionGPU.h @@ -15,7 +15,7 @@ class RGBController_RGBFusionGPU : public RGBController { public: - RGBController_RGBFusionGPU(RGBFusionGPUController* rgb_fusion_ptr); + RGBController_RGBFusionGPU(RGBFusionGPUController* controller_ptr); ~RGBController_RGBFusionGPU(); void SetupZones(); @@ -31,5 +31,5 @@ public: void DeviceSaveMode(); private: - RGBFusionGPUController* rgb_fusion; + RGBFusionGPUController* controller; };