diff --git a/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp b/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp index dd5304f7..c4ea1c23 100644 --- a/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp +++ b/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp @@ -31,7 +31,7 @@ static unsigned int keys_k95_plat[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115, 116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 139, 140, 141, - 0x10, 114, 0x0a, 0x16, 0x22, 0x2e, 0x3a, 0x46, + 0x10, 114, 0x0a, 0x16, 0x22, 0x2e, 0x3a, 0x46, 125, 144, 145, 146, 158, 160, 147, 148, 149, 150, 151, 152, 153, 154, 155, 159, 162, 161, 156, 157}; @@ -55,7 +55,20 @@ CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle, ReadFirmwareInfo(); + /*-----------------------------------------------------*\ + | K95 Platinum requires additional steps | + \*-----------------------------------------------------*/ + if (logical_layout == CORSAIR_TYPE_K95_PLAT) + { + SpecialFunctionControl(); + } + LightingControl(); + + if (logical_layout == CORSAIR_TYPE_K95_PLAT) + { + SetupK95LightingControl(); + } } CorsairPeripheralController::~CorsairPeripheralController() @@ -328,7 +341,7 @@ void CorsairPeripheralController::LightingControl() { default: case DEVICE_TYPE_KEYBOARD: - usb_buf[0x05] = 0x03; + usb_buf[0x05] = 0x03; // On K95 Platinum, this controls keyboard brightness break; case DEVICE_TYPE_MOUSE: @@ -350,6 +363,70 @@ void CorsairPeripheralController::LightingControl() hid_write(dev, (unsigned char *)usb_buf, 65); } +/*-----------------------------------------------------*\ +| Probably a key mapping packet? | +\*-----------------------------------------------------*/ + +void CorsairPeripheralController::SetupK95LightingControl() +{ + char usb_buf[65]; + + /*-----------------------------------------------------*\ + | Zero out buffer | + \*-----------------------------------------------------*/ + memset(usb_buf, 0x00, sizeof(usb_buf)); + + /*-----------------------------------------------------*\ + | Set up a packet | + \*-----------------------------------------------------*/ + usb_buf[0x00] = 0x00; + usb_buf[0x01] = CORSAIR_COMMAND_WRITE; + usb_buf[0x02] = CORSAIR_PROPERTY_LIGHTING_CONTROL; + usb_buf[0x03] = 0x08; + + usb_buf[0x05] = 0x01; + + /*-----------------------------------------------------*\ + | Send packet | + \*-----------------------------------------------------*/ + hid_write(dev, (unsigned char *)usb_buf, 65); + + int identifier = 0; + for (int i = 0; i < 4; i++) + { + /*-----------------------------------------------------*\ + | Zero out buffer | + \*-----------------------------------------------------*/ + memset(usb_buf, 0x00, sizeof(usb_buf)); + + /*-----------------------------------------------------*\ + | Set up a packet - a sequence of 120 ids | + \*-----------------------------------------------------*/ + usb_buf[0x00] = 0x00; + usb_buf[0x01] = CORSAIR_COMMAND_WRITE; + usb_buf[0x02] = 0x40; + usb_buf[0x03] = 0x1E; + + for (int j = 0; j < 30; j++) + { + while (identifier == 0x31 || identifier == 0x41 || identifier == 0x42 || identifier == 0x48 + || identifier == 0x49 || identifier == 0x51 || identifier == 0x55 || identifier == 0x6f + || identifier == 0x7e || identifier == 0x7f || identifier == 0x80 || identifier == 0x81) + { + identifier++; + } + + usb_buf[5 + 2 * j] = identifier++; + usb_buf[5 + 2 * j + 1] = 0xC0; + } + + /*-----------------------------------------------------*\ + | Send packet | + \*-----------------------------------------------------*/ + hid_write(dev, (unsigned char *)usb_buf, 65); + } +} + void CorsairPeripheralController::SpecialFunctionControl() { char usb_buf[65]; diff --git a/Controllers/CorsairPeripheralController/CorsairPeripheralController.h b/Controllers/CorsairPeripheralController/CorsairPeripheralController.h index 611361d3..58f7cf69 100644 --- a/Controllers/CorsairPeripheralController/CorsairPeripheralController.h +++ b/Controllers/CorsairPeripheralController/CorsairPeripheralController.h @@ -97,6 +97,7 @@ private: int logical_layout; //Normal, K95 or K95 Platinum void LightingControl(); + void SetupK95LightingControl(); void SpecialFunctionControl(); void ReadFirmwareInfo(); diff --git a/Controllers/CorsairPeripheralController/RGBController_CorsairPeripheral.cpp b/Controllers/CorsairPeripheralController/RGBController_CorsairPeripheral.cpp index 60f6c668..f61f33ff 100644 --- a/Controllers/CorsairPeripheralController/RGBController_CorsairPeripheral.cpp +++ b/Controllers/CorsairPeripheralController/RGBController_CorsairPeripheral.cpp @@ -21,7 +21,7 @@ static unsigned int matrix_map[6][23] = { 5, 14, 23, NA, NA, NA, NA, 41, NA, NA, NA, NA, 69, 79, 89, 71, 90, 99, 108, 101, NA, 110, NA } }; static unsigned int matrix_map_k95_platinum[7][24] = - { { NA, NA, NA, NA, 107, 8, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 16, NA, NA, NA,}, + { { NA, NA, NA, 119, 107, 8, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 16, NA, NA, NA,}, { 113, 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 }, { 114, 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 }, { 115, 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 }, @@ -67,7 +67,7 @@ static const char* zone_names_k95_platinum[] = static const unsigned int zone_sizes_k95_platinum[] = { - 119, + 120, 19 }; @@ -357,6 +357,7 @@ static const char* led_names_k95_plat[] = "Key: Macro G4", "Key: Macro G5", "Key: Macro G6", + "Key: Preset", "Light Bar 1", "Light Bar 2", "Light Bar 3",