mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-02-01 02:41:09 -05:00
Initial commit for HyperX Quadcast S
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
/*-----------------------------------------*\
|
||||
| HyperXMicrophoneController.cpp |
|
||||
| |
|
||||
| Driver for HyperX Microphone lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "HyperXMicrophoneController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
HyperXMicrophoneController::HyperXMicrophoneController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
HyperXMicrophoneController::~HyperXMicrophoneController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string HyperXMicrophoneController::GetDeviceLocation()
|
||||
{
|
||||
return("HID " + location);
|
||||
}
|
||||
|
||||
std::string HyperXMicrophoneController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HyperXMicrophoneController::SendDirect
|
||||
(
|
||||
RGBColor* color_data
|
||||
)
|
||||
{
|
||||
unsigned char buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x00;
|
||||
buf[0x01] = 0x04;
|
||||
buf[0x02] = 0xF2;
|
||||
|
||||
buf[0x09] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x00;
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
{
|
||||
buf[(i * 4) + 1] = 0x81;
|
||||
buf[(i * 4) + 2] = RGBGetRValue(color_data[i]);
|
||||
buf[(i * 4) + 3] = RGBGetGValue(color_data[i]);
|
||||
buf[(i * 4) + 4] = RGBGetBValue(color_data[i]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 65);
|
||||
}
|
||||
Reference in New Issue
Block a user