Add support for Gigabyte AORUS C300 Glass PC Case
This commit is contained in:
parent
6a944b311a
commit
f856480077
6 changed files with 428 additions and 0 deletions
|
|
@ -0,0 +1,106 @@
|
|||
/*------------------------------------------*\
|
||||
| GigabyteAorusPCCaseController.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus PC Case |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Denis Nazarov (nenderus) 2/10/2024 |
|
||||
\*------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "GigabyteAorusPCCaseController.h"
|
||||
|
||||
GigabyteAorusPCCaseController::GigabyteAorusPCCaseController(hid_device *dev_handle, const char *path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
GigabyteAorusPCCaseController::~GigabyteAorusPCCaseController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string GigabyteAorusPCCaseController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string GigabyteAorusPCCaseController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void GigabyteAorusPCCaseController::SendColor(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
uint8_t usb_buf[9] = { 0x00, 0x01, 0xC8, red, green, blue, 0x08, 0x01, 0x00 };
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
void GigabyteAorusPCCaseController::SendMode(uint8_t mode, uint8_t speed, uint8_t brightness)
|
||||
{
|
||||
uint8_t usb_buf[9] = { 0x00, 0x01, 0xC9, mode, brightness, speed, 0x01, 0x08, 0x00 };
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
void GigabyteAorusPCCaseController::SendOk()
|
||||
{
|
||||
uint8_t usb_buf[9] = { 0x00, 0x01, 0xB6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
void GigabyteAorusPCCaseController::SetMode(uint8_t mode, mode_config zone_config)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case AORUS_PC_CASE_MODE_CUSTOM:
|
||||
{
|
||||
SendColor(RGBGetRValue(zone_config.color), RGBGetGValue(zone_config.color), RGBGetBValue(zone_config.color));
|
||||
SendMode(mode, AORUS_PC_CASE_SPEED_NORMAL, zone_config.brightness);
|
||||
}
|
||||
break;
|
||||
|
||||
case AORUS_PC_CASE_MODE_OFF:
|
||||
{
|
||||
SendColor(0x00, 0x00, 0x00);
|
||||
SendMode(AORUS_PC_CASE_MODE_CUSTOM, AORUS_PC_CASE_SPEED_SLOWEST, AORUS_PC_CASE_BRIGHTNESS_MAX + 0x01);
|
||||
}
|
||||
break;
|
||||
|
||||
case AORUS_PC_CASE_MODE_BREATHING:
|
||||
{
|
||||
SendColor(RGBGetRValue(zone_config.color), RGBGetGValue(zone_config.color), RGBGetBValue(zone_config.color));
|
||||
SendMode(mode, zone_config.speed, AORUS_PC_CASE_BRIGHTNESS_MAX);
|
||||
}
|
||||
break;
|
||||
|
||||
case AORUS_PC_CASE_MODE_SPECTRUM_CYCLE:
|
||||
{
|
||||
SendColor(0xFF, 0x00, 0x00);
|
||||
SendMode(mode, zone_config.speed, AORUS_PC_CASE_BRIGHTNESS_MAX);
|
||||
}
|
||||
break;
|
||||
|
||||
case AORUS_PC_CASE_MODE_FLASHING:
|
||||
case AORUS_PC_CASE_MODE_DOUBLE_FLASHING:
|
||||
{
|
||||
SendColor(RGBGetRValue(zone_config.color), RGBGetGValue(zone_config.color), RGBGetBValue(zone_config.color));
|
||||
SendMode(mode, zone_config.speed, zone_config.brightness * 0x0A);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
SendOk();
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*------------------------------------------*\
|
||||
| GigabyteAorusPCCaseController.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| PC Case lighting controller |
|
||||
| |
|
||||
| Denis Nazarov (nenderus) 2/10/2024 |
|
||||
\*------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
struct mode_config
|
||||
{
|
||||
RGBColor color;
|
||||
uint8_t speed;
|
||||
uint8_t brightness;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AORUS_PC_CASE_MODE_OFF = 0x00,
|
||||
AORUS_PC_CASE_MODE_CUSTOM = 0x01,
|
||||
AORUS_PC_CASE_MODE_BREATHING = 0x02,
|
||||
AORUS_PC_CASE_MODE_SPECTRUM_CYCLE = 0x03,
|
||||
AORUS_PC_CASE_MODE_FLASHING = 0x04,
|
||||
AORUS_PC_CASE_MODE_DOUBLE_FLASHING = 0x05,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AORUS_PC_CASE_SPEED_SLOWEST = 0x0A,
|
||||
AORUS_PC_CASE_SPEED_NORMAL = 0x09,
|
||||
AORUS_PC_CASE_SPEED_FASTEST = 0x06,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AORUS_PC_CASE_BRIGHTNESS_MIN = 0x00,
|
||||
AORUS_PC_CASE_BRIGHTNESS_MAX = 0x09,
|
||||
};
|
||||
|
||||
class GigabyteAorusPCCaseController
|
||||
{
|
||||
public:
|
||||
GigabyteAorusPCCaseController(hid_device* dev_handle, const char* path);
|
||||
~GigabyteAorusPCCaseController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SendColor(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void SendMode(uint8_t mode, uint8_t speed, uint8_t brightness);
|
||||
void SendOk();
|
||||
|
||||
void SetMode(uint8_t mode, mode_config zone_config);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
};
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "Detector.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
#include "GigabyteAorusPCCaseController.h"
|
||||
#include "RGBController_GigabyteAorusPCCase.h"
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define HOLTEK_VID 0x1044
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Controller product ids |
|
||||
\*-----------------------------------------------------*/
|
||||
#define C300_GLASS_PID 0x7A30
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectGigabyteAorusPCCaseControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Gigabyte Aorus PC Case exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
void DetectGigabyteAorusPCCaseControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
GigabyteAorusPCCaseController* controller = new GigabyteAorusPCCaseController(dev, info->path);
|
||||
RGBController_GigabyteAorusPCCase* rgb_controller = new RGBController_GigabyteAorusPCCase(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Gigabyte AORUS C300 GLASS", DetectGigabyteAorusPCCaseControllers, HOLTEK_VID, C300_GLASS_PID, 0, 0xFF01, 0x01);
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
/*------------------------------------------*\
|
||||
| RGBController_GigabyteAorusPCCase.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for for Gigabyte |
|
||||
| Aorus PC Case driver |
|
||||
| |
|
||||
| Denis Nazarov (nenderus) 2/10/2024 |
|
||||
\*------------------------------------------*/
|
||||
|
||||
#include "RGBController_GigabyteAorusPCCase.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Gigabyte AORUS PC Case
|
||||
@category Case
|
||||
@type USB
|
||||
@save :robot:
|
||||
@direct :x:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectGigabyteAorusPCCaseControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_GigabyteAorusPCCase::RGBController_GigabyteAorusPCCase(GigabyteAorusPCCaseController *controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Gigabyte AORUS PC Case";
|
||||
vendor = "Gigabyte";
|
||||
description = "Gigabyte AORUS PC Case";
|
||||
|
||||
type = DEVICE_TYPE_CASE;
|
||||
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Custom;
|
||||
Custom.name = "Custom";
|
||||
Custom.value = AORUS_PC_CASE_MODE_CUSTOM;
|
||||
Custom.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Custom.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Custom.colors_min = 1;
|
||||
Custom.colors_max = 1;
|
||||
Custom.colors.resize(1);
|
||||
Custom.brightness_min = AORUS_PC_CASE_BRIGHTNESS_MIN;
|
||||
Custom.brightness_max = AORUS_PC_CASE_BRIGHTNESS_MAX;
|
||||
Custom.brightness = AORUS_PC_CASE_BRIGHTNESS_MAX;
|
||||
modes.push_back(Custom);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AORUS_PC_CASE_MODE_OFF;
|
||||
Off.flags = MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AORUS_PC_CASE_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = AORUS_PC_CASE_SPEED_SLOWEST;
|
||||
Breathing.speed_max = AORUS_PC_CASE_SPEED_FASTEST;
|
||||
Breathing.speed = AORUS_PC_CASE_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AORUS_PC_CASE_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
SpectrumCycle.speed_min = AORUS_PC_CASE_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = AORUS_PC_CASE_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = AORUS_PC_CASE_SPEED_NORMAL;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AORUS_PC_CASE_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flashing.colors_min = 1;
|
||||
Flashing.colors_max = 1;
|
||||
Flashing.colors.resize(1);
|
||||
Flashing.speed_min = AORUS_PC_CASE_SPEED_SLOWEST;
|
||||
Flashing.speed_max = AORUS_PC_CASE_SPEED_FASTEST;
|
||||
Flashing.speed = AORUS_PC_CASE_SPEED_NORMAL;
|
||||
Flashing.brightness_min = AORUS_PC_CASE_BRIGHTNESS_MIN;
|
||||
Flashing.brightness_max = AORUS_PC_CASE_BRIGHTNESS_MAX;
|
||||
Flashing.brightness = AORUS_PC_CASE_BRIGHTNESS_MAX;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode DoubleFlashing;
|
||||
DoubleFlashing.name = "Double Flashing";
|
||||
DoubleFlashing.value = AORUS_PC_CASE_MODE_DOUBLE_FLASHING;
|
||||
DoubleFlashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
DoubleFlashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
DoubleFlashing.colors_min = 1;
|
||||
DoubleFlashing.colors_max = 1;
|
||||
DoubleFlashing.colors.resize(1);
|
||||
DoubleFlashing.speed_min = AORUS_PC_CASE_SPEED_SLOWEST;
|
||||
DoubleFlashing.speed_max = AORUS_PC_CASE_SPEED_FASTEST;
|
||||
DoubleFlashing.speed = AORUS_PC_CASE_SPEED_NORMAL;
|
||||
DoubleFlashing.brightness_min = AORUS_PC_CASE_BRIGHTNESS_MIN;
|
||||
DoubleFlashing.brightness_max = AORUS_PC_CASE_BRIGHTNESS_MAX;
|
||||
DoubleFlashing.brightness = AORUS_PC_CASE_BRIGHTNESS_MAX;
|
||||
modes.push_back(DoubleFlashing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_GigabyteAorusPCCase::~RGBController_GigabyteAorusPCCase()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_GigabyteAorusPCCase::SetupZones()
|
||||
{
|
||||
zone case_zone;
|
||||
case_zone.name = "Case";
|
||||
case_zone.type = ZONE_TYPE_SINGLE;
|
||||
case_zone.leds_min = 1;
|
||||
case_zone.leds_max = 1;
|
||||
case_zone.leds_count = 1;
|
||||
case_zone.matrix_map = NULL;
|
||||
zones.push_back(case_zone);
|
||||
|
||||
led case_led;
|
||||
case_led.name = "Case";
|
||||
leds.push_back(case_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_GigabyteAorusPCCase::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_GigabyteAorusPCCase::DeviceUpdateLEDs()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not need update leds |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_GigabyteAorusPCCase::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not need update zone leds |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_GigabyteAorusPCCase::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not need update single led |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_GigabyteAorusPCCase::DeviceUpdateMode()
|
||||
{
|
||||
mode_config zone_config;
|
||||
zone_config.color = 0x000000;
|
||||
zone_config.speed = modes[active_mode].speed;
|
||||
zone_config.brightness = modes[active_mode].brightness;
|
||||
|
||||
if (modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
zone_config.color = modes[active_mode].colors[0];
|
||||
}
|
||||
|
||||
controller->SetMode(modes[active_mode].value, zone_config);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*------------------------------------------*\
|
||||
| RGBController_GigabyteAorusPCCase.h |
|
||||
| |
|
||||
| Generic RGB Interface for for Gigabyte |
|
||||
| Aorus PC Case driver |
|
||||
| |
|
||||
| Denis Nazarov (nenderus) 2/10/2024 |
|
||||
\*------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "GigabyteAorusPCCaseController.h"
|
||||
|
||||
class RGBController_GigabyteAorusPCCase : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_GigabyteAorusPCCase(GigabyteAorusPCCaseController* controller_ptr);
|
||||
~RGBController_GigabyteAorusPCCase();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
GigabyteAorusPCCaseController* controller;
|
||||
};
|
||||
|
|
@ -162,6 +162,7 @@ INCLUDEPATH +=
|
|||
Controllers/GigabyteAorusCPUCoolerController/ \
|
||||
Controllers/GigabyteAorusLaptopController/ \
|
||||
Controllers/GigabyteAorusMouseController/ \
|
||||
Controllers/GigabyteAorusPCCaseController/ \
|
||||
Controllers/GigabyteRGBFusion2DRAMController/ \
|
||||
Controllers/GigabyteRGBFusion2SMBusController/ \
|
||||
Controllers/GigabyteRGBFusion2USBController/ \
|
||||
|
|
@ -518,6 +519,8 @@ HEADERS +=
|
|||
Controllers/GigabyteAorusLaptopController/RGBController_GigabyteAorusLaptop.h \
|
||||
Controllers/GigabyteAorusMouseController/GigabyteAorusMouseController.h \
|
||||
Controllers/GigabyteAorusMouseController/RGBController_GigabyteAorusMouse.h \
|
||||
Controllers/GigabyteAorusPCCaseController/GigabyteAorusPCCaseController.h \
|
||||
Controllers/GigabyteAorusPCCaseController/RGBController_GigabyteAorusPCCase.h \
|
||||
Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMController.h \
|
||||
Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.h \
|
||||
Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusController.h \
|
||||
|
|
@ -1204,6 +1207,9 @@ SOURCES +=
|
|||
Controllers/GigabyteAorusMouseController/GigabyteAorusMouseController.cpp \
|
||||
Controllers/GigabyteAorusMouseController/GigabyteAorusMouseControllerDetect.cpp \
|
||||
Controllers/GigabyteAorusMouseController/RGBController_GigabyteAorusMouse.cpp \
|
||||
Controllers/GigabyteAorusPCCaseController/GigabyteAorusPCCaseController.cpp \
|
||||
Controllers/GigabyteAorusPCCaseController/GigabyteAorusPCCaseControllerDetect.cpp \
|
||||
Controllers/GigabyteAorusPCCaseController/RGBController_GigabyteAorusPCCase.cpp \
|
||||
Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMController.cpp \
|
||||
Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp \
|
||||
Controllers/GigabyteRGBFusion2DRAMController/RGBController_GigabyteRGBFusion2DRAM.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue