diff --git a/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp b/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp index b6e19e57..ce3ccc7b 100644 --- a/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp +++ b/Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp @@ -22,6 +22,30 @@ static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x 116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 139, 140, 141}; + +static unsigned int keys_k95_plat[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12, + 0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26, + 0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78, + 79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97, + 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, + 144, 145, 146, 158, 160, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 159, 162, 161, 156, 157}; + +static unsigned int keys_k95[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12, + 0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26, + 0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78, + 79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97, + 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, 0x52, 0x5e, 0x6a, 0x76, 0x3b, 0x47, 0x53, + 0x5f, 0x6b, 0x77, 0x83, 0x8f, 0x0b, 0x17, 0x23, 0x2f}; + static unsigned int st100[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, 0x04 }; CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle) @@ -43,6 +67,16 @@ device_type CorsairPeripheralController::GetDeviceType() return type; } +int CorsairPeripheralController::GetPhysicalLayout() +{ + return physical_layout; +} + +int CorsairPeripheralController::GetLogicalLayout() +{ + return logical_layout; +} + std::string CorsairPeripheralController::GetFirmwareString() { return firmware_version; @@ -88,9 +122,9 @@ void CorsairPeripheralController::SetLEDs(std::vectorcolors) void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector colors) { - unsigned char red_val[144]; - unsigned char grn_val[144]; - unsigned char blu_val[144]; + unsigned char red_val[168]; + unsigned char grn_val[168]; + unsigned char blu_val[168]; /*-----------------------------------------------------*\ | Zero out buffers | @@ -105,9 +139,24 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector colo for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++) { RGBColor color = colors[color_idx]; - red_val[keys[color_idx]] = RGBGetRValue(color); - grn_val[keys[color_idx]] = RGBGetGValue(color); - blu_val[keys[color_idx]] = RGBGetBValue(color); + if (logical_layout == CORSAIR_TYPE_K95_PLAT) + { + red_val[keys_k95_plat[color_idx]] = RGBGetRValue(color); + grn_val[keys_k95_plat[color_idx]] = RGBGetGValue(color); + blu_val[keys_k95_plat[color_idx]] = RGBGetBValue(color); + } + else if (logical_layout == CORSAIR_TYPE_K95) + { + red_val[keys_k95[color_idx]] = RGBGetRValue(color); + grn_val[keys_k95[color_idx]] = RGBGetGValue(color); + blu_val[keys_k95[color_idx]] = RGBGetBValue(color); + } + else + { + red_val[keys[color_idx]] = RGBGetRValue(color); + grn_val[keys[color_idx]] = RGBGetGValue(color); + blu_val[keys[color_idx]] = RGBGetBValue(color); + } } /*-----------------------------------------------------*\ @@ -115,7 +164,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector colo \*-----------------------------------------------------*/ StreamPacket(1, 60, &red_val[0]); StreamPacket(2, 60, &red_val[60]); - StreamPacket(3, 24, &red_val[120]); + StreamPacket(3, 48, &red_val[120]); SubmitKeyboardFullColors(1, 3, 1); /*-----------------------------------------------------*\ @@ -123,7 +172,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector colo \*-----------------------------------------------------*/ StreamPacket(1, 60, &grn_val[0]); StreamPacket(2, 60, &grn_val[60]); - StreamPacket(3, 24, &grn_val[120]); + StreamPacket(3, 48, &grn_val[120]); SubmitKeyboardFullColors(2, 3, 1); /*-----------------------------------------------------*\ @@ -131,7 +180,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector colo \*-----------------------------------------------------*/ StreamPacket(1, 60, &blu_val[0]); StreamPacket(2, 60, &blu_val[60]); - StreamPacket(3, 24, &blu_val[120]); + StreamPacket(3, 48, &blu_val[120]); SubmitKeyboardFullColors(3, 3, 2); } @@ -286,6 +335,7 @@ void CorsairPeripheralController::SpecialFunctionControl() hid_write(dev, (unsigned char *)usb_buf, 65); } + void CorsairPeripheralController::ReadFirmwareInfo() { int actual; @@ -340,6 +390,23 @@ void CorsairPeripheralController::ReadFirmwareInfo() switch((unsigned char)usb_buf[0x14 + offset]) { case 0xC0: + { + unsigned short pid = (unsigned short)(usb_buf[0x0F] << 8) + (unsigned char)(usb_buf[0x0E]); + + switch(pid) + { + case 0x2D1B: + logical_layout = CORSAIR_TYPE_K95_PLAT; + break; + + case 0x1B11: + logical_layout = CORSAIR_TYPE_K95; + break; + + default: + logical_layout = CORSAIR_TYPE_NORMAL; + } + } type = DEVICE_TYPE_KEYBOARD; break; @@ -379,6 +446,21 @@ void CorsairPeripheralController::ReadFirmwareInfo() { firmware_version = std::to_string(usb_buf[0x09 + offset]) + "." + std::to_string(usb_buf[0x08 + offset]); } + + /*-----------------------------------------------------*\ + | Get the correct Keyboard Layout | + \*-----------------------------------------------------*/ + switch((unsigned char)usb_buf[0x17 + offset]) + { + case CORSAIR_LAYOUT_ANSI: + physical_layout = CORSAIR_LAYOUT_ANSI; + break; + case CORSAIR_LAYOUT_ISO: + physical_layout = CORSAIR_LAYOUT_ISO; + break; + default: + physical_layout = CORSAIR_LAYOUT_ANSI; + } } void CorsairPeripheralController::StreamPacket diff --git a/Controllers/CorsairPeripheralController/CorsairPeripheralController.h b/Controllers/CorsairPeripheralController/CorsairPeripheralController.h index d810dcc4..8bc9c551 100644 --- a/Controllers/CorsairPeripheralController/CorsairPeripheralController.h +++ b/Controllers/CorsairPeripheralController/CorsairPeripheralController.h @@ -47,12 +47,30 @@ enum CORSAIR_COLOR_CHANNEL_BLUE = 0x03 }; +enum +{ + CORSAIR_LAYOUT_ANSI = 0x00, + CORSAIR_LAYOUT_ISO = 0x01, + CORSAIR_LAYOUT_ABNT = 0x02, + CORSAIR_LAYOUT_JIS = 0x03, + CORSAIR_LAYOUT_DUBEOLSIK = 0x04 +}; + +enum +{ + CORSAIR_TYPE_NORMAL = 0, + CORSAIR_TYPE_K95_PLAT = 1, + CORSAIR_TYPE_K95 = 2 +}; + class CorsairPeripheralController { public: CorsairPeripheralController(hid_device* dev_handle); ~CorsairPeripheralController(); + int GetLogicalLayout(); + int GetPhysicalLayout(); device_type GetDeviceType(); std::string GetFirmwareString(); @@ -67,6 +85,8 @@ private: std::string firmware_version; device_type type; + int physical_layout; //ANSI, ISO, etc. + int logical_layout; //Normal, K95 or K95 Platinum void LightingControl(); void SpecialFunctionControl(); diff --git a/RGBController/RGBController_CorsairPeripheral.cpp b/RGBController/RGBController_CorsairPeripheral.cpp index 05488e9d..9d66fa57 100644 --- a/RGBController/RGBController_CorsairPeripheral.cpp +++ b/RGBController/RGBController_CorsairPeripheral.cpp @@ -16,25 +16,86 @@ static unsigned int matrix_map[6][23] = { { 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 }, { 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 }, { 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 }, - { 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, NA, NA, NA, NA, 45, 54, 63, NA }, - { 4, NA, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 }, + { 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, 112, NA, NA, NA, 45, 54, 63, NA }, + { 4, 111, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 }, { 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,}, + { 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 }, + { 116, 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, 112, NA, NA, NA, 45, 54, 63, NA }, + { 117, 4, 111, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 }, + { 118, 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[7][26] = + { { NA, NA, NA, 131, 132, 133, 134, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 107, 8, NA, NA, 16, NA, NA,}, + { 113, 114, 115, 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 }, + { 116, 117, 118, 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 }, + { 119, 120, 121, 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 }, + { 122, 123, 124, 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, 112, NA, NA, NA, 45, 54, 63, NA }, + { 125, 126, 127, 4, 111, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 }, + { 128, 129, 130, 5, 14, 23, NA, NA, NA, NA, 41, NA, NA, NA, NA, 69, 79, 89, 71, 90, 99, 108, 101, NA, 110, NA } }; + +/*---------------------------------------------------------*\ +| Normal Corsair Layout | +\*---------------------------------------------------------*/ static const char* zone_names[] = { - "Keyboard" + "Keyboard", }; static const unsigned int zone_sizes[] = { - 111 + 113 }; static const zone_type zone_types[] = +{ + ZONE_TYPE_MATRIX, +}; + +/*---------------------------------------------------------*\ +| K95 Platinum | +\*---------------------------------------------------------*/ +static const char* zone_names_k95_platinum[] = +{ + "Keyboard", + "Light Bar" +}; + +static const unsigned int zone_sizes_k95_platinum[] = +{ + 119, + 19 +}; + +static const zone_type zone_types_k95_platinum[] = +{ + ZONE_TYPE_MATRIX, + ZONE_TYPE_LINEAR +}; + +/*---------------------------------------------------------*\ +| K95 non-Platinum | +\*---------------------------------------------------------*/ +static const char* zone_names_k95[] = +{ + "Keyboard", +}; + +static const unsigned int zone_sizes_k95[] = +{ + 135 +}; + +static const zone_type zone_types_k95[] = { ZONE_TYPE_MATRIX }; + static const char* led_names[] = { "Key: Escape", //0 @@ -148,6 +209,289 @@ static const char* led_names[] = "Key: Right Arrow", //139 "Key: Number Pad Enter",//140 "Key: Number Pad .", //141 + "Key: / (ISO)", + "Key: \\ (ISO)", +}; + +static const char* led_names_k95_plat[] = +{ + "Key: Escape", //0 + "Key: `", //1 + "Key: Tab", //2 + "Key: Caps Lock", //3 + "Key: Left Shift", //4 + "Key: Left Control", //5 + "Key: F12", //6 + "Key: =", //7 + "Key: Lock", //8 + "Key: Number Pad 7", //9 + "Key: F1", //12 + "Key: 1", //13 + "Key: Q", //14 + "Key: A", //15 + "Key: Left Windows", //17 + "Key: Print Screen", //18 + "Key: Media Mute", //20 + "Key: Number Pad 8", //21 + "Key: F2", //24 + "Key: 2", //25 + "Key: W", //26 + "Key: S", //27 + "Key: Z", //28 + "Key: Left Alt", //29 + "Key: Scroll Lock", //30 + "Key: Backspace", //31 + "Key: Media Stop", //32 + "Key: Number Pad 9", //33 + "Key: F3", //36 + "Key: 3", //37 + "Key: E", //38 + "Key: D", //39 + "Key: X", //40 + "Key: Pause/Break", //42 + "Key: Delete", //43 + "Key: Media Previous", //44 + "Key: F4", //48 + "Key: 4", //49 + "Key: R", //50 + "Key: F", //51 + "Key: C", //52 + "Key: Space", //53 + "Key: Insert", //54 + "Key: End", //55 + "Key: Media Play/Pause",//56 + "Key: Number Pad 4", //57 + "Key: F5", //60 + "Key: 5", //61 + "Key: T", //62 + "Key: G", //63 + "Key: V", //64 + "Key: Home", //66 + "Key: Page Down", //67 + "Key: Media Next", //68 + "Key: Number Pad 5", //69 + "Key: F6", //72 + "Key: 6", //73 + "Key: Y", //74 + "Key: H", //75 + "Key: B", //76 + "Key: Page Up", //78 + "Key: Right Shift", //79 + "Key: Num Lock", //80 + "Key: Number Pad 6", //81 + "Key: F7", //84 + "Key: 7", //85 + "Key: U", //86 + "Key: J", //87 + "Key: N", //88 + "Key: Right Alt", //89 + "Key: ]", //90 + "Key: Right Control", //91 + "Key: Number Pad /", //92 + "Key: Number Pad 1", //93 + "Key: F8", //96 + "Key: 8", //97 + "Key: I", //98 + "Key: K", //99 + "Key: M", //100 + "Key: Right Windows", //101 + "Key: \\ (ANSI)", //102 + "Key: Up Arrow", //103 + "Key: Number Pad *", //104 + "Key: Number Pad 2", //105 + "Key: F9", //108 + "Key: 9", //109 + "Key: O", //110 + "Key: L", //111 + "Key: ,", //112 + "Key: Menu", //113 + "Key: Left Arrow", //115 + "Key: Number Pad -", //116 + "Key: Number Pad 3", //117 + "Key: F10", //120 + "Key: 0", //121 + "Key: P", //122 + "Key: ;", //123 + "Key: .", //124 + "Key: Enter", //126 + "Key: Down Arrow", //127 + "Key: Number Pad +", //128 + "Key: Number Pad 0", //129 + "Key: F11", //132 + "Key: -", //133 + "Key: [", //134 + "Key: '", //135 + "Key: /", //136 + "Key: Brightness", //137 + "Key: Right Arrow", //139 + "Key: Number Pad Enter",//140 + "Key: Number Pad .", //141 + "Key: / (ISO)", + "Key: \\ (ISO)", + "Key: Macro G1", + "Key: Macro G2", + "Key: Macro G3", + "Key: Macro G4", + "Key: Macro G5", + "Key: Macro G6", + "Light Bar 1", + "Light Bar 2", + "Light Bar 3", + "Light Bar 4", + "Light Bar 5", + "Light Bar 6", + "Light Bar 7", + "Light Bar 8", + "Light Bar 9", + "Light Bar 10", + "Light Bar 11", + "Light Bar 12", + "Light Bar 13", + "Light Bar 14", + "Light Bar 15", + "Light Bar 16", + "Light Bar 17", + "Light Bar 18", + "Light Bar 19" +}; + +static const char* led_names_k95[] = +{ + "Key: Escape", //0 + "Key: `", //1 + "Key: Tab", //2 + "Key: Caps Lock", //3 + "Key: Left Shift", //4 + "Key: Left Control", //5 + "Key: F12", //6 + "Key: =", //7 + "Key: Lock", //8 + "Key: Number Pad 7", //9 + "Key: F1", //12 + "Key: 1", //13 + "Key: Q", //14 + "Key: A", //15 + "Key: Left Windows", //17 + "Key: Print Screen", //18 + "Key: Media Mute", //20 + "Key: Number Pad 8", //21 + "Key: F2", //24 + "Key: 2", //25 + "Key: W", //26 + "Key: S", //27 + "Key: Z", //28 + "Key: Left Alt", //29 + "Key: Scroll Lock", //30 + "Key: Backspace", //31 + "Key: Media Stop", //32 + "Key: Number Pad 9", //33 + "Key: F3", //36 + "Key: 3", //37 + "Key: E", //38 + "Key: D", //39 + "Key: X", //40 + "Key: Pause/Break", //42 + "Key: Delete", //43 + "Key: Media Previous", //44 + "Key: F4", //48 + "Key: 4", //49 + "Key: R", //50 + "Key: F", //51 + "Key: C", //52 + "Key: Space", //53 + "Key: Insert", //54 + "Key: End", //55 + "Key: Media Play/Pause",//56 + "Key: Number Pad 4", //57 + "Key: F5", //60 + "Key: 5", //61 + "Key: T", //62 + "Key: G", //63 + "Key: V", //64 + "Key: Home", //66 + "Key: Page Down", //67 + "Key: Media Next", //68 + "Key: Number Pad 5", //69 + "Key: F6", //72 + "Key: 6", //73 + "Key: Y", //74 + "Key: H", //75 + "Key: B", //76 + "Key: Page Up", //78 + "Key: Right Shift", //79 + "Key: Num Lock", //80 + "Key: Number Pad 6", //81 + "Key: F7", //84 + "Key: 7", //85 + "Key: U", //86 + "Key: J", //87 + "Key: N", //88 + "Key: Right Alt", //89 + "Key: ]", //90 + "Key: Right Control", //91 + "Key: Number Pad /", //92 + "Key: Number Pad 1", //93 + "Key: F8", //96 + "Key: 8", //97 + "Key: I", //98 + "Key: K", //99 + "Key: M", //100 + "Key: Right Windows", //101 + "Key: \\ (ANSI)", //102 + "Key: Up Arrow", //103 + "Key: Number Pad *", //104 + "Key: Number Pad 2", //105 + "Key: F9", //108 + "Key: 9", //109 + "Key: O", //110 + "Key: L", //111 + "Key: ,", //112 + "Key: Menu", //113 + "Key: Left Arrow", //115 + "Key: Number Pad -", //116 + "Key: Number Pad 3", //117 + "Key: F10", //120 + "Key: 0", //121 + "Key: P", //122 + "Key: ;", //123 + "Key: .", //124 + "Key: Enter", //126 + "Key: Down Arrow", //127 + "Key: Number Pad +", //128 + "Key: Number Pad 0", //129 + "Key: F11", //132 + "Key: -", //133 + "Key: [", //134 + "Key: '", //135 + "Key: /", //136 + "Key: Brightness", //137 + "Key: Right Arrow", //139 + "Key: Number Pad Enter",//140 + "Key: Number Pad .", //141 + "Key: / (ISO)", + "Key: \\ (ISO)", + "Key: Macro G1", + "Key: Macro G2", + "Key: Macro G3", + "Key: Macro G4", + "Key: Macro G5", + "Key: Macro G6", + "Key: Macro G7", + "Key: Macro G8", + "Key: Macro G9", + "Key: Macro G10", + "Key: Macro G11", + "Key: Macro G12", + "Key: Macro G13", + "Key: Macro G14", + "Key: Macro G15", + "Key: Macro G16", + "Key: Macro G17", + "Key: Macro G18", + "Key: MR", + "Key: M1", + "Key: M2", + "Key: M3", }; RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr) @@ -159,6 +503,9 @@ RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripher type = corsair->GetDeviceType(); version = corsair->GetFirmwareString(); + physical_layout = corsair->GetPhysicalLayout(); + logical_layout = corsair->GetLogicalLayout(); + mode Direct; Direct.name = "Direct"; Direct.value = 0; @@ -185,6 +532,11 @@ void RGBController_CorsairPeripheral::SetupZones() switch(type) { case DEVICE_TYPE_KEYBOARD: + if (logical_layout == CORSAIR_TYPE_K95_PLAT) + { + num_zones = 2; + break; + } num_zones = 1; break; @@ -208,25 +560,69 @@ void RGBController_CorsairPeripheral::SetupZones() switch(type) { case DEVICE_TYPE_KEYBOARD: - new_zone.name = zone_names[zone_idx]; - new_zone.type = zone_types[zone_idx]; - new_zone.leds_min = zone_sizes[zone_idx]; - new_zone.leds_max = zone_sizes[zone_idx]; - new_zone.leds_count = zone_sizes[zone_idx]; - - if(zone_types[zone_idx] == ZONE_TYPE_MATRIX) + if (logical_layout == CORSAIR_TYPE_K95_PLAT) { - new_zone.matrix_map = new matrix_map_type; - new_zone.matrix_map->height = 6; - new_zone.matrix_map->width = 23; - new_zone.matrix_map->map = (unsigned int *)&matrix_map; + new_zone.name = zone_names_k95_platinum[zone_idx]; + new_zone.type = zone_types_k95_platinum[zone_idx]; + new_zone.leds_min = zone_sizes_k95_platinum[zone_idx]; + new_zone.leds_max = zone_sizes_k95_platinum[zone_idx]; + new_zone.leds_count = zone_sizes_k95_platinum[zone_idx]; + + if(zone_types[zone_idx] == ZONE_TYPE_MATRIX) + { + new_zone.matrix_map = new matrix_map_type; + new_zone.matrix_map->height = 7; + new_zone.matrix_map->width = 24; + new_zone.matrix_map->map = (unsigned int *)&matrix_map_k95_platinum; + } + else + { + new_zone.matrix_map = NULL; + } } - else + else if (logical_layout == CORSAIR_TYPE_K95) { - new_zone.matrix_map = NULL; + new_zone.name = zone_names_k95[zone_idx]; + new_zone.type = zone_types_k95[zone_idx]; + new_zone.leds_min = zone_sizes_k95[zone_idx]; + new_zone.leds_max = zone_sizes_k95[zone_idx]; + new_zone.leds_count = zone_sizes_k95[zone_idx]; + + if(zone_types[zone_idx] == ZONE_TYPE_MATRIX) + { + new_zone.matrix_map = new matrix_map_type; + new_zone.matrix_map->height = 7; + new_zone.matrix_map->width = 26; + new_zone.matrix_map->map = (unsigned int *)&matrix_map_k95; + } + else + { + new_zone.matrix_map = NULL; + } + } + else //default layout + { + new_zone.name = zone_names[zone_idx]; + new_zone.type = zone_types[zone_idx]; + new_zone.leds_min = zone_sizes[zone_idx]; + new_zone.leds_max = zone_sizes[zone_idx]; + new_zone.leds_count = zone_sizes[zone_idx]; + + if(zone_types[zone_idx] == ZONE_TYPE_MATRIX) + { + new_zone.matrix_map = new matrix_map_type; + new_zone.matrix_map->height = 6; + new_zone.matrix_map->width = 23; + new_zone.matrix_map->map = (unsigned int *)&matrix_map; + } + else + { + new_zone.matrix_map = NULL; + } } break; + case DEVICE_TYPE_MOUSE: new_zone.name = "Mousemat Zone"; new_zone.type = ZONE_TYPE_SINGLE; @@ -279,7 +675,18 @@ void RGBController_CorsairPeripheral::SetupZones() switch(type) { case DEVICE_TYPE_KEYBOARD: - new_led.name = led_names[led_idx]; + if(logical_layout == CORSAIR_TYPE_K95_PLAT) + { + new_led.name = led_names_k95_plat[led_idx]; + } + else if(logical_layout == CORSAIR_TYPE_K95) + { + new_led.name = led_names_k95[led_idx]; + } + else + { + new_led.name = led_names[led_idx]; + } break; case DEVICE_TYPE_MOUSE: diff --git a/RGBController/RGBController_CorsairPeripheral.h b/RGBController/RGBController_CorsairPeripheral.h index 16598cc5..1c330c29 100644 --- a/RGBController/RGBController_CorsairPeripheral.h +++ b/RGBController/RGBController_CorsairPeripheral.h @@ -17,6 +17,9 @@ public: RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr); ~RGBController_CorsairPeripheral(); + int physical_layout; + int logical_layout; + void SetupZones(); void ResizeZone(int zone, int new_size);