Initial support for Corsair Hydro Series devices (only H100i Pro RGB for now)
This commit is contained in:
parent
4f5cf83e47
commit
68a16fadc2
7 changed files with 317 additions and 0 deletions
|
|
@ -0,0 +1,69 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| Processing Code for Corsair Hydro Series |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com), 8/17/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "CorsairHydroController.h"
|
||||
|
||||
CorsairHydroController::CorsairHydroController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
SendFirmwareRequest();
|
||||
}
|
||||
|
||||
std::string CorsairHydroController::GetFirmwareString()
|
||||
{
|
||||
return(firmware_version);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendFirmwareRequest()
|
||||
{
|
||||
unsigned char usb_buf[8];
|
||||
int actual;
|
||||
|
||||
usb_buf[0] = 0xAA;
|
||||
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 1, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 7, &actual, 1000);
|
||||
|
||||
firmware_version = std::to_string(usb_buf[3]) + "." + std::to_string(usb_buf[4]) + "." + std::to_string(usb_buf[5]) + "." + std::to_string(usb_buf[6]);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SetFixed
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[8];
|
||||
int actual;
|
||||
|
||||
usb_buf[0] = 0x56;
|
||||
usb_buf[1] = 0x02;
|
||||
usb_buf[2] = red;
|
||||
usb_buf[3] = green;
|
||||
usb_buf[4] = blue;
|
||||
usb_buf[5] = red;
|
||||
usb_buf[6] = green;
|
||||
usb_buf[7] = blue;
|
||||
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 8, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
|
||||
|
||||
SendApply();
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendApply()
|
||||
{
|
||||
unsigned char usb_buf[3];
|
||||
int actual;
|
||||
|
||||
usb_buf[0] = 0x55;
|
||||
usb_buf[1] = 0x01;
|
||||
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
|
||||
}
|
||||
55
Controllers/CorsairHydroController/CorsairHydroController.h
Normal file
55
Controllers/CorsairHydroController/CorsairHydroController.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Hydro Series |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com), 8/17/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_HYDRO_CMD_READ_PUMP_SPEED = 0x31,
|
||||
CORSAIR_HYDRO_CMD_WRITE_PUMP_MODE = 0x32,
|
||||
CORSAIR_HYDRO_CMD_READ_PUMP_MODE = 0x33,
|
||||
CORSAIR_HYDRO_CMD_READ_FAN_SPEED = 0x41,
|
||||
CORSAIR_HYDRO_CMD_READ_AIO_TEMP = 0xA9,
|
||||
CORSAIR_HYDRO_CMD_READ_FIRMWARE = 0xAA,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_HYDRO_PUMP_MODE_QUIET = 0x00,
|
||||
CORSAIR_HYDRO_PUMP_MODE_BALANCED = 0x01,
|
||||
CORSAIR_HYDRO_PUMP_MODE_PERFORMANCE = 0x02,
|
||||
};
|
||||
|
||||
class CorsairHydroController
|
||||
{
|
||||
public:
|
||||
CorsairHydroController(libusb_device_handle* dev_handle);
|
||||
~CorsairHydroController();
|
||||
|
||||
unsigned char GetFanPercent(unsigned char fan_channel);
|
||||
|
||||
unsigned short GetFanRPM(unsigned char fan_channel);
|
||||
|
||||
std::string GetFirmwareString();
|
||||
|
||||
void SetFixed
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
std::string firmware_version;
|
||||
|
||||
void SendApply();
|
||||
void SendFirmwareRequest();
|
||||
};
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
#include "Detector.h"
|
||||
#include "CorsairHydroController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairHydro.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Corsair vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_VID 0x1B1C
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard Hydro Series product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_H100I_PRO_RGB_PID 0x0C15
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_interface;
|
||||
const char * name;
|
||||
} corsair_hydro_device;
|
||||
|
||||
#define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const corsair_hydro_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Coolers |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ CORSAIR_VID, CORSAIR_H100I_PRO_RGB_PID, 0, "Corsair H100i PRO RGB" }
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairHydroControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Corsair RGB Cooler controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for Corsair RGB Peripheral
|
||||
if(dev)
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairHydroController* controller = new CorsairHydroController(dev);//, device_list[device_idx].usb_endpoint);
|
||||
|
||||
RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
} /* DetectCorsairHydroControllers() */
|
||||
|
||||
REGISTER_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers);
|
||||
Loading…
Add table
Add a link
Reference in a new issue