Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,160 @@
/*---------------------------------------------------------*\
| RGBController_ThermaltakeRiingQuad.cpp |
| |
| RGBController for Thermaltake Riing Quad |
| |
| Chris M (Dr_No) 15 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_ThermaltakeRiingQuad.h"
/**------------------------------------------------------------------*\
@name Thermaltake Riing Quad
@category Cooler
@type USB
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectThermaltakeRiingQuadControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_ThermaltakeRiingQuad::RGBController_ThermaltakeRiingQuad(ThermaltakeRiingQuadController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "Thermaltake";
type = DEVICE_TYPE_COOLER;
description = "Thermaltake Riing Quad Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerial();
mode Direct;
Direct.name = "Direct";
Direct.value = THERMALTAKE_QUAD_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.speed_min = 0;
Direct.speed_max = 0;
Direct.speed = 0;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_ThermaltakeRiingQuad::~RGBController_ThermaltakeRiingQuad()
{
delete controller;
}
void RGBController_ThermaltakeRiingQuad::SetupZones()
{
/*-------------------------------------------------*\
| Only set LED count on the first run |
\*-------------------------------------------------*/
bool first_run = false;
if(zones.size() == 0)
{
first_run = true;
}
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(THERMALTAKE_QUAD_NUM_CHANNELS);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
for (unsigned int channel_idx = 0; channel_idx < THERMALTAKE_QUAD_NUM_CHANNELS; channel_idx++)
{
char ch_idx_string[2];
snprintf(ch_idx_string, 2, "%d", channel_idx + 1);
zones[channel_idx].name = "Riing Channel ";
zones[channel_idx].name.append(ch_idx_string);
zones[channel_idx].type = ZONE_TYPE_LINEAR;
/*-------------------------------------------------*\
| The maximum number of colors that would fit in the|
| Riing Quad protocol is 54 |
\*-------------------------------------------------*/
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 60;
if(first_run)
{
zones[channel_idx].leds_count = 0;
}
zones[channel_idx].matrix_map = NULL;
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
char led_idx_string[3];
snprintf(led_idx_string, 3, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Riing Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
}
}
SetupColors();
}
void RGBController_ThermaltakeRiingQuad::ResizeZone(int zone, int new_size)
{
if((size_t) zone >= zones.size())
{
return;
}
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
void RGBController_ThermaltakeRiingQuad::DeviceUpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
controller->SetChannelLEDs((unsigned char)zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
}
void RGBController_ThermaltakeRiingQuad::UpdateZoneLEDs(int zone)
{
controller->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
}
void RGBController_ThermaltakeRiingQuad::UpdateSingleLED(int led)
{
unsigned int channel = leds_channel[led];
controller->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
}
void RGBController_ThermaltakeRiingQuad::DeviceUpdateMode()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
controller->SetMode(modes[active_mode].value, modes[active_mode].speed);
controller->SetChannelLEDs((unsigned char)zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
}
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| RGBController_ThermaltakeRiingQuad.h |
| |
| RGBController for Thermaltake Riing Quad |
| |
| Chris M (Dr_No) 15 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "ThermaltakeRiingQuadController.h"
class RGBController_ThermaltakeRiingQuad : public RGBController
{
public:
RGBController_ThermaltakeRiingQuad(ThermaltakeRiingQuadController* controller_ptr);
~RGBController_ThermaltakeRiingQuad();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
ThermaltakeRiingQuadController* controller;
std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel;
};
@@ -0,0 +1,164 @@
/*---------------------------------------------------------*\
| ThermaltakeRiingQuadController.cpp |
| |
| Driver for Thermaltake Riing Quad |
| |
| Chris M (Dr_No) 15 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "StringUtils.h"
#include "ThermaltakeRiingQuadController.h"
ThermaltakeRiingQuadController::ThermaltakeRiingQuadController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
/*---------------------------------------------------------*\
| Get device name from HID manufacturer and product strings |
\*---------------------------------------------------------*/
wchar_t name_string[HID_MAX_STR];
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
device_name = StringUtils::wstring_to_string(name_string);
hid_get_product_string(dev, name_string, HID_MAX_STR);
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
SendInit();
/*-----------------------------------------------------*\
| The Riing Quad only seems to run in direct mode and |
| requires a packet within seconds to remain in the |
| set mode (similar to Corsair Node Pro). Start a thread|
| to send a packet every TT_QUAD_KEEPALIVE seconds |
\*-----------------------------------------------------*/
memset(tt_quad_buffer, 0x00, sizeof(tt_quad_buffer));
unsigned char temp_buffer[3] = { 0x00, 0x32, 0x52 };
for(std::size_t zone_index = 0; zone_index < THERMALTAKE_QUAD_NUM_CHANNELS; zone_index++)
{
/*-------------------------------------------------*\
| Add the constant bytes for the mode info buffer |
\*-------------------------------------------------*/
memcpy(&tt_quad_buffer[zone_index][0], temp_buffer, 3);
}
keepalive_thread_run = 1;
keepalive_thread = new std::thread(&ThermaltakeRiingQuadController::KeepaliveThread, this);
}
ThermaltakeRiingQuadController::~ThermaltakeRiingQuadController()
{
keepalive_thread_run = 0;
keepalive_thread->join();
delete keepalive_thread;
hid_close(dev);
}
void ThermaltakeRiingQuadController::KeepaliveThread()
{
while(keepalive_thread_run.load())
{
if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::seconds(THERMALTAKE_QUAD_KEEPALIVE))
{
SendBuffer();
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
std::string ThermaltakeRiingQuadController::GetDeviceName()
{
return device_name;
}
std::string ThermaltakeRiingQuadController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string ThermaltakeRiingQuadController::GetSerial()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
return(StringUtils::wstring_to_string(serial_string));
}
void ThermaltakeRiingQuadController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
{
unsigned char* color_data = new unsigned char[3 * num_colors];
for(unsigned int color = 0; color < num_colors; color++)
{
unsigned int color_idx = color * 3;
color_data[color_idx + 0] = RGBGetGValue(colors[color]);
color_data[color_idx + 1] = RGBGetRValue(colors[color]);
color_data[color_idx + 2] = RGBGetBValue(colors[color]);
}
tt_quad_buffer[channel][THERMALTAKE_QUAD_ZONE_BYTE] = channel + 1;
tt_quad_buffer[channel][THERMALTAKE_QUAD_MODE_BYTE] = current_mode + ( current_speed & 0x03 );
memcpy(&tt_quad_buffer[channel][THERMALTAKE_QUAD_DATA_BYTE], color_data, (num_colors * 3));
hid_write(dev, tt_quad_buffer[channel], THERMALTAKE_QUAD_PACKET_SIZE);
delete[] color_data;
}
void ThermaltakeRiingQuadController::SetMode(unsigned char mode, unsigned char speed)
{
current_mode = mode;
current_speed = speed;
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void ThermaltakeRiingQuadController::SendInit()
{
unsigned char usb_buf[THERMALTAKE_QUAD_PACKET_SIZE];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Init packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xFE;
usb_buf[0x02] = 0x33;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, THERMALTAKE_QUAD_PACKET_SIZE);
hid_read_timeout(dev, usb_buf, THERMALTAKE_QUAD_PACKET_SIZE, THERMALTAKE_QUAD_INTERRUPT_TIMEOUT);
}
void ThermaltakeRiingQuadController::SendBuffer()
{
for(std::size_t channel_index = 0; channel_index < THERMALTAKE_QUAD_NUM_CHANNELS; channel_index++)
{
hid_write(dev, tt_quad_buffer[channel_index], THERMALTAKE_QUAD_PACKET_SIZE);
}
/*-------------------------------------*\
| Update the last commit time |
\*-------------------------------------*/
last_commit_time = std::chrono::steady_clock::now();
}
@@ -0,0 +1,81 @@
/*---------------------------------------------------------*\
| ThermaltakeRiingQuadController.h |
| |
| Driver for Thermaltake Riing Quad |
| |
| Chris M (Dr_No) 15 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <chrono>
#include <vector>
#include <hidapi.h>
#include "RGBController.h"
#define THERMALTAKE_QUAD_PACKET_SIZE 193
#define THERMALTAKE_QUAD_INTERRUPT_TIMEOUT 250
#define THERMALTAKE_QUAD_KEEPALIVE 3
#define HID_MAX_STR 255
enum
{
THERMALTAKE_QUAD_COMMAND_BYTE = 1,
THERMALTAKE_QUAD_FUNCTION_BYTE = 2,
THERMALTAKE_QUAD_ZONE_BYTE = 3,
THERMALTAKE_QUAD_MODE_BYTE = 4,
THERMALTAKE_QUAD_DATA_BYTE = 5,
};
enum
{
THERMALTAKE_QUAD_MODE_DIRECT = 0x24
};
enum
{
THERMALTAKE_QUAD_SPEED_EXTREME = 0x00,
THERMALTAKE_QUAD_SPEED_FAST = 0x01,
THERMALTAKE_QUAD_SPEED_NORMAL = 0x02,
THERMALTAKE_QUAD_SPEED_SLOW = 0x03,
};
#define THERMALTAKE_QUAD_NUM_CHANNELS 5
class ThermaltakeRiingQuadController
{
public:
ThermaltakeRiingQuadController(hid_device* dev_handle, const char* path);
~ThermaltakeRiingQuadController();
std::string GetDeviceName();
std::string GetDeviceLocation();
std::string GetSerial();
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
void SetMode(unsigned char mode, unsigned char speed);
private:
hid_device* dev;
unsigned char current_mode;
unsigned char current_speed;
std::string device_name;
std::string location;
uint8_t tt_quad_buffer[THERMALTAKE_QUAD_NUM_CHANNELS][THERMALTAKE_QUAD_PACKET_SIZE];
std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run;
std::chrono::time_point<std::chrono::steady_clock> last_commit_time;
void SendBuffer();
void KeepaliveThread();
void SendInit();
void SendFan();
void SendSave();
};