From d4b2d3c381ea1d8bf0135c32e9df23c4cc7cf9f0 Mon Sep 17 00:00:00 2001 From: Chris M Date: Sat, 5 Aug 2023 12:21:19 +1000 Subject: [PATCH] Initial commit for the Corsair K70 Pro TKL keyboard * Adding key layout and metadata to CorsairPeripheralV2Devices.cpp * Adding lighting control endpoint check * Adding new detector * Small style fixes * Resolves #3260 --- .../CorsairPeripheralV2ControllerDetect.cpp | 2 + .../CorsairPeripheralV2Devices.cpp | 111 +++++++++++++++++- .../CorsairPeripheralV2Devices.h | 2 + .../RGBController_CorsairV2Hardware.cpp | 5 +- .../RGBController_CorsairV2Software.cpp | 5 +- 5 files changed, 121 insertions(+), 4 deletions(-) diff --git a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp index b0e36b6f..92a3bdd2 100644 --- a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp +++ b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp @@ -60,6 +60,8 @@ void DetectCorsairV2SoftwareControllers(hid_device_info* info, const std::string REGISTER_HID_DETECTOR_IP("Corsair K55 RGB PRO", DetectCorsairV2SoftwareControllers, CORSAIR_VID, CORSAIR_K55_RGB_PRO_PID, 1, 0xFF42); REGISTER_HID_DETECTOR_IP("Corsair K60 RGB PRO", DetectCorsairV2SoftwareControllers, CORSAIR_VID, CORSAIR_K60_RGB_PRO_PID, 1, 0xFF42); REGISTER_HID_DETECTOR_IP("Corsair K60 RGB PRO Low Profile", DetectCorsairV2SoftwareControllers, CORSAIR_VID, CORSAIR_K60_RGB_PRO_LP_PID, 1, 0xFF42); +REGISTER_HID_DETECTOR_IP("Corsair K70 RGB TKL", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K70_RGB_TKL_PID, 1, 0xFF42); +REGISTER_HID_DETECTOR_IP("Corsair K70 RGB TKL Champion Series", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K70_RGB_TKL_CS_PID, 1, 0xFF42); /*-----------------------------------------------------------------------------------------------------*\ | Mice | diff --git a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.cpp b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.cpp index cd202392..57e8c5c6 100644 --- a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.cpp +++ b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.cpp @@ -4,6 +4,22 @@ | Corsair Key Values | \*-------------------------------------------------------------------------*/ +std::vector corsair_tkl_values = +{ + /* ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 PRSC SCLK PSBK */ + 41, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + /* BKTK 1 2 3 4 5 6 7 8 9 0 - = BSPC INS HOME PGUP */ + 53, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 45, 46, 42, 73, 74, 75, + /* TAB Q W E R T Y U I O P [ ] \ DEL END PGDN */ + 43, 20, 26, 8, 21, 23, 28, 24, 12, 18, 19, 47, 48, 49, 76, 77, 78, + /* CPLK A S D F G H J K L ; " # ENTR */ + 57, 4, 22, 7, 9, 10, 11, 13, 14, 15, 51, 52, 50, 40, + /* LSFT ISO\ Z X C V B N M , . / RSFT ARWU */ + 106, 100, 29, 27, 6, 25, 5, 17, 16, 54, 55, 56, 110, 82, + /* LCTL LWIN LALT SPC RALT RFNC RMNU RCTL ARWR ARWD ARWR */ + 105, 108, 107, 44, 111, 122, 101, 109, 80, 81, 79, +}; + std::vector corsair_full_size_values = { /* ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 PRSC SCLK PSBK */ @@ -40,6 +56,33 @@ keyboard_keymap_overlay_values corsair_K60_layout } }; +keyboard_keymap_overlay_values corsair_K70_TKL_cs_layout +{ + KEYBOARD_SIZE::KEYBOARD_SIZE_TKL, + { + corsair_tkl_values, + { + /* Add more regional layout fixes here */ + } + }, + { + /*---------------------------------------------------------------------------------------------------------*\ + | Edit Keys | + | Zone, Row, Column, Value, Key, OpCode, | + \*---------------------------------------------------------------------------------------------------------*/ + { 0, 0, 1, 123, KEY_EN_MEDIA_STOP, KEYBOARD_OPCODE_INSERT_ROW, }, // Insert Stop Key into new media keys row + { 0, 0, 2, 126, KEY_EN_MEDIA_PREVIOUS, KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert Previous Track Key + { 0, 0, 3, 124, KEY_EN_MEDIA_PLAY_PAUSE, KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert Play Pause Key + { 0, 0, 4, 125, KEY_EN_MEDIA_NEXT, KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert Next Tack Key + { 0, 0, 7, 1, "Logo L", KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert 'Logo Left' + { 0, 0, 8, 3, "Logo R", KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert 'Logo Right' + { 0, 0, 11, 128, "Profile", KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert Profile + { 0, 0, 12, 113, "Light", KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert Light key + { 0, 0, 13, 114, "Lock", KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert Lock Key + { 0, 0, 14, 102, KEY_EN_MEDIA_MUTE, KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT, }, // Insert Mute Key + } +}; + /*-------------------------------------------------------------------------*\ | CORSAIR DEVICES | \*-------------------------------------------------------------------------*/ @@ -381,6 +424,70 @@ static const corsair_v2_device k60_rgb_pro_lp_device = &corsair_K60_layout }; +/*-------------------------------------------------------------*\ +| Corsair K70 RGB TKL 1B1C:1B73 | +| | +| Zone "Keyboard" | +| Matrix | +| 7 Rows, 17 Columns | +\*-------------------------------------------------------------*/ +static const corsair_v2_zone k70_rgb_tkl_zone = +{ + ZONE_EN_KEYBOARD, + ZONE_TYPE_MATRIX, + 7, + 17 +}; + +static const corsair_v2_device k70_rgb_tkl_device = +{ + CORSAIR_K70_RGB_TKL_PID, + DEVICE_TYPE_KEYBOARD, + 7, + 17, + { + &k70_rgb_tkl_zone, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr + }, + &corsair_K70_TKL_cs_layout +}; + +/*-------------------------------------------------------------*\ +| Corsair K70 RGB TKL Champion Series 1B1C:1BB9 | +| | +| Zone "Keyboard" | +| Matrix | +| 7 Rows, 17 Columns | +\*-------------------------------------------------------------*/ +static const corsair_v2_zone k70_rgb_tkl_cs_zone = +{ + ZONE_EN_KEYBOARD, + ZONE_TYPE_MATRIX, + 7, + 17 +}; + +static const corsair_v2_device k70_rgb_tkl_cs_device = +{ + CORSAIR_K70_RGB_TKL_CS_PID, + DEVICE_TYPE_KEYBOARD, + 7, + 17, + { + &k70_rgb_tkl_cs_zone, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr + }, + &corsair_K70_TKL_cs_layout +}; + /*-------------------------------------------------------------*\ | Corsair M55 1B1C:1B70 | | | @@ -452,9 +559,7 @@ static const corsair_v2_zone m65_ultra_rgb_dpi_zone = static const corsair_v2_device m65_ultra_rgb_device = { CORSAIR_M65_ULTRA_RGB_PID, - //false, DEVICE_TYPE_MOUSE, - //CORSAIR_V2_TYPE_SW_COLOUR_BLOCK, 1, 2, { @@ -530,6 +635,8 @@ const corsair_v2_device* corsair_v2_device_list_data[] = &k55_rgb_pro_device, &k60_rgb_pro_device, &k60_rgb_pro_lp_device, + &k70_rgb_tkl_device, + &k70_rgb_tkl_cs_device, /*-----------------------------------------------------------------*\ | MICE | diff --git a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.h b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.h index a8770713..825fd705 100644 --- a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.h +++ b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.h @@ -62,6 +62,8 @@ typedef struct #define CORSAIR_K55_RGB_PRO_PID 0x1BA4 #define CORSAIR_K60_RGB_PRO_PID 0x1BA0 #define CORSAIR_K60_RGB_PRO_LP_PID 0x1BAD +#define CORSAIR_K70_RGB_TKL_PID 0x1B73 +#define CORSAIR_K70_RGB_TKL_CS_PID 0x1BB9 /*-----------------------------------------------------*\ | Corsair V2 Protocol Mice | diff --git a/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Hardware.cpp b/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Hardware.cpp index ea7b3782..76b50703 100644 --- a/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Hardware.cpp +++ b/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Hardware.cpp @@ -145,7 +145,6 @@ void RGBController_CorsairV2HW::SetupZones() /*---------------------------------------------------------*\ | Minor adjustments to keyboard layout | \*---------------------------------------------------------*/ - new_zone.leds_count = new_kb.GetKeyCount(); keyboard_keymap_overlay_values* temp = corsair->layout_new; new_kb.ChangeKeys(*temp); @@ -159,6 +158,10 @@ void RGBController_CorsairV2HW::SetupZones() | Create LEDs for the Matrix zone | | Place keys in the layout to populate the matrix | \*---------------------------------------------------------*/ + new_zone.leds_count = new_kb.GetKeyCount(); + LOG_DEBUG("[%s] Created KB matrix with %d rows and %d columns containing %d keys", + controller->GetName().c_str(), new_kb.GetRowCount(), new_kb.GetColumnCount(), new_zone.leds_count); + for(size_t led_idx = 0; led_idx < new_zone.leds_count; led_idx++) { led new_led; diff --git a/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Software.cpp b/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Software.cpp index 18ee62bb..34e35fcc 100644 --- a/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Software.cpp +++ b/Controllers/CorsairPeripheralV2Controller/RGBController_CorsairV2Software.cpp @@ -133,7 +133,6 @@ void RGBController_CorsairV2SW::SetupZones() /*---------------------------------------------------------*\ | Minor adjustments to keyboard layout | \*---------------------------------------------------------*/ - new_zone.leds_count = new_kb.GetKeyCount(); keyboard_keymap_overlay_values* temp = corsair->layout_new; new_kb.ChangeKeys(*temp); @@ -147,6 +146,10 @@ void RGBController_CorsairV2SW::SetupZones() | Create LEDs for the Matrix zone | | Place keys in the layout to populate the matrix | \*---------------------------------------------------------*/ + new_zone.leds_count = new_kb.GetKeyCount(); + LOG_DEBUG("[%s] Created KB matrix with %d rows and %d columns containing %d keys", + controller->GetName().c_str(), new_kb.GetRowCount(), new_kb.GetColumnCount(), new_zone.leds_count); + for(size_t led_idx = 0; led_idx < new_zone.leds_count; led_idx++) { led new_led;