Add support for Corsair HydroSeries H100i v2
This commit is contained in:
parent
a936f91509
commit
dc92567202
6 changed files with 306 additions and 0 deletions
|
|
@ -0,0 +1,91 @@
|
|||
/*-----------------------------------------*\
|
||||
| CorsairHydro2Controller.cpp |
|
||||
| |
|
||||
| Controller for Corsair H100i v2 |
|
||||
| |
|
||||
| Tim Demand (tim.dmd) 1/10/2023 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairHydro2Controller.h"
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
CorsairHydro2Controller::CorsairHydro2Controller(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(libusb_get_device(dev_handle), &descriptor);
|
||||
|
||||
std::stringstream location_stream;
|
||||
location_stream << std::hex << std::setfill('0') << std::setw(4) << descriptor.idVendor << ":" << std::hex << std::setfill('0') << std::setw(4) << descriptor.idProduct;
|
||||
location = location_stream.str();
|
||||
|
||||
SendInit();
|
||||
}
|
||||
|
||||
CorsairHydro2Controller::~CorsairHydro2Controller()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
libusb_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CorsairHydro2Controller::GetLocation()
|
||||
{
|
||||
return("USB: " + location);
|
||||
}
|
||||
|
||||
void CorsairHydro2Controller::SetLED(std::vector<RGBColor>& colors)
|
||||
{
|
||||
unsigned char usb_buf[32];
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
int actual;
|
||||
|
||||
unsigned char led_enable = 0x01;
|
||||
|
||||
unsigned char rr = RGBGetRValue(colors[0]);
|
||||
unsigned char gg = RGBGetBValue(colors[0]);
|
||||
unsigned char bb = RGBGetGValue(colors[0]);
|
||||
|
||||
if((rr + gg + bb) == 0)
|
||||
{
|
||||
led_enable = 0x00; // needed because leds won't turn off completely if color is 00 00 00
|
||||
}
|
||||
|
||||
usb_buf[0] = 0x10;
|
||||
usb_buf[1] = rr;
|
||||
usb_buf[2] = bb;
|
||||
usb_buf[3] = gg;
|
||||
usb_buf[4] = 0x00;
|
||||
usb_buf[5] = 0xFF;
|
||||
usb_buf[6] = 0xFF;
|
||||
usb_buf[7] = 0xFF;
|
||||
usb_buf[8] = 0xFF;
|
||||
usb_buf[9] = 0xFF;
|
||||
usb_buf[10] = 0x00;
|
||||
usb_buf[11] = 0x0A;
|
||||
usb_buf[12] = 0x05;
|
||||
usb_buf[13] = led_enable;
|
||||
usb_buf[14] = 0x00;
|
||||
usb_buf[15] = 0x00;
|
||||
usb_buf[16] = 0x00;
|
||||
usb_buf[17] = 0x00;
|
||||
usb_buf[18] = 0x01;
|
||||
|
||||
libusb_bulk_transfer(dev, 0x02, usb_buf, 19, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x82, usb_buf, 32, &actual, 1000);
|
||||
if(actual != 32) SendInit(); // reinitialization after sleep
|
||||
}
|
||||
|
||||
void CorsairHydro2Controller::SendInit()
|
||||
{
|
||||
libusb_reset_device(dev); // needed for reinitialization after sleep
|
||||
|
||||
libusb_control_transfer(dev, 0x40, 0, 0xffff, 0x0000, NULL, 0, 0);
|
||||
libusb_control_transfer(dev, 0x40, 2, 0x0002, 0x0000, NULL, 0, 0);
|
||||
libusb_control_transfer(dev, 0x40, 1, 0x0002, 0x0000, NULL, 0, 0);
|
||||
libusb_control_transfer(dev, 0x40, 4, 0x0002, 0x0000, NULL, 0, 0);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*-----------------------------------------*\
|
||||
| CorsairHydro2Controller.h |
|
||||
| |
|
||||
| Controller for Corsair H100i v2 |
|
||||
| |
|
||||
| Tim Demand (tim.dmd) 1/10/2023 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#ifdef __FreeBSD__
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
class CorsairHydro2Controller
|
||||
{
|
||||
public:
|
||||
CorsairHydro2Controller(libusb_device_handle* dev_handle);
|
||||
~CorsairHydro2Controller();
|
||||
|
||||
std::string GetLocation();
|
||||
|
||||
void SetLED(std::vector<RGBColor>& colors);
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
std::string firmware_version;
|
||||
std::string location;
|
||||
|
||||
void SendInit();
|
||||
};
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*-----------------------------------------*\
|
||||
| CorsairHydro2ControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Corsair H100i v2 |
|
||||
| |
|
||||
| Tim Demand (tim.dmd) 1/10/2023 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "CorsairHydro2Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairHydro2.h"
|
||||
#include <vector>
|
||||
#ifdef __FreeBSD__
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
#define CORSAIR_VID 0x1B1C
|
||||
#define H100I_V2_PID 0x0C09
|
||||
|
||||
void DetectCorsairHydro2Controllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_init(NULL);
|
||||
|
||||
#ifdef _WIN32
|
||||
libusb_set_option(NULL, LIBUSB_OPTION_USE_USBDK);
|
||||
#endif
|
||||
|
||||
libusb_device_handle* dev = libusb_open_device_with_vid_pid(NULL, CORSAIR_VID, H100I_V2_PID);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairHydro2Controller* controller = new CorsairHydro2Controller(dev);
|
||||
RGBController_CorsairHydro2* rgb_controller = new RGBController_CorsairHydro2(controller);
|
||||
|
||||
rgb_controller->name = "Corsair H100i v2";
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_DETECTOR("Corsair H100i v2", DetectCorsairHydro2Controllers);
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
| Entries for dynamic UDEV rules |
|
||||
| |
|
||||
| DUMMY_DEVICE_DETECTOR("Corsair H100i v2", DetectCorsairHydro2Controllers, 0x1B1C, 0x0C09 ) |
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairHydro2.cpp |
|
||||
| |
|
||||
| RGB Controller for Corsair H100i v2 |
|
||||
| |
|
||||
| Tim Demand (tim.dmd) 1/10/2023 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairHydro2.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Corsair Hydro Series H100i v2 AIO
|
||||
@category Cooler
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :x:
|
||||
@detectors DetectCorsairHydro2Controllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_CorsairHydro2::RGBController_CorsairHydro2(CorsairHydro2Controller* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
vendor = "Corsair";
|
||||
description = "Corsair H100i v2";
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
location = controller->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CorsairHydro2::~RGBController_CorsairHydro2()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro2::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Pump Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
led new_led;
|
||||
|
||||
new_led.name = "Pump LED";
|
||||
leds.push_back(new_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro2::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro2::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLED(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro2::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
controller->SetLED(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro2::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
controller->SetLED(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro2::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairHydro2.h |
|
||||
| |
|
||||
| RGB Controller for Corsair H100i v2 |
|
||||
| |
|
||||
| Tim Demand (tim.dmd) 1/10/2023 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CorsairHydro2Controller.h"
|
||||
|
||||
class RGBController_CorsairHydro2 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairHydro2(CorsairHydro2Controller* controller_ptr);
|
||||
~RGBController_CorsairHydro2();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
CorsairHydro2Controller* controller;
|
||||
};
|
||||
|
|
@ -88,6 +88,7 @@ INCLUDEPATH +=
|
|||
Controllers/CorsairCommanderCoreController/ \
|
||||
Controllers/CorsairDominatorPlatinumController/ \
|
||||
Controllers/CorsairHydroController/ \
|
||||
Controllers/CorsairHydro2Controller/ \
|
||||
Controllers/CorsairHydroPlatinumController/ \
|
||||
Controllers/CorsairPeripheralController/ \
|
||||
Controllers/CorsairPeripheralV2Controller/ \
|
||||
|
|
@ -328,6 +329,8 @@ HEADERS +=
|
|||
Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.h \
|
||||
Controllers/CorsairHydroController/CorsairHydroController.h \
|
||||
Controllers/CorsairHydroController/RGBController_CorsairHydro.h \
|
||||
Controllers/CorsairHydro2Controller/CorsairHydro2Controller.h \
|
||||
Controllers/CorsairHydro2Controller/RGBController_CorsairHydro2.h \
|
||||
Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumController.h \
|
||||
Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.h \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \
|
||||
|
|
@ -864,6 +867,9 @@ SOURCES +=
|
|||
Controllers/CorsairHydroController/CorsairHydroController.cpp \
|
||||
Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp \
|
||||
Controllers/CorsairHydroController/RGBController_CorsairHydro.cpp \
|
||||
Controllers/CorsairHydro2Controller/CorsairHydro2Controller.cpp \
|
||||
Controllers/CorsairHydro2Controller/CorsairHydro2ControllerDetect.cpp \
|
||||
Controllers/CorsairHydro2Controller/RGBController_CorsairHydro2.cpp \
|
||||
Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumController.cpp \
|
||||
Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumControllerDetect.cpp \
|
||||
Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue