Add initial driver for Thermaltake Riing controller. Fixed configuration has 9 LEDs for channels 1, 2, and 3 but will make this configurable in the future. Only direct mode supported so far
This commit is contained in:
parent
ea1f21106c
commit
2f00fb9186
7 changed files with 407 additions and 2 deletions
|
|
@ -0,0 +1,111 @@
|
|||
/*-----------------------------------------*\
|
||||
| ThermaltakeRiingController.cpp |
|
||||
| |
|
||||
| Definitions and types for Thermaltake |
|
||||
| Riing Plus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/7/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "ThermaltakeRiingController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
ThermaltakeRiingController::ThermaltakeRiingController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
SendInit();
|
||||
|
||||
channel_leds[0] = 9;
|
||||
channel_leds[1] = 9;
|
||||
channel_leds[2] = 9;
|
||||
channel_leds[4] = 0;
|
||||
channel_leds[4] = 0;
|
||||
}
|
||||
|
||||
ThermaltakeRiingController::~ThermaltakeRiingController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char* color_data = new unsigned char[colors.size()];
|
||||
|
||||
for(int color = 0; color < colors.size(); color++)
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
SendRGB(channel, THERMALTAKE_MODE_PER_LED, THERMALTAKE_SPEED_FAST, colors.size(), color_data);
|
||||
|
||||
delete[] color_data;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void ThermaltakeRiingController::SendInit()
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Init packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xFE;
|
||||
usb_buf[0x01] = 0x33;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SendRGB
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char num_colors,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up RGB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x32;
|
||||
usb_buf[0x01] = 0x52;
|
||||
usb_buf[0x02] = port;
|
||||
usb_buf[0x03] = mode + speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in GRB color data |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x04], color_data, (num_colors * 3));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*-----------------------------------------*\
|
||||
| ThermaltakeRiingController.h |
|
||||
| |
|
||||
| Definitions and types for Thermaltake |
|
||||
| Riing Plus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/7/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_PORT_1 = 0x01,
|
||||
THERMALTAKE_PORT_2 = 0x02,
|
||||
THERMALTAKE_PORT_3 = 0x03,
|
||||
THERMALTAKE_PORT_4 = 0x04,
|
||||
THERMALTAKE_PORT_5 = 0x05
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_MODE_FLOW = 0x00,
|
||||
THERMALTAKE_MODE_SPECTRUM = 0x04,
|
||||
THERMALTAKE_MODE_RIPPLE = 0x08,
|
||||
THERMALTAKE_MODE_BLINK = 0x0C,
|
||||
THERMALTAKE_MODE_PULSE = 0x10,
|
||||
THERMALTAKE_MODE_WAVE = 0x14,
|
||||
THERMALTAKE_MODE_PER_LED = 0x18,
|
||||
THERMALTAKE_MODE_FULL = 0x19
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_SPEED_SLOW = 0x03,
|
||||
THERMALTAKE_SPEED_NORMAL = 0x02,
|
||||
THERMALTAKE_SPEED_FAST = 0x01,
|
||||
THERMALTAKE_SPEED_EXTREME = 0x00
|
||||
};
|
||||
|
||||
class ThermaltakeRiingController
|
||||
{
|
||||
public:
|
||||
ThermaltakeRiingController(libusb_device_handle* dev_handle);
|
||||
~ThermaltakeRiingController();
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
|
||||
unsigned int channel_leds[5];
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
void SendInit();
|
||||
|
||||
void ThermaltakeRiingController::SendRGB
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char num_colors,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendFan();
|
||||
void SendSave();
|
||||
};
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#include "ThermaltakeRiingController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ThermaltakeRiing.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define THERMALTAKE_RIING_VID 0x264A
|
||||
#define THERMALTAKE_RIING_PID_BEGIN 0x1FA5
|
||||
#define THERMALTAKE_RIING_PID_END 0x1FB5
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectThermaltakeRiingControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an AMD Wraith Prism controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
for(int pid = THERMALTAKE_RIING_PID_BEGIN; pid <= THERMALTAKE_RIING_PID_END; pid++)
|
||||
{
|
||||
//Look for Thermaltake Riing device
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, THERMALTAKE_RIING_VID, pid);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
ThermaltakeRiingController* controller = new ThermaltakeRiingController(dev);
|
||||
|
||||
RGBController_ThermaltakeRiing* rgb_controller = new RGBController_ThermaltakeRiing(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -339,6 +339,7 @@ void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controlle
|
|||
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
|
|
@ -371,6 +372,7 @@ void DetectRGBControllers(void)
|
|||
DetectCorsairCmdrProControllers(rgb_controllers);
|
||||
DetectCorsairKeyboardControllers(rgb_controllers);
|
||||
DetectCorsairNodeProControllers(rgb_controllers);
|
||||
DetectThermaltakeRiingControllers(rgb_controllers);
|
||||
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
|
||||
|
|
|
|||
10
OpenRGB.pro
10
OpenRGB.pro
|
|
@ -28,6 +28,7 @@ INCLUDEPATH += \
|
|||
Controllers/PolychromeController/ \
|
||||
Controllers/PoseidonZRGBController/ \
|
||||
Controllers/RGBFusionController/ \
|
||||
Controllers/ThermaltakeRiingController/ \
|
||||
RGBController/ \
|
||||
qt/
|
||||
|
||||
|
|
@ -79,6 +80,8 @@ SOURCES += \
|
|||
Controllers/PoseidonZRGBController/PoseidonZRGBControllerDetect.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionController.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
|
||||
RGBController/RGBController.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_AMDWraithPrism.cpp \
|
||||
|
|
@ -98,7 +101,8 @@ SOURCES += \
|
|||
RGBController/RGBController_PatriotViper.cpp \
|
||||
RGBController/RGBController_Polychrome.cpp \
|
||||
RGBController/RGBController_PoseidonZRGB.cpp \
|
||||
RGBController/RGBController_RGBFusion.cpp
|
||||
RGBController/RGBController_RGBFusion.cpp \
|
||||
RGBController/RGBController_ThermaltakeRiing.cpp \
|
||||
|
||||
HEADERS += \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
|
|
@ -128,6 +132,7 @@ HEADERS += \
|
|||
Controllers/PolychromeController/PolychromeController.h \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_AMDWraithPrism.h \
|
||||
RGBController/RGBController_Aura.h \
|
||||
|
|
@ -145,7 +150,8 @@ HEADERS += \
|
|||
RGBController/RGBController_PatriotViper.h \
|
||||
RGBController/RGBController_Polychrome.h \
|
||||
RGBController/RGBController_PoseidonZRGB.h \
|
||||
RGBController/RGBController_RGBFusion.h
|
||||
RGBController/RGBController_RGBFusion.h \
|
||||
RGBController/RGBController_ThermaltakeRiing.h \
|
||||
|
||||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
|
|
|||
144
RGBController/RGBController_ThermaltakeRiing.cpp
Normal file
144
RGBController/RGBController_ThermaltakeRiing.cpp
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_ThermaltakeRiing.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Thermaltake |
|
||||
| Riing controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_ThermaltakeRiing.h"
|
||||
|
||||
|
||||
RGBController_ThermaltakeRiing::RGBController_ThermaltakeRiing(ThermaltakeRiingController* riing_ptr)
|
||||
{
|
||||
riing = riing_ptr;
|
||||
|
||||
name = "Thermaltake Riing";
|
||||
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_count = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < 5; channel_idx++)
|
||||
{
|
||||
led_count += riing->channel_leds[channel_idx];
|
||||
}
|
||||
colors.resize(led_count);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_idx = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < 5; channel_idx++)
|
||||
{
|
||||
if(riing->channel_leds[channel_idx] > 0)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
new_zone->name = "Riing Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < riing->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%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 + 1);
|
||||
|
||||
new_zone_map->push_back(led_idx);
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone->map.push_back(*new_zone_map);
|
||||
zones.push_back(*new_zone);
|
||||
zones_channel.push_back(channel_idx + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_ThermaltakeRiing::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
riing->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_ThermaltakeRiing::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
riing->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_ThermaltakeRiing::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds_channel[led];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
riing->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_ThermaltakeRiing::SetCustomMode()
|
||||
{
|
||||
}
|
||||
|
||||
void RGBController_ThermaltakeRiing::UpdateMode()
|
||||
{
|
||||
}
|
||||
30
RGBController/RGBController_ThermaltakeRiing.h
Normal file
30
RGBController/RGBController_ThermaltakeRiing.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_ThermaltakeRiing.h |
|
||||
| |
|
||||
| Generic RGB Interface for Thermaltake |
|
||||
| Riing controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 2/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "ThermaltakeRiingController.h"
|
||||
|
||||
class RGBController_ThermaltakeRiing : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_ThermaltakeRiing(ThermaltakeRiingController* riing_ptr);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
ThermaltakeRiingController* riing;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue