RGB Fusion 2.0 driver based on summerblind's code

This commit is contained in:
Adam Honse 2020-01-15 12:38:30 -06:00
parent 3948e74711
commit c52eb528ea
6 changed files with 328 additions and 0 deletions

View file

@ -0,0 +1,119 @@
/*-----------------------------------------*\
| RGBFusion2Controller.cpp |
| |
| Driver for Gigabyte Aorus RGB Fusion 2.0 |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include "RGBFusion2Controller.h"
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
RGBFusion2Controller::RGBFusion2Controller(hid_device* dev_handle)
{
dev = dev_handle;
// Set Device name
strcpy(device_name, "Gigabyte Motherboard");
// Set LED count
led_count = 8;
}
RGBFusion2Controller::~RGBFusion2Controller()
{
}
std::string RGBFusion2Controller::GetDeviceName()
{
return(device_name);
}
std::string RGBFusion2Controller::GetDeviceLocation()
{
return("");
}
unsigned int RGBFusion2Controller::GetLEDCount()
{
return(led_count);
}
unsigned char RGBFusion2Controller::GetMode()
{
return(0);
}
void RGBFusion2Controller::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
}
void RGBFusion2Controller::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char usb_buf[] =
{
0xCC, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x5A, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
usb_buf[0x01] = (0x20 | led);
usb_buf[0x02] = (0x01 << led );
usb_buf[0x0E] = red;
usb_buf[0x0F] = green;
usb_buf[0x10] = blue;
hid_send_feature_report(dev, usb_buf, 64);
}
void RGBFusion2Controller::SendApply()
{
unsigned char usb_buf[] =
{
0xCC, 0x28, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
hid_send_feature_report(dev, usb_buf, 64);
}
void RGBFusion2Controller::SetMode(unsigned char mode)
{
}
void RGBFusion2Controller::dump()
{
}

View file

@ -0,0 +1,39 @@
/*-----------------------------------------*\
| RGBFusion2Controller.h |
| |
| Definitions and types for Gigabyte Aorus |
| RGB Fusion 2.0 lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class RGBFusion2Controller
{
public:
RGBFusion2Controller(hid_device* dev_handle);
~RGBFusion2Controller();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned char GetMode();
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
private:
void dump();
char device_name[32];
unsigned int led_count;
void SendApply();
hid_device* dev;
};

View file

@ -0,0 +1,36 @@
#include "RGBFusion2Controller.h"
#include "RGBController.h"
#include "RGBController_RGBFusion2.h"
#include <vector>
#include <hidapi/hidapi.h>
#define RGB_FUSION_2_VID 0x048D
#define RGB_FUSION_2_PID 0x8297
/******************************************************************************************\
* *
* DetectRGBFusion2Controllers *
* *
* Detect RGB Fusion 2.0 controllers on the USB interface. *
* *
\******************************************************************************************/
void DetectRGBFusion2Controllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device* dev;
//Look for RGB Fusion 2.0 Controller
hid_init();
dev = hid_open(RGB_FUSION_2_VID, RGB_FUSION_2_PID, 0);
if( dev )
{
RGBFusion2Controller* controller = new RGBFusion2Controller(dev);
RGBController_RGBFusion2* rgb_controller = new RGBController_RGBFusion2(controller);
rgb_controllers.push_back(rgb_controller);
}
} /* DetectRGBFusionControllers() */

View file

@ -29,6 +29,7 @@ INCLUDEPATH += \
Controllers/PolychromeController/ \
Controllers/PoseidonZRGBController/ \
Controllers/RGBFusionController/ \
Controllers/RGBFusion2Controller/ \
Controllers/ThermaltakeRiingController/ \
RGBController/ \
qt/
@ -82,6 +83,8 @@ SOURCES += \
Controllers/PoseidonZRGBController/PoseidonZRGBControllerDetect.cpp \
Controllers/RGBFusionController/RGBFusionController.cpp \
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
Controllers/RGBFusion2Controller/RGBFusion2Controller.cpp \
Controllers/RGBFusion2Controller/RGBFusion2ControllerDetect.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
RGBController/RGBController.cpp \
@ -104,6 +107,7 @@ SOURCES += \
RGBController/RGBController_Polychrome.cpp \
RGBController/RGBController_PoseidonZRGB.cpp \
RGBController/RGBController_RGBFusion.cpp \
RGBController/RGBController_RGBFusion2.cpp \
RGBController/RGBController_ThermaltakeRiing.cpp \
HEADERS += \
@ -135,6 +139,7 @@ HEADERS += \
Controllers/PolychromeController/PolychromeController.h \
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
Controllers/RGBFusionController/RGBFusionController.h \
Controllers/RGBFusion2Controller/RGBFusion2Controller.h \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
RGBController/RGBController.h \
RGBController/RGBController_AMDWraithPrism.h \
@ -154,6 +159,7 @@ HEADERS += \
RGBController/RGBController_Polychrome.h \
RGBController/RGBController_PoseidonZRGB.h \
RGBController/RGBController_RGBFusion.h \
RGBController/RGBController_RGBFusion2.h \
RGBController/RGBController_ThermaltakeRiing.h \
RESOURCES += \

View file

@ -0,0 +1,100 @@
/*-----------------------------------------*\
| RGBController_RGBFusion2.cpp |
| |
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 Driver |
| |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include "RGBController_RGBFusion2.h"
int RGBController_RGBFusion2::GetMode()
{
return(rgb_fusion->GetMode());
}
void RGBController_RGBFusion2::SetMode(int mode)
{
rgb_fusion->SetMode(mode);
}
void RGBController_RGBFusion2::SetCustomMode()
{
rgb_fusion->SetMode(0);
}
void RGBController_RGBFusion2::UpdateLEDs()
{
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_RGBFusion2::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_RGBFusion2::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
RGBController_RGBFusion2::RGBController_RGBFusion2(RGBFusion2Controller* rgb_fusion_ptr)
{
rgb_fusion = rgb_fusion_ptr;
name = rgb_fusion->GetDeviceName();
description = "RGB Fusion 2.0";
location = rgb_fusion->GetDeviceLocation();
type = DEVICE_TYPE_MOTHERBOARD;
mode rgb_fusion_modes[1];
rgb_fusion_modes[0].name = "Static";
for (int i = 0; i < 1; i++)
{
modes.push_back(rgb_fusion_modes[i]);
}
colors.resize(rgb_fusion->GetLEDCount());
// Search through all LEDs and create zones for each channel type
for (unsigned int i = 0; i < rgb_fusion->GetLEDCount(); i++)
{
zone* new_zone = new zone();
led* new_led = new led();
std::vector<int>* zone_row = new std::vector<int>();
// Set zone name to channel name
new_zone->name = "Zone";
new_led->name = "LED";
zone_row->push_back(i);
// Aura devices can be either single or linear, never matrix
// That means only one row is needed
new_zone->map.push_back(*zone_row);
// Push new LED to LEDs vector
leds.push_back(*new_led);
// Push new zone to zones vector
zones.push_back(*new_zone);
}
}

View file

@ -0,0 +1,28 @@
/*-----------------------------------------*\
| RGBController_RGBFusion2.h |
| |
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 Driver |
| |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "RGBFusion2Controller.h"
class RGBController_RGBFusion2 : public RGBController
{
public:
RGBController_RGBFusion2(RGBFusion2Controller* rgb_fusion_ptr);
int GetMode();
void SetMode(int mode);
void SetCustomMode();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
private:
RGBFusion2Controller* rgb_fusion;
};