diff --git a/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp b/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp index cf5f25c84..92a2a8071 100644 --- a/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp +++ b/Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp @@ -101,18 +101,28 @@ void EVisionKeyboardController::SendKeyboardModeEx unsigned char blue ) { - unsigned char parameter_data[8]; - - parameter_data[0] = mode; - parameter_data[1] = brightness; - parameter_data[2] = speed; - parameter_data[3] = direction; - parameter_data[4] = random_flag; - parameter_data[5] = red; - parameter_data[6] = green; - parameter_data[7] = blue; - - SendKeyboardParameter(0, 8, parameter_data); + /*-----------------------------------------------------*\ + | Build 27-byte compound parameter (param_id = 0x00) | + | as observed in Windows firmware captures | + \*-----------------------------------------------------*/ + unsigned char profile[27]; + + memset(profile, 0x00, sizeof(profile)); + profile[0] = 0x00; /* profile index */ + profile[1] = mode; + profile[2] = brightness; + profile[3] = speed; + profile[4] = direction; + profile[5] = random_flag; + profile[6] = red; + profile[7] = green; + profile[8] = blue; + profile[18] = 0x03; + profile[22] = 0x03; + + SendKeyboardBegin(); + SendKeyboardParameter(EVISION_KB_PARAMETER_MODE, sizeof(profile), profile); + SendKeyboardEnd(); } /*-------------------------------------------------------------------------------------------------*\ @@ -158,7 +168,7 @@ void EVisionKeyboardController::SendKeyboardBegin() | Send packet | \*-----------------------------------------------------*/ hid_write(dev, (unsigned char *)usb_buf, 64); - hid_read(dev, (unsigned char *)usb_buf, 64); + hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100); } void EVisionKeyboardController::SendKeyboardEnd() @@ -184,14 +194,14 @@ void EVisionKeyboardController::SendKeyboardEnd() | Send packet | \*-----------------------------------------------------*/ hid_write(dev, (unsigned char *)usb_buf, 64); - hid_read(dev, (unsigned char *)usb_buf, 64); + hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100); } void EVisionKeyboardController::SendKeyboardData ( unsigned char * data, unsigned char data_size, - unsigned short data_offset + unsigned int data_offset ) { char usb_buf[64]; @@ -202,14 +212,15 @@ void EVisionKeyboardController::SendKeyboardData memset(usb_buf, 0x00, sizeof(usb_buf)); /*-----------------------------------------------------*\ - | Set up Keyboard Color Data (0x11) packet | + | Set up Keyboard Color Data (0x12) packet | \*-----------------------------------------------------*/ usb_buf[0x00] = 0x04; - usb_buf[0x03] = 0x11; + usb_buf[0x03] = 0x12; usb_buf[0x04] = data_size; - usb_buf[0x05] = data_offset & 0x00FF; - usb_buf[0x06] = data_offset >> 8; + usb_buf[0x05] = data_offset & 0xFF; + usb_buf[0x06] = (data_offset >> 8) & 0xFF; + usb_buf[0x07] = (data_offset >> 16) & 0xFF; /*-----------------------------------------------------*\ | Copy in data bytes | @@ -225,7 +236,7 @@ void EVisionKeyboardController::SendKeyboardData | Send packet | \*-----------------------------------------------------*/ hid_write(dev, (unsigned char *)usb_buf, 64); - hid_read(dev, (unsigned char *)usb_buf, 64); + hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100); } void EVisionKeyboardController::SendKeyboardParameter @@ -264,5 +275,5 @@ void EVisionKeyboardController::SendKeyboardParameter | Send packet | \*-----------------------------------------------------*/ hid_write(dev, (unsigned char *)usb_buf, 64); - hid_read(dev, (unsigned char *)usb_buf, 64); + hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100); } diff --git a/Controllers/EVisionKeyboardController/EVisionKeyboardController.h b/Controllers/EVisionKeyboardController/EVisionKeyboardController.h index d8f5d1c4a..f689c1b29 100644 --- a/Controllers/EVisionKeyboardController/EVisionKeyboardController.h +++ b/Controllers/EVisionKeyboardController/EVisionKeyboardController.h @@ -16,7 +16,7 @@ #include #include "RGBController.h" -#define EVISION_KB_MAX_PACKET_SIZE ( 0x36 )/* max packet size for color*/ +#define EVISION_KB_MAX_PACKET_SIZE ( 0x38 )/* max packet size for color*/ /* update packets */ enum { @@ -130,7 +130,7 @@ class EVisionKeyboardController ( unsigned char * data, unsigned char data_size, - unsigned short data_offset + unsigned int data_offset ); void SendKeyboardEnd(); diff --git a/Controllers/EVisionKeyboardController/RGBController_EVisionKeyboard.cpp b/Controllers/EVisionKeyboardController/RGBController_EVisionKeyboard.cpp index bba253290..b20dda402 100644 --- a/Controllers/EVisionKeyboardController/RGBController_EVisionKeyboard.cpp +++ b/Controllers/EVisionKeyboardController/RGBController_EVisionKeyboard.cpp @@ -322,9 +322,9 @@ void RGBController_EVisionKeyboard::SetupZones() new_zone.name = "Keyboard"; new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = 126; - new_zone.leds_max = 126; - new_zone.leds_count = 126; + new_zone.leds_min = 128; + new_zone.leds_max = 128; + new_zone.leds_count = 128; new_zone.matrix_map = new matrix_map_type; new_zone.matrix_map->height = 6; new_zone.matrix_map->width = 23; @@ -332,7 +332,7 @@ void RGBController_EVisionKeyboard::SetupZones() zones.push_back(new_zone); - for(int led_idx = 0; led_idx < 126; led_idx++) + for(int led_idx = 0; led_idx < 128; led_idx++) { led new_led; @@ -354,9 +354,9 @@ void RGBController_EVisionKeyboard::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_EVisionKeyboard::DeviceUpdateLEDs() { - unsigned char color_data[7*0x36]; + unsigned char color_data[128 * 3]; - for(int led_idx = 0; led_idx < 126; led_idx++) + for(int led_idx = 0; led_idx < 128; led_idx++) { color_data[(3 * led_idx) + 0] = RGBGetRValue(colors[led_idx]); color_data[(3 * led_idx) + 1] = RGBGetGValue(colors[led_idx]); @@ -366,7 +366,7 @@ void RGBController_EVisionKeyboard::DeviceUpdateLEDs() controller->SetKeyboardColors ( color_data, - 0x36 * 7 + 128 * 3 ); }