More hidapi changes for windows

This commit is contained in:
Adam Honse
2021-02-25 21:59:18 -06:00
parent 289f14214f
commit 156cbfab0f

View File

@@ -51,7 +51,7 @@ void ThermaltakeRiingController::GetFanData
unsigned short * rpm
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -61,15 +61,16 @@ void ThermaltakeRiingController::GetFanData
/*-----------------------------------------------------*\
| Set up Get Fan Data packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x33;
usb_buf[0x01] = 0x51;
usb_buf[0x02] = port;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x33;
usb_buf[0x02] = 0x51;
usb_buf[0x03] = port;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 65);
*speed = usb_buf[0x04];
*rpm = (usb_buf[0x06] << 8) + usb_buf[0x05];
@@ -77,7 +78,7 @@ void ThermaltakeRiingController::GetFanData
std::string ThermaltakeRiingController::GetFirmwareVersion()
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -87,14 +88,15 @@ std::string ThermaltakeRiingController::GetFirmwareVersion()
/*-----------------------------------------------------*\
| Set up Get Firmware Version packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x33;
usb_buf[0x01] = 0x50;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x33;
usb_buf[0x02] = 0x50;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 65);
std::string ret_str = std::to_string(usb_buf[2]) + "." + std::to_string(usb_buf[3]) + "." + std::to_string(usb_buf[4]);
@@ -158,7 +160,7 @@ void ThermaltakeRiingController::SendFan
unsigned char speed
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -168,17 +170,18 @@ void ThermaltakeRiingController::SendFan
/*-----------------------------------------------------*\
| Set up RGB packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x32;
usb_buf[0x01] = 0x51;
usb_buf[0x02] = port;
usb_buf[0x03] = mode;
usb_buf[0x04] = speed;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x32;
usb_buf[0x02] = 0x51;
usb_buf[0x03] = port;
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 65);
}
void ThermaltakeRiingController::SendRGB