Code cleanup round 3

This commit is contained in:
Adam Honse 2022-01-17 21:27:58 -06:00
parent 97e154ea84
commit c09e4c9c92
52 changed files with 2953 additions and 3065 deletions

View file

@ -13,7 +13,6 @@ using namespace std::chrono_literals;
bool TestForCorsairDominatorPlatinumController(i2c_smbus_interface *bus, unsigned char address) bool TestForCorsairDominatorPlatinumController(i2c_smbus_interface *bus, unsigned char address)
{ {
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
LOG_DEBUG("[%s] Trying address %02X", CORSAIR_DOMINATOR_PLATINUM_NAME, address); LOG_DEBUG("[%s] Trying address %02X", CORSAIR_DOMINATOR_PLATINUM_NAME, address);
@ -62,12 +61,13 @@ void DetectCorsairDominatorPlatinumControllers(std::vector<i2c_smbus_interface *
{ {
LOG_DEBUG("[%s] Testing bus %d", CORSAIR_DOMINATOR_PLATINUM_NAME, bus); LOG_DEBUG("[%s] Testing bus %d", CORSAIR_DOMINATOR_PLATINUM_NAME, bus);
for(unsigned char addr = 0x58; addr <= 0x5f; addr++) for(unsigned char addr = 0x58; addr <= 0x5F; addr++)
{ {
if(TestForCorsairDominatorPlatinumController(busses[bus], addr)) if(TestForCorsairDominatorPlatinumController(busses[bus], addr))
{ {
CorsairDominatorPlatinumController* new_controller = new CorsairDominatorPlatinumController(busses[bus], addr); CorsairDominatorPlatinumController* new_controller = new CorsairDominatorPlatinumController(busses[bus], addr);
RGBController_CorsairDominatorPlatinum* new_rgbcontroller = new RGBController_CorsairDominatorPlatinum(new_controller); RGBController_CorsairDominatorPlatinum* new_rgbcontroller = new RGBController_CorsairDominatorPlatinum(new_controller);
ResourceManager::get()->RegisterRGBController(new_rgbcontroller); ResourceManager::get()->RegisterRGBController(new_rgbcontroller);
} }
std::this_thread::sleep_for(10ms); std::this_thread::sleep_for(10ms);
@ -78,6 +78,6 @@ void DetectCorsairDominatorPlatinumControllers(std::vector<i2c_smbus_interface *
LOG_DEBUG("[%s] Bus %d is not a DRAM bus", CORSAIR_DOMINATOR_PLATINUM_NAME, bus); LOG_DEBUG("[%s] Bus %d is not a DRAM bus", CORSAIR_DOMINATOR_PLATINUM_NAME, bus);
} }
} }
} } /* DetectCorsairDominatorPlatinumControllers() */
REGISTER_I2C_DETECTOR("Corsair Dominator Platinum", DetectCorsairDominatorPlatinumControllers); REGISTER_I2C_DETECTOR("Corsair Dominator Platinum", DetectCorsairDominatorPlatinumControllers);

View file

@ -1,114 +1,115 @@
/*-------------------------------------------------*\ /*-------------------------------------------------*\
| RGBController_CorsairDominatorPlatinum.cpp | | RGBController_CorsairDominatorPlatinum.cpp |
| | | |
| Corsair Vengeance Pro RGB driver | | Corsair Vengeance Pro RGB driver |
| | | |
| Erik Gilling (konkers) 9/25/2020 | | Erik Gilling (konkers) 9/25/2020 |
\*-------------------------------------------------*/ \*-------------------------------------------------*/
#include "RGBController_CorsairDominatorPlatinum.h" #include "RGBController_CorsairDominatorPlatinum.h"
RGBController_CorsairDominatorPlatinum::RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* corsair_ptr) RGBController_CorsairDominatorPlatinum::RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = corsair->GetDeviceName(); name = controller->GetDeviceName();
vendor = "Corsair"; vendor = "Corsair";
type = DEVICE_TYPE_DRAM; type = DEVICE_TYPE_DRAM;
description = "Corsair Dominator Platinum RGB Device"; description = "Corsair Dominator Platinum RGB Device";
location = corsair->GetDeviceLocation(); location = controller->GetDeviceLocation();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = 0; Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.speed_min = 0; Direct.speed_min = 0;
Direct.speed_max = 0; Direct.speed_max = 0;
Direct.speed = 0; Direct.speed = 0;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
SetupZones(); SetupZones();
active_mode = 0; active_mode = 0;
} }
RGBController_CorsairDominatorPlatinum::~RGBController_CorsairDominatorPlatinum() RGBController_CorsairDominatorPlatinum::~RGBController_CorsairDominatorPlatinum()
{ {
delete corsair; delete controller;
} }
void RGBController_CorsairDominatorPlatinum::SetupZones() void RGBController_CorsairDominatorPlatinum::SetupZones()
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Set up zone | | Set up zone |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
zone new_zone; zone new_zone;
new_zone.name = "Corsair Platinum Zone"; new_zone.name = "Corsair Platinum Zone";
new_zone.type = ZONE_TYPE_LINEAR; new_zone.type = ZONE_TYPE_LINEAR;
new_zone.leds_min = corsair->GetLEDCount(); new_zone.leds_min = controller->GetLEDCount();
new_zone.leds_max = corsair->GetLEDCount(); new_zone.leds_max = controller->GetLEDCount();
new_zone.leds_count = corsair->GetLEDCount(); new_zone.leds_count = controller->GetLEDCount();
new_zone.matrix_map = NULL; new_zone.matrix_map = NULL;
zones.push_back(new_zone); zones.push_back(new_zone);
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Set up LEDs | | Set up LEDs |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++) for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{ {
led *new_led = new led(); led *new_led = new led();
new_led->name = "Corsair Platinum LED "; new_led->name = "Corsair Platinum LED ";
new_led->name.append(std::to_string(led_idx)); new_led->name.append(std::to_string(led_idx));
leds.push_back(*new_led); leds.push_back(*new_led);
} }
SetupColors(); SetupColors();
} }
void RGBController_CorsairDominatorPlatinum::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_CorsairDominatorPlatinum::ResizeZone(int /*zone*/, int /*new_size*/)
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| This device does not support resizing zones | | This device does not support resizing zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
} }
void RGBController_CorsairDominatorPlatinum::DeviceUpdateLEDs() void RGBController_CorsairDominatorPlatinum::DeviceUpdateLEDs()
{ {
for(std::size_t led = 0; led < colors.size(); led++) for(std::size_t led = 0; led < colors.size(); led++)
{ {
RGBColor color = colors[led]; RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color); unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color); unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu);
} controller->SetLEDColor(led, red, grn, blu);
}
corsair->ApplyColors();
} controller->ApplyColors();
}
void RGBController_CorsairDominatorPlatinum::UpdateZoneLEDs(int /*zone*/)
{ void RGBController_CorsairDominatorPlatinum::UpdateZoneLEDs(int /*zone*/)
DeviceUpdateLEDs(); {
} DeviceUpdateLEDs();
}
void RGBController_CorsairDominatorPlatinum::UpdateSingleLED(int led)
{ void RGBController_CorsairDominatorPlatinum::UpdateSingleLED(int led)
RGBColor color = colors[led]; {
unsigned char red = RGBGetRValue(color); RGBColor color = colors[led];
unsigned char grn = RGBGetGValue(color); unsigned char red = RGBGetRValue(color);
unsigned char blu = RGBGetBValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu);
corsair->ApplyColors(); controller->SetLEDColor(led, red, grn, blu);
} controller->ApplyColors();
}
void RGBController_CorsairDominatorPlatinum::SetCustomMode()
{ void RGBController_CorsairDominatorPlatinum::SetCustomMode()
active_mode = 0; {
} active_mode = 0;
}
void RGBController_CorsairDominatorPlatinum::DeviceUpdateMode()
{ void RGBController_CorsairDominatorPlatinum::DeviceUpdateMode()
{
}
}

View file

@ -1,33 +1,33 @@
/*--------------------------------------------*\ /*--------------------------------------------*\
| RGBController_CorsairDominatorPlatinum.h | | RGBController_CorsairDominatorPlatinum.h |
| | | |
| Corsair Dominator Platinum RGB driver | | Corsair Dominator Platinum RGB driver |
| | | |
| Erik Gilling (konkers) 9/25/2020 | | Erik Gilling (konkers) 9/25/2020 |
\*--------------------------------------------*/ \*--------------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairDominatorPlatinumController.h" #include "CorsairDominatorPlatinumController.h"
class RGBController_CorsairDominatorPlatinum : public RGBController class RGBController_CorsairDominatorPlatinum : public RGBController
{ {
public: public:
RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* corsair_ptr); RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* controller_ptr);
~RGBController_CorsairDominatorPlatinum(); ~RGBController_CorsairDominatorPlatinum();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CorsairDominatorPlatinumController* corsair; CorsairDominatorPlatinumController* controller;
}; };

View file

@ -1,77 +1,76 @@
#include "Detector.h" #include "Detector.h"
#include "CorsairHydroController.h" #include "CorsairHydroController.h"
#include "RGBController.h" #include "RGBController.h"
#include "RGBController_CorsairHydro.h" #include "RGBController_CorsairHydro.h"
#include <vector> #include <vector>
#include <libusb-1.0/libusb.h> #include <libusb-1.0/libusb.h>
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Corsair vendor ID | | Corsair vendor ID |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CORSAIR_VID 0x1B1C #define CORSAIR_VID 0x1B1C
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Keyboard Hydro Series product IDs | | Keyboard Hydro Series product IDs |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CORSAIR_H115I_PRO_RGB_PID 0x0C13 #define CORSAIR_H115I_PRO_RGB_PID 0x0C13
#define CORSAIR_H100I_PRO_RGB_PID 0x0C15 #define CORSAIR_H100I_PRO_RGB_PID 0x0C15
#define CORSAIR_H150I_PRO_RGB_PID 0x0C12 #define CORSAIR_H150I_PRO_RGB_PID 0x0C12
typedef struct typedef struct
{ {
unsigned short usb_vid; unsigned short usb_vid;
unsigned short usb_pid; unsigned short usb_pid;
unsigned char usb_interface; unsigned char usb_interface;
const char * name; const char * name;
} corsair_hydro_device; } corsair_hydro_device;
#define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ])) #define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const corsair_hydro_device device_list[] = static const corsair_hydro_device device_list[] =
{ {
/*-----------------------------------------------------------------------------------------------------*\ /*-----------------------------------------------------------------------------------------------------*\
| Coolers | | Coolers |
\*-----------------------------------------------------------------------------------------------------*/ \*-----------------------------------------------------------------------------------------------------*/
{ CORSAIR_VID, CORSAIR_H100I_PRO_RGB_PID, 0, "Corsair H100i PRO RGB" }, { CORSAIR_VID, CORSAIR_H100I_PRO_RGB_PID, 0, "Corsair H100i PRO RGB" },
{ CORSAIR_VID, CORSAIR_H115I_PRO_RGB_PID, 0, "Corsair H115i PRO RGB" }, { CORSAIR_VID, CORSAIR_H115I_PRO_RGB_PID, 0, "Corsair H115i PRO RGB" },
{ CORSAIR_VID, CORSAIR_H150I_PRO_RGB_PID, 0, "Corsair H150i PRO RGB" }, { CORSAIR_VID, CORSAIR_H150I_PRO_RGB_PID, 0, "Corsair H150i PRO RGB" },
}; };
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectCorsairHydroControllers * * DetectCorsairHydroControllers *
* * * *
* Tests the USB address to see if a Corsair RGB Cooler controller exists there. * * Tests the USB address to see if a Corsair RGB Cooler controller exists there. *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers) void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers)
{ {
libusb_init(NULL); libusb_init(NULL);
#ifdef _WIN32 #ifdef _WIN32
libusb_set_option(NULL, LIBUSB_OPTION_USE_USBDK); libusb_set_option(NULL, LIBUSB_OPTION_USE_USBDK);
#endif #endif
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++) for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
{ {
libusb_device_handle * dev = libusb_open_device_with_vid_pid(NULL, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid); libusb_device_handle * dev = libusb_open_device_with_vid_pid(NULL, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Corsair RGB Peripheral //Look for Corsair RGB Peripheral
if(dev) if(dev)
{ {
libusb_detach_kernel_driver(dev, 0); libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0); libusb_claim_interface(dev, 0);
CorsairHydroController* controller = new CorsairHydroController(dev);//, device_list[device_idx].usb_endpoint); CorsairHydroController* controller = new CorsairHydroController(dev);
RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller);
RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controllers.push_back(rgb_controller); }
} }
} } /* DetectCorsairHydroControllers() */
} /* DetectCorsairHydroControllers() */
REGISTER_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers);
REGISTER_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers);

View file

@ -1,143 +1,143 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairHydro.cpp | | RGBController_CorsairHydro.cpp |
| | | |
| Generic RGB Interface for Corsair | | Generic RGB Interface for Corsair |
| Hydro Series | | Hydro Series |
| | | |
| Adam Honse (CalcProgrammer1) 8/18/2020 | | Adam Honse (CalcProgrammer1) 8/18/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_CorsairHydro.h" #include "RGBController_CorsairHydro.h"
RGBController_CorsairHydro::RGBController_CorsairHydro(CorsairHydroController* corsair_ptr) RGBController_CorsairHydro::RGBController_CorsairHydro(CorsairHydroController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
vendor = "Corsair"; vendor = "Corsair";
description = "Corsair Hydro Series Device"; description = "Corsair Hydro Series Device";
version = corsair->GetFirmwareString(); version = controller->GetFirmwareString();
type = DEVICE_TYPE_COOLER; type = DEVICE_TYPE_COOLER;
location = corsair->GetLocation(); location = controller->GetLocation();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = 0; Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
mode Blinking; mode Blinking;
Blinking.name = "Blinking"; Blinking.name = "Blinking";
Blinking.value = 1; Blinking.value = 1;
Blinking.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; Blinking.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC; Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC;
Blinking.speed_min = 0x0F; Blinking.speed_min = 0x0F;
Blinking.speed_max = 0x05; Blinking.speed_max = 0x05;
Blinking.speed = 0x0A; Blinking.speed = 0x0A;
Blinking.colors_min = 2; Blinking.colors_min = 2;
Blinking.colors_max = 2; Blinking.colors_max = 2;
Blinking.colors.resize(2); Blinking.colors.resize(2);
modes.push_back(Blinking); modes.push_back(Blinking);
mode ColorShift; mode ColorShift;
ColorShift.name = "Color Shift"; ColorShift.name = "Color Shift";
ColorShift.value = 2; ColorShift.value = 2;
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC; ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorShift.speed_min = 0x46; ColorShift.speed_min = 0x46;
ColorShift.speed_max = 0x0F; ColorShift.speed_max = 0x0F;
ColorShift.speed = 0x28; ColorShift.speed = 0x28;
ColorShift.colors_min = 2; ColorShift.colors_min = 2;
ColorShift.colors_max = 2; ColorShift.colors_max = 2;
ColorShift.colors.resize(2); ColorShift.colors.resize(2);
modes.push_back(ColorShift); modes.push_back(ColorShift);
mode Pulsing; mode Pulsing;
Pulsing.name = "Pulsing"; Pulsing.name = "Pulsing";
Pulsing.value = 3; Pulsing.value = 3;
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Pulsing.color_mode = MODE_COLORS_MODE_SPECIFIC; Pulsing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Pulsing.speed_min = 0x50; Pulsing.speed_min = 0x50;
Pulsing.speed_max = 0x1E; Pulsing.speed_max = 0x1E;
Pulsing.speed = 0x37; Pulsing.speed = 0x37;
Pulsing.colors_min = 2; Pulsing.colors_min = 2;
Pulsing.colors_max = 2; Pulsing.colors_max = 2;
Pulsing.colors.resize(2); Pulsing.colors.resize(2);
modes.push_back(Pulsing); modes.push_back(Pulsing);
SetupZones(); SetupZones();
} }
RGBController_CorsairHydro::~RGBController_CorsairHydro() RGBController_CorsairHydro::~RGBController_CorsairHydro()
{ {
delete corsair; delete controller;
} }
void RGBController_CorsairHydro::SetupZones() void RGBController_CorsairHydro::SetupZones()
{ {
zone new_zone; zone new_zone;
new_zone.name = "Pump Zone"; new_zone.name = "Pump Zone";
new_zone.type = ZONE_TYPE_SINGLE; new_zone.type = ZONE_TYPE_SINGLE;
new_zone.leds_min = 1; new_zone.leds_min = 1;
new_zone.leds_max = 1; new_zone.leds_max = 1;
new_zone.leds_count = 1; new_zone.leds_count = 1;
new_zone.matrix_map = NULL; new_zone.matrix_map = NULL;
zones.push_back(new_zone); zones.push_back(new_zone);
led new_led; led new_led;
new_led.name = "Pump LED"; new_led.name = "Pump LED";
leds.push_back(new_led); leds.push_back(new_led);
SetupColors(); SetupColors();
} }
void RGBController_CorsairHydro::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_CorsairHydro::ResizeZone(int /*zone*/, int /*new_size*/)
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| This device does not support resizing zones | | This device does not support resizing zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
} }
void RGBController_CorsairHydro::DeviceUpdateLEDs() void RGBController_CorsairHydro::DeviceUpdateLEDs()
{ {
DeviceUpdateMode(); DeviceUpdateMode();
} }
void RGBController_CorsairHydro::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairHydro::UpdateZoneLEDs(int /*zone*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CorsairHydro::UpdateSingleLED(int /*led*/) void RGBController_CorsairHydro::UpdateSingleLED(int /*led*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CorsairHydro::SetCustomMode() void RGBController_CorsairHydro::SetCustomMode()
{ {
active_mode = 0; active_mode = 0;
} }
void RGBController_CorsairHydro::DeviceUpdateMode() void RGBController_CorsairHydro::DeviceUpdateMode()
{ {
switch(modes[active_mode].value) switch(modes[active_mode].value)
{ {
case 0: case 0:
corsair->SetFixed(colors); controller->SetFixed(colors);
break; break;
case 1: case 1:
corsair->SetBlink(modes[active_mode].colors, modes[active_mode].speed); controller->SetBlink(modes[active_mode].colors, modes[active_mode].speed);
break; break;
case 2: case 2:
corsair->SetShift(modes[active_mode].colors, modes[active_mode].speed); controller->SetShift(modes[active_mode].colors, modes[active_mode].speed);
break; break;
case 3: case 3:
corsair->SetPulse(modes[active_mode].colors, modes[active_mode].speed); controller->SetPulse(modes[active_mode].colors, modes[active_mode].speed);
break; break;
} }
} }

View file

@ -1,33 +1,33 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairHydro.h | | RGBController_CorsairHydro.h |
| | | |
| Generic RGB Interface for Corsair | | Generic RGB Interface for Corsair |
| Hydro Series | | Hydro Series |
| | | |
| Adam Honse (CalcProgrammer1) 8/17/2020 | | Adam Honse (CalcProgrammer1) 8/17/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairHydroController.h" #include "CorsairHydroController.h"
class RGBController_CorsairHydro : public RGBController class RGBController_CorsairHydro : public RGBController
{ {
public: public:
RGBController_CorsairHydro(CorsairHydroController* corsair_ptr); RGBController_CorsairHydro(CorsairHydroController* controller_ptr);
~RGBController_CorsairHydro(); ~RGBController_CorsairHydro();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CorsairHydroController* corsair; CorsairHydroController* controller;
}; };

View file

@ -1,49 +1,49 @@
/*-------------------------------------------------------------------*\ /*-------------------------------------------------------------------*\
| CorsairHydroPlatinumControllerDetect.cpp | | CorsairHydroPlatinumControllerDetect.cpp |
| | | |
| Driver for Corsair Hydro Platinum AIO Coolers | | Driver for Corsair Hydro Platinum AIO Coolers |
| | | |
| Kasper 28th March 2021 | | Kasper 28th March 2021 |
| | | |
\*-------------------------------------------------------------------*/ \*-------------------------------------------------------------------*/
#include "Detector.h" #include "Detector.h"
#include "CorsairHydroPlatinumController.h" #include "CorsairHydroPlatinumController.h"
#include "RGBController.h" #include "RGBController.h"
#include "RGBController_CorsairHydroPlatinum.h" #include "RGBController_CorsairHydroPlatinum.h"
#include <hidapi/hidapi.h> #include <hidapi/hidapi.h>
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Corsair vendor ID | | Corsair vendor ID |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CORSAIR_VID 0x1B1C #define CORSAIR_VID 0x1B1C
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Product IDs | | Product IDs |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CORSAIR_HYDRO_H100I_PLATINUM_PID 0x0c18 #define CORSAIR_HYDRO_H100I_PLATINUM_PID 0x0C18
#define CORSAIR_HYDRO_H100I_PLATINUM_SE_PID 0x0C19 #define CORSAIR_HYDRO_H100I_PLATINUM_SE_PID 0x0C19
#define CORSAIR_HYDRO_H115I_PLATINUM_PID 0x0c17 #define CORSAIR_HYDRO_H115I_PLATINUM_PID 0x0C17
#define CORSAIR_HYDRO_H100I_PRO_XT_PID 0x0c20 #define CORSAIR_HYDRO_H100I_PRO_XT_PID 0x0C20
#define CORSAIR_HYDRO_H115I_PRO_XT_PID 0x0c21 #define CORSAIR_HYDRO_H115I_PRO_XT_PID 0x0C21
#define CORSAIR_HYDRO_H150I_PRO_XT_PID 0x0c22 #define CORSAIR_HYDRO_H150I_PRO_XT_PID 0x0C22
void DetectCorsairHydroPlatinumControllers(hid_device_info* info, const std::string& name) void DetectCorsairHydroPlatinumControllers(hid_device_info* info, const std::string& name)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev ) if(dev)
{ {
CorsairHydroPlatinumController* controller = new CorsairHydroPlatinumController(dev, info->path); CorsairHydroPlatinumController* controller = new CorsairHydroPlatinumController(dev, info->path);
RGBController_CorsairHydroPlatinum* rgb_controller = new RGBController_CorsairHydroPlatinum(controller); RGBController_CorsairHydroPlatinum* rgb_controller = new RGBController_CorsairHydroPlatinum(controller);
rgb_controller->name = name; rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} }
REGISTER_HID_DETECTOR("Corsair Hydro H100i Platinum", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PLATINUM_PID ); REGISTER_HID_DETECTOR("Corsair Hydro H100i Platinum", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PLATINUM_PID );
REGISTER_HID_DETECTOR("Corsair Hydro H100i Platinum SE", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PLATINUM_SE_PID ); REGISTER_HID_DETECTOR("Corsair Hydro H100i Platinum SE", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PLATINUM_SE_PID );
REGISTER_HID_DETECTOR("Corsair Hydro H115i Platinum", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H115I_PLATINUM_PID ); REGISTER_HID_DETECTOR("Corsair Hydro H115i Platinum", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H115I_PLATINUM_PID );
REGISTER_HID_DETECTOR("Corsair Hydro H100i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PRO_XT_PID ); REGISTER_HID_DETECTOR("Corsair Hydro H100i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PRO_XT_PID );
REGISTER_HID_DETECTOR("Corsair Hydro H115i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H115I_PRO_XT_PID ); REGISTER_HID_DETECTOR("Corsair Hydro H115i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H115I_PRO_XT_PID );
REGISTER_HID_DETECTOR("Corsair Hydro H150i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H150I_PRO_XT_PID ); REGISTER_HID_DETECTOR("Corsair Hydro H150i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H150I_PRO_XT_PID );

View file

@ -1,127 +1,127 @@
/*-------------------------------------------------------------------*\ /*-------------------------------------------------------------------*\
| RGBController_CorsairHydroPlatinum.cpp | | RGBController_CorsairHydroPlatinum.cpp |
| | | |
| Driver for Corsair Hydro Platinum AIO Coolers | | Driver for Corsair Hydro Platinum AIO Coolers |
| | | |
| Kasper 28th March 2021 | | Kasper 28th March 2021 |
| | | |
\*-------------------------------------------------------------------*/ \*-------------------------------------------------------------------*/
#include "RGBController_CorsairHydroPlatinum.h" #include "RGBController_CorsairHydroPlatinum.h"
#define NA 0xFFFFFFFF #define NA 0xFFFFFFFF
static unsigned int matrix_map[5][5] = static unsigned int matrix_map[5][5] =
{ {
{ NA, 11, 12, 13, NA }, { NA, 11, 12, 13, NA },
{ 10, NA, 1, NA, 14 }, { 10, NA, 1, NA, 14 },
{ 9, 0, NA, 2, 15 }, { 9, 0, NA, 2, 15 },
{ 8, NA, 3, NA, 4 }, { 8, NA, 3, NA, 4 },
{ NA, 7, 6, 5, NA } { NA, 7, 6, 5, NA }
}; };
RGBController_CorsairHydroPlatinum::RGBController_CorsairHydroPlatinum(CorsairHydroPlatinumController* corsair_ptr) RGBController_CorsairHydroPlatinum::RGBController_CorsairHydroPlatinum(CorsairHydroPlatinumController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = "Corsair Hydro Platinum Series Device"; name = "Corsair Hydro Platinum Series Device";
vendor = "Corsair"; vendor = "Corsair";
description = "Corsair Hydro Platinum Series Device"; description = "Corsair Hydro Platinum Series Device";
type = DEVICE_TYPE_COOLER; type = DEVICE_TYPE_COOLER;
location = corsair->GetLocation(); location = controller->GetLocation();
version = corsair->GetFirmwareString(); version = controller->GetFirmwareString();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = 0; Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
Init_Controller(); Init_Controller();
SetupZones(); SetupZones();
} }
void RGBController_CorsairHydroPlatinum::Init_Controller() void RGBController_CorsairHydroPlatinum::Init_Controller()
{ {
zone cpu_block_zone; zone cpu_block_zone;
cpu_block_zone.name = "CPU Block"; cpu_block_zone.name = "CPU Block";
cpu_block_zone.type = ZONE_TYPE_MATRIX; cpu_block_zone.type = ZONE_TYPE_MATRIX;
cpu_block_zone.leds_min = 16; cpu_block_zone.leds_min = 16;
cpu_block_zone.leds_max = 16; cpu_block_zone.leds_max = 16;
cpu_block_zone.leds_count = 16; cpu_block_zone.leds_count = 16;
cpu_block_zone.matrix_map = new matrix_map_type; cpu_block_zone.matrix_map = new matrix_map_type;
cpu_block_zone.matrix_map->height = 5; cpu_block_zone.matrix_map->height = 5;
cpu_block_zone.matrix_map->width = 5; cpu_block_zone.matrix_map->width = 5;
cpu_block_zone.matrix_map->map = (unsigned int *)&matrix_map; cpu_block_zone.matrix_map->map = (unsigned int *)&matrix_map;
zones.push_back(cpu_block_zone); zones.push_back(cpu_block_zone);
zone fans_zone; zone fans_zone;
fans_zone.name = "Fans"; fans_zone.name = "Fans";
fans_zone.type = ZONE_TYPE_LINEAR; fans_zone.type = ZONE_TYPE_LINEAR;
fans_zone.leds_min = 0; fans_zone.leds_min = 0;
fans_zone.leds_max = 32; fans_zone.leds_max = 32;
fans_zone.leds_count = 0; fans_zone.leds_count = 0;
fans_zone.matrix_map = NULL; fans_zone.matrix_map = NULL;
zones.push_back(fans_zone); zones.push_back(fans_zone);
} }
void RGBController_CorsairHydroPlatinum::SetupZones() void RGBController_CorsairHydroPlatinum::SetupZones()
{ {
/*-------------------------------------------------*\ /*-------------------------------------------------*\
| Clear any existing color/LED configuration | | Clear any existing color/LED configuration |
\*-------------------------------------------------*/ \*-------------------------------------------------*/
leds.clear(); leds.clear();
colors.clear(); colors.clear();
for (unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++) for (unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{ {
for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{ {
led new_led; led new_led;
new_led.name = zones[zone_idx].name + " " + std::to_string(led_idx);; new_led.name = zones[zone_idx].name + " " + std::to_string(led_idx);;
leds.push_back(new_led); leds.push_back(new_led);
} }
} }
SetupColors(); SetupColors();
} }
void RGBController_CorsairHydroPlatinum::ResizeZone(int zone, int new_size) void RGBController_CorsairHydroPlatinum::ResizeZone(int zone, int new_size)
{ {
if((size_t) zone >= zones.size()) if((size_t) zone >= zones.size())
{ {
return; return;
} }
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{ {
zones[zone].leds_count = new_size; zones[zone].leds_count = new_size;
SetupZones(); SetupZones();
} }
} }
void RGBController_CorsairHydroPlatinum::DeviceUpdateLEDs() void RGBController_CorsairHydroPlatinum::DeviceUpdateLEDs()
{ {
corsair->SetupColors(colors); controller->SetupColors(colors);
} }
void RGBController_CorsairHydroPlatinum::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairHydroPlatinum::UpdateZoneLEDs(int /*zone*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CorsairHydroPlatinum::UpdateSingleLED(int /*led*/) void RGBController_CorsairHydroPlatinum::UpdateSingleLED(int /*led*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CorsairHydroPlatinum::SetCustomMode() void RGBController_CorsairHydroPlatinum::SetCustomMode()
{ {
active_mode = 0; active_mode = 0;
} }
void RGBController_CorsairHydroPlatinum::DeviceUpdateMode() void RGBController_CorsairHydroPlatinum::DeviceUpdateMode()
{ {
} }

View file

@ -1,34 +1,34 @@
/*-------------------------------------------------------------------*\ /*-------------------------------------------------------------------*\
| RGBController_CorsairHydroPlatinum.h | | RGBController_CorsairHydroPlatinum.h |
| | | |
| Driver for Corsair Hydro Platinum AIO Coolers | | Driver for Corsair Hydro Platinum AIO Coolers |
| | | |
| Kasper 28th March 2021 | | Kasper 28th March 2021 |
| | | |
\*-------------------------------------------------------------------*/ \*-------------------------------------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairHydroPlatinumController.h" #include "CorsairHydroPlatinumController.h"
class RGBController_CorsairHydroPlatinum : public RGBController class RGBController_CorsairHydroPlatinum : public RGBController
{ {
public: public:
RGBController_CorsairHydroPlatinum(CorsairHydroPlatinumController* corsair_ptr); RGBController_CorsairHydroPlatinum(CorsairHydroPlatinumController* controller_ptr);
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CorsairHydroPlatinumController* corsair; CorsairHydroPlatinumController* controller;
void Init_Controller(); void Init_Controller();
}; };

View file

@ -1,43 +1,44 @@
#include "Detector.h" #include "Detector.h"
#include "CorsairLightingNodeController.h" #include "CorsairLightingNodeController.h"
#include "RGBController.h" #include "RGBController.h"
#include "RGBController_CorsairLightingNode.h" #include "RGBController_CorsairLightingNode.h"
#include <vector> #include <vector>
#include <hidapi/hidapi.h> #include <hidapi/hidapi.h>
#define CORSAIR_VID 0x1B1C #define CORSAIR_VID 0x1B1C
#define CORSAIR_LIGHTING_NODE_CORE_PID 0x0C1A #define CORSAIR_LIGHTING_NODE_CORE_PID 0x0C1A
#define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B #define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B
#define CORSAIR_COMMANDER_PRO_PID 0x0C10 #define CORSAIR_COMMANDER_PRO_PID 0x0C10
#define CORSAIR_LS100_PID 0x0C1E #define CORSAIR_LS100_PID 0x0C1E
#define CORSAIR_1000D_OBSIDIAN_PID 0x1D00 #define CORSAIR_1000D_OBSIDIAN_PID 0x1D00
#define CORSAIR_SPEC_OMEGA_RGB_PID 0x1D04 #define CORSAIR_SPEC_OMEGA_RGB_PID 0x1D04
#define CORSAIR_LT100_PID 0x0C23 #define CORSAIR_LT100_PID 0x0C23
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectCorsairLightingNodeControllers * * DetectCorsairLightingNodeControllers *
* * * *
* Detect devices supported by the Corsair Lighting Node Pro driver * * Detect devices supported by the Corsair Lighting Node Pro driver *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectCorsairLightingNodeControllers(hid_device_info* info, const std::string& name) void DetectCorsairLightingNodeControllers(hid_device_info* info, const std::string& name)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev )
{ if(dev)
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev, info->path); {
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller); CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev, info->path);
rgb_controller->name = name; RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller); rgb_controller->name = name;
} ResourceManager::get()->RegisterRGBController(rgb_controller);
} /* DetectCorsairLightingNodeControllers() */ }
} /* DetectCorsairLightingNodeControllers() */
REGISTER_HID_DETECTOR("Corsair Lighting Node Core", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID); // 1 channel
REGISTER_HID_DETECTOR("Corsair Lighting Node Pro", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID); // 2 channels REGISTER_HID_DETECTOR("Corsair Lighting Node Core", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID); // 1 channel
REGISTER_HID_DETECTOR("Corsair Commander Pro", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_COMMANDER_PRO_PID); // 2 channels REGISTER_HID_DETECTOR("Corsair Lighting Node Pro", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID); // 2 channels
REGISTER_HID_DETECTOR("Corsair LS100 Lighting Kit", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LS100_PID); // 1 channel REGISTER_HID_DETECTOR("Corsair Commander Pro", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_COMMANDER_PRO_PID); // 2 channels
REGISTER_HID_DETECTOR("Corsair 1000D Obsidian", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_1000D_OBSIDIAN_PID); // 2 channels REGISTER_HID_DETECTOR("Corsair LS100 Lighting Kit", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LS100_PID); // 1 channel
REGISTER_HID_DETECTOR("Corsair SPEC OMEGA RGB", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID); // 2 channels REGISTER_HID_DETECTOR("Corsair 1000D Obsidian", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_1000D_OBSIDIAN_PID); // 2 channels
REGISTER_HID_DETECTOR("Corsair SPEC OMEGA RGB", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID); // 2 channels
REGISTER_HID_DETECTOR("Corsair LT100", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LT100_PID); // 2 channels REGISTER_HID_DETECTOR("Corsair LT100", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LT100_PID); // 2 channels

View file

@ -10,17 +10,17 @@
#include "RGBController_CorsairLightingNode.h" #include "RGBController_CorsairLightingNode.h"
RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLightingNodeController* corsair_ptr) RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLightingNodeController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = "Corsair Lighting Node Device"; name = "Corsair Lighting Node Device";
vendor = "Corsair"; vendor = "Corsair";
description = "Corsair Lighting Node Device"; description = "Corsair Lighting Node Device";
type = DEVICE_TYPE_LEDSTRIP; type = DEVICE_TYPE_LEDSTRIP;
version = corsair->GetFirmwareString(); version = controller->GetFirmwareString();
location = corsair->GetLocationString(); location = controller->GetLocationString();
serial = corsair->GetSerialString(); serial = controller->GetSerialString();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
@ -202,7 +202,7 @@ RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLigh
RGBController_CorsairLightingNode::~RGBController_CorsairLightingNode() RGBController_CorsairLightingNode::~RGBController_CorsairLightingNode()
{ {
delete corsair; delete controller;
} }
void RGBController_CorsairLightingNode::SetupZones() void RGBController_CorsairLightingNode::SetupZones()
@ -241,8 +241,8 @@ void RGBController_CorsairLightingNode::SetupZones()
| maximum number of LEDs the Corsair Commander Pro | | maximum number of LEDs the Corsair Commander Pro |
| can support is 200. | | can support is 200. |
\*-------------------------------------------------*/ \*-------------------------------------------------*/
zones[channel_idx].leds_min = 0; zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 204; zones[channel_idx].leds_max = 204;
if(first_run) if(first_run)
{ {
@ -289,20 +289,20 @@ void RGBController_CorsairLightingNode::DeviceUpdateLEDs()
{ {
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{ {
corsair->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count); controller->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
} }
} }
void RGBController_CorsairLightingNode::UpdateZoneLEDs(int zone) void RGBController_CorsairLightingNode::UpdateZoneLEDs(int zone)
{ {
corsair->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count); controller->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
} }
void RGBController_CorsairLightingNode::UpdateSingleLED(int led) void RGBController_CorsairLightingNode::UpdateSingleLED(int led)
{ {
unsigned int channel = leds_channel[led]; unsigned int channel = leds_channel[led];
corsair->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count); controller->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
} }
void RGBController_CorsairLightingNode::SetCustomMode() void RGBController_CorsairLightingNode::SetCustomMode()
@ -340,30 +340,30 @@ void RGBController_CorsairLightingNode::DeviceUpdateMode()
} }
} }
corsair->SetChannelEffect(channel, controller->SetChannelEffect(channel,
zones[channel].leds_count, zones[channel].leds_count,
modes[active_mode].value, modes[active_mode].value,
modes[active_mode].speed, modes[active_mode].speed,
direction, direction,
random, random,
mode_colors[0], mode_colors[0],
mode_colors[1], mode_colors[1],
mode_colors[2], mode_colors[2],
mode_colors[3], mode_colors[3],
mode_colors[4], mode_colors[4],
mode_colors[5], mode_colors[5],
mode_colors[6], mode_colors[6],
mode_colors[7], mode_colors[7],
mode_colors[8]); mode_colors[8]);
} }
} }
if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS) if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
{ {
corsair->SetBrightness(modes[active_mode].brightness); controller->SetBrightness(modes[active_mode].brightness);
} }
else else
{ {
corsair->SetBrightness(100); controller->SetBrightness(100);
} }
} }

View file

@ -1,35 +1,35 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairLightingNode.h | | RGBController_CorsairLightingNode.h |
| | | |
| Generic RGB Interface for Corsair | | Generic RGB Interface for Corsair |
| Lighting Node Pro | | Lighting Node Pro |
| | | |
| Adam Honse (CalcProgrammer1) 1/12/2020 | | Adam Honse (CalcProgrammer1) 1/12/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairLightingNodeController.h" #include "CorsairLightingNodeController.h"
class RGBController_CorsairLightingNode : public RGBController class RGBController_CorsairLightingNode : public RGBController
{ {
public: public:
RGBController_CorsairLightingNode(CorsairLightingNodeController* corsair_ptr); RGBController_CorsairLightingNode(CorsairLightingNodeController* controller_ptr);
~RGBController_CorsairLightingNode(); ~RGBController_CorsairLightingNode();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CorsairLightingNodeController* corsair; CorsairLightingNodeController* controller;
std::vector<unsigned int> leds_channel; std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel; std::vector<unsigned int> zones_channel;
}; };

View file

@ -110,7 +110,7 @@ void DetectCorsairK55RGBPROControllers(hid_device_info* info, const std::string&
if(dev) if(dev)
{ {
CorsairK55RGBPROController* controller = new CorsairK55RGBPROController(dev, info->path); CorsairK55RGBPROController* controller = new CorsairK55RGBPROController(dev, info->path);
controller->SetName(name); controller->SetName(name);
RGBController_CorsairK55RGBPRO* rgb_controller = new RGBController_CorsairK55RGBPRO(controller); RGBController_CorsairK55RGBPRO* rgb_controller = new RGBController_CorsairK55RGBPRO(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);

View file

@ -218,19 +218,19 @@ typedef struct
matrix_map_type* matrix; matrix_map_type* matrix;
} led_zone_layout; } led_zone_layout;
RGBController_CorsairK100::RGBController_CorsairK100(CorsairK100Controller* corsair_ptr) RGBController_CorsairK100::RGBController_CorsairK100(CorsairK100Controller* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = corsair->GetName(); name = controller->GetName();
vendor = "Corsair"; vendor = "Corsair";
description = "Corsair K100 Keyboard Device"; description = "Corsair K100 Keyboard Device";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
version = corsair->GetFirmwareString(); version = controller->GetFirmwareString();
location = corsair->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = corsair->GetSerialString(); serial = controller->GetSerialString();
logical_layout = corsair->GetKeyboardType(); logical_layout = controller->GetKeyboardType();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
@ -240,6 +240,7 @@ RGBController_CorsairK100::RGBController_CorsairK100(CorsairK100Controller* cors
modes.push_back(Direct); modes.push_back(Direct);
SetupZones(); SetupZones();
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| The Corsair K100 requires a packet within | | The Corsair K100 requires a packet within |
| 1 minutes of sending the lighting change in order | | 1 minutes of sending the lighting change in order |
@ -270,7 +271,7 @@ RGBController_CorsairK100::~RGBController_CorsairK100()
} }
} }
delete corsair; delete controller;
} }
void RGBController_CorsairK100::SetupZones() void RGBController_CorsairK100::SetupZones()
@ -333,17 +334,17 @@ void RGBController_CorsairK100::DeviceUpdateLEDs()
{ {
last_update_time = std::chrono::steady_clock::now(); last_update_time = std::chrono::steady_clock::now();
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairK100::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairK100::UpdateZoneLEDs(int /*zone*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairK100::UpdateSingleLED(int /*led*/) void RGBController_CorsairK100::UpdateSingleLED(int /*led*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairK100::SetCustomMode() void RGBController_CorsairK100::SetCustomMode()

View file

@ -13,7 +13,7 @@
class RGBController_CorsairK100 : public RGBController class RGBController_CorsairK100 : public RGBController
{ {
public: public:
RGBController_CorsairK100(CorsairK100Controller* corsair_ptr); RGBController_CorsairK100(CorsairK100Controller* controller_ptr);
~RGBController_CorsairK100(); ~RGBController_CorsairK100();
void SetupZones(); void SetupZones();
@ -28,11 +28,11 @@ public:
void KeepaliveThread(); void KeepaliveThread();
private: private:
CorsairK100Controller* corsair; CorsairK100Controller* controller;
CorsairKeyboardType logical_layout; CorsairKeyboardType logical_layout;
std::thread* keepalive_thread; std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run; std::atomic<bool> keepalive_thread_run;
std::chrono::time_point<std::chrono::steady_clock> last_update_time; std::chrono::time_point<std::chrono::steady_clock> last_update_time;
}; };

View file

@ -9,17 +9,17 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
RGBController_CorsairK55RGBPRO::RGBController_CorsairK55RGBPRO(CorsairK55RGBPROController* corsair_ptr) RGBController_CorsairK55RGBPRO::RGBController_CorsairK55RGBPRO(CorsairK55RGBPROController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = corsair->GetName(); name = controller->GetName();
vendor = "Corsair"; vendor = "Corsair";
description = "Corsair K55 RGB PRO Keyboard Device"; description = "Corsair K55 RGB PRO Keyboard Device";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
version = corsair->GetFirmwareString(); version = controller->GetFirmwareString();
location = corsair->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = corsair->GetSerialString(); serial = controller->GetSerialString();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
@ -59,7 +59,7 @@ RGBController_CorsairK55RGBPRO::~RGBController_CorsairK55RGBPRO()
} }
} }
delete corsair; delete controller;
} }
void RGBController_CorsairK55RGBPRO::SetupZones() void RGBController_CorsairK55RGBPRO::SetupZones()
@ -96,17 +96,17 @@ void RGBController_CorsairK55RGBPRO::DeviceUpdateLEDs()
{ {
last_update_time = std::chrono::steady_clock::now(); last_update_time = std::chrono::steady_clock::now();
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairK55RGBPRO::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairK55RGBPRO::UpdateZoneLEDs(int /*zone*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairK55RGBPRO::UpdateSingleLED(int /*led*/) void RGBController_CorsairK55RGBPRO::UpdateSingleLED(int /*led*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairK55RGBPRO::SetCustomMode() void RGBController_CorsairK55RGBPRO::SetCustomMode()

View file

@ -7,7 +7,7 @@
class RGBController_CorsairK55RGBPRO : public RGBController class RGBController_CorsairK55RGBPRO : public RGBController
{ {
public: public:
RGBController_CorsairK55RGBPRO(CorsairK55RGBPROController* corsair_ptr); RGBController_CorsairK55RGBPRO(CorsairK55RGBPROController* controller_ptr);
~RGBController_CorsairK55RGBPRO(); ~RGBController_CorsairK55RGBPRO();
void SetupZones(); void SetupZones();
@ -22,10 +22,10 @@ public:
void KeepaliveThread(); void KeepaliveThread();
private: private:
CorsairK55RGBPROController* corsair; CorsairK55RGBPROController* controller;
std::thread* keepalive_thread; std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run; std::atomic<bool> keepalive_thread_run;
std::chrono::time_point<std::chrono::steady_clock> last_update_time; std::chrono::time_point<std::chrono::steady_clock> last_update_time;
}; };

View file

@ -753,20 +753,20 @@ static const char* corsair_harpoon_pro_leds[] =
"", "",
}; };
RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr) RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripheralController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = corsair->GetName(); name = controller->GetName();
vendor = "Corsair"; vendor = "Corsair";
description = "Corsair RGB Peripheral Device"; description = "Corsair RGB Peripheral Device";
type = corsair->GetDeviceType(); type = controller->GetDeviceType();
version = corsair->GetFirmwareString(); version = controller->GetFirmwareString();
location = corsair->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = corsair->GetSerialString(); serial = controller->GetSerialString();
physical_layout = corsair->GetPhysicalLayout(); physical_layout = controller->GetPhysicalLayout();
logical_layout = corsair->GetLogicalLayout(); logical_layout = controller->GetLogicalLayout();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
@ -791,7 +791,7 @@ RGBController_CorsairPeripheral::~RGBController_CorsairPeripheral()
} }
} }
delete corsair; delete controller;
} }
void RGBController_CorsairPeripheral::SetupZones() void RGBController_CorsairPeripheral::SetupZones()
@ -1049,17 +1049,17 @@ void RGBController_CorsairPeripheral::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_CorsairPeripheral::DeviceUpdateLEDs() void RGBController_CorsairPeripheral::DeviceUpdateLEDs()
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairPeripheral::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairPeripheral::UpdateZoneLEDs(int /*zone*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairPeripheral::UpdateSingleLED(int /*led*/) void RGBController_CorsairPeripheral::UpdateSingleLED(int /*led*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairPeripheral::SetCustomMode() void RGBController_CorsairPeripheral::SetCustomMode()

View file

@ -1,36 +1,36 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairPeripheral.h | | RGBController_CorsairPeripheral.h |
| | | |
| Generic RGB Interface for Corsair RGB | | Generic RGB Interface for Corsair RGB |
| keyboard, mouse, and mousemat devices | | keyboard, mouse, and mousemat devices |
| | | |
| Adam Honse (CalcProgrammer1) 1/9/2020 | | Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairPeripheralController.h" #include "CorsairPeripheralController.h"
class RGBController_CorsairPeripheral : public RGBController class RGBController_CorsairPeripheral : public RGBController
{ {
public: public:
RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr); RGBController_CorsairPeripheral(CorsairPeripheralController* controller_ptr);
~RGBController_CorsairPeripheral(); ~RGBController_CorsairPeripheral();
int physical_layout; int physical_layout;
int logical_layout; int logical_layout;
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CorsairPeripheralController* corsair; CorsairPeripheralController* controller;
}; };

View file

@ -1,132 +1,76 @@
#include "Detector.h" #include "Detector.h"
#include "CorsairVengeanceController.h" #include "CorsairVengeanceController.h"
#include "RGBController.h" #include "RGBController.h"
#include "RGBController_CorsairVengeance.h" #include "RGBController_CorsairVengeance.h"
#include "i2c_smbus.h" #include "i2c_smbus.h"
#include "pci_ids.h" #include "pci_ids.h"
#include <vector> #include <vector>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/******************************************************************************************\ /******************************************************************************************\
* * * *
* TestForCorsairVengeanceController * * TestForCorsairVengeanceController *
* * * *
* Tests the given address to see if a Corsair controller exists there. * * Tests the given address to see if a Corsair controller exists there. *
* * * *
\******************************************************************************************/ \******************************************************************************************/
bool TestForCorsairVengeanceController(i2c_smbus_interface* bus, unsigned char address) bool TestForCorsairVengeanceController(i2c_smbus_interface* bus, unsigned char address)
{ {
bool pass = false; bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0) if (res >= 0)
{ {
pass = true; pass = true;
for (int i = 0xA0; i < 0xB0; i++) for (int i = 0xA0; i < 0xB0; i++)
{ {
res = bus->i2c_smbus_read_byte_data(address, i); res = bus->i2c_smbus_read_byte_data(address, i);
if (res != 0xBA) if (res != 0xBA)
{ {
pass = false; pass = false;
} }
} }
} }
return(pass); return(pass);
} /* TestForCorsairVengeanceController() */ } /* TestForCorsairVengeanceController() */
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectCorsairVengeanceControllers * * DetectCorsairVengeanceControllers *
* * * *
* Detect Corsair controllers on the enumerated I2C busses. * * Detect Corsair controllers on the enumerated I2C busses. *
* * * *
* bus - pointer to i2c_smbus_interface where Aura device is connected * * bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device * * dev - I2C address of Aura device *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectCorsairVengeanceControllers(std::vector<i2c_smbus_interface*> &busses) void DetectCorsairVengeanceControllers(std::vector<i2c_smbus_interface*> &busses)
{ {
CorsairVengeanceController* new_corsair; for(unsigned int bus = 0; bus < busses.size(); bus++)
RGBController_CorsairVengeance* new_controller; {
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
for (unsigned int bus = 0; bus < busses.size(); bus++) {
{ for(unsigned char addr = 0x58; addr <= 0x5F; addr++)
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) {
{ if(TestForCorsairVengeanceController(busses[bus], addr))
// Check for Corsair controller at 0x58 {
if (TestForCorsairVengeanceController(busses[bus], 0x58)) CorsairVengeanceController* new_controller = new CorsairVengeanceController(busses[bus], addr);
{ RGBController_CorsairVengeance* new_rgbcontroller = new RGBController_CorsairVengeance(new_controller);
new_corsair = new CorsairVengeanceController(busses[bus], 0x58);
new_controller = new RGBController_CorsairVengeance(new_corsair); ResourceManager::get()->RegisterRGBController(new_rgbcontroller);
ResourceManager::get()->RegisterRGBController(new_controller); }
} }
}
// Check for Corsair controller at 0x59 }
if (TestForCorsairVengeanceController(busses[bus], 0x59))
{ } /* DetectCorsairVengeanceControllers() */
new_corsair = new CorsairVengeanceController(busses[bus], 0x59);
new_controller = new RGBController_CorsairVengeance(new_corsair); REGISTER_I2C_DETECTOR("Corsair Vengeance", DetectCorsairVengeanceControllers);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5A
if (TestForCorsairVengeanceController(busses[bus], 0x5A))
{
new_corsair = new CorsairVengeanceController(busses[bus], 0x5A);
new_controller = new RGBController_CorsairVengeance(new_corsair);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5B
if (TestForCorsairVengeanceController(busses[bus], 0x5B))
{
new_corsair = new CorsairVengeanceController(busses[bus], 0x5B);
new_controller = new RGBController_CorsairVengeance(new_corsair);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5C
if (TestForCorsairVengeanceController(busses[bus], 0x5C))
{
new_corsair = new CorsairVengeanceController(busses[bus], 0x5C);
new_controller = new RGBController_CorsairVengeance(new_corsair);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5D
if (TestForCorsairVengeanceController(busses[bus], 0x5D))
{
new_corsair = new CorsairVengeanceController(busses[bus], 0x5D);
new_controller = new RGBController_CorsairVengeance(new_corsair);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5E
if (TestForCorsairVengeanceController(busses[bus], 0x5E))
{
new_corsair = new CorsairVengeanceController(busses[bus], 0x5E);
new_controller = new RGBController_CorsairVengeance(new_corsair);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5F
if (TestForCorsairVengeanceController(busses[bus], 0x5F))
{
new_corsair = new CorsairVengeanceController(busses[bus], 0x5F);
new_controller = new RGBController_CorsairVengeance(new_corsair);
ResourceManager::get()->RegisterRGBController(new_controller);
}
}
}
} /* DetectCorsairVengeanceControllers() */
REGISTER_I2C_DETECTOR("Corsair Vengeance", DetectCorsairVengeanceControllers);

View file

@ -1,113 +1,113 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairVengeance.cpp | | RGBController_CorsairVengeance.cpp |
| | | |
| Generic RGB Interface for OpenAuraSDK | | Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance RGB driver | | Corsair Vengeance RGB driver |
| | | |
| Adam Honse (CalcProgrammer1) 6/13/2019 | | Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_CorsairVengeance.h" #include "RGBController_CorsairVengeance.h"
RGBController_CorsairVengeance::RGBController_CorsairVengeance(CorsairVengeanceController* corsair_ptr) RGBController_CorsairVengeance::RGBController_CorsairVengeance(CorsairVengeanceController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = corsair->GetDeviceName(); name = controller->GetDeviceName();
vendor = "Corsair"; vendor = "Corsair";
type = DEVICE_TYPE_DRAM; type = DEVICE_TYPE_DRAM;
description = "Corsair Vengeance RGB Device"; description = "Corsair Vengeance RGB Device";
location = corsair->GetDeviceLocation(); location = controller->GetDeviceLocation();
mode Static; mode Static;
Static.name = "Static"; Static.name = "Static";
Static.value = CORSAIR_VENGEANCE_RGB_MODE_SINGLE; Static.value = CORSAIR_VENGEANCE_RGB_MODE_SINGLE;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED; Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static); modes.push_back(Static);
mode Fade; mode Fade;
Fade.name = "Fade"; Fade.name = "Fade";
Fade.value = CORSAIR_VENGEANCE_RGB_MODE_FADE; Fade.value = CORSAIR_VENGEANCE_RGB_MODE_FADE;
Fade.flags = MODE_FLAG_HAS_PER_LED_COLOR; Fade.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Fade.color_mode = MODE_COLORS_PER_LED; Fade.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Fade); modes.push_back(Fade);
mode Pulse; mode Pulse;
Pulse.name = "Pulse"; Pulse.name = "Pulse";
Pulse.value = CORSAIR_VENGEANCE_RGB_MODE_PULSE; Pulse.value = CORSAIR_VENGEANCE_RGB_MODE_PULSE;
Pulse.flags = MODE_FLAG_HAS_PER_LED_COLOR; Pulse.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Pulse.color_mode = MODE_COLORS_PER_LED; Pulse.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Pulse); modes.push_back(Pulse);
SetupZones(); SetupZones();
} }
RGBController_CorsairVengeance::~RGBController_CorsairVengeance() RGBController_CorsairVengeance::~RGBController_CorsairVengeance()
{ {
delete corsair; delete controller;
} }
void RGBController_CorsairVengeance::SetupZones() void RGBController_CorsairVengeance::SetupZones()
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Create a single zone | | Create a single zone |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
zone new_zone; zone new_zone;
new_zone.name = "Corsair Zone"; new_zone.name = "Corsair Zone";
new_zone.type = ZONE_TYPE_SINGLE; new_zone.type = ZONE_TYPE_SINGLE;
new_zone.leds_min = corsair->GetLEDCount(); new_zone.leds_min = controller->GetLEDCount();
new_zone.leds_max = corsair->GetLEDCount(); new_zone.leds_max = controller->GetLEDCount();
new_zone.leds_count = corsair->GetLEDCount(); new_zone.leds_count = controller->GetLEDCount();
new_zone.matrix_map = NULL; new_zone.matrix_map = NULL;
zones.push_back(new_zone); zones.push_back(new_zone);
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Set up LEDs | | Set up LEDs |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++) for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{ {
led* new_led = new led(); led* new_led = new led();
new_led->name = "Corsair LED"; new_led->name = "Corsair LED";
leds.push_back(*new_led); leds.push_back(*new_led);
} }
SetupColors(); SetupColors();
} }
void RGBController_CorsairVengeance::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_CorsairVengeance::ResizeZone(int /*zone*/, int /*new_size*/)
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| This device does not support resizing zones | | This device does not support resizing zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
} }
void RGBController_CorsairVengeance::DeviceUpdateLEDs() void RGBController_CorsairVengeance::DeviceUpdateLEDs()
{ {
RGBColor color = colors[0]; RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color); unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color); unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(red, grn, blu); controller->SetLEDColor(red, grn, blu);
} }
void RGBController_CorsairVengeance::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairVengeance::UpdateZoneLEDs(int /*zone*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CorsairVengeance::UpdateSingleLED(int /*led*/) void RGBController_CorsairVengeance::UpdateSingleLED(int /*led*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CorsairVengeance::SetCustomMode() void RGBController_CorsairVengeance::SetCustomMode()
{ {
active_mode = 0; active_mode = 0;
} }
void RGBController_CorsairVengeance::DeviceUpdateMode() void RGBController_CorsairVengeance::DeviceUpdateMode()
{ {
corsair->SetMode(modes[active_mode].value); controller->SetMode(modes[active_mode].value);
} }

View file

@ -1,34 +1,34 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairVengeance.h | | RGBController_CorsairVengeance.h |
| | | |
| Generic RGB Interface for OpenAuraSDK | | Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance RGB driver | | Corsair Vengeance RGB driver |
| | | |
| Adam Honse (CalcProgrammer1) 6/13/2019 | | Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairVengeanceController.h" #include "CorsairVengeanceController.h"
class RGBController_CorsairVengeance : public RGBController class RGBController_CorsairVengeance : public RGBController
{ {
public: public:
RGBController_CorsairVengeance(CorsairVengeanceController* corsair_ptr); RGBController_CorsairVengeance(CorsairVengeanceController* controller_ptr);
~RGBController_CorsairVengeance(); ~RGBController_CorsairVengeance();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CorsairVengeanceController* corsair; CorsairVengeanceController* controller;
}; };

View file

@ -74,74 +74,21 @@ void DetectCorsairVengeanceProControllers(std::vector<i2c_smbus_interface*> &bus
CorsairVengeanceProController* new_corsair_pro; CorsairVengeanceProController* new_corsair_pro;
RGBController_CorsairVengeancePro* new_controller; RGBController_CorsairVengeancePro* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++) for(unsigned int bus = 0; bus < busses.size(); bus++)
{ {
LOG_DEBUG("[%s] Testing bus %d", CORSAIR_VENGEANCE_RGB_PRO_NAME, bus); LOG_DEBUG("[%s] Testing bus %d", CORSAIR_VENGEANCE_RGB_PRO_NAME, bus);
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
{ {
// Check for Corsair controller at 0x58 for(unsigned char addr = 0x58; addr <= 0x5F; addr++)
if (TestForCorsairVengeanceProController(busses[bus], 0x58))
{ {
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x58); if(TestForCorsairVengeanceProController(busses[bus], addr))
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro); {
ResourceManager::get()->RegisterRGBController(new_controller); CorsairVengeanceProController* new_controller = new CorsairVengeanceProController(busses[bus], addr);
} RGBController_CorsairVengeancePro* new_rgbcontroller = new RGBController_CorsairVengeancePro(new_controller);
// Check for Corsair controller at 0x59 ResourceManager::get()->RegisterRGBController(new_rgbcontroller);
if (TestForCorsairVengeanceProController(busses[bus], 0x59)) }
{
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x59);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5A
if (TestForCorsairVengeanceProController(busses[bus], 0x5A))
{
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5A);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5B
if (TestForCorsairVengeanceProController(busses[bus], 0x5B))
{
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5B);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5C
if (TestForCorsairVengeanceProController(busses[bus], 0x5C))
{
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5C);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5D
if (TestForCorsairVengeanceProController(busses[bus], 0x5D))
{
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5D);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5E
if (TestForCorsairVengeanceProController(busses[bus], 0x5E))
{
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5E);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
ResourceManager::get()->RegisterRGBController(new_controller);
}
// Check for Corsair controller at 0x5F
if (TestForCorsairVengeanceProController(busses[bus], 0x5F))
{
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5F);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
ResourceManager::get()->RegisterRGBController(new_controller);
} }
} }
else else

View file

@ -1,308 +1,308 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairVengeancePro.cpp | | RGBController_CorsairVengeancePro.cpp |
| | | |
| Generic RGB Interface for OpenAuraSDK | | Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance Pro RGB driver | | Corsair Vengeance Pro RGB driver |
| | | |
| Adam Honse (CalcProgrammer1) 6/30/2019 | | Adam Honse (CalcProgrammer1) 6/30/2019 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_CorsairVengeancePro.h" #include "RGBController_CorsairVengeancePro.h"
RGBController_CorsairVengeancePro::RGBController_CorsairVengeancePro(CorsairVengeanceProController* corsair_ptr) RGBController_CorsairVengeancePro::RGBController_CorsairVengeancePro(CorsairVengeanceProController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = corsair->GetDeviceName(); name = controller->GetDeviceName();
vendor = "Corsair"; vendor = "Corsair";
type = DEVICE_TYPE_DRAM; type = DEVICE_TYPE_DRAM;
description = "Corsair Vengeance Pro RGB Device"; description = "Corsair Vengeance Pro RGB Device";
location = corsair->GetDeviceLocation(); location = controller->GetDeviceLocation();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = CORSAIR_PRO_MODE_DIRECT; Direct.value = CORSAIR_PRO_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.speed_min = 0; Direct.speed_min = 0;
Direct.speed_max = 0; Direct.speed_max = 0;
Direct.speed = 0; Direct.speed = 0;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
mode Static; mode Static;
Static.name = "Static"; Static.name = "Static";
Static.value = CORSAIR_PRO_MODE_STATIC; Static.value = CORSAIR_PRO_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.speed_min = 0; Static.speed_min = 0;
Static.speed_max = 0; Static.speed_max = 0;
Static.speed = 0; Static.speed = 0;
Static.color_mode = MODE_COLORS_PER_LED; Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static); modes.push_back(Static);
mode ColorShift; mode ColorShift;
ColorShift.name = "Color Shift"; ColorShift.name = "Color Shift";
ColorShift.value = CORSAIR_PRO_MODE_COLOR_SHIFT; ColorShift.value = CORSAIR_PRO_MODE_COLOR_SHIFT;
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorShift.speed_min = CORSAIR_PRO_SPEED_SLOW; ColorShift.speed_min = CORSAIR_PRO_SPEED_SLOW;
ColorShift.speed_max = CORSAIR_PRO_SPEED_FAST; ColorShift.speed_max = CORSAIR_PRO_SPEED_FAST;
ColorShift.colors_min = 2; ColorShift.colors_min = 2;
ColorShift.colors_max = 2; ColorShift.colors_max = 2;
ColorShift.speed = CORSAIR_PRO_SPEED_SLOW; ColorShift.speed = CORSAIR_PRO_SPEED_SLOW;
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC; ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorShift.colors.resize(2); ColorShift.colors.resize(2);
modes.push_back(ColorShift); modes.push_back(ColorShift);
mode ColorPulse; mode ColorPulse;
ColorPulse.name = "Color Pulse"; ColorPulse.name = "Color Pulse";
ColorPulse.value = CORSAIR_PRO_MODE_COLOR_PULSE; ColorPulse.value = CORSAIR_PRO_MODE_COLOR_PULSE;
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorPulse.speed_min = CORSAIR_PRO_SPEED_SLOW; ColorPulse.speed_min = CORSAIR_PRO_SPEED_SLOW;
ColorPulse.speed_max = CORSAIR_PRO_SPEED_FAST; ColorPulse.speed_max = CORSAIR_PRO_SPEED_FAST;
ColorPulse.colors_min = 2; ColorPulse.colors_min = 2;
ColorPulse.colors_max = 2; ColorPulse.colors_max = 2;
ColorPulse.speed = CORSAIR_PRO_SPEED_SLOW; ColorPulse.speed = CORSAIR_PRO_SPEED_SLOW;
ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC; ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorPulse.colors.resize(2); ColorPulse.colors.resize(2);
modes.push_back(ColorPulse); modes.push_back(ColorPulse);
mode RainbowWave; mode RainbowWave;
RainbowWave.name = "Rainbow Wave"; RainbowWave.name = "Rainbow Wave";
RainbowWave.value = CORSAIR_PRO_MODE_RAINBOW_WAVE; RainbowWave.value = CORSAIR_PRO_MODE_RAINBOW_WAVE;
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD; RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD;
RainbowWave.speed_min = CORSAIR_PRO_SPEED_SLOW; RainbowWave.speed_min = CORSAIR_PRO_SPEED_SLOW;
RainbowWave.speed_max = CORSAIR_PRO_SPEED_FAST; RainbowWave.speed_max = CORSAIR_PRO_SPEED_FAST;
RainbowWave.speed = CORSAIR_PRO_SPEED_SLOW; RainbowWave.speed = CORSAIR_PRO_SPEED_SLOW;
RainbowWave.direction = MODE_DIRECTION_DOWN; RainbowWave.direction = MODE_DIRECTION_DOWN;
RainbowWave.color_mode = MODE_COLORS_NONE; RainbowWave.color_mode = MODE_COLORS_NONE;
modes.push_back(RainbowWave); modes.push_back(RainbowWave);
mode ColorWave; mode ColorWave;
ColorWave.name = "Color Wave"; ColorWave.name = "Color Wave";
ColorWave.value = CORSAIR_PRO_MODE_COLOR_WAVE; ColorWave.value = CORSAIR_PRO_MODE_COLOR_WAVE;
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorWave.speed_min = CORSAIR_PRO_SPEED_SLOW; ColorWave.speed_min = CORSAIR_PRO_SPEED_SLOW;
ColorWave.speed_max = CORSAIR_PRO_SPEED_FAST; ColorWave.speed_max = CORSAIR_PRO_SPEED_FAST;
ColorWave.colors_min = 2; ColorWave.colors_min = 2;
ColorWave.colors_max = 2; ColorWave.colors_max = 2;
ColorWave.speed = CORSAIR_PRO_SPEED_SLOW; ColorWave.speed = CORSAIR_PRO_SPEED_SLOW;
ColorWave.direction = MODE_DIRECTION_DOWN; ColorWave.direction = MODE_DIRECTION_DOWN;
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC; ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorWave.colors.resize(2); ColorWave.colors.resize(2);
modes.push_back(ColorWave); modes.push_back(ColorWave);
mode Visor; mode Visor;
Visor.name = "Visor"; Visor.name = "Visor";
Visor.value = CORSAIR_PRO_MODE_VISOR; Visor.value = CORSAIR_PRO_MODE_VISOR;
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_HV | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_HV | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Visor.speed_min = CORSAIR_PRO_SPEED_SLOW; Visor.speed_min = CORSAIR_PRO_SPEED_SLOW;
Visor.speed_max = CORSAIR_PRO_SPEED_FAST; Visor.speed_max = CORSAIR_PRO_SPEED_FAST;
Visor.colors_min = 2; Visor.colors_min = 2;
Visor.colors_max = 2; Visor.colors_max = 2;
Visor.speed = CORSAIR_PRO_SPEED_SLOW; Visor.speed = CORSAIR_PRO_SPEED_SLOW;
Visor.direction = MODE_DIRECTION_VERTICAL; Visor.direction = MODE_DIRECTION_VERTICAL;
Visor.color_mode = MODE_COLORS_MODE_SPECIFIC; Visor.color_mode = MODE_COLORS_MODE_SPECIFIC;
Visor.colors.resize(2); Visor.colors.resize(2);
modes.push_back(Visor); modes.push_back(Visor);
mode Rain; mode Rain;
Rain.name = "Rain"; Rain.name = "Rain";
Rain.value = CORSAIR_PRO_MODE_RAIN; Rain.value = CORSAIR_PRO_MODE_RAIN;
Rain.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; Rain.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Rain.speed_min = CORSAIR_PRO_SPEED_SLOW; Rain.speed_min = CORSAIR_PRO_SPEED_SLOW;
Rain.speed_max = CORSAIR_PRO_SPEED_FAST; Rain.speed_max = CORSAIR_PRO_SPEED_FAST;
Rain.colors_min = 2; Rain.colors_min = 2;
Rain.colors_max = 2; Rain.colors_max = 2;
Rain.speed = CORSAIR_PRO_SPEED_SLOW; Rain.speed = CORSAIR_PRO_SPEED_SLOW;
Rain.direction = MODE_DIRECTION_DOWN; Rain.direction = MODE_DIRECTION_DOWN;
Rain.color_mode = MODE_COLORS_MODE_SPECIFIC; Rain.color_mode = MODE_COLORS_MODE_SPECIFIC;
Rain.colors.resize(2); Rain.colors.resize(2);
modes.push_back(Rain); modes.push_back(Rain);
mode Marquee; mode Marquee;
Marquee.name = "Marquee"; Marquee.name = "Marquee";
Marquee.value = CORSAIR_PRO_MODE_MARQUEE; Marquee.value = CORSAIR_PRO_MODE_MARQUEE;
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Marquee.speed_min = CORSAIR_PRO_SPEED_SLOW; Marquee.speed_min = CORSAIR_PRO_SPEED_SLOW;
Marquee.speed_max = CORSAIR_PRO_SPEED_FAST; Marquee.speed_max = CORSAIR_PRO_SPEED_FAST;
Marquee.colors_min = 1; Marquee.colors_min = 1;
Marquee.colors_max = 1; Marquee.colors_max = 1;
Marquee.speed = CORSAIR_PRO_SPEED_SLOW; Marquee.speed = CORSAIR_PRO_SPEED_SLOW;
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC; Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
Marquee.colors.resize(1); Marquee.colors.resize(1);
modes.push_back(Marquee); modes.push_back(Marquee);
mode Rainbow; mode Rainbow;
Rainbow.name = "Rainbow"; Rainbow.name = "Rainbow";
Rainbow.value = CORSAIR_PRO_MODE_RAINBOW; Rainbow.value = CORSAIR_PRO_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED; Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = CORSAIR_PRO_SPEED_SLOW; Rainbow.speed_min = CORSAIR_PRO_SPEED_SLOW;
Rainbow.speed_max = CORSAIR_PRO_SPEED_FAST; Rainbow.speed_max = CORSAIR_PRO_SPEED_FAST;
Rainbow.speed = CORSAIR_PRO_SPEED_SLOW; Rainbow.speed = CORSAIR_PRO_SPEED_SLOW;
Rainbow.color_mode = MODE_COLORS_NONE; Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow); modes.push_back(Rainbow);
mode Sequential; mode Sequential;
Sequential.name = "Sequential"; Sequential.name = "Sequential";
Sequential.value = CORSAIR_PRO_MODE_SEQUENTIAL; Sequential.value = CORSAIR_PRO_MODE_SEQUENTIAL;
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Sequential.speed_min = CORSAIR_PRO_SPEED_SLOW; Sequential.speed_min = CORSAIR_PRO_SPEED_SLOW;
Sequential.speed_max = CORSAIR_PRO_SPEED_FAST; Sequential.speed_max = CORSAIR_PRO_SPEED_FAST;
Sequential.colors_min = 1; Sequential.colors_min = 1;
Sequential.colors_max = 1; Sequential.colors_max = 1;
Sequential.speed = CORSAIR_PRO_SPEED_SLOW; Sequential.speed = CORSAIR_PRO_SPEED_SLOW;
Sequential.direction = MODE_DIRECTION_DOWN; Sequential.direction = MODE_DIRECTION_DOWN;
Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC; Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC;
Sequential.colors.resize(1); Sequential.colors.resize(1);
modes.push_back(Sequential); modes.push_back(Sequential);
SetupZones(); SetupZones();
active_mode = 9; active_mode = 9;
} }
RGBController_CorsairVengeancePro::~RGBController_CorsairVengeancePro() RGBController_CorsairVengeancePro::~RGBController_CorsairVengeancePro()
{ {
delete corsair; delete controller;
} }
void RGBController_CorsairVengeancePro::SetupZones() void RGBController_CorsairVengeancePro::SetupZones()
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Set up zone | | Set up zone |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
zone new_zone; zone new_zone;
new_zone.name = "Corsair Pro Zone"; new_zone.name = "Corsair Pro Zone";
new_zone.type = ZONE_TYPE_LINEAR; new_zone.type = ZONE_TYPE_LINEAR;
new_zone.leds_min = corsair->GetLEDCount(); new_zone.leds_min = controller->GetLEDCount();
new_zone.leds_max = corsair->GetLEDCount(); new_zone.leds_max = controller->GetLEDCount();
new_zone.leds_count = corsair->GetLEDCount(); new_zone.leds_count = controller->GetLEDCount();
new_zone.matrix_map = NULL; new_zone.matrix_map = NULL;
zones.push_back(new_zone); zones.push_back(new_zone);
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Set up LEDs | | Set up LEDs |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++) for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{ {
led* new_led = new led(); led* new_led = new led();
new_led->name = "Corsair Pro LED "; new_led->name = "Corsair Pro LED ";
new_led->name.append(std::to_string(led_idx)); new_led->name.append(std::to_string(led_idx));
leds.push_back(*new_led); leds.push_back(*new_led);
} }
SetupColors(); SetupColors();
} }
void RGBController_CorsairVengeancePro::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_CorsairVengeancePro::ResizeZone(int /*zone*/, int /*new_size*/)
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| This device does not support resizing zones | | This device does not support resizing zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
} }
void RGBController_CorsairVengeancePro::DeviceUpdateLEDs() void RGBController_CorsairVengeancePro::DeviceUpdateLEDs()
{ {
for (std::size_t led = 0; led < colors.size(); led++) for(std::size_t led = 0; led < colors.size(); led++)
{ {
RGBColor color = colors[led]; RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color); unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color); unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu); controller->SetLEDColor(led, red, grn, blu);
} }
corsair->ApplyColors(); controller->ApplyColors();
} }
void RGBController_CorsairVengeancePro::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairVengeancePro::UpdateZoneLEDs(int /*zone*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CorsairVengeancePro::UpdateSingleLED(int led) void RGBController_CorsairVengeancePro::UpdateSingleLED(int led)
{ {
RGBColor color = colors[led]; RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color); unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color); unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu); controller->SetLEDColor(led, red, grn, blu);
corsair->ApplyColors(); controller->ApplyColors();
} }
void RGBController_CorsairVengeancePro::SetCustomMode() void RGBController_CorsairVengeancePro::SetCustomMode()
{ {
active_mode = 0; active_mode = 0;
} }
void RGBController_CorsairVengeancePro::DeviceUpdateMode() void RGBController_CorsairVengeancePro::DeviceUpdateMode()
{ {
unsigned int corsair_direction = 0; unsigned int corsair_direction = 0;
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM); bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
unsigned char mode_colors[6]; unsigned char mode_colors[6];
switch(modes[active_mode].direction) switch(modes[active_mode].direction)
{ {
case MODE_DIRECTION_LEFT: case MODE_DIRECTION_LEFT:
corsair_direction = CORSAIR_PRO_DIRECTION_LEFT; corsair_direction = CORSAIR_PRO_DIRECTION_LEFT;
break; break;
case MODE_DIRECTION_RIGHT: case MODE_DIRECTION_RIGHT:
corsair_direction = CORSAIR_PRO_DIRECTION_RIGHT; corsair_direction = CORSAIR_PRO_DIRECTION_RIGHT;
break; break;
case MODE_DIRECTION_UP: case MODE_DIRECTION_UP:
corsair_direction = CORSAIR_PRO_DIRECTION_UP; corsair_direction = CORSAIR_PRO_DIRECTION_UP;
break; break;
case MODE_DIRECTION_DOWN: case MODE_DIRECTION_DOWN:
corsair_direction = CORSAIR_PRO_DIRECTION_DOWN; corsair_direction = CORSAIR_PRO_DIRECTION_DOWN;
break; break;
case MODE_DIRECTION_HORIZONTAL: case MODE_DIRECTION_HORIZONTAL:
corsair_direction = CORSAIR_PRO_DIRECTION_HORIZONTAL; corsair_direction = CORSAIR_PRO_DIRECTION_HORIZONTAL;
break; break;
case MODE_DIRECTION_VERTICAL: case MODE_DIRECTION_VERTICAL:
corsair_direction = CORSAIR_PRO_DIRECTION_VERTICAL; corsair_direction = CORSAIR_PRO_DIRECTION_VERTICAL;
break; break;
} }
mode_colors[0] = 0; mode_colors[0] = 0;
mode_colors[1] = 0; mode_colors[1] = 0;
mode_colors[2] = 0; mode_colors[2] = 0;
mode_colors[3] = 0; mode_colors[3] = 0;
mode_colors[4] = 0; mode_colors[4] = 0;
mode_colors[5] = 0; mode_colors[5] = 0;
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{ {
mode_colors[0] = RGBGetRValue(modes[active_mode].colors[0]); mode_colors[0] = RGBGetRValue(modes[active_mode].colors[0]);
mode_colors[1] = RGBGetGValue(modes[active_mode].colors[0]); mode_colors[1] = RGBGetGValue(modes[active_mode].colors[0]);
mode_colors[2] = RGBGetBValue(modes[active_mode].colors[0]); mode_colors[2] = RGBGetBValue(modes[active_mode].colors[0]);
if(modes[active_mode].colors.size() == 2) if(modes[active_mode].colors.size() == 2)
{ {
mode_colors[3] = RGBGetRValue(modes[active_mode].colors[1]); mode_colors[3] = RGBGetRValue(modes[active_mode].colors[1]);
mode_colors[4] = RGBGetGValue(modes[active_mode].colors[1]); mode_colors[4] = RGBGetGValue(modes[active_mode].colors[1]);
mode_colors[5] = RGBGetBValue(modes[active_mode].colors[1]); mode_colors[5] = RGBGetBValue(modes[active_mode].colors[1]);
} }
} }
if (modes[active_mode].name == "Direct") if (modes[active_mode].name == "Direct")
{ {
corsair->SetDirect(true); controller->SetDirect(true);
} }
else else
{ {
corsair->SetDirect(false); controller->SetDirect(false);
} }
corsair->SetEffect(modes[active_mode].value, controller->SetEffect(modes[active_mode].value,
modes[active_mode].speed, modes[active_mode].speed,
corsair_direction, corsair_direction,
random, random,
mode_colors[0], mode_colors[0],
mode_colors[1], mode_colors[1],
mode_colors[2], mode_colors[2],
mode_colors[3], mode_colors[3],
mode_colors[4], mode_colors[4],
mode_colors[5]); mode_colors[5]);
std::this_thread::sleep_for(std::chrono::milliseconds(15)); std::this_thread::sleep_for(std::chrono::milliseconds(15));
} }

View file

@ -1,34 +1,34 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairVengeancePro.h | | RGBController_CorsairVengeancePro.h |
| | | |
| Generic RGB Interface for OpenAuraSDK | | Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance Pro RGB driver | | Corsair Vengeance Pro RGB driver |
| | | |
| Adam Honse (CalcProgrammer1) 6/30/2019 | | Adam Honse (CalcProgrammer1) 6/30/2019 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairVengeanceProController.h" #include "CorsairVengeanceProController.h"
class RGBController_CorsairVengeancePro : public RGBController class RGBController_CorsairVengeancePro : public RGBController
{ {
public: public:
RGBController_CorsairVengeancePro(CorsairVengeanceProController* corsair_ptr); RGBController_CorsairVengeancePro(CorsairVengeanceProController* controller_ptr);
~RGBController_CorsairVengeancePro(); ~RGBController_CorsairVengeancePro();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CorsairVengeanceProController* corsair; CorsairVengeanceProController* controller;
}; };

View file

@ -1,50 +1,51 @@
#include "Detector.h" #include "Detector.h"
#include "CorsairWirelessController.h" #include "CorsairWirelessController.h"
#include "RGBController.h" #include "RGBController.h"
#include "RGBController_CorsairWireless.h" #include "RGBController_CorsairWireless.h"
#include <hidapi/hidapi.h> #include <hidapi/hidapi.h>
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Corsair vendor ID | | Corsair vendor ID |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CORSAIR_VID 0x1B1C #define CORSAIR_VID 0x1B1C
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Keyboard product IDs | | Keyboard product IDs |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CORSAIR_K57_RGB_WIRED_PID 0x1B6E #define CORSAIR_K57_RGB_WIRED_PID 0x1B6E
#define CORSAIR_K57_RGB_WIRELESS_PID 0x1B62 #define CORSAIR_K57_RGB_WIRELESS_PID 0x1B62
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectCorsairWirelessControllers * * DetectCorsairWirelessControllers *
* * * *
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. * * Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectCorsairWirelessControllers(hid_device_info* info, const std::string& name) void DetectCorsairWirelessControllers(hid_device_info* info, const std::string& name)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev )
{ if(dev)
CorsairWirelessController* controller = new CorsairWirelessController(dev, info->path); {
controller->SetName(name); CorsairWirelessController* controller = new CorsairWirelessController(dev, info->path);
controller->SetName(name);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{ if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
RGBController_CorsairWireless* rgb_controller = new RGBController_CorsairWireless(controller); {
ResourceManager::get()->RegisterRGBController(rgb_controller); RGBController_CorsairWireless* rgb_controller = new RGBController_CorsairWireless(controller);
} ResourceManager::get()->RegisterRGBController(rgb_controller);
else }
{ else
delete controller; {
} delete controller;
} }
} /* DetectCorsairWirelessControllers() */ }
} /* DetectCorsairWirelessControllers() */
/*-----------------------------------------------------------------------------------------------------*\
| Keyboards | /*-----------------------------------------------------------------------------------------------------*\
\*-----------------------------------------------------------------------------------------------------*/ | Keyboards |
REGISTER_HID_DETECTOR_IPU("Corsair K57 RGB (Wired)", DetectCorsairWirelessControllers, CORSAIR_VID, CORSAIR_K57_RGB_WIRED_PID, 1, 0xFF42, 1); \*-----------------------------------------------------------------------------------------------------*/
//REGISTER_HID_DETECTOR_IPU("Corsair K57 RGB (Wireless)", DetectCorsairWirelessControllers, CORSAIR_VID, CORSAIR_K57_RGB_WIRELESS_PID, 1, 0xFF42, 1); REGISTER_HID_DETECTOR_IPU("Corsair K57 RGB (Wired)", DetectCorsairWirelessControllers, CORSAIR_VID, CORSAIR_K57_RGB_WIRED_PID, 1, 0xFF42, 1);
//REGISTER_HID_DETECTOR_IPU("Corsair K57 RGB (Wireless)", DetectCorsairWirelessControllers, CORSAIR_VID, CORSAIR_K57_RGB_WIRELESS_PID, 1, 0xFF42, 1);

View file

@ -179,17 +179,17 @@ static const char* led_names[] =
"Key: G6", "Key: G6",
}; };
RGBController_CorsairWireless::RGBController_CorsairWireless(CorsairWirelessController* corsair_ptr) RGBController_CorsairWireless::RGBController_CorsairWireless(CorsairWirelessController* controller_ptr)
{ {
corsair = corsair_ptr; controller = controller_ptr;
name = corsair->GetName(); name = controller->GetName();
vendor = "Corsair"; vendor = "Corsair";
description = "Corsair RGB Peripheral Device"; description = "Corsair RGB Peripheral Device";
type = corsair->GetDeviceType(); type = controller->GetDeviceType();
version = corsair->GetFirmwareString(); version = controller->GetFirmwareString();
location = corsair->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = corsair->GetSerialString(); serial = controller->GetSerialString();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
@ -218,6 +218,7 @@ RGBController_CorsairWireless::~RGBController_CorsairWireless()
keepalive_thread_run = false; keepalive_thread_run = false;
keepalive_thread->join(); keepalive_thread->join();
delete keepalive_thread; delete keepalive_thread;
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Delete the matrix map | | Delete the matrix map |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
@ -229,7 +230,7 @@ RGBController_CorsairWireless::~RGBController_CorsairWireless()
} }
} }
delete corsair; delete controller;
} }
void RGBController_CorsairWireless::SetupZones() void RGBController_CorsairWireless::SetupZones()
@ -274,7 +275,7 @@ void RGBController_CorsairWireless::SetupZones()
{ {
led new_led; led new_led;
new_led.name = led_names[led_idx]; new_led.name = led_names[led_idx];
leds.push_back(new_led); leds.push_back(new_led);
} }
@ -293,17 +294,17 @@ void RGBController_CorsairWireless::DeviceUpdateLEDs()
{ {
last_update_time = std::chrono::steady_clock::now(); last_update_time = std::chrono::steady_clock::now();
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairWireless::UpdateZoneLEDs(int /*zone*/) void RGBController_CorsairWireless::UpdateZoneLEDs(int /*zone*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairWireless::UpdateSingleLED(int /*led*/) void RGBController_CorsairWireless::UpdateSingleLED(int /*led*/)
{ {
corsair->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_CorsairWireless::SetCustomMode() void RGBController_CorsairWireless::SetCustomMode()

View file

@ -1,41 +1,41 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_CorsairWireless.h | | RGBController_CorsairWireless.h |
| | | |
| Generic RGB Interface for Corsair RGB | | Generic RGB Interface for Corsair RGB |
| wireless keyboard devices | | wireless keyboard devices |
| | | |
| Adam Honse (CalcProgrammer1) 5/8/2021 | | Adam Honse (CalcProgrammer1) 5/8/2021 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CorsairWirelessController.h" #include "CorsairWirelessController.h"
class RGBController_CorsairWireless : public RGBController class RGBController_CorsairWireless : public RGBController
{ {
public: public:
RGBController_CorsairWireless(CorsairWirelessController* corsair_ptr); RGBController_CorsairWireless(CorsairWirelessController* controller_ptr);
~RGBController_CorsairWireless(); ~RGBController_CorsairWireless();
int physical_layout; int physical_layout;
int logical_layout; int logical_layout;
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
void KeepaliveThread(); void KeepaliveThread();
private: private:
CorsairWirelessController* corsair; CorsairWirelessController* controller;
std::thread* keepalive_thread; std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run; std::atomic<bool> keepalive_thread_run;
std::chrono::time_point<std::chrono::steady_clock> last_update_time; std::chrono::time_point<std::chrono::steady_clock> last_update_time;
}; };

View file

@ -1,30 +1,31 @@
#include "CreativeSoundBlasterXG6Controller.h" #include "CreativeSoundBlasterXG6Controller.h"
#include "RGBController_CreativeSoundBlasterXG6.h" #include "RGBController_CreativeSoundBlasterXG6.h"
#include "Detector.h" #include "Detector.h"
#include <hidapi/hidapi.h> #include <hidapi/hidapi.h>
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Creative vendor ID | | Creative vendor ID |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CREATIVE_VID 0x041E #define CREATIVE_VID 0x041E
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| SoundCards | | SoundCards |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
#define CREATIVE_SOUNDBLASTERX_G6_PID 0x3256 #define CREATIVE_SOUNDBLASTERX_G6_PID 0x3256
void DetectCreativeDevice(hid_device_info* info, const std::string& name) void DetectCreativeDevice(hid_device_info* info, const std::string& name)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if(dev)
{ if(dev)
CreativeSoundBlasterXG6Controller* controller = new CreativeSoundBlasterXG6Controller(dev, info->path); {
RGBController_CreativeSoundBlasterXG6* rgb_controller = new RGBController_CreativeSoundBlasterXG6(controller); CreativeSoundBlasterXG6Controller* controller = new CreativeSoundBlasterXG6Controller(dev, info->path);
rgb_controller->name = name; RGBController_CreativeSoundBlasterXG6* rgb_controller = new RGBController_CreativeSoundBlasterXG6(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller); rgb_controller->name = name;
} ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
}
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Sound Cards | /*-------------------------------------------------------------------------------------------------------------------------------------------------*\
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/ | Sound Cards |
REGISTER_HID_DETECTOR_I("Creative SoundBlasterX G6", DetectCreativeDevice, CREATIVE_VID, CREATIVE_SOUNDBLASTERX_G6_PID, 4); \*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_I("Creative SoundBlasterX G6", DetectCreativeDevice, CREATIVE_VID, CREATIVE_SOUNDBLASTERX_G6_PID, 4);

View file

@ -1,81 +1,81 @@
#include "RGBController_CreativeSoundBlasterXG6.h" #include "RGBController_CreativeSoundBlasterXG6.h"
RGBController_CreativeSoundBlasterXG6::RGBController_CreativeSoundBlasterXG6(CreativeSoundBlasterXG6Controller* creative_device) RGBController_CreativeSoundBlasterXG6::RGBController_CreativeSoundBlasterXG6(CreativeSoundBlasterXG6Controller* controller_ptr)
{ {
creative = creative_device; controller = controller_ptr;
name = "Creative SoundBlasterX G6 Device"; name = "Creative SoundBlasterX G6 Device";
vendor = "Creative"; vendor = "Creative";
type = DEVICE_TYPE_HEADSET; type = DEVICE_TYPE_HEADSET;
description = "Creative SoundBlasterX G6 Device"; description = "Creative SoundBlasterX G6 Device";
location = creative_device->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = ""; serial = "";
mode Static; mode Static;
Static.name = "Direct"; Static.name = "Direct";
Static.value = 0; Static.value = 0;
Static.flags = MODE_COLORS_PER_LED; Static.flags = MODE_COLORS_PER_LED;
Static.color_mode = MODE_COLORS_PER_LED; Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static); modes.push_back(Static);
SetupZones(); SetupZones();
} }
RGBController_CreativeSoundBlasterXG6::~RGBController_CreativeSoundBlasterXG6() RGBController_CreativeSoundBlasterXG6::~RGBController_CreativeSoundBlasterXG6()
{ {
delete creative; delete controller;
} }
void RGBController_CreativeSoundBlasterXG6::SetupZones() void RGBController_CreativeSoundBlasterXG6::SetupZones()
{ {
zone logo_zone; zone logo_zone;
logo_zone.name = "Logo"; logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE; logo_zone.type = ZONE_TYPE_SINGLE;
logo_zone.leds_min = 1; logo_zone.leds_min = 1;
logo_zone.leds_max = 1; logo_zone.leds_max = 1;
logo_zone.leds_count = 1; logo_zone.leds_count = 1;
logo_zone.matrix_map = NULL; logo_zone.matrix_map = NULL;
zones.push_back(logo_zone); zones.push_back(logo_zone);
led logo_led; led logo_led;
logo_led.name = "Logo"; logo_led.name = "Logo";
leds.push_back(logo_led); leds.push_back(logo_led);
SetupColors(); SetupColors();
} }
void RGBController_CreativeSoundBlasterXG6::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_CreativeSoundBlasterXG6::ResizeZone(int /*zone*/, int /*new_size*/)
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| This device does not support resizing zones | | This device does not support resizing zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
} }
void RGBController_CreativeSoundBlasterXG6::DeviceUpdateLEDs() void RGBController_CreativeSoundBlasterXG6::DeviceUpdateLEDs()
{ {
unsigned char red = RGBGetRValue(colors[0]); unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]); unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]); unsigned char blu = RGBGetBValue(colors[0]);
creative->SetLedColor(red, grn, blu); controller->SetLedColor(red, grn, blu);
} }
void RGBController_CreativeSoundBlasterXG6::UpdateZoneLEDs(int /*zone*/) void RGBController_CreativeSoundBlasterXG6::UpdateZoneLEDs(int /*zone*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CreativeSoundBlasterXG6::UpdateSingleLED(int /*led*/) void RGBController_CreativeSoundBlasterXG6::UpdateSingleLED(int /*led*/)
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void RGBController_CreativeSoundBlasterXG6::SetCustomMode() void RGBController_CreativeSoundBlasterXG6::SetCustomMode()
{ {
active_mode = 0; active_mode = 0;
} }
void RGBController_CreativeSoundBlasterXG6::DeviceUpdateMode() void RGBController_CreativeSoundBlasterXG6::DeviceUpdateMode()
{ {
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }

View file

@ -1,24 +1,24 @@
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CreativeSoundBlasterXG6Controller.h" #include "CreativeSoundBlasterXG6Controller.h"
class RGBController_CreativeSoundBlasterXG6: public RGBController class RGBController_CreativeSoundBlasterXG6: public RGBController
{ {
public: public:
RGBController_CreativeSoundBlasterXG6(CreativeSoundBlasterXG6Controller* creative_device); RGBController_CreativeSoundBlasterXG6(CreativeSoundBlasterXG6Controller* controller_ptr);
~RGBController_CreativeSoundBlasterXG6(); ~RGBController_CreativeSoundBlasterXG6();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CreativeSoundBlasterXG6Controller* creative; CreativeSoundBlasterXG6Controller* controller;
}; };

View file

@ -161,9 +161,6 @@ void CrucialRegisterWrite(i2c_smbus_interface* bus, unsigned char dev, unsigned
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses) void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses)
{ {
CrucialController* new_crucial;
RGBController_Crucial* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++) for (unsigned int bus = 0; bus < busses.size(); bus++)
{ {
int address_list_idx = -1; int address_list_idx = -1;
@ -214,9 +211,10 @@ void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses)
{ {
if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx])) if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx]))
{ {
new_crucial = new CrucialController(busses[bus], crucial_addresses[address_list_idx]); CrucialController* controller = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
new_controller = new RGBController_Crucial(new_crucial); RGBController_Crucial* rgb_controller = new RGBController_Crucial(controller);
ResourceManager::get()->RegisterRGBController(new_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(1ms);

View file

@ -9,16 +9,16 @@
#include "RGBController_Crucial.h" #include "RGBController_Crucial.h"
RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr) RGBController_Crucial::RGBController_Crucial(CrucialController* controller_ptr)
{ {
crucial = crucial_ptr; controller = controller_ptr;
name = "Crucial DRAM"; name = "Crucial DRAM";
vendor = "Crucial"; vendor = "Crucial";
type = DEVICE_TYPE_DRAM; type = DEVICE_TYPE_DRAM;
description = "Crucial DRAM Device"; description = "Crucial DRAM Device";
version = crucial->GetDeviceVersion(); version = controller->GetDeviceVersion();
location = crucial->GetDeviceLocation(); location = controller->GetDeviceLocation();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
@ -116,7 +116,7 @@ RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
RGBController_Crucial::~RGBController_Crucial() RGBController_Crucial::~RGBController_Crucial()
{ {
delete crucial; delete controller;
} }
void RGBController_Crucial::SetupZones() void RGBController_Crucial::SetupZones()
@ -139,7 +139,7 @@ void RGBController_Crucial::SetupZones()
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++) for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{ {
led new_led; led new_led;
new_led.name = "DRAM LED "; new_led.name = "DRAM LED ";
new_led.name.append(std::to_string(led_idx)); new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led); leds.push_back(new_led);
} }
@ -158,15 +158,15 @@ void RGBController_Crucial::DeviceUpdateLEDs()
{ {
if(modes[active_mode].value == 0xFFFF) if(modes[active_mode].value == 0xFFFF)
{ {
crucial->SetAllColorsDirect(&colors[0]); controller->SetAllColorsDirect(&colors[0]);
} }
else else
{ {
crucial->SetAllColorsEffect(&colors[0]); controller->SetAllColorsEffect(&colors[0]);
if(modes[active_mode].value == CRUCIAL_MODE_STATIC) if(modes[active_mode].value == CRUCIAL_MODE_STATIC)
{ {
crucial->SetMode(modes[active_mode].value); controller->SetMode(modes[active_mode].value);
} }
} }
} }
@ -190,14 +190,14 @@ void RGBController_Crucial::DeviceUpdateMode()
{ {
if(modes[active_mode].value == 0xFFFF) if(modes[active_mode].value == 0xFFFF)
{ {
crucial->SetMode(CRUCIAL_MODE_STATIC); controller->SetMode(CRUCIAL_MODE_STATIC);
return; return;
} }
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED) if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{ {
crucial->SetAllColorsEffect(&colors[0]); controller->SetAllColorsEffect(&colors[0]);
} }
crucial->SetMode(modes[active_mode].value); controller->SetMode(modes[active_mode].value);
} }

View file

@ -1,34 +1,34 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_Crucial.h | | RGBController_Crucial.h |
| | | |
| Generic RGB Interface for Crucial | | Generic RGB Interface for Crucial |
| Ballistix RGB controller | | Ballistix RGB controller |
| | | |
| Adam Honse (CalcProgrammer1) 1/19/2020 | | Adam Honse (CalcProgrammer1) 1/19/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "CrucialController.h" #include "CrucialController.h"
class RGBController_Crucial : public RGBController class RGBController_Crucial : public RGBController
{ {
public: public:
RGBController_Crucial(CrucialController* crucial_ptr); RGBController_Crucial(CrucialController* controller_ptr);
~RGBController_Crucial(); ~RGBController_Crucial();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
CrucialController* crucial; CrucialController* controller;
}; };

View file

@ -1,346 +1,346 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_DasKeyboard.cpp | | RGBController_DasKeyboard.cpp |
| | | |
| Generic RGB Interface for Das Keyboard | | Generic RGB Interface for Das Keyboard |
| RGB keyboard devices | | RGB keyboard devices |
| | | |
| Frank Niessen (denk_mal) 12/16/2020 | | Frank Niessen (denk_mal) 12/16/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_DasKeyboard.h" #include "RGBController_DasKeyboard.h"
using namespace std::chrono_literals; using namespace std::chrono_literals;
//0xFFFFFFFF indicates an unused entry in matrix //0xFFFFFFFF indicates an unused entry in matrix
#define NA 0xFFFFFFFF #define NA 0xFFFFFFFF
// US Layout TODO: mus be checked/corrected // US Layout TODO: mus be checked/corrected
static unsigned int matrix_map_us[7][21] = static unsigned int matrix_map_us[7][21] =
{ {
{NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 126, NA, NA, NA}, {NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 126, NA, NA, NA},
{ 5, NA, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 127, 128, 129, 130}, { 5, NA, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 127, 128, 129, 130},
{ 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, 106, 112, 118, 124}, { 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, 106, 112, 118, 124},
{ 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 7, 87, 93, 99, 105, 111, 117, 123}, { 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 7, 87, 93, 99, 105, 111, 117, 123},
{ 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, NA, 80, NA, NA, NA, 104, 110, 116, NA}, { 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, NA, 80, NA, NA, NA, 104, 110, 116, NA},
{ 1, NA, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 79, NA, NA, 91, NA, 103, 109, 115, 122}, { 1, NA, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 79, NA, NA, 91, NA, 103, 109, 115, 122},
{ 0, 6, 12, NA, NA, NA, 36, NA, NA, NA, 60, 66, 72, 78, 84, 90, 96, 102, NA, 114, NA} { 0, 6, 12, NA, NA, NA, 36, NA, NA, NA, 60, 66, 72, 78, 84, 90, 96, 102, NA, 114, NA}
}; };
// EU Layout // EU Layout
static unsigned int matrix_map_eu[7][21] = static unsigned int matrix_map_eu[7][21] =
{ {
{NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 126, NA, NA, NA}, {NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 126, NA, NA, NA},
{ 5, NA, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 127, 128, 129, 130}, { 5, NA, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 127, 128, 129, 130},
{ 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, 106, 112, 118, 124}, { 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, 106, 112, 118, 124},
{ 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, NA, 87, 93, 99, 105, 111, 117, 123}, { 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, NA, 87, 93, 99, 105, 111, 117, 123},
{ 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 81, 80, NA, NA, NA, 104, 110, 116, NA}, { 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 81, 80, NA, NA, NA, 104, 110, 116, NA},
{ 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 79, NA, NA, 91, NA, 103, 109, 115, 122}, { 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 79, NA, NA, 91, NA, 103, 109, 115, 122},
{ 0, 6, 12, NA, NA, NA, 36, NA, NA, NA, 60, 66, 72, 78, 84, 90, 96, 102, NA, 114, NA} { 0, 6, 12, NA, NA, NA, 36, NA, NA, NA, 60, 66, 72, 78, 84, 90, 96, 102, NA, 114, NA}
}; };
static const char *zone_names[] = static const char *zone_names[] =
{ {
"Keyboard" "Keyboard"
}; };
static zone_type zone_types[] = static zone_type zone_types[] =
{ {
ZONE_TYPE_MATRIX, ZONE_TYPE_MATRIX,
}; };
static const unsigned int zone_sizes[] = static const unsigned int zone_sizes[] =
{ {
131 131
}; };
// UK Layout // UK Layout
static const char *led_names[] = static const char *led_names[] =
{ {
"Key: Left Control", "Key: Left Control",
"Key: Left Shift", "Key: Left Shift",
"Key: Caps Lock", "Key: Caps Lock",
"Key: Tab", "Key: Tab",
"Key: `", "Key: `",
"Key: Escape", "Key: Escape",
"Key: Left Windows", "Key: Left Windows",
"Key: \\ (ANSI)", "Key: \\ (ANSI)",
"Key: A", "Key: A",
"Key: Q", "Key: Q",
"Key: 1", "Key: 1",
"Undefined", "Undefined",
"Key: Left Alt", "Key: Left Alt",
"Key: Z", "Key: Z",
"Key: S", "Key: S",
"Key: W", "Key: W",
"Key: 2", "Key: 2",
"Key: F1", "Key: F1",
"Undefined", "Undefined",
"Key: X", "Key: X",
"Key: D", "Key: D",
"Key: E", "Key: E",
"Key: 3", "Key: 3",
"Key: F2", "Key: F2",
"Undefined", "Undefined",
"Key: C", "Key: C",
"Key: F", "Key: F",
"Key: R", "Key: R",
"Key: 4", "Key: 4",
"Key: F3", "Key: F3",
"Undefined", "Undefined",
"Key: V", "Key: V",
"Key: G", "Key: G",
"Key: T", "Key: T",
"Key: 5", "Key: 5",
"Key: F4", "Key: F4",
"Key: Space", "Key: Space",
"Key: B", "Key: B",
"Key: H", "Key: H",
"Key: Y", "Key: Y",
"Key: 6", "Key: 6",
"Key: F5", "Key: F5",
"Undefined", "Undefined",
"Key: N", "Key: N",
"Key: J", "Key: J",
"Key: U", "Key: U",
"Key: 7", "Key: 7",
"Key: F6", "Key: F6",
"Undefined", "Undefined",
"Key: M", "Key: M",
"Key: K", "Key: K",
"Key: I", "Key: I",
"Key: 8", "Key: 8",
"Key: F7", "Key: F7",
"Undefined", "Undefined",
"Key: ,", "Key: ,",
"Key: L", "Key: L",
"Key: O", "Key: O",
"Key: 9", "Key: 9",
"Key: F8", "Key: F8",
"Key: Right Alt", "Key: Right Alt",
"Key: .", "Key: .",
"Key: ;", "Key: ;",
"Key: P", "Key: P",
"Key: 0", "Key: 0",
"Key: F9", "Key: F9",
"Key: Right Windows", "Key: Right Windows",
"Key: /", "Key: /",
"Key: '", "Key: '",
"Key: [", "Key: [",
"Key: -", "Key: -",
"Key: F10", "Key: F10",
"Key: Menu", "Key: Menu",
"Undefined", "Undefined",
"Undefined", "Undefined",
"Key: ]", "Key: ]",
"Key: =", "Key: =",
"Key: F11", "Key: F11",
"Key: Right Control", "Key: Right Control",
"Key: Right Shift", "Key: Right Shift",
"Key: Enter", "Key: Enter",
"Key: #", "Key: #",
"Key: Backspace", "Key: Backspace",
"Key: F12", "Key: F12",
"Key: Left Arrow", "Key: Left Arrow",
"Undefined", "Undefined",
"Undefined", "Undefined",
"Key: Delete", "Key: Delete",
"Key: Insert", "Key: Insert",
"Key: Print Screen", "Key: Print Screen",
"Key: Down Arrow", "Key: Down Arrow",
"Key: Up Arrow", "Key: Up Arrow",
"Undefined", "Undefined",
"Key: End", "Key: End",
"Key: Home", "Key: Home",
"Key: Scroll Lock", "Key: Scroll Lock",
"Key: Right Arrow", "Key: Right Arrow",
"Undefined", "Undefined",
"Undefined", "Undefined",
"Key: Page Down", "Key: Page Down",
"Key: Page Up", "Key: Page Up",
"Key: Pause/Break", "Key: Pause/Break",
"Key: Number Pad 0", "Key: Number Pad 0",
"Key: Number Pad 1", "Key: Number Pad 1",
"Key: Number Pad 4", "Key: Number Pad 4",
"Key: Number Pad 7", "Key: Number Pad 7",
"Key: Num Lock", "Key: Num Lock",
"Undefined", "Undefined",
"Undefined", "Undefined",
"Key: Number Pad 2", "Key: Number Pad 2",
"Key: Number Pad 5", "Key: Number Pad 5",
"Key: Number Pad 8", "Key: Number Pad 8",
"Key: Number Pad /", "Key: Number Pad /",
"Undefined", "Undefined",
"Key: Number Pad .", "Key: Number Pad .",
"Key: Number Pad 3", "Key: Number Pad 3",
"Key: Number Pad 6", "Key: Number Pad 6",
"Key: Number Pad 9", "Key: Number Pad 9",
"Key: Number Pad *", "Key: Number Pad *",
"Undefined", "Undefined",
"Undefined", "Undefined",
"Undefined", "Undefined",
"Key: Number Pad Enter", "Key: Number Pad Enter",
"Key: Number Pad +", "Key: Number Pad +",
"Key: Number Pad -", "Key: Number Pad -",
"Undefined", "Undefined",
"Key: Sleep", "Key: Sleep",
"Key: Brightness", "Key: Brightness",
"Key: Media Play/Pause", "Key: Media Play/Pause",
"Key: Media Next", "Key: Media Next",
"Key: Q-Button" "Key: Q-Button"
}; };
RGBController_DasKeyboard::RGBController_DasKeyboard(DasKeyboardController *das_ptr) RGBController_DasKeyboard::RGBController_DasKeyboard(DasKeyboardController* controller_ptr)
{ {
das = das_ptr; controller = controller_ptr;
for(unsigned int ii = 0; ii < zone_sizes[0]; ii++) for(unsigned int ii = 0; ii < zone_sizes[0]; ii++)
{ {
double_buffer.push_back(-1); double_buffer.push_back(-1);
} }
updateDevice = true; updateDevice = true;
name = "Das Keyboard Device"; name = "Das Keyboard Device";
vendor = "Metadot"; vendor = "Metadot";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "Das Keyboard Device"; description = "Das Keyboard Device";
location = das->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = das->GetSerialString(); serial = controller->GetSerialString();
version = das->GetVersionString(); version = controller->GetVersionString();
modes.resize(4); modes.resize(4);
modes[0].name = "Direct"; modes[0].name = "Direct";
modes[0].value = DAS_KEYBOARD_MODE_DIRECT; modes[0].value = DAS_KEYBOARD_MODE_DIRECT;
modes[0].flags = MODE_FLAG_HAS_PER_LED_COLOR; modes[0].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[0].color_mode = MODE_COLORS_PER_LED; modes[0].color_mode = MODE_COLORS_PER_LED;
modes[1].name = "Flashing"; modes[1].name = "Flashing";
modes[1].value = DAS_KEYBOARD_MODE_FLASHING; modes[1].value = DAS_KEYBOARD_MODE_FLASHING;
modes[1].flags = MODE_FLAG_HAS_PER_LED_COLOR; modes[1].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[1].color_mode = MODE_COLORS_PER_LED; modes[1].color_mode = MODE_COLORS_PER_LED;
modes[2].name = "Breathing"; modes[2].name = "Breathing";
modes[2].value = DAS_KEYBOARD_MODE_BREATHING; modes[2].value = DAS_KEYBOARD_MODE_BREATHING;
modes[2].flags = MODE_FLAG_HAS_PER_LED_COLOR; modes[2].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[2].color_mode = MODE_COLORS_PER_LED; modes[2].color_mode = MODE_COLORS_PER_LED;
modes[3].name = "Spectrum Cycle"; modes[3].name = "Spectrum Cycle";
modes[3].value = DAS_KEYBOARD_MODE_SPECTRUM_CYCLE; modes[3].value = DAS_KEYBOARD_MODE_SPECTRUM_CYCLE;
modes[3].flags = MODE_FLAG_HAS_PER_LED_COLOR; modes[3].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[3].color_mode = MODE_COLORS_PER_LED; modes[3].color_mode = MODE_COLORS_PER_LED;
} }
RGBController_DasKeyboard::~RGBController_DasKeyboard() RGBController_DasKeyboard::~RGBController_DasKeyboard()
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Delete the matrix map | | Delete the matrix map |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
unsigned int zone_size = zones.size(); unsigned int zone_size = zones.size();
for(unsigned int zone_index = 0; zone_index < zone_size; zone_index++) for(unsigned int zone_index = 0; zone_index < zone_size; zone_index++)
{ {
delete zones[zone_index].matrix_map; delete zones[zone_index].matrix_map;
} }
delete das; delete controller;
} }
void RGBController_DasKeyboard::SetupZones() void RGBController_DasKeyboard::SetupZones()
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Set up zones | | Set up zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
unsigned int total_led_count = 0; unsigned int total_led_count = 0;
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++) for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
{ {
zone new_zone; zone new_zone;
new_zone.name = zone_names[zone_idx]; new_zone.name = zone_names[zone_idx];
new_zone.type = zone_types[zone_idx]; new_zone.type = zone_types[zone_idx];
new_zone.leds_min = zone_sizes[zone_idx]; new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx]; new_zone.leds_max = zone_sizes[zone_idx];
new_zone.leds_count = zone_sizes[zone_idx]; new_zone.leds_count = zone_sizes[zone_idx];
new_zone.matrix_map = new matrix_map_type; new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 7; new_zone.matrix_map->height = 7;
new_zone.matrix_map->width = 21; new_zone.matrix_map->width = 21;
if(das->GetLayoutString() == "US") if(controller->GetLayoutString() == "US")
{ {
new_zone.matrix_map->map = (unsigned int *) &matrix_map_us; new_zone.matrix_map->map = (unsigned int *) &matrix_map_us;
} }
else else
{ {
new_zone.matrix_map->map = (unsigned int *) &matrix_map_eu; new_zone.matrix_map->map = (unsigned int *) &matrix_map_eu;
} }
zones.push_back(new_zone); zones.push_back(new_zone);
total_led_count += zone_sizes[zone_idx]; total_led_count += zone_sizes[zone_idx];
} }
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++) for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{ {
led new_led; led new_led;
new_led.name = led_names[led_idx]; new_led.name = led_names[led_idx];
leds.push_back(new_led); leds.push_back(new_led);
} }
SetupColors(); SetupColors();
} }
void RGBController_DasKeyboard::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_DasKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| This device does not support resizing zones | | This device does not support resizing zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
} }
void RGBController_DasKeyboard::DeviceUpdateLEDs() void RGBController_DasKeyboard::DeviceUpdateLEDs()
{ {
UpdateZoneLEDs(0); UpdateZoneLEDs(0);
} }
void RGBController_DasKeyboard::UpdateZoneLEDs(int /*zone*/) void RGBController_DasKeyboard::UpdateZoneLEDs(int /*zone*/)
{ {
updateDevice = false; updateDevice = false;
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++) for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
{ {
UpdateSingleLED(static_cast<int>(led_idx)); UpdateSingleLED(static_cast<int>(led_idx));
} }
updateDevice = true; updateDevice = true;
das->SendApply(); controller->SendApply();
} }
void RGBController_DasKeyboard::UpdateSingleLED(int led) void RGBController_DasKeyboard::UpdateSingleLED(int led)
{ {
mode selected_mode = modes[active_mode]; mode selected_mode = modes[active_mode];
if(double_buffer[led] == colors[led]) if(double_buffer[led] == colors[led])
{ {
return; return;
} }
das->SendColors(led, selected_mode.value, controller->SendColors(led, selected_mode.value,
RGBGetRValue(colors[led]), RGBGetRValue(colors[led]),
RGBGetGValue(colors[led]), RGBGetGValue(colors[led]),
RGBGetBValue(colors[led])); RGBGetBValue(colors[led]));
double_buffer[led] = colors[led]; double_buffer[led] = colors[led];
if(updateDevice) if(updateDevice)
{ {
das->SendApply(); controller->SendApply();
} }
} }
void RGBController_DasKeyboard::SetCustomMode() void RGBController_DasKeyboard::SetCustomMode()
{ {
active_mode = 0; active_mode = 0;
} }
void RGBController_DasKeyboard::DeviceUpdateMode() void RGBController_DasKeyboard::DeviceUpdateMode()
{ {
} }

View file

@ -1,50 +1,49 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_DasKeyboard.h | | RGBController_DasKeyboard.h |
| | | |
| Generic RGB Interface for Das Keyboard | | Generic RGB Interface for Das Keyboard |
| RGB keyboard devices | | RGB keyboard devices |
| | | |
| Frank Niessen (denk_mal) 12/16/2020 | | Frank Niessen (denk_mal) 12/16/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "DasKeyboardController.h" #include "DasKeyboardController.h"
enum enum
{ {
DAS_KEYBOARD_MODE_DIRECT = 0x01, DAS_KEYBOARD_MODE_DIRECT = 0x01,
DAS_KEYBOARD_MODE_FLASHING = 0x1F, DAS_KEYBOARD_MODE_FLASHING = 0x1F,
DAS_KEYBOARD_MODE_BREATHING = 0x08, DAS_KEYBOARD_MODE_BREATHING = 0x08,
DAS_KEYBOARD_MODE_SPECTRUM_CYCLE = 0x14 DAS_KEYBOARD_MODE_SPECTRUM_CYCLE = 0x14
}; };
class RGBController_DasKeyboard : public RGBController class RGBController_DasKeyboard : public RGBController
{ {
public: public:
RGBController_DasKeyboard(DasKeyboardController *das_ptr); RGBController_DasKeyboard(DasKeyboardController* controller_ptr);
~RGBController_DasKeyboard();
~RGBController_DasKeyboard();
void SetupZones();
void SetupZones();
void ResizeZone(int zone, int new_size);
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void UpdateSingleLED(int led);
void SetCustomMode();
void SetCustomMode();
void DeviceUpdateMode();
void DeviceUpdateMode();
private:
private: DasKeyboardController* controller;
DasKeyboardController *das;
std::vector<RGBColor> double_buffer;
std::vector<RGBColor> double_buffer; bool updateDevice;
bool updateDevice; };
};

View file

@ -15,9 +15,10 @@
void DetectDuckyKeyboardControllers(hid_device_info* info, const std::string& name) void DetectDuckyKeyboardControllers(hid_device_info* info, const std::string& name)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev )
if(dev)
{ {
DuckyKeyboardController* controller = new DuckyKeyboardController(dev, info->path, info->product_id); DuckyKeyboardController* controller = new DuckyKeyboardController(dev, info->path, info->product_id);
RGBController_DuckyKeyboard* rgb_controller = new RGBController_DuckyKeyboard(controller); RGBController_DuckyKeyboard* rgb_controller = new RGBController_DuckyKeyboard(controller);
rgb_controller->name = name; rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);

View file

@ -185,16 +185,16 @@ static const char *led_names[] =
"Key: Number Pad Enter", "Key: Number Pad Enter",
}; };
RGBController_DuckyKeyboard::RGBController_DuckyKeyboard(DuckyKeyboardController* ducky_ptr) RGBController_DuckyKeyboard::RGBController_DuckyKeyboard(DuckyKeyboardController* controller_ptr)
{ {
ducky = ducky_ptr; controller = controller_ptr;
name = "Ducky Keyboard Device"; name = "Ducky Keyboard Device";
vendor = "Ducky"; vendor = "Ducky";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "Ducky Keyboard Device"; description = "Ducky Keyboard Device";
location = ducky->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = ducky->GetSerialString(); serial = controller->GetSerialString();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
@ -219,7 +219,7 @@ RGBController_DuckyKeyboard::~RGBController_DuckyKeyboard()
} }
} }
delete ducky; delete controller;
} }
void RGBController_DuckyKeyboard::SetupZones() void RGBController_DuckyKeyboard::SetupZones()
@ -234,7 +234,7 @@ void RGBController_DuckyKeyboard::SetupZones()
unsigned int matrix_width = 0; unsigned int matrix_width = 0;
unsigned int* matrix_map_ptr = NULL; unsigned int* matrix_map_ptr = NULL;
switch(ducky->GetUSBPID()) switch(controller->GetUSBPID())
{ {
case DUCKY_SHINE_7_ONE_2_RGB_PID: case DUCKY_SHINE_7_ONE_2_RGB_PID:
zone_size = zone_sizes[zone_idx]; zone_size = zone_sizes[zone_idx];
@ -292,7 +292,7 @@ void RGBController_DuckyKeyboard::DeviceUpdateLEDs()
colordata[(color_idx*3)+2] = RGBGetBValue(colors[color_idx]); colordata[(color_idx*3)+2] = RGBGetBValue(colors[color_idx]);
} }
ducky->SendColors(colordata, sizeof(colordata)); controller->SendColors(colordata, sizeof(colordata));
} }
void RGBController_DuckyKeyboard::UpdateZoneLEDs(int /*zone*/) void RGBController_DuckyKeyboard::UpdateZoneLEDs(int /*zone*/)

View file

@ -1,33 +1,33 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_DuckyKeyboard.h | | RGBController_DuckyKeyboard.h |
| | | |
| Generic RGB Interface for Ducky RGB | | Generic RGB Interface for Ducky RGB |
| keyboard devices | | keyboard devices |
| | | |
| Adam Honse (CalcProgrammer1) 7/4/2020 | | Adam Honse (CalcProgrammer1) 7/4/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "DuckyKeyboardController.h" #include "DuckyKeyboardController.h"
class RGBController_DuckyKeyboard : public RGBController class RGBController_DuckyKeyboard : public RGBController
{ {
public: public:
RGBController_DuckyKeyboard(DuckyKeyboardController* ducky_ptr); RGBController_DuckyKeyboard(DuckyKeyboardController* controller_ptr);
~RGBController_DuckyKeyboard(); ~RGBController_DuckyKeyboard();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
DuckyKeyboardController* ducky; DuckyKeyboardController* controller;
}; };

View file

@ -1,31 +1,31 @@
#include "Detector.h" #include "Detector.h"
#include "EKController.h" #include "EKController.h"
#include "RGBController.h" #include "RGBController.h"
#include "RGBController_EKController.h" #include "RGBController_EKController.h"
#include <hidapi/hidapi.h> #include <hidapi/hidapi.h>
#define EK_VID 0x0483 #define EK_VID 0x0483
#define EK_LOOP_CONNECT 0x5750 #define EK_LOOP_CONNECT 0x5750
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectEKControllers * * DetectEKControllers *
* * * *
* Tests the USB address to see if any EK Controllers exists there. * * Tests the USB address to see if any EK Controllers exists there. *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectEKControllers(hid_device_info* info, const std::string&) void DetectEKControllers(hid_device_info* info, const std::string&)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if(dev)
{ if(dev)
EKController* controller = new EKController(dev, info->path); {
RGBController_EKController* rgb_controller = new RGBController_EKController(controller); EKController* controller = new EKController(dev, info->path);
// Constructor sets the name RGBController_EKController* rgb_controller = new RGBController_EKController(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller); // Constructor sets the name
} ResourceManager::get()->RegisterRGBController(rgb_controller);
info = info->next; }
} /* DetectEKControllers() */ } /* DetectEKControllers() */
REGISTER_HID_DETECTOR_IPU("EK Loop Connect", DetectEKControllers, EK_VID, EK_LOOP_CONNECT, 0, 0xFFA0, 1); REGISTER_HID_DETECTOR_IPU("EK Loop Connect", DetectEKControllers, EK_VID, EK_LOOP_CONNECT, 0, 0xFFA0, 1);

View file

@ -1,174 +1,175 @@
/*-------------------------------------------------------------------*\ /*-------------------------------------------------------------------*\
| RGBController_EKController.cpp | | RGBController_EKController.cpp |
| | | |
| Driver for EK Loop Connect | | Driver for EK Loop Connect |
| | | |
| Chris M (Dr_No) 16th Jul 2020 | | Chris M (Dr_No) 16th Jul 2020 |
| | | |
\*-------------------------------------------------------------------*/ \*-------------------------------------------------------------------*/
#include "RGBController_EKController.h" #include "RGBController_EKController.h"
RGBController_EKController::RGBController_EKController(EKController* _dev) RGBController_EKController::RGBController_EKController(EKController* controller_ptr)
{ {
EK_dev = _dev; controller = controller_ptr;
name = EK_dev->GetDeviceName(); name = controller->GetDeviceName();
vendor = "EK"; vendor = "EK";
type = DEVICE_TYPE_LEDSTRIP; type = DEVICE_TYPE_LEDSTRIP;
description = EK_dev->GetDeviceName(); description = controller->GetDeviceName();
version = "1.0"; serial = controller->GetSerial();
serial = EK_dev->GetSerial(); location = controller->GetLocation();
location = EK_dev->GetLocation();
mode Static;
mode Static; Static.name = "Static";
Static.name = "Static"; Static.value = EK_MODE_STATIC;
Static.value = EK_MODE_STATIC; Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; Static.color_mode = MODE_COLORS_PER_LED;
Static.color_mode = MODE_COLORS_PER_LED; modes.push_back(Static);
modes.push_back(Static);
mode Breathing;
mode Breathing; Breathing.name = "Breathing";
Breathing.name = "Breathing"; Breathing.value = EK_MODE_BREATHING;
Breathing.value = EK_MODE_BREATHING; Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; Breathing.speed_min = EK_SPEED_SLOWEST;
Breathing.speed_min = EK_SPEED_SLOWEST; Breathing.speed_max = EK_SPEED_FASTEST;
Breathing.speed_max = EK_SPEED_FASTEST; Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.color_mode = MODE_COLORS_PER_LED; Breathing.speed = EK_SPEED_NORMAL;
Breathing.speed = EK_SPEED_NORMAL; modes.push_back(Breathing);
modes.push_back(Breathing);
mode Fading;
mode Fading; Fading.name = "Fading";
Fading.name = "Fading"; Fading.value = EK_MODE_FADING;
Fading.value = EK_MODE_FADING; Fading.flags = MODE_FLAG_HAS_SPEED;
Fading.flags = MODE_FLAG_HAS_SPEED; Fading.speed_min = EK_SPEED_SLOWEST;
Fading.speed_min = EK_SPEED_SLOWEST; Fading.speed_max = EK_SPEED_FASTEST;
Fading.speed_max = EK_SPEED_FASTEST; Fading.color_mode = MODE_COLORS_NONE;
Fading.color_mode = MODE_COLORS_NONE; Fading.speed = EK_SPEED_NORMAL;
Fading.speed = EK_SPEED_NORMAL; modes.push_back(Fading);
modes.push_back(Fading);
mode Marquee;
mode Marquee; Marquee.name = "Marquee";
Marquee.name = "Marquee"; Marquee.value = EK_MODE_MARQUEE;
Marquee.value = EK_MODE_MARQUEE; Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; Marquee.speed_min = EK_SPEED_SLOWEST;
Marquee.speed_min = EK_SPEED_SLOWEST; Marquee.speed_max = EK_SPEED_FASTEST;
Marquee.speed_max = EK_SPEED_FASTEST; Marquee.color_mode = MODE_COLORS_PER_LED;
Marquee.color_mode = MODE_COLORS_PER_LED; Marquee.speed = EK_SPEED_NORMAL;
Marquee.speed = EK_SPEED_NORMAL; modes.push_back(Marquee);
modes.push_back(Marquee);
mode Covering_Marquee;
mode Covering_Marquee; Covering_Marquee.name = "Covering Marquee";
Covering_Marquee.name = "Covering Marquee"; Covering_Marquee.value = EK_MODE_COVERING_MARQUEE;
Covering_Marquee.value = EK_MODE_COVERING_MARQUEE; Covering_Marquee.flags = MODE_FLAG_HAS_SPEED;
Covering_Marquee.flags = MODE_FLAG_HAS_SPEED; Covering_Marquee.speed_min = EK_SPEED_SLOWEST;
Covering_Marquee.speed_min = EK_SPEED_SLOWEST; Covering_Marquee.speed_max = EK_SPEED_FASTEST;
Covering_Marquee.speed_max = EK_SPEED_FASTEST; Covering_Marquee.color_mode = MODE_COLORS_NONE;
Covering_Marquee.color_mode = MODE_COLORS_NONE; Covering_Marquee.speed = EK_SPEED_NORMAL;
Covering_Marquee.speed = EK_SPEED_NORMAL; modes.push_back(Covering_Marquee);
modes.push_back(Covering_Marquee);
mode Pulse;
mode Pulse; Pulse.name = "Pulse";
Pulse.name = "Pulse"; Pulse.value = EK_MODE_PULSE;
Pulse.value = EK_MODE_PULSE; Pulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Pulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; Pulse.speed_min = EK_SPEED_SLOWEST;
Pulse.speed_min = EK_SPEED_SLOWEST; Pulse.speed_max = EK_SPEED_FASTEST;
Pulse.speed_max = EK_SPEED_FASTEST; Pulse.color_mode = MODE_COLORS_PER_LED;
Pulse.color_mode = MODE_COLORS_PER_LED; Pulse.speed = EK_SPEED_NORMAL;
Pulse.speed = EK_SPEED_NORMAL; modes.push_back(Pulse);
modes.push_back(Pulse);
mode Spectrum_Wave;
mode Spectrum_Wave; Spectrum_Wave.name = "Spectrum_Wave";
Spectrum_Wave.name = "Spectrum_Wave"; Spectrum_Wave.value = EK_MODE_SPECTRUM_WAVE;
Spectrum_Wave.value = EK_MODE_SPECTRUM_WAVE; Spectrum_Wave.flags = MODE_FLAG_HAS_SPEED;
Spectrum_Wave.flags = MODE_FLAG_HAS_SPEED; Spectrum_Wave.speed_min = EK_SPEED_SLOWEST;
Spectrum_Wave.speed_min = EK_SPEED_SLOWEST; Spectrum_Wave.speed_max = EK_SPEED_FASTEST;
Spectrum_Wave.speed_max = EK_SPEED_FASTEST; Spectrum_Wave.color_mode = MODE_COLORS_NONE;
Spectrum_Wave.color_mode = MODE_COLORS_NONE; Spectrum_Wave.speed = EK_SPEED_NORMAL;
Spectrum_Wave.speed = EK_SPEED_NORMAL; modes.push_back(Spectrum_Wave);
modes.push_back(Spectrum_Wave);
mode Alternating;
mode Alternating; Alternating.name = "Alternating";
Alternating.name = "Alternating"; Alternating.value = EK_MODE_ALTERNATING;
Alternating.value = EK_MODE_ALTERNATING; Alternating.flags = MODE_FLAG_HAS_SPEED;
Alternating.flags = MODE_FLAG_HAS_SPEED; Alternating.speed_min = EK_SPEED_SLOWEST;
Alternating.speed_min = EK_SPEED_SLOWEST; Alternating.speed_max = EK_SPEED_FASTEST;
Alternating.speed_max = EK_SPEED_FASTEST; Alternating.color_mode = MODE_COLORS_PER_LED;
Alternating.color_mode = MODE_COLORS_PER_LED; Alternating.speed = EK_SPEED_NORMAL;
Alternating.speed = EK_SPEED_NORMAL; modes.push_back(Alternating);
modes.push_back(Alternating);
mode Candle;
mode Candle; Candle.name = "Candle";
Candle.name = "Candle"; Candle.value = EK_MODE_CANDLE;
Candle.value = EK_MODE_CANDLE; Candle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Candle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR; Candle.speed_min = EK_SPEED_SLOWEST;
Candle.speed_min = EK_SPEED_SLOWEST; Candle.speed_max = EK_SPEED_FASTEST;
Candle.speed_max = EK_SPEED_FASTEST; Candle.color_mode = MODE_COLORS_PER_LED;
Candle.color_mode = MODE_COLORS_PER_LED; Candle.speed = EK_SPEED_NORMAL;
Candle.speed = EK_SPEED_NORMAL; modes.push_back(Candle);
modes.push_back(Candle);
SetupZones();
SetupZones(); }
}
RGBController_EKController::~RGBController_EKController()
RGBController_EKController::~RGBController_EKController() {
{ delete controller;
delete EK_dev; }
}
void RGBController_EKController::SetupZones()
void RGBController_EKController::SetupZones() {
{ zone EK_zone;
zone EK_zone; EK_zone.name = "Loop Connect";
EK_zone.name = "Loop Connect"; EK_zone.type = ZONE_TYPE_SINGLE;
EK_zone.type = ZONE_TYPE_SINGLE; EK_zone.leds_min = 1;
EK_zone.leds_min = 1; EK_zone.leds_max = 1;
EK_zone.leds_max = 1; EK_zone.leds_count = 1;
EK_zone.leds_count = 1; EK_zone.matrix_map = NULL;
EK_zone.matrix_map = NULL; zones.push_back(EK_zone);
zones.push_back(EK_zone);
led EK_led;
led EK_led; EK_led.name = "EK LED";
EK_led.name = "EK LED"; leds.push_back(EK_led);
leds.push_back(EK_led);
SetupColors();
SetupColors(); }
}
void RGBController_EKController::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_EKController::ResizeZone(int /*zone*/, int /*new_size*/) {
{ /*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | ToDo |
| ToDo | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ }
}
void RGBController_EKController::DeviceUpdateLEDs()
void RGBController_EKController::DeviceUpdateLEDs() {
{ unsigned char red = RGBGetRValue(colors[0]);
unsigned char red = RGBGetRValue(colors[0]); unsigned char grn = RGBGetGValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]); unsigned char blu = RGBGetBValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
EK_dev->SetColor(red, grn, blu); controller->SetColor(red, grn, blu);
} }
void RGBController_EKController::UpdateZoneLEDs(int zone) void RGBController_EKController::UpdateZoneLEDs(int zone)
{ {
RGBColor color = colors[zone]; RGBColor color = colors[zone];
unsigned char red = RGBGetRValue(color); unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color); unsigned char blu = RGBGetBValue(color);
EK_dev->SetColor(red, grn, blu);
} controller->SetColor(red, grn, blu);
}
void RGBController_EKController::UpdateSingleLED(int led)
{ void RGBController_EKController::UpdateSingleLED(int led)
UpdateZoneLEDs(led); {
} UpdateZoneLEDs(led);
}
void RGBController_EKController::SetCustomMode()
{ void RGBController_EKController::SetCustomMode()
active_mode = 0; {
} active_mode = 0;
}
void RGBController_EKController::DeviceUpdateMode()
{ void RGBController_EKController::DeviceUpdateMode()
EK_dev->SetMode(modes[active_mode].value, modes[active_mode].speed); {
} controller->SetMode(modes[active_mode].value, modes[active_mode].speed);
}

View file

@ -1,35 +1,35 @@
/*-------------------------------------------------------------------*\ /*-------------------------------------------------------------------*\
| RGBController_EKController.h | | RGBController_EKController.h |
| | | |
| Driver for EK Loop Connect | | Driver for EK Loop Connect |
| | | |
| Chris M (Dr_No) 16th Jul 2020 | | Chris M (Dr_No) 16th Jul 2020 |
| | | |
\*-------------------------------------------------------------------*/ \*-------------------------------------------------------------------*/
#ifndef RGBCONTROLLER_EKCONTROLLER_H #ifndef RGBCONTROLLER_EKCONTROLLER_H
#define RGBCONTROLLER_EKCONTROLLER_H #define RGBCONTROLLER_EKCONTROLLER_H
#include "RGBController.h" #include "RGBController.h"
#include "Controllers/EKController/EKController.h" #include "Controllers/EKController/EKController.h"
class RGBController_EKController : public RGBController class RGBController_EKController : public RGBController
{ {
public: public:
RGBController_EKController(EKController *_dev); RGBController_EKController(EKController* controller_ptr);
~RGBController_EKController(); ~RGBController_EKController();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
EKController* EK_dev; EKController* controller;
}; };
#endif // RGBCONTROLLER_EKCONTROLLER_H #endif // RGBCONTROLLER_EKCONTROLLER_H

View file

@ -30,9 +30,10 @@
void DetectEVisionKeyboards(hid_device_info* info, const std::string& /*name*/) void DetectEVisionKeyboards(hid_device_info* info, const std::string& /*name*/)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev )
if(dev)
{ {
EVisionKeyboardController* controller = new EVisionKeyboardController(dev, info->path); EVisionKeyboardController* controller = new EVisionKeyboardController(dev, info->path);
RGBController_EVisionKeyboard* rgb_controller = new RGBController_EVisionKeyboard(controller); RGBController_EVisionKeyboard* rgb_controller = new RGBController_EVisionKeyboard(controller);
rgb_controller->name = "EVision Keyboard"; rgb_controller->name = "EVision Keyboard";
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);

View file

@ -1,74 +1,73 @@
#include "Detector.h" #include "Detector.h"
#include "EspurnaController.h" #include "EspurnaController.h"
#include "RGBController.h" #include "RGBController.h"
#include "RGBController_Espurna.h" #include "RGBController_Espurna.h"
#include "SettingsManager.h" #include "SettingsManager.h"
#include <vector> #include <vector>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectEspurnaControllers * * DetectEspurnaControllers *
* * * *
* Detect devices supported by the Espurna driver * * Detect devices supported by the Espurna driver *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectEspurnaControllers(std::vector<RGBController*> &rgb_controllers) void DetectEspurnaControllers(std::vector<RGBController*> &rgb_controllers)
{ {
EspurnaController* new_espurna; json espurna_settings;
RGBController_Espurna* new_controller;
json espurna_settings; /*-------------------------------------------------*\
| Get Espurna settings from settings manager |
/*-------------------------------------------------*\ \*-------------------------------------------------*/
| Get Espurna settings from settings manager | espurna_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("EspurnaDevices");
\*-------------------------------------------------*/
espurna_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("EspurnaDevices"); /*-------------------------------------------------*\
| If the Espurna settings contains devices, process |
/*-------------------------------------------------*\ \*-------------------------------------------------*/
| If the Espurna settings contains devices, process | if(espurna_settings.contains("devices"))
\*-------------------------------------------------*/ {
if(espurna_settings.contains("devices")) for(unsigned int device_idx = 0; device_idx < espurna_settings["devices"].size(); device_idx++)
{ {
for(unsigned int device_idx = 0; device_idx < espurna_settings["devices"].size(); device_idx++) std::string ip;
{ std::string port;
std::string ip; std::string apikey;
std::string port;
std::string apikey; if(espurna_settings["devices"][device_idx].contains("ip"))
{
if(espurna_settings["devices"][device_idx].contains("ip")) ip = espurna_settings["devices"][device_idx]["ip"];
{ }
ip = espurna_settings["devices"][device_idx]["ip"];
} if(espurna_settings["devices"][device_idx].contains("port"))
{
if(espurna_settings["devices"][device_idx].contains("port")) if(espurna_settings["devices"][device_idx]["port"].type() == json::value_t::string)
{ {
if(espurna_settings["devices"][device_idx]["port"].type() == json::value_t::string) port = espurna_settings["devices"][device_idx]["port"];
{ }
port = espurna_settings["devices"][device_idx]["port"]; else
} {
else port = std::to_string((unsigned int)espurna_settings["devices"][device_idx]["port"]);
{ }
port = std::to_string((unsigned int)espurna_settings["devices"][device_idx]["port"]); }
}
} if(espurna_settings["devices"][device_idx].contains("apikey"))
{
if(espurna_settings["devices"][device_idx].contains("apikey")) apikey = espurna_settings["devices"][device_idx]["apikey"];
{ }
apikey = espurna_settings["devices"][device_idx]["apikey"];
} std::string value = ip + "," + port + "," + apikey;
std::string value = ip + "," + port + "," + apikey; EspurnaController* controller = new EspurnaController();
controller->Initialize((char *)value.c_str());
new_espurna = new EspurnaController();
new_espurna->Initialize((char *)value.c_str()); RGBController_Espurna* rgb_controller = new RGBController_Espurna(controller);
new_controller = new RGBController_Espurna(new_espurna); rgb_controllers.push_back(rgb_controller);
rgb_controllers.push_back(new_controller); }
} }
}
} /* DetectEspurnaControllers() */
} /* DetectEspurnaControllers() */
REGISTER_DETECTOR("Espurna", DetectEspurnaControllers);
REGISTER_DETECTOR("Espurna", DetectEspurnaControllers);

View file

@ -1,84 +1,84 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_Espurna.cpp | | RGBController_Espurna.cpp |
| | | |
| Generic RGB Interface for Espurna | | Generic RGB Interface for Espurna |
| | | |
| Adam Honse (CalcProgrammer1) 6/20/2019 | | Adam Honse (CalcProgrammer1) 6/20/2019 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_Espurna.h" #include "RGBController_Espurna.h"
RGBController_Espurna::RGBController_Espurna(EspurnaController* espurna_ptr) RGBController_Espurna::RGBController_Espurna(EspurnaController* controller_ptr)
{ {
espurna = espurna_ptr; controller = controller_ptr;
name = "Espurna"; name = "Espurna";
type = DEVICE_TYPE_LIGHT; type = DEVICE_TYPE_LIGHT;
description = "Espurna Device"; description = "Espurna Device";
location = espurna->GetLocation(); location = controller->GetLocation();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = 0; Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
SetupZones(); SetupZones();
} }
RGBController_Espurna::~RGBController_Espurna() RGBController_Espurna::~RGBController_Espurna()
{ {
delete espurna; delete controller;
} }
void RGBController_Espurna::SetupZones() void RGBController_Espurna::SetupZones()
{ {
zone led_zone; zone led_zone;
led_zone.name = "RGB Light"; led_zone.name = "RGB Light";
led_zone.type = ZONE_TYPE_SINGLE; led_zone.type = ZONE_TYPE_SINGLE;
led_zone.leds_min = 1; led_zone.leds_min = 1;
led_zone.leds_max = 1; led_zone.leds_max = 1;
led_zone.leds_count = 1; led_zone.leds_count = 1;
led_zone.matrix_map = NULL; led_zone.matrix_map = NULL;
zones.push_back(led_zone); zones.push_back(led_zone);
led new_led; led new_led;
new_led.name = "RGB Light"; new_led.name = "RGB Light";
leds.push_back(new_led); leds.push_back(new_led);
SetupColors(); SetupColors();
} }
void RGBController_Espurna::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_Espurna::ResizeZone(int /*zone*/, int /*new_size*/)
{ {
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| This device does not support resizing zones | | This device does not support resizing zones |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
} }
void RGBController_Espurna::DeviceUpdateLEDs() void RGBController_Espurna::DeviceUpdateLEDs()
{ {
espurna->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_Espurna::UpdateZoneLEDs(int /*zone*/) void RGBController_Espurna::UpdateZoneLEDs(int /*zone*/)
{ {
espurna->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_Espurna::UpdateSingleLED(int /*led*/) void RGBController_Espurna::UpdateSingleLED(int /*led*/)
{ {
espurna->SetLEDs(colors); controller->SetLEDs(colors);
} }
void RGBController_Espurna::SetCustomMode() void RGBController_Espurna::SetCustomMode()
{ {
} }
void RGBController_Espurna::DeviceUpdateMode() void RGBController_Espurna::DeviceUpdateMode()
{ {
} }

View file

@ -1,32 +1,32 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_Espurna.h | | RGBController_Espurna.h |
| | | |
| Generic RGB Interface for Espurna | | Generic RGB Interface for Espurna |
| | | |
| Adam Honse (CalcProgrammer1) 9/11/2020 | | Adam Honse (CalcProgrammer1) 9/11/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "EspurnaController.h" #include "EspurnaController.h"
class RGBController_Espurna : public RGBController class RGBController_Espurna : public RGBController
{ {
public: public:
RGBController_Espurna(EspurnaController* espurna_ptr); RGBController_Espurna(EspurnaController* controller_ptr);
~RGBController_Espurna(); ~RGBController_Espurna();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
EspurnaController* espurna; EspurnaController* controller;
}; };

View file

@ -1,45 +1,42 @@
#include "Detector.h" #include "Detector.h"
#include "FanBusController.h" #include "FanBusController.h"
#include "RGBController_FanBus.h" #include "RGBController_FanBus.h"
void DetectFanBusControllers(std::vector<RGBController*> &rgb_controllers) void DetectFanBusControllers(std::vector<RGBController*> &rgb_controllers)
{ {
FanBusInterface* new_interface; FanBusInterface* new_interface;
FanBusController* new_controller; json fanbus_settings;
RGBController_FanBus* new_rgbcontroller;
/*-------------------------------------------------*\
json fanbus_settings; | Get LED Strip settings from settings manager |
\*-------------------------------------------------*/
/*-------------------------------------------------*\ fanbus_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("FanBusDevices");
| Get LED Strip settings from settings manager |
\*-------------------------------------------------*/ /*-------------------------------------------------*\
fanbus_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("FanBusDevices"); | If the LEDStrip settings contains devices, process|
\*-------------------------------------------------*/
/*-------------------------------------------------*\ if(fanbus_settings.contains("devices"))
| If the LEDStrip settings contains devices, process| {
\*-------------------------------------------------*/ for(unsigned int device_idx = 0; device_idx < fanbus_settings["devices"].size(); device_idx++)
if(fanbus_settings.contains("devices")) {
{ if(fanbus_settings["devices"][device_idx].contains("port"))
for(unsigned int device_idx = 0; device_idx < fanbus_settings["devices"].size(); device_idx++) {
{ std::string port_val = fanbus_settings["devices"][device_idx]["port"];
if(fanbus_settings["devices"][device_idx].contains("port"))
{ new_interface = new FanBusInterface(port_val.c_str());
std::string port_val = fanbus_settings["devices"][device_idx]["port"];
std::vector<unsigned char> detected_controllers = new_interface->DetectControllers();
new_interface = new FanBusInterface(port_val.c_str());
for(unsigned int controller_idx = 0; controller_idx < detected_controllers.size(); controller_idx++)
std::vector<unsigned char> detected_controllers = new_interface->DetectControllers(); {
FanBusController* controller = new FanBusController(new_interface, detected_controllers[controller_idx]);
for(unsigned int controller_idx = 0; controller_idx < detected_controllers.size(); controller_idx++) RGBController_FanBus* rgb_controller = new RGBController_FanBus(controller);
{
new_controller = new FanBusController(new_interface, detected_controllers[controller_idx]); rgb_controllers.push_back(rgb_controller);
new_rgbcontroller = new RGBController_FanBus(new_controller); }
}
rgb_controllers.push_back(new_rgbcontroller); }
} }
} }
}
} REGISTER_DETECTOR("FanBus", DetectFanBusControllers);
}
REGISTER_DETECTOR("FanBus", DetectFanBusControllers);

View file

@ -111,26 +111,24 @@ void DetectGainwardGPUControllers(std::vector<i2c_smbus_interface*> &busses)
case RGB_V1: case RGB_V1:
{ {
LOG_DEBUG(GPU_DETECT_MESSAGE, "Gainward v1", bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name ); LOG_DEBUG(GPU_DETECT_MESSAGE, "Gainward v1", bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name );
GainwardGPUv1Controller* new_GainwardGPU;
RGBController_GainwardGPUv1* new_controller;
new_GainwardGPU = new GainwardGPUv1Controller(busses[bus], 0x08); GainwardGPUv1Controller* controller = new GainwardGPUv1Controller(busses[bus], 0x08);
new_controller = new RGBController_GainwardGPUv1(new_GainwardGPU); RGBController_GainwardGPUv1* rgb_controller = new RGBController_GainwardGPUv1(controller);
new_controller->name = device_list[dev_idx].name; rgb_controller->name = device_list[dev_idx].name;
ResourceManager::get()->RegisterRGBController(new_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
break; break;
case RGB_V2: case RGB_V2:
{ {
LOG_DEBUG(GPU_DETECT_MESSAGE, "Gainward v2", bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name ); LOG_DEBUG(GPU_DETECT_MESSAGE, "Gainward v2", bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name );
GainwardGPUv2Controller* new_GainwardGPU;
RGBController_GainwardGPUv2* new_controller;
new_GainwardGPU = new GainwardGPUv2Controller(busses[bus], 0x49); GainwardGPUv2Controller* controller = new GainwardGPUv2Controller(busses[bus], 0x49);
new_controller = new RGBController_GainwardGPUv2(new_GainwardGPU); RGBController_GainwardGPUv2* rgb_controller = new RGBController_GainwardGPUv2(controller);
new_controller->name = device_list[dev_idx].name; rgb_controller->name = device_list[dev_idx].name;
ResourceManager::get()->RegisterRGBController(new_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
break; break;
} }

View file

@ -1,113 +1,112 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_GainwardGPUv1.cpp | | RGBController_GainwardGPUv1.cpp |
| | | |
| Driver for Gainward RGB v1 on GPUs | | Driver for Gainward RGB v1 on GPUs |
| | | |
| TheRogueZeta 11/05/2020 | | TheRogueZeta 11/05/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_GainwardGPUv1.h" #include "RGBController_GainwardGPUv1.h"
int RGBController_GainwardGPUv1::GetDeviceMode() int RGBController_GainwardGPUv1::GetDeviceMode()
{ {
active_mode = 1; active_mode = 1;
return(active_mode); return(active_mode);
} }
RGBController_GainwardGPUv1::RGBController_GainwardGPUv1(GainwardGPUv1Controller * gainward_gpu_ptr) RGBController_GainwardGPUv1::RGBController_GainwardGPUv1(GainwardGPUv1Controller* controller_ptr)
{ {
gainward_gpu = gainward_gpu_ptr; controller = controller_ptr;
name = "Gainward GPU"; name = "Gainward GPU";
vendor = "Gainward"; vendor = "Gainward";
type = DEVICE_TYPE_GPU; type = DEVICE_TYPE_GPU;
description = "Gainward GTX GPU"; description = "Gainward GTX GPU";
version = ""; location = controller->GetDeviceLocation();
location = gainward_gpu->GetDeviceLocation();
mode Direct;
mode Direct; Direct.name = "Direct";
Direct.name = "Direct"; Direct.value = 1;
Direct.value = 1; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.color_mode = MODE_COLORS_PER_LED;
Direct.color_mode = MODE_COLORS_PER_LED; modes.push_back(Direct);
modes.push_back(Direct);
SetupZones();
SetupZones(); }
}
RGBController_GainwardGPUv1::~RGBController_GainwardGPUv1()
RGBController_GainwardGPUv1::~RGBController_GainwardGPUv1() {
{ delete controller;
delete gainward_gpu; }
}
void RGBController_GainwardGPUv1::SetupZones()
void RGBController_GainwardGPUv1::SetupZones() {
{ /*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | Set up zone |
| Set up zone | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ zone gainward_gpu_zone;
zone gainward_gpu_zone; gainward_gpu_zone.name = "GPU";
gainward_gpu_zone.name = "GPU"; gainward_gpu_zone.type = ZONE_TYPE_SINGLE;
gainward_gpu_zone.type = ZONE_TYPE_SINGLE; gainward_gpu_zone.leds_min = 1;
gainward_gpu_zone.leds_min = 1; gainward_gpu_zone.leds_max = 1;
gainward_gpu_zone.leds_max = 1; gainward_gpu_zone.leds_count = 1;
gainward_gpu_zone.leds_count = 1; gainward_gpu_zone.matrix_map = NULL;
gainward_gpu_zone.matrix_map = NULL; zones.push_back(gainward_gpu_zone);
zones.push_back(gainward_gpu_zone);
/*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | Set up LED |
| Set up LED | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ led gainward_gpu_led;
led gainward_gpu_led; gainward_gpu_led.name = "GPU";
gainward_gpu_led.name = "GPU"; leds.push_back(gainward_gpu_led);
leds.push_back(gainward_gpu_led);
SetupColors();
SetupColors();
/*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | Initialize color |
| Initialize color | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ unsigned char red = controller->GetLEDRed();
unsigned char red = gainward_gpu->GetLEDRed(); unsigned char grn = controller->GetLEDGreen();
unsigned char grn = gainward_gpu->GetLEDGreen(); unsigned char blu = controller->GetLEDBlue();
unsigned char blu = gainward_gpu->GetLEDBlue();
colors[0] = ToRGBColor(red, grn, blu);
colors[0] = ToRGBColor(red, grn, blu); }
}
void RGBController_GainwardGPUv1::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_GainwardGPUv1::ResizeZone(int /*zone*/, int /*new_size*/) {
{ /*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | This device does not support resizing zones |
| This device does not support resizing zones | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ }
}
void RGBController_GainwardGPUv1::DeviceUpdateLEDs()
void RGBController_GainwardGPUv1::DeviceUpdateLEDs() {
{ for(std::size_t led = 0; led < colors.size(); led++)
for(std::size_t led = 0; led < colors.size(); led++) {
{ unsigned char red = RGBGetRValue(colors[led]);
unsigned char red = RGBGetRValue(colors[led]); unsigned char grn = RGBGetGValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]); unsigned char blu = RGBGetBValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SetLEDColors(red, grn, blu);
gainward_gpu->SetLEDColors(red, grn, blu); }
} }
}
void RGBController_GainwardGPUv1::UpdateZoneLEDs(int /*zone*/)
void RGBController_GainwardGPUv1::UpdateZoneLEDs(int /*zone*/) {
{ DeviceUpdateLEDs();
DeviceUpdateLEDs(); }
}
void RGBController_GainwardGPUv1::UpdateSingleLED(int /*led*/)
void RGBController_GainwardGPUv1::UpdateSingleLED(int /*led*/) {
{ DeviceUpdateLEDs();
DeviceUpdateLEDs(); }
}
void RGBController_GainwardGPUv1::SetCustomMode()
void RGBController_GainwardGPUv1::SetCustomMode() {
{ active_mode = 0;
active_mode = 0; }
}
void RGBController_GainwardGPUv1::DeviceUpdateMode()
void RGBController_GainwardGPUv1::DeviceUpdateMode() {
{
}
}

View file

@ -1,35 +1,35 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_GainwardGPU.h | | RGBController_GainwardGPU.h |
| | | |
| Driver for Gainward RGB v1 on GPUs | | Driver for Gainward RGB v1 on GPUs |
| | | |
| TheRogueZeta 11/05/2020 | | TheRogueZeta 11/05/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "GainwardGPUv1Controller.h" #include "GainwardGPUv1Controller.h"
class RGBController_GainwardGPUv1 : public RGBController class RGBController_GainwardGPUv1 : public RGBController
{ {
public: public:
RGBController_GainwardGPUv1(GainwardGPUv1Controller* gainward_gpu_ptr); RGBController_GainwardGPUv1(GainwardGPUv1Controller* controller_ptr);
~RGBController_GainwardGPUv1(); ~RGBController_GainwardGPUv1();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
GainwardGPUv1Controller* gainward_gpu; GainwardGPUv1Controller* controller;
int GetDeviceMode(); int GetDeviceMode();
}; };

View file

@ -1,185 +1,184 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_GainwardGPUv2.cpp | | RGBController_GainwardGPUv2.cpp |
| | | |
| Driver for Gainward RGB v2 on GPUs | | Driver for Gainward RGB v2 on GPUs |
| | | |
| KundaPanda 01/04/2021 | | KundaPanda 01/04/2021 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_GainwardGPUv2.h" #include "RGBController_GainwardGPUv2.h"
RGBController_GainwardGPUv2::RGBController_GainwardGPUv2(GainwardGPUv2Controller* gainward_gpu_ptr) RGBController_GainwardGPUv2::RGBController_GainwardGPUv2(GainwardGPUv2Controller* controller_ptr)
{ {
gainward_gpu = gainward_gpu_ptr; controller = controller_ptr;
name = "Gainward GPU"; name = "Gainward GPU";
vendor = "Gainward"; vendor = "Gainward";
type = DEVICE_TYPE_GPU; type = DEVICE_TYPE_GPU;
description = "Gainward RTX GPU"; description = "Gainward RTX GPU";
version = ""; location = controller->GetDeviceLocation();
location = gainward_gpu->GetDeviceLocation();
mode Static;
mode Static; Static.name = "Static";
Static.name = "Static"; Static.value = GAINWARD_V2_MODE_STATIC;
Static.value = GAINWARD_V2_MODE_STATIC; Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; Static.color_mode = MODE_COLORS_PER_LED;
Static.color_mode = MODE_COLORS_PER_LED; modes.push_back(Static);
modes.push_back(Static);
mode Breathe;
mode Breathe; Breathe.name = "Breathing";
Breathe.name = "Breathing"; Breathe.value = GAINWARD_V2_MODE_STATIC;
Breathe.value = GAINWARD_V2_MODE_STATIC; Breathe.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
Breathe.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED; Breathe.speed_max = 0x000a;
Breathe.speed_max = 0x000a; Breathe.speed_min = 0x1324;
Breathe.speed_min = 0x1324; Breathe.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathe.color_mode = MODE_COLORS_MODE_SPECIFIC; Breathe.colors_min = 2;
Breathe.colors_min = 2; Breathe.colors_max = 2;
Breathe.colors_max = 2; Breathe.colors.resize(2);
Breathe.colors.resize(2); modes.push_back(Breathe);
modes.push_back(Breathe);
mode RainbowWave;
mode RainbowWave; RainbowWave.name = "Rainbow Wave";
RainbowWave.name = "Rainbow Wave"; RainbowWave.value = GAINWARD_V2_MODE_CYCLE;
RainbowWave.value = GAINWARD_V2_MODE_CYCLE; RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR; RainbowWave.speed_max = 0x0;
RainbowWave.speed_max = 0x0; RainbowWave.speed_min = 0xF;
RainbowWave.speed_min = 0xF; RainbowWave.color_mode = MODE_COLORS_NONE;
RainbowWave.color_mode = MODE_COLORS_NONE; modes.push_back(RainbowWave);
modes.push_back(RainbowWave);
mode Strobe;
mode Strobe; Strobe.name = "Strobe";
Strobe.name = "Strobe"; Strobe.value = GAINWARD_V2_MODE_STROBE;
Strobe.value = GAINWARD_V2_MODE_STROBE; Strobe.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Strobe.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; Strobe.color_mode = MODE_COLORS_MODE_SPECIFIC;
Strobe.color_mode = MODE_COLORS_MODE_SPECIFIC; Strobe.colors_min = 1;
Strobe.colors_min = 1; Strobe.colors_max = 1;
Strobe.colors_max = 1; Strobe.colors.resize(1);
Strobe.colors.resize(1); Strobe.speed_max = 0x0;
Strobe.speed_max = 0x0; Strobe.speed_min = 0xF;
Strobe.speed_min = 0xF; modes.push_back(Strobe);
modes.push_back(Strobe);
SetupZones();
SetupZones();
/*-------------------------*\
/*-------------------------*\ | Initialize active mode |
| Initialize active mode | \*-------------------------*/
\*-------------------------*/ active_mode = 0;
active_mode = 0; }
}
RGBController_GainwardGPUv2::~RGBController_GainwardGPUv2()
RGBController_GainwardGPUv2::~RGBController_GainwardGPUv2() {
{ delete controller;
delete gainward_gpu; }
}
void RGBController_GainwardGPUv2::SetupZones()
void RGBController_GainwardGPUv2::SetupZones() {
{ /*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | Set up zone |
| Set up zone | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ zone gainward_gpu_zone;
zone gainward_gpu_zone; gainward_gpu_zone.name = "GPU";
gainward_gpu_zone.name = "GPU"; gainward_gpu_zone.type = ZONE_TYPE_SINGLE;
gainward_gpu_zone.type = ZONE_TYPE_SINGLE; gainward_gpu_zone.leds_min = 1;
gainward_gpu_zone.leds_min = 1; gainward_gpu_zone.leds_max = 1;
gainward_gpu_zone.leds_max = 1; gainward_gpu_zone.leds_count = 1;
gainward_gpu_zone.leds_count = 1; gainward_gpu_zone.matrix_map = NULL;
gainward_gpu_zone.matrix_map = NULL; zones.push_back(gainward_gpu_zone);
zones.push_back(gainward_gpu_zone);
/*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | Set up LED |
| Set up LED | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ led gainward_gpu_led;
led gainward_gpu_led; gainward_gpu_led.name = "GPU";
gainward_gpu_led.name = "GPU"; leds.push_back(gainward_gpu_led);
leds.push_back(gainward_gpu_led);
SetupColors();
SetupColors();
/*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | Initialize color |
| Initialize color | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ unsigned char red = controller->GetLEDRed();
unsigned char red = gainward_gpu->GetLEDRed(); unsigned char grn = controller->GetLEDGreen();
unsigned char grn = gainward_gpu->GetLEDGreen(); unsigned char blu = controller->GetLEDBlue();
unsigned char blu = gainward_gpu->GetLEDBlue();
colors[0] = ToRGBColor(red, grn, blu);
colors[0] = ToRGBColor(red, grn, blu); }
}
void RGBController_GainwardGPUv2::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_GainwardGPUv2::ResizeZone(int /*zone*/, int /*new_size*/) {
{ /*---------------------------------------------------------*\
/*---------------------------------------------------------*\ | This device does not support resizing zones |
| This device does not support resizing zones | \*---------------------------------------------------------*/
\*---------------------------------------------------------*/ }
}
void RGBController_GainwardGPUv2::DeviceUpdateLEDs()
void RGBController_GainwardGPUv2::DeviceUpdateLEDs() {
{ for(unsigned int color : colors)
for(unsigned int color : colors) {
{ unsigned char red = RGBGetRValue(color);
unsigned char red = RGBGetRValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char grn = RGBGetGValue(color); unsigned char blu = RGBGetBValue(color);
unsigned char blu = RGBGetBValue(color);
controller->SetLEDColors(red, grn, blu);
gainward_gpu->SetLEDColors(red, grn, blu); controller->SetMode(GAINWARD_V2_MODE_STATIC, 0x2);
gainward_gpu->SetMode(GAINWARD_V2_MODE_STATIC, 0x2); }
} }
}
void RGBController_GainwardGPUv2::UpdateZoneLEDs(int /*zone*/)
void RGBController_GainwardGPUv2::UpdateZoneLEDs(int /*zone*/) {
{ DeviceUpdateLEDs();
DeviceUpdateLEDs(); }
}
void RGBController_GainwardGPUv2::UpdateSingleLED(int /*led*/)
void RGBController_GainwardGPUv2::UpdateSingleLED(int /*led*/) {
{ DeviceUpdateLEDs();
DeviceUpdateLEDs(); }
}
void RGBController_GainwardGPUv2::SetCustomMode()
void RGBController_GainwardGPUv2::SetCustomMode() {
{ active_mode = 0;
active_mode = 0; }
}
void RGBController_GainwardGPUv2::DeviceUpdateMode()
void RGBController_GainwardGPUv2::DeviceUpdateMode() {
{ mode current_mode = modes[(unsigned int)active_mode];
mode current_mode = modes[(unsigned int)active_mode]; switch (active_mode)
switch (active_mode) {
{ case 1:
case 1: {
{ controller->SetBreathingSpeed(current_mode.speed);
gainward_gpu->SetBreathingSpeed(current_mode.speed);
unsigned char r1 = RGBGetRValue(current_mode.colors[0]);
unsigned char r1 = RGBGetRValue(current_mode.colors[0]); unsigned char g1 = RGBGetGValue(current_mode.colors[0]);
unsigned char g1 = RGBGetGValue(current_mode.colors[0]); unsigned char b1 = RGBGetBValue(current_mode.colors[0]);
unsigned char b1 = RGBGetBValue(current_mode.colors[0]); controller->SetLEDColors(r1, g1, b1);
gainward_gpu->SetLEDColors(r1, g1, b1);
unsigned char r2 = RGBGetRValue(current_mode.colors[1]);
unsigned char r2 = RGBGetRValue(current_mode.colors[1]); unsigned char g2 = RGBGetGValue(current_mode.colors[1]);
unsigned char g2 = RGBGetGValue(current_mode.colors[1]); unsigned char b2 = RGBGetBValue(current_mode.colors[1]);
unsigned char b2 = RGBGetBValue(current_mode.colors[1]); controller->SetLEDColors(r2, g2, b2, GAINWARD_V2_COLOR_REGISTER_SECONDARY);
gainward_gpu->SetLEDColors(r2, g2, b2, GAINWARD_V2_COLOR_REGISTER_SECONDARY); controller->SetMode(GAINWARD_V2_MODE_STATIC, 0x2, GAINWARD_V2_STATIC_BREATHING);
gainward_gpu->SetMode(GAINWARD_V2_MODE_STATIC, 0x2, GAINWARD_V2_STATIC_BREATHING); }
} break;
break;
/*---------------------------------------------*\
/*---------------------------------------------*\ | Case 3 intentionally falls through to case 2 |
| Case 3 intentionally falls through to case 2 | \*---------------------------------------------*/
\*---------------------------------------------*/ case 3:
case 3: {
{ unsigned char r = RGBGetRValue(current_mode.colors[0]);
unsigned char r = RGBGetRValue(current_mode.colors[0]); unsigned char g = RGBGetGValue(current_mode.colors[0]);
unsigned char g = RGBGetGValue(current_mode.colors[0]); unsigned char b = RGBGetBValue(current_mode.colors[0]);
unsigned char b = RGBGetBValue(current_mode.colors[0]); controller->SetLEDColors(r, g, b, GAINWARD_V2_COLOR_REGISTER_TERTIARY);
gainward_gpu->SetLEDColors(r, g, b, GAINWARD_V2_COLOR_REGISTER_TERTIARY); }
}
case 2:
case 2: controller->SetMode((unsigned char)(current_mode.value), (unsigned char)(current_mode.speed));
gainward_gpu->SetMode((unsigned char)(current_mode.value), (unsigned char)(current_mode.speed)); controller->SetDirection(current_mode.direction);
gainward_gpu->SetDirection(current_mode.direction); break;
break;
default:
default: controller->SetMode((unsigned char)(current_mode.value), (unsigned char)(current_mode.speed));
gainward_gpu->SetMode((unsigned char)(current_mode.value), (unsigned char)(current_mode.speed)); break;
break; }
} }
}

View file

@ -1,33 +1,33 @@
/*-----------------------------------------*\ /*-----------------------------------------*\
| RGBController_GainwardGPUv2.h | | RGBController_GainwardGPUv2.h |
| | | |
| Driver for Gainward RGB v2 on GPUs | | Driver for Gainward RGB v2 on GPUs |
| | | |
| KundaPanda 01/04/2021 | | KundaPanda 01/04/2021 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "GainwardGPUv2Controller.h" #include "GainwardGPUv2Controller.h"
class RGBController_GainwardGPUv2 : public RGBController class RGBController_GainwardGPUv2 : public RGBController
{ {
public: public:
RGBController_GainwardGPUv2(GainwardGPUv2Controller* gainward_gpu_ptr); RGBController_GainwardGPUv2(GainwardGPUv2Controller* controller_ptr);
~RGBController_GainwardGPUv2(); ~RGBController_GainwardGPUv2();
void SetupZones(); void SetupZones();
void ResizeZone(int zone, int new_size); void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs(); void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode(); void SetCustomMode();
void DeviceUpdateMode(); void DeviceUpdateMode();
private: private:
GainwardGPUv2Controller* gainward_gpu; GainwardGPUv2Controller* controller;
}; };