Files
OpenRGB/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.cpp
Cheerpipe b32ef76121 Creative Sound BlasterX G6 support
Commits squashed and amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-04-21 00:03:46 -05:00

83 lines
3.0 KiB
C++

#include "CreativeSoundBlasterXG6Controller.h"
CreativeSoundBlasterXG6Controller::CreativeSoundBlasterXG6Controller(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
CreativeSoundBlasterXG6Controller::~CreativeSoundBlasterXG6Controller()
{
hid_close(dev);
}
std::string CreativeSoundBlasterXG6Controller::GetDeviceLocation()
{
return("HID " + location);
}
void CreativeSoundBlasterXG6Controller::SetLedColor (unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
//5A 3A 02 06 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
usb_buf[0x01] = 0x5A;
usb_buf[0x02] = 0x3A;
usb_buf[0x03] = 0x02;
usb_buf[0x04] = 0x06;
usb_buf[0x05] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
//5A 3A 06 04 00 03 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
usb_buf[0x01] = 0x5A;
usb_buf[0x02] = 0x3A;
usb_buf[0x03] = 0x06;
usb_buf[0x04] = 0x04;
usb_buf[0x06] = 0x03;
usb_buf[0x07] = 0x01;
usb_buf[0x09] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
//5A 3A 09 0A 00 03 01 01 FF BB GG RR
usb_buf[0x01] = 0x5A;
usb_buf[0x02] = 0x3A;
usb_buf[0x03] = 0x09;
usb_buf[0x04] = 0x0A;
usb_buf[0x06] = 0x03;
usb_buf[0x07] = 0x01;
usb_buf[0x08] = 0x01;
usb_buf[0x09] = 0x0FF;
usb_buf[0x0A] = blue;
usb_buf[0x0B] = green;
usb_buf[0x0C] = red;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
}