Fix issues preventing hidapi from working without WinUSB on Windows

This commit is contained in:
Adam Honse 2020-06-29 14:51:26 -05:00
parent ffc02e6c98
commit 595248cc10
19 changed files with 412 additions and 340 deletions

View file

@ -198,7 +198,7 @@ void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBCol
void CorsairLightingNodeController::SendFirmwareRequest()
{
int actual;
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -208,13 +208,14 @@ void CorsairLightingNodeController::SendFirmwareRequest()
/*-----------------------------------------------------*\
| Set up Firmware Version Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
actual = hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
actual = hid_read(dev, usb_buf, 17);
if(actual > 0)
{
@ -231,7 +232,7 @@ void CorsairLightingNodeController::SendDirect
unsigned char* color_data
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -241,27 +242,28 @@ void CorsairLightingNodeController::SendDirect
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
usb_buf[0x04] = color_channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT;
usb_buf[0x02] = channel;
usb_buf[0x03] = start;
usb_buf[0x04] = count;
usb_buf[0x05] = color_channel;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], color_data, count);
memcpy(&usb_buf[0x06], color_data, count);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendCommit()
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -276,14 +278,15 @@ void CorsairLightingNodeController::SendCommit()
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
usb_buf[0x02] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendBegin
@ -291,7 +294,7 @@ void CorsairLightingNodeController::SendBegin
unsigned char channel
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -301,14 +304,15 @@ void CorsairLightingNodeController::SendBegin
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
usb_buf[0x02] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendEffectConfig
@ -334,7 +338,7 @@ void CorsairLightingNodeController::SendEffectConfig
unsigned short temperature_2
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -344,48 +348,49 @@ void CorsairLightingNodeController::SendEffectConfig
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count;
usb_buf[0x03] = led_type;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x02] = channel;
usb_buf[0x03] = count;
usb_buf[0x04] = led_type;
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
usb_buf[0x06] = direction;
usb_buf[0x07] = change_style;
usb_buf[0x08] = 0;
usb_buf[0x05] = mode;
usb_buf[0x06] = speed;
usb_buf[0x07] = direction;
usb_buf[0x08] = change_style;
usb_buf[0x09] = 0;
/*-----------------------------------------------------*\
| Set up mode colors |
\*-----------------------------------------------------*/
usb_buf[0x09] = color_0_red;
usb_buf[0x0A] = color_0_green;
usb_buf[0x0B] = color_0_blue;
usb_buf[0x0C] = color_1_red;
usb_buf[0x0D] = color_1_green;
usb_buf[0x0E] = color_1_blue;
usb_buf[0x0F] = color_2_red;
usb_buf[0x10] = color_2_green;
usb_buf[0x11] = color_2_blue;
usb_buf[0x0A] = color_0_red;
usb_buf[0x0B] = color_0_green;
usb_buf[0x0C] = color_0_blue;
usb_buf[0x0D] = color_1_red;
usb_buf[0x0E] = color_1_green;
usb_buf[0x0F] = color_1_blue;
usb_buf[0x10] = color_2_red;
usb_buf[0x11] = color_2_green;
usb_buf[0x12] = color_2_blue;
/*-----------------------------------------------------*\
| Set up temperatures |
\*-----------------------------------------------------*/
usb_buf[0x12] = (temperature_0 >> 8);
usb_buf[0x13] = (temperature_0 & 0xFF);
usb_buf[0x14] = (temperature_1 >> 8);
usb_buf[0x15] = (temperature_1 & 0xFF);
usb_buf[0x16] = (temperature_2 >> 8);
usb_buf[0x17] = (temperature_2 & 0xFF);
usb_buf[0x13] = (temperature_0 >> 8);
usb_buf[0x14] = (temperature_0 & 0xFF);
usb_buf[0x15] = (temperature_1 >> 8);
usb_buf[0x16] = (temperature_1 & 0xFF);
usb_buf[0x17] = (temperature_2 >> 8);
usb_buf[0x18] = (temperature_2 & 0xFF);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendTemperature()
@ -398,7 +403,7 @@ void CorsairLightingNodeController::SendReset
unsigned char channel
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -408,14 +413,15 @@ void CorsairLightingNodeController::SendReset
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
usb_buf[0x01] = channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
usb_buf[0x02] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendPortState
@ -424,7 +430,7 @@ void CorsairLightingNodeController::SendPortState
unsigned char state
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -434,15 +440,16 @@ void CorsairLightingNodeController::SendPortState
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
usb_buf[0x02] = channel;
usb_buf[0x03] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendBrightness()

View file

@ -24,20 +24,6 @@ static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x
static unsigned int st100[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, 0x04 };
static void send_usb_msg(hid_device* dev, char * data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
bytes++;
std::this_thread::sleep_for(1ms);
}
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
{
dev = dev_handle;
@ -233,7 +219,7 @@ void CorsairPeripheralController::SetLEDsKeyboardLimited(std::vector<RGBColor> c
void CorsairPeripheralController::LightingControl()
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -243,9 +229,10 @@ void CorsairPeripheralController::LightingControl()
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x03] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Lighting control byte needs to be 3 for keyboards and |
@ -255,31 +242,31 @@ void CorsairPeripheralController::LightingControl()
{
default:
case DEVICE_TYPE_KEYBOARD:
usb_buf[0x04] = 0x03;
usb_buf[0x05] = 0x03;
break;
case DEVICE_TYPE_MOUSE:
usb_buf[0x04] = 0x01;
usb_buf[0x05] = 0x01;
break;
case DEVICE_TYPE_MOUSEMAT:
usb_buf[0x04] = 0x04;
usb_buf[0x05] = 0x04;
break;
case DEVICE_TYPE_HEADSET_STAND:
usb_buf[0x04] = 0x03;
usb_buf[0x05] = 0x03;
break;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SpecialFunctionControl()
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -289,20 +276,22 @@ void CorsairPeripheralController::SpecialFunctionControl()
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SPECIAL_FUNCTION;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SPECIAL_FUNCTION;
usb_buf[0x03] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::ReadFirmwareInfo()
{
int actual;
char usb_buf[64];
char usb_buf[65];
char offset = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
@ -312,16 +301,17 @@ void CorsairPeripheralController::ReadFirmwareInfo()
/*-----------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_READ;
usb_buf[0x02] = CORSAIR_PROPERTY_FIRMWARE_INFO;
/*-----------------------------------------------------*\
| Send packet and try reading it using an HID read |
| If that fails, repeat the send and read the reply as |
| a feature report. |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char*)usb_buf, 64);
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 64, 1000);
hid_write(dev, (unsigned char*)usb_buf, 65);
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 65, 1000);
if(actual == 0)
{
@ -333,11 +323,13 @@ void CorsairPeripheralController::ReadFirmwareInfo()
/*-------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_READ;
usb_buf[0x02] = CORSAIR_PROPERTY_FIRMWARE_INFO;
hid_write(dev, (unsigned char*)usb_buf, 64);
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 64);
hid_send_feature_report(dev, (unsigned char*)usb_buf, 65);
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 65);
offset = 1;
}
/*-----------------------------------------------------*\
@ -346,7 +338,7 @@ void CorsairPeripheralController::ReadFirmwareInfo()
| 0xC1 Device is a mouse |
| 0xC2 Device is a mousepad or headset stand |
\*-----------------------------------------------------*/
switch((unsigned char)usb_buf[0x14])
switch((unsigned char)usb_buf[0x14 + offset])
{
case 0xC0:
type = DEVICE_TYPE_KEYBOARD;
@ -383,7 +375,7 @@ void CorsairPeripheralController::ReadFirmwareInfo()
\*-----------------------------------------------------*/
if(type != DEVICE_TYPE_UNKNOWN)
{
firmware_version = std::to_string(usb_buf[0x09]) + "." + std::to_string(usb_buf[0x08]);
firmware_version = std::to_string(usb_buf[0x09 + offset]) + "." + std::to_string(usb_buf[0x08 + offset]);
}
}
@ -394,7 +386,7 @@ void CorsairPeripheralController::StreamPacket
unsigned char* data_ptr
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -404,19 +396,20 @@ void CorsairPeripheralController::StreamPacket
/*-----------------------------------------------------*\
| Set up Stream packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
usb_buf[0x01] = packet_id;
usb_buf[0x02] = data_sz;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_STREAM;
usb_buf[0x02] = packet_id;
usb_buf[0x03] = data_sz;
/*-----------------------------------------------------*\
| Copy in data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], data_ptr, data_sz);
memcpy(&usb_buf[0x05], data_ptr, data_sz);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitKeyboardFullColors
@ -426,7 +419,7 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
unsigned char finish_val
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -436,16 +429,17 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
/*-----------------------------------------------------*\
| Set up Submit Keyboard 24-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
usb_buf[0x02] = color_channel;
usb_buf[0x03] = packet_count;
usb_buf[0x04] = finish_val;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
usb_buf[0x03] = color_channel;
usb_buf[0x04] = packet_count;
usb_buf[0x05] = finish_val;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitKeyboardLimitedColors
@ -453,7 +447,7 @@ void CorsairPeripheralController::SubmitKeyboardLimitedColors
unsigned char byte_count
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -463,14 +457,15 @@ void CorsairPeripheralController::SubmitKeyboardLimitedColors
/*-----------------------------------------------------*\
| Set up Submit Keyboard 9-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x04] = byte_count;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x05] = byte_count;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitMouseColors
@ -479,7 +474,7 @@ void CorsairPeripheralController::SubmitMouseColors
RGBColor * color_data
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -489,26 +484,27 @@ void CorsairPeripheralController::SubmitMouseColors
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x03] = num_zones;
usb_buf[0x04] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <ZONE> <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
usb_buf[(zone_idx * 4) + 4] = zone_idx;
usb_buf[(zone_idx * 4) + 5] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 6] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 7] = RGBGetBValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 5] = zone_idx;
usb_buf[(zone_idx * 4) + 6] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 7] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 8] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitMousematColors
@ -517,7 +513,7 @@ void CorsairPeripheralController::SubmitMousematColors
RGBColor * color_data
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -527,24 +523,25 @@ void CorsairPeripheralController::SubmitMousematColors
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x03] = num_zones;
usb_buf[0x04] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
usb_buf[(zone_idx * 3) + 4] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 5] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 6] = RGBGetBValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 5] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 6] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 7] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet using feature reports, as headset stand |
| seems to not update completely using HID writes |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}

View file

@ -130,30 +130,30 @@ void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_control
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
#ifdef USE_HID_USAGE
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
&&(info->usage_page == 0xFFC2))
#else
&&(info->product_id == device_list[device_idx].usb_pid))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
}
info = info->next;
}
}
}

View file

@ -29,9 +29,14 @@ void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controller
//Look for Glorious Model O
while(info)
{
if((info->vendor_id == Glorious_Model_O_VID)
&&(info->product_id == Glorious_Model_O_PID)
if((info->vendor_id == Glorious_Model_O_VID)
&&(info->product_id == Glorious_Model_O_PID)
#ifdef USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF00))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;

View file

@ -58,41 +58,50 @@ void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controller
//Look for HyperX RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
if((device_list[device_idx].usb_pid != HYPERX_ALLOY_ORIGINS_PID)
&&(info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF01))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
if( dev )
{
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
if((device_list[device_idx].usb_pid == HYPERX_ALLOY_ORIGINS_PID)
&&(info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
{
dev = hid_open_path(info->path);
break;
if( dev )
{
HyperXAlloyOriginsController* controller = new HyperXAlloyOriginsController(dev);
RGBController_HyperXAlloyOrigins* rgb_controller = new RGBController_HyperXAlloyOrigins(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
if(device_list[device_idx].usb_pid == HYPERX_ALLOY_ORIGINS_PID)
{
HyperXAlloyOriginsController* controller = new HyperXAlloyOriginsController(dev);
RGBController_HyperXAlloyOrigins* rgb_controller = new RGBController_HyperXAlloyOrigins(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
else
{
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
info = info->next;
}
}
}

View file

@ -65,78 +65,132 @@ static const logitech_device device_list[] =
void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
for(int device_idx = 0; device_idx < LOGITECH_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Logitech RGB Peripheral
while(info)
switch(device_list[device_idx].type)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
/*-------------------------------------------------------------------------------------------------*\
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
\*-------------------------------------------------------------------------------------------------*/
case DEVICE_TYPE_KEYBOARD:
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF43)
&&(info->usage == 0x0602))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
LogitechG810Controller* controller = new LogitechG810Controller(dev);
hid_device* dev_usage_0x0602 = hid_open_path(info->path);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
switch(device_list[device_idx].usb_pid)
{
case LOGITECH_G203_PID:
if(dev_usage_0x0602)
{
LogitechG203Controller* controller = new LogitechG203Controller(dev);
#ifdef USE_HID_USAGE
hid_device_info* tmp_info_0x0604 = info;
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G403_PID:
case LOGITECH_G403H_PID:
{
LogitechG403Controller* controller = new LogitechG403Controller(dev);
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
while(tmp_info_0x0604)
{
if((tmp_info_0x0604->vendor_id == device_list[device_idx].usb_vid)
&&(tmp_info_0x0604->product_id == device_list[device_idx].usb_pid)
&&(tmp_info_0x0604->interface_number == device_list[device_idx].usb_interface)
&&(tmp_info_0x0604->usage_page == 0xFF43)
&&(tmp_info_0x0604->usage == 0x0604))
{
hid_device* dev_usage_0x0604 = hid_open_path(tmp_info_0x0604->path);
if(dev_usage_0x0604)
{
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
tmp_info_0x0604 = tmp_info_0x0604->next;
}
#else
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0602);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
#endif
}
}
}
break;
info = info->next;
}
hid_free_enumeration(info);
}
break;
/*-------------------------------------------------------------------------------------------------*\
| Logitech mice use a single usage on page 0xFF00 |
\*-------------------------------------------------------------------------------------------------*/
case DEVICE_TYPE_MOUSE:
{
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF00)
&&(info->usage == 2))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
switch(device_list[device_idx].usb_pid)
{
case LOGITECH_G203_PID:
{
LogitechG203Controller* controller = new LogitechG203Controller(dev);
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G403_PID:
case LOGITECH_G403H_PID:
{
LogitechG403Controller* controller = new LogitechG403Controller(dev);
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
}
}
info = info->next;
}
hid_free_enumeration(info);
}
break;
}
hid_free_enumeration(info);
}
}

View file

@ -10,9 +10,10 @@
#include "LogitechG810Controller.h"
#include <cstring>
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle)
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12)
{
dev = dev_handle;
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
}
LogitechG810Controller::~LogitechG810Controller()
@ -74,8 +75,8 @@ void LogitechG810Controller::SendCommit()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
void LogitechG810Controller::SendDirectFrame
@ -110,8 +111,8 @@ void LogitechG810Controller::SendDirectFrame
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x12, (unsigned char *)usb_buf, 64);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
void LogitechG810Controller::SendMode
@ -163,6 +164,6 @@ void LogitechG810Controller::SendMode
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}

View file

@ -49,7 +49,7 @@ enum
class LogitechG810Controller
{
public:
LogitechG810Controller(hid_device* dev_handle);
LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12);
~LogitechG810Controller();
void Commit();
@ -71,7 +71,8 @@ public:
);
private:
hid_device* dev;
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
void SendDirectFrame
(

View file

@ -30,23 +30,25 @@ void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers)
{
if((info->vendor_id == TT_POSEIDON_Z_RGB_VID)
&&(info->product_id == TT_POSEIDON_Z_RGB_PID)
&&(info->interface_number == 2))
#ifdef USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF01))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
if( dev )
{
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
rgb_controllers.push_back(rgb_controller);
}
}

View file

@ -10,6 +10,7 @@
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_KEYBOARD_VID 0x0C45
#define REDRAGON_KEYBOARD_USAGE_PAGE 0xFF1C
#define REDRAGON_K550_PID 0x5204
#define REDRAGON_K552_PID 0x5104
#define REDRAGON_K556_PID 0x5004
@ -20,6 +21,7 @@
| Mouse product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_MOUSE_VID 0x04D9
#define REDRAGON_MOUSE_USAGE_PAGE 0xFFA0
#define REDRAGON_M711_PID 0xFC30
#define REDRAGON_M715_PID 0xFC39
@ -28,6 +30,7 @@ typedef struct
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
unsigned short usb_usage_page;
device_type type;
const char * name;
} redragon_device;
@ -36,22 +39,22 @@ typedef struct
static const redragon_device device_list[] =
{
/*-------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mice |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
};
/******************************************************************************************\
@ -78,45 +81,46 @@ void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
//Look for Redragon RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == device_list[device_idx].usb_usage_page))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
if( dev )
{
switch(device_list[device_idx].type)
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
case DEVICE_TYPE_KEYBOARD:
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
info = info->next;
}
}
}

View file

@ -2,21 +2,6 @@
#include <cstring>
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
{
char* usb_pkt = new char[size + 1];
usb_pkt[0] = 0x00;
for(int i = 1; i < size + 1; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
hid_send_feature_report(dev, (unsigned char *)usb_pkt, size + 1);
delete usb_pkt;
}
RedragonM711Controller::RedragonM711Controller(hid_device* dev_handle)
{
dev = dev_handle;
@ -103,7 +88,7 @@ void RedragonM711Controller::SendMouseApply()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
hid_send_feature_report(dev, (unsigned char *)usb_buf, 16);
}
void RedragonM711Controller::SendWritePacket
@ -137,5 +122,5 @@ void RedragonM711Controller::SendWritePacket
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
hid_send_feature_report(dev, (unsigned char *)usb_buf, 16);
}

View file

@ -52,7 +52,7 @@ void ThermaltakeRiingController::SetMode(unsigned char mode, unsigned char speed
void ThermaltakeRiingController::SendInit()
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -62,14 +62,15 @@ void ThermaltakeRiingController::SendInit()
/*-----------------------------------------------------*\
| Set up Init packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xFE;
usb_buf[0x01] = 0x33;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xFE;
usb_buf[0x02] = 0x33;
/*-----------------------------------------------------*\
| 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
@ -81,7 +82,7 @@ void ThermaltakeRiingController::SendRGB
unsigned char* color_data
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@ -91,19 +92,20 @@ void ThermaltakeRiingController::SendRGB
/*-----------------------------------------------------*\
| Set up RGB packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x32;
usb_buf[0x01] = 0x52;
usb_buf[0x02] = port;
usb_buf[0x03] = mode + ( speed & 0x03 );
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x32;
usb_buf[0x02] = 0x52;
usb_buf[0x03] = port;
usb_buf[0x04] = mode + ( speed & 0x03 );
/*-----------------------------------------------------*\
| Copy in GRB color data |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], color_data, (num_colors * 3));
memcpy(&usb_buf[0x05], color_data, (num_colors * 3));
/*-----------------------------------------------------*\
| 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);
}

View file

@ -387,7 +387,7 @@ win32:INCLUDEPATH += \
wmi/ \
win32:SOURCES += \
dependencies/hidapi/hidapi.c \
# dependencies/hidapi/hidapi.c \
dependencies/NVFC/nvapi.cpp \
i2c_smbus/i2c_smbus_amdadl.cpp \
i2c_smbus/i2c_smbus_i801.cpp \
@ -417,6 +417,7 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \
-L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x64/" -lhidapi \
}
win32:contains(QMAKE_TARGET.arch, x86) {
@ -424,17 +425,19 @@ win32:contains(QMAKE_TARGET.arch, x86) {
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi \
}
win32:DEFINES -= \
UNICODE
win32:DEFINES += \
USE_HID_USAGE \
_MBCS \
WIN32 \
_CRT_SECURE_NO_WARNINGS \
_WINSOCK_DEPRECATED_NO_WARNINGS \
WIN32_LEAN_AND_MEAN
WIN32_LEAN_AND_MEAN \
win32:RC_ICONS += \
qt/OpenRGB.ico
@ -463,6 +466,7 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/x64/inpoutx64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS64/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/hidapi-win/x64/hidapi.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
@ -473,6 +477,7 @@ win32:contains(QMAKE_TARGET.arch, x86) {
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/Win32/inpout32.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS32/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/hidapi-win/x86/hidapi.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
first.depends = $(first) copydata
export(first.depends)

BIN
dependencies/hidapi-win/x64/hidapi.dll vendored Normal file

Binary file not shown.

BIN
dependencies/hidapi-win/x64/hidapi.lib vendored Normal file

Binary file not shown.

BIN
dependencies/hidapi-win/x86/hidapi.dll vendored Normal file

Binary file not shown.

BIN
dependencies/hidapi-win/x86/hidapi.lib vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.