From 55269cff8adb2cb569b00e65e5df727a697de06e Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 10 Nov 2021 00:39:41 +1100 Subject: [PATCH] Fixing missing keys in matrix map to resolve #1918 * Re-arranging `led_names` to have the numpad at the end to accomodate both full size and TKL variants - Removing redundant `led_names_tkl` from RGBController_SteelSeriesApex.cpp - Removing redundant `keys_tkl[]` from SteelSeriesApexController.cpp * adjusted matrix maps to index correct `led_names[]` * adjusted `keys[]`and `keys_m[]` for new indexing in colors[]` --- .../RGBController_SteelSeriesApex.cpp | 141 +++--------------- .../SteelSeriesApexController.cpp | 48 ++---- .../SteelSeriesApexMController.cpp | 55 ++++--- 3 files changed, 70 insertions(+), 174 deletions(-) diff --git a/Controllers/SteelSeriesController/RGBController_SteelSeriesApex.cpp b/Controllers/SteelSeriesController/RGBController_SteelSeriesApex.cpp index 91e53668..f5785718 100644 --- a/Controllers/SteelSeriesController/RGBController_SteelSeriesApex.cpp +++ b/Controllers/SteelSeriesController/RGBController_SteelSeriesApex.cpp @@ -16,19 +16,19 @@ using namespace std::chrono_literals; static unsigned int matrix_map[6][23] = { { 37, NA, 53, 54, 55, 56, NA, 57, 58, 59, 60, NA, 61 , 62 , 63 , 64 , 65, 66, 67, NA, NA, NA, NA }, - { 48, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 41, 42 , NA , 38 , 105, 68, 69, 70, 78, 79, 80, 81 }, - { 39, NA, 16, 22, 4 , 17, 19, 24, 20, 8 , 14, 15, 43 , 44 , NA , 36 , 71, 72, 73, 90, 91, 92, 82 }, - { 52, NA, 0 , 18, 3 , 5 , 6 , 7 , 9 , 10, 11, 46, 47 , 45 , NA , NA , NA, NA, NA, 87, 88, 89, NA }, - { 97, 95, 25, 23, 2 , 21, NA, 1 , 13, 12, 49, 50, 51 , NA , 101, NA , NA, 77, NA, 84, 85, 86, 83 }, - { 96, 99, 98, NA, NA, NA, NA, 40, NA, NA, NA, NA, 102, 103, 104, 100, 75, 76, 74, 93, NA, 94, NA } }; + { 48, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 41, 42 , NA , 38 , 88 , 68, 69, 70, 89, 90, 91, 92 }, + { 39, NA, 16, 22, 4 , 17, 19, 24, 20, 8 , 14, 15, 43 , 44 , NA , 36 , 71, 72, 73, 101, 102, 103, 93 }, + { 52, NA, 0 , 18, 3 , 5 , 6 , 7 , 9 , 10, 11, 46, 47 , 45 , NA , NA , NA, NA, NA, 98, 99, 100, NA }, + { 80, 78, 25, 23, 2 , 21, NA, 1 , 13, 12, 49, 50, 51 , NA , 84 , NA , NA, 77, NA, 95, 96, 97, 94 }, + { 79, 82, 81, NA, NA, NA, NA, 40, NA, NA, NA, NA, 85 , 86 , 87 , 83 , 75, 76, 74, 104, NA, 105, NA } }; static unsigned int matrix_map_tkl[6][19] = { { 37, NA, 53, 54, 55, 56, NA, 57, 58, 59, 60, NA, 61 , 62 , 63 , 64 , 65, 66, 67}, - { 48, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 41, 42 , NA , 38 , 105, 68, 69, 70}, + { 48, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 41, 42 , NA , 38 , 88 , 68, 69, 70}, { 39, NA, 16, 22, 4 , 17, 19, 24, 20, 8 , 14, 15, 43 , 44 , NA , 36 , 71, 72, 73}, { 52, NA, 0 , 18, 3 , 5 , 6 , 7 , 9 , 10, 11, 46, 47 , 45 , NA , NA , NA, NA, NA}, - { 97, 95, 25, 23, 2 , 21, NA, 1 , 13, 12, 49, 50, 51 , NA , 101, NA , NA, 77, NA}, - { 96, 99, 98, NA, NA, NA, NA, 40, NA, NA, NA, NA, 102, 103, 104, 100, 75, 76, 74} }; + { 80, 78, 25, 23, 2 , 21, NA, 1 , 13, 12, 49, 50, 51 , NA , 84 , NA , NA, 77, NA}, + { 79, 82, 81, NA, NA, NA, NA, 40, NA, NA, NA, NA, 85 , 86, 87, 83 , 75, 76, 74} }; static const char* zone_names[] = { @@ -130,6 +130,17 @@ static const char *led_names[] = "Key: Left Arrow", "Key: Down Arrow", "Key: Up Arrow", + "Key: \\ (ISO)", + "Key: Left Control", + "Key: Left Shift", + "Key: Left Alt", + "Key: Left Windows", + "Key: Right Control", + "Key: Right Shift", + "Key: Right Alt", + "Key: Right Windows", + "Key: Right Fn", + "Key: \\ (ANSI)", "Key: Num Lock", "Key: Number Pad /", "Key: Number Pad *", @@ -147,110 +158,6 @@ static const char *led_names[] = "Key: Number Pad 9", "Key: Number Pad 0", "Key: Number Pad .", - "Key: \\ (ISO)", - "Key: Left Control", - "Key: Left Shift", - "Key: Left Alt", - "Key: Left Windows", - "Key: Right Control", - "Key: Right Shift", - "Key: Right Alt", - "Key: Right Windows", - "Key: Right Fn", - "Key: \\ (ANSI)", -}; - -static const char *led_names_tkl[] = -{ - "Key: A", - "Key: B", - "Key: C", - "Key: D", - "Key: E", - "Key: F", - "Key: G", - "Key: H", - "Key: I", - "Key: J", - "Key: K", - "Key: L", - "Key: M", - "Key: N", - "Key: O", - "Key: P", - "Key: Q", - "Key: R", - "Key: S", - "Key: T", - "Key: U", - "Key: V", - "Key: W", - "Key: X", - "Key: Y", - "Key: Z", - "Key: 1", - "Key: 2", - "Key: 3", - "Key: 4", - "Key: 5", - "Key: 6", - "Key: 7", - "Key: 8", - "Key: 9", - "Key: 0", - "Key: Enter", - "Key: Escape", - "Key: Backspace", - "Key: Tab", - "Key: Space", - "Key: -", - "Key: =", - "Key: [", - "Key: ]", - "Key: #", - "Key: ;", - "Key: '", - "Key: `", - "Key: ,", - "Key: .", - "Key: /", - "Key: Caps Lock", - "Key: F1", - "Key: F2", - "Key: F3", - "Key: F4", - "Key: F5", - "Key: F6", - "Key: F7", - "Key: F8", - "Key: F9", - "Key: F10", - "Key: F11", - "Key: F12", - "Key: Print Screen", - "Key: Scroll Lock", - "Key: Pause", - "Key: Insert", - "Key: Home", - "Key: Page Up", - "Key: Delete", - "Key: End", - "Key: Page Down", - "Key: Right Arrow", - "Key: Left Arrow", - "Key: Down Arrow", - "Key: Up Arrow", - "Key: \\ (ISO)", - "Key: Left Control", - "Key: Left Shift", - "Key: Left Alt", - "Key: Left Windows", - "Key: Right Control", - "Key: Right Shift", - "Key: Right Alt", - "Key: Right Windows", - "Key: Right Fn", - "Key: \\", }; RGBController_SteelSeriesApex::RGBController_SteelSeriesApex(SteelSeriesApexBaseController* steelseries_ptr) @@ -353,14 +260,8 @@ void RGBController_SteelSeriesApex::SetupZones() for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++) { led new_led; - if((proto_type == APEX) || (proto_type == APEX_M)) - { - new_led.name = led_names[led_idx]; - } - else - { - new_led.name = led_names_tkl[led_idx]; - } + new_led.name = led_names[led_idx]; + leds.push_back(new_led); } diff --git a/Controllers/SteelSeriesController/SteelSeriesApexController.cpp b/Controllers/SteelSeriesController/SteelSeriesApexController.cpp index 2e928a0c..02f4ffe1 100644 --- a/Controllers/SteelSeriesController/SteelSeriesApexController.cpp +++ b/Controllers/SteelSeriesController/SteelSeriesApexController.cpp @@ -13,23 +13,17 @@ using namespace std::chrono_literals; -static unsigned int keys[] = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, - 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, - 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, - 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, - 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xf0, 0x31 }; - -static unsigned int keys_tkl[] = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, - 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, - 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, - 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, - 0x64, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xf0, 0x31 }; +static unsigned int keys[] = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, + 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, //20 + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, + 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, //40 + 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x32, 0x33, 0x34, 0x35, 0x36, + 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, //60 + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, + 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x64, 0xe0, //80 + 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xf0, 0x31, 0x53, + 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, //100 + 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63 }; SteelSeriesApexController::SteelSeriesApexController(hid_device* dev_handle, steelseries_type type, const char* path) { @@ -54,7 +48,6 @@ void SteelSeriesApexController::SetMode active_mode = mode; memset(mode_colors, 0x00, sizeof(mode_colors)); - } void SteelSeriesApexController::SetLEDsDirect(std::vector colors) @@ -62,14 +55,7 @@ void SteelSeriesApexController::SetLEDsDirect(std::vector colors) unsigned char buf[643]; int num_keys = 0; - if(proto_type == APEX) - { - num_keys = sizeof(keys) / sizeof(*keys); - } - else - { - num_keys = sizeof(keys_tkl) / sizeof(*keys_tkl); - } + num_keys = sizeof(keys) / sizeof(*keys); /*-----------------------------------------------------*\ | Zero out buffer | @@ -88,14 +74,7 @@ void SteelSeriesApexController::SetLEDsDirect(std::vector colors) \*-----------------------------------------------------*/ for(int i = 0; i < num_keys; i++) { - if(proto_type == APEX) - { - buf[(i*4)+3] = keys[i]; - } - else - { - buf[(i*4)+3] = keys_tkl[i]; - } + buf[(i*4)+3] = keys[i]; buf[(i*4)+4] = RGBGetRValue(colors[i]); buf[(i*4)+5] = RGBGetGValue(colors[i]); buf[(i*4)+6] = RGBGetBValue(colors[i]); @@ -126,5 +105,4 @@ void SteelSeriesApexController::SelectProfile buf[0x01] = 0x89; buf[0x02] = profile; hid_send_feature_report(dev, buf, 65); - } diff --git a/Controllers/SteelSeriesController/SteelSeriesApexMController.cpp b/Controllers/SteelSeriesController/SteelSeriesApexMController.cpp index ad1f9037..4f89db40 100644 --- a/Controllers/SteelSeriesController/SteelSeriesApexMController.cpp +++ b/Controllers/SteelSeriesController/SteelSeriesApexMController.cpp @@ -11,13 +11,28 @@ #include +#define SS_APEX_M_PACKET_SIZE 513 #define NA 0xFF -static unsigned int keys_m[] = { 96, 99, 98, NA, 40, NA, NA, NA, NA, 102, 103, 104, 100, NA, NA , 75, 76, 74, NA, 93, NA, 94, - 97, 25, 23, 2 , 21, 1 , 13, 12, 49, 50 , 51 , NA , 101, NA, NA , NA, 77, NA, 84, 85, 86, 83, - 52, 0 , 18, 3 , 5 , 6 , 7 , 9 , 10, 11 , 46 , 47 , NA , 36, NA , NA, NA, NA, 87, 88, 89, NA, - 39, 16, 22, 4 , 17, 19, 24, 20, 8 , 14 , 15 , 43 , 44 , NA, 105, 71, 72, 73, 90, 91, 92, 82, - 48, 26, 27, 28, 29, 30, 31, 32, 33, 34 , 35 , 41 , 42 , NA, 38 , 68, 69, 70, 78, 79, 80, 81, - 37, 53, 54, 55, 56, NA, 57, 58, 59, 60 , NA , 61 , 62 , 63, 64 , 65, 66, 67, NA, NA, NA, NA }; +static unsigned int keys_m[] = +{ +/* LCTRL LWIN LALT XXX SPACE XXX XXX XXX XXX RALT RWIN FNC RCTRL XXX XXX LEFT DOWN RIGHT XXX #0 XXX #. */ + 79, 82, 81, NA, 40, NA, NA, NA, NA, 85, 86, 87, 83, NA, NA, 75, 76, 74, NA, 104, NA, 105, + +/* LSHFT Z X C V B N M , . / XXX RSHFT XXX XXX XXX UP XXX #1 #2 #3 #ENTR */ + 80, 25, 23, 2, 21, 1, 13, 12, 49, 50, 51, NA, 84, NA, NA, NA, 77, NA, 95, 96, 97, 94, + +/* CAPLK A S D F G H J K L ; ' XXX ENTER XXX XXX XXX XXX #4 #5 #6 XXX */ + 52, 0, 18, 3, 5, 6, 7, 9, 10, 11, 46, 47, NA, 36, NA, NA, NA, NA, 98, 99, 100, NA, + +/* TAB Q W E R T Y U I O P [ ] XXX \ DELTE END PGDN #7 #8 #9 #+ */ + 39, 16, 22, 4, 17, 19, 24, 20, 8, 14, 15, 43, 44, NA, 88, 71, 72, 73, 101, 102, 103, 93, + +/* ` 1 2 3 4 5 6 7 8 9 0 - = XXX BKSPC INSRT HOME PGUP NUMLK #/ #* #- */ + 48, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 41, 42, NA, 38, 68, 69, 70, 89, 90, 91, 92, + +/* ESC F1 F2 F3 F4 XXX F5 F6 F7 F8 XXX F9 F10 F11 F12 PRTSC SCRLK PAUSE XXX XXX XXX XXX */ + 37, 53, 54, 55, 56, NA, 57, 58, 59, 60, NA, 61, 62, 63, 64, 65, 66, 67, NA, NA, NA, NA +}; SteelSeriesApexMController::SteelSeriesApexMController(hid_device* dev_handle, steelseries_type type, const char* path) { @@ -34,7 +49,8 @@ SteelSeriesApexMController::~SteelSeriesApexMController() void SteelSeriesApexMController::EnableLEDControl() { - unsigned char buf[513] = { 0x00 }; + unsigned char buf[SS_APEX_M_PACKET_SIZE] = { 0x00 }; + buf[0x00] = 0x00; buf[0x01] = 0x00; buf[0x02] = 0x00; @@ -42,7 +58,8 @@ void SteelSeriesApexMController::EnableLEDControl() buf[0x04] = 0x01; buf[0x05] = 0x00; buf[0x06] = 0x85; - hid_send_feature_report(dev, buf, 513); + hid_send_feature_report(dev, buf, SS_APEX_M_PACKET_SIZE); + buf[0x00] = 0x00; buf[0x01] = 0x00; buf[0x02] = 0x00; @@ -51,7 +68,8 @@ void SteelSeriesApexMController::EnableLEDControl() buf[0x05] = 0x01; buf[0x06] = 0x00; buf[0x07] = 0xff; - hid_send_feature_report(dev, buf, 513); + hid_send_feature_report(dev, buf, SS_APEX_M_PACKET_SIZE); + buf[0x00] = 0x00; buf[0x01] = 0x00; buf[0x02] = 0x00; @@ -59,7 +77,7 @@ void SteelSeriesApexMController::EnableLEDControl() buf[0x04] = 0x01; buf[0x05] = 0x00; buf[0x06] = 0x85; - hid_send_feature_report(dev, buf, 513); + hid_send_feature_report(dev, buf, SS_APEX_M_PACKET_SIZE); } void SteelSeriesApexMController::SetMode(unsigned char /*mode*/, std::vector /*colors*/) @@ -68,7 +86,7 @@ void SteelSeriesApexMController::SetMode(unsigned char /*mode*/, std::vector colors) { - unsigned char buf[513] = { 0x00 }; + unsigned char buf[SS_APEX_M_PACKET_SIZE] = { 0x00 }; int num_keys = sizeof(keys_m) / sizeof(*keys_m); /*-----------------------------------------------------*\ @@ -91,21 +109,20 @@ void SteelSeriesApexMController::SetLEDsDirect(std::vector colors) { if (keys_m[i] == NA) { - buf[i * 3 + 9] = 0xFF; - buf[i * 3 + 10] = 0x32; - buf[i * 3 + 11] = 0x00; + buf[i * 3 + 9] = 0xFF; + buf[i * 3 + 10] = 0x32; + buf[i * 3 + 11] = 0x00; } else { - buf[(i * 3) + 9] = RGBGetRValue(colors[keys_m[i]]); - buf[(i * 3) + 10] = RGBGetGValue(colors[keys_m[i]]); - buf[(i * 3) + 11] = RGBGetBValue(colors[keys_m[i]]); + buf[(i * 3) + 9] = RGBGetRValue(colors[keys_m[i]]); + buf[(i * 3) + 10] = RGBGetGValue(colors[keys_m[i]]); + buf[(i * 3) + 11] = RGBGetBValue(colors[keys_m[i]]); } } /*-----------------------------------------------------*\ | Send packet | \*-----------------------------------------------------*/ - hid_send_feature_report(dev, buf, 513); - + hid_send_feature_report(dev, buf, SS_APEX_M_PACKET_SIZE); }