diff --git a/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.cpp b/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.cpp index da0cd4d36..4327abc60 100644 --- a/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.cpp +++ b/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.cpp @@ -3,7 +3,7 @@ | | | RGBController for Wooting keyboard | | | -| Diogo Trindade (diogotr7) 04 Mar 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | @@ -13,281 +13,590 @@ #include "RGBController_WootingKeyboard.h" #include "LogManager.h" +//TODO: These matrix maps have indices to the 6x21 full layout. +// This is incorrect. The values in the matrix map should be indices to the `leds` vector. +// the Value property in each LED is what should map to the index in the full 6x21 layout. + //0xFFFFFFFF indicates an unused entry in matrix #define NA 0xFFFFFFFF -#define RGB_RAW_BUFFER_SIZE 96 -static unsigned int matrix_map_tkl[6][17] = -{ - { 0, NA, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96}, - { 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97}, - { 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98}, - { 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, NA, NA, NA}, - { 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, NA, 82, NA, 94, NA}, - { 5, 11, 17, NA, NA, NA, 41, NA, NA, NA, 65, 71, 77, 83, 89, 95, 101} +static unsigned int matrix_map_full[6][21] = { + { 0, NA, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }, + { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41 }, + { 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 }, + { 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, NA, NA, NA, 80, 81, 82, NA }, + { 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, NA, 97, NA, 99, NA, 101, 102, 103, 104 }, + { 105, 106, 107, NA, NA, NA, 111, NA, NA, NA, 115, 116, 117, 118, 119, 120, 121, NA, 123, 124, NA } }; -static unsigned int matrix_map_80HE[6][17] = -{ - { 0, 6, 12, 18, 24, 30, 36, 42, 48, NA, 60, 66, 72, 78, 84, 90, 100}, - { 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97}, - { 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98}, - { 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, NA, NA}, - { 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, NA, 82, 88, 94, NA}, - { 5, 11, 17, NA, NA, NA, 41, NA, NA, NA, 65, 71, 77, NA, 89, 95, 101} +static const char *led_names_full[6][21] { + //Row 0 + { + KEY_EN_ESCAPE, + KEY_EN_UNUSED, + KEY_EN_F1, + KEY_EN_F2, + KEY_EN_F3, + KEY_EN_F4, + KEY_EN_F5, + KEY_EN_F6, + KEY_EN_F7, + KEY_EN_F8, + KEY_EN_F9, + KEY_EN_F10, + KEY_EN_F11, + KEY_EN_F12, + KEY_EN_PRINT_SCREEN, + KEY_EN_PAUSE_BREAK, + KEY_EN_SCROLL_LOCK, + "Key: Custom1", + "Key: Custom2", + "Key: Custom3", + "Key: Mode", + }, + //row 1 + { + KEY_EN_BACK_TICK, + KEY_EN_1, + KEY_EN_2, + KEY_EN_3, + KEY_EN_4, + KEY_EN_5, + KEY_EN_6, + KEY_EN_7, + KEY_EN_8, + KEY_EN_9, + KEY_EN_0, + KEY_EN_MINUS, + KEY_EN_PLUS, + KEY_EN_BACKSPACE, + KEY_EN_INSERT, + KEY_EN_HOME, + KEY_EN_PAGE_UP, + KEY_EN_NUMPAD_LOCK, + KEY_EN_NUMPAD_DIVIDE, + KEY_EN_NUMPAD_TIMES, + KEY_EN_NUMPAD_MINUS, + }, + //row 2 + { + KEY_EN_TAB, + KEY_EN_Q, + KEY_EN_W, + KEY_EN_E, + KEY_EN_R, + KEY_EN_T, + KEY_EN_Y, + KEY_EN_U, + KEY_EN_I, + KEY_EN_O, + KEY_EN_P, + KEY_EN_LEFT_BRACKET, + KEY_EN_RIGHT_BRACKET, + KEY_EN_BACK_SLASH, + KEY_EN_DELETE, + KEY_EN_END, + KEY_EN_PAGE_DOWN, + KEY_EN_NUMPAD_7, + KEY_EN_NUMPAD_8, + KEY_EN_NUMPAD_9, + KEY_EN_NUMPAD_PLUS, + }, + //row 3 + { + KEY_EN_CAPS_LOCK, + KEY_EN_A, + KEY_EN_S, + KEY_EN_D, + KEY_EN_F, + KEY_EN_G, + KEY_EN_H, + KEY_EN_J, + KEY_EN_K, + KEY_EN_L, + KEY_EN_SEMICOLON, + KEY_EN_QUOTE, + KEY_EN_POUND, + KEY_EN_ANSI_ENTER, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_NUMPAD_4, + KEY_EN_NUMPAD_5, + KEY_EN_NUMPAD_6, + KEY_EN_UNUSED, + }, + //row 4 + { + KEY_EN_LEFT_SHIFT, + KEY_EN_ISO_BACK_SLASH, + KEY_EN_Z, + KEY_EN_X, + KEY_EN_C, + KEY_EN_V, + KEY_EN_B, + KEY_EN_N, + KEY_EN_M, + KEY_EN_COMMA, + KEY_EN_PERIOD, + KEY_EN_FORWARD_SLASH, + KEY_EN_UNUSED, + KEY_EN_RIGHT_SHIFT, + KEY_EN_UNUSED, + KEY_EN_UP_ARROW, + KEY_EN_UNUSED, + KEY_EN_NUMPAD_1, + KEY_EN_NUMPAD_2, + KEY_EN_NUMPAD_3, + KEY_EN_NUMPAD_ENTER, + }, + //row 5 + { + KEY_EN_LEFT_CONTROL, + KEY_EN_LEFT_WINDOWS, + KEY_EN_LEFT_ALT, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_SPACE, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_RIGHT_ALT, + KEY_EN_RIGHT_WINDOWS, + KEY_EN_RIGHT_FUNCTION, + KEY_EN_RIGHT_CONTROL, + KEY_EN_LEFT_ARROW, + KEY_EN_DOWN_ARROW, + KEY_EN_RIGHT_ARROW, + KEY_EN_UNUSED, + KEY_EN_NUMPAD_0, + KEY_EN_NUMPAD_PERIOD, + KEY_EN_UNUSED, + } }; -static unsigned int matrix_map_full[6][21] = -{ - { 0, NA, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 100, 102, 108, 114, 120}, - { 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121}, - { 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, 104, 110, 116, 122}, - { 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, NA, NA, NA, 105, 111, 117, NA}, - { 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, NA, 82, NA, 94, NA, 106, 112, 118, 124}, - { 5, 11, 17, NA, NA, NA, 41, NA, NA, NA, 65, 71, 77, 83, 89, 95, 101, NA, 113, 119, NA} +static unsigned int matrix_map_tkl[6][17] = { + { 0, NA, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 }, + { 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58 }, + { 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, NA, NA, NA }, + { 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, NA, 97, NA, 99, NA }, + { 105, 106, 107, NA, NA, NA, 111, NA, NA, NA, 115, 116, 117, 118, 119, 120, 121 } }; -static const unsigned int zone_sizes[] = -{ - 102, - 126, - 102 +static const char *led_names_tkl[6][17] { + //Row 0 + { + KEY_EN_ESCAPE, + KEY_EN_UNUSED, + KEY_EN_F1, + KEY_EN_F2, + KEY_EN_F3, + KEY_EN_F4, + KEY_EN_F5, + KEY_EN_F6, + KEY_EN_F7, + KEY_EN_F8, + KEY_EN_F9, + KEY_EN_F10, + KEY_EN_F11, + KEY_EN_F12, + KEY_EN_PRINT_SCREEN, + KEY_EN_PAUSE_BREAK, + "Key: Custom1", + }, + //row 1 + { + KEY_EN_BACK_TICK, + KEY_EN_1, + KEY_EN_2, + KEY_EN_3, + KEY_EN_4, + KEY_EN_5, + KEY_EN_6, + KEY_EN_7, + KEY_EN_8, + KEY_EN_9, + KEY_EN_0, + KEY_EN_MINUS, + KEY_EN_PLUS, + KEY_EN_BACKSPACE, + KEY_EN_INSERT, + KEY_EN_HOME, + KEY_EN_PAGE_UP, + }, + //row 2 + { + KEY_EN_TAB, + KEY_EN_Q, + KEY_EN_W, + KEY_EN_E, + KEY_EN_R, + KEY_EN_T, + KEY_EN_Y, + KEY_EN_U, + KEY_EN_I, + KEY_EN_O, + KEY_EN_P, + KEY_EN_LEFT_BRACKET, + KEY_EN_RIGHT_BRACKET, + KEY_EN_BACK_SLASH, + KEY_EN_DELETE, + KEY_EN_END, + KEY_EN_PAGE_DOWN, + }, + //row 3 + { + KEY_EN_CAPS_LOCK, + KEY_EN_A, + KEY_EN_S, + KEY_EN_D, + KEY_EN_F, + KEY_EN_G, + KEY_EN_H, + KEY_EN_J, + KEY_EN_K, + KEY_EN_L, + KEY_EN_SEMICOLON, + KEY_EN_QUOTE, + KEY_EN_POUND, + KEY_EN_ANSI_ENTER, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + }, + //row 4 + { + KEY_EN_LEFT_SHIFT, + KEY_EN_ISO_BACK_SLASH, + KEY_EN_Z, + KEY_EN_X, + KEY_EN_C, + KEY_EN_V, + KEY_EN_B, + KEY_EN_N, + KEY_EN_M, + KEY_EN_COMMA, + KEY_EN_PERIOD, + KEY_EN_FORWARD_SLASH, + KEY_EN_UNUSED, + KEY_EN_RIGHT_SHIFT, + KEY_EN_UNUSED, + KEY_EN_UP_ARROW, + KEY_EN_UNUSED, + }, + //row 5 + { + KEY_EN_LEFT_CONTROL, + KEY_EN_LEFT_WINDOWS, + KEY_EN_LEFT_ALT, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_SPACE, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_RIGHT_ALT, + KEY_EN_RIGHT_WINDOWS, + KEY_EN_RIGHT_FUNCTION, + KEY_EN_RIGHT_CONTROL, + KEY_EN_LEFT_ARROW, + KEY_EN_DOWN_ARROW, + KEY_EN_RIGHT_ARROW, + } }; -static const char *led_names_default[] = -{ - KEY_EN_ESCAPE, - KEY_EN_BACK_TICK, - KEY_EN_TAB, - KEY_EN_CAPS_LOCK, - KEY_EN_LEFT_SHIFT, - KEY_EN_LEFT_CONTROL, - KEY_EN_UNUSED, - KEY_EN_1, - KEY_EN_Q, - KEY_EN_A, - KEY_EN_ISO_BACK_SLASH, //iso key - 10 - KEY_EN_LEFT_WINDOWS, - KEY_EN_F1, - KEY_EN_2, - KEY_EN_W, - KEY_EN_S, - KEY_EN_Z, - KEY_EN_LEFT_ALT, - KEY_EN_F2, - KEY_EN_3, - KEY_EN_E, //20 - KEY_EN_D, - KEY_EN_X, - KEY_EN_UNUSED, //space - KEY_EN_F3, - KEY_EN_4, - KEY_EN_R, - KEY_EN_F, - KEY_EN_C, - KEY_EN_UNUSED, //space - KEY_EN_F4, //30 - KEY_EN_5, - KEY_EN_T, - KEY_EN_G, - KEY_EN_V, - KEY_EN_UNUSED, //space - KEY_EN_F5, - KEY_EN_6, - KEY_EN_Y, - KEY_EN_H, - KEY_EN_B, //40 - KEY_EN_SPACE, - KEY_EN_F6, - KEY_EN_7, - KEY_EN_U, - KEY_EN_J, - KEY_EN_N, - KEY_EN_UNUSED, //space - KEY_EN_F7, - KEY_EN_8, - KEY_EN_I, //50 - KEY_EN_K, - KEY_EN_M, - KEY_EN_UNUSED, //space - KEY_EN_F8, - KEY_EN_9, - KEY_EN_O, - KEY_EN_L, - KEY_EN_COMMA, - KEY_EN_UNUSED, //space - KEY_EN_F9, //60 - KEY_EN_0, - KEY_EN_P, - KEY_EN_SEMICOLON, - KEY_EN_PERIOD, - KEY_EN_RIGHT_ALT, - KEY_EN_F10, - KEY_EN_MINUS, - KEY_EN_LEFT_BRACKET, - KEY_EN_QUOTE, - KEY_EN_FORWARD_SLASH, //70 - KEY_EN_RIGHT_WINDOWS, - KEY_EN_F11, - KEY_EN_EQUALS, - KEY_EN_RIGHT_BRACKET, - KEY_EN_POUND, //iso only - KEY_EN_UNUSED, - KEY_EN_RIGHT_FUNCTION, - KEY_EN_F12, - KEY_EN_BACKSPACE, - KEY_EN_ANSI_BACK_SLASH, //80 - KEY_EN_ANSI_ENTER, - KEY_EN_RIGHT_SHIFT, - KEY_EN_RIGHT_CONTROL, - KEY_EN_PRINT_SCREEN, - KEY_EN_INSERT, - KEY_EN_DELETE, - KEY_EN_UNUSED, - KEY_EN_UNUSED, - KEY_EN_LEFT_ARROW, - KEY_EN_PAUSE_BREAK, //90 - KEY_EN_HOME, - KEY_EN_END, - KEY_EN_UNUSED, - KEY_EN_UP_ARROW, - KEY_EN_DOWN_ARROW, - "Key: Mode", - KEY_EN_PAGE_UP, - KEY_EN_PAGE_DOWN, - KEY_EN_UNUSED, - KEY_EN_SCROLL_LOCK, //100 - Scroll lock for WootingTwo KB's - KEY_EN_RIGHT_ARROW, - "Key: A1", - KEY_EN_NUMPAD_LOCK, - KEY_EN_NUMPAD_7, - KEY_EN_NUMPAD_4, - KEY_EN_NUMPAD_1, - KEY_EN_UNUSED, - "Key: A2", - KEY_EN_NUMPAD_DIVIDE, - KEY_EN_NUMPAD_8, //110 - KEY_EN_NUMPAD_5, - KEY_EN_NUMPAD_2, - KEY_EN_NUMPAD_0, - "Key: A3", - KEY_EN_NUMPAD_TIMES, - KEY_EN_NUMPAD_9, - KEY_EN_NUMPAD_6, - KEY_EN_NUMPAD_3, - KEY_EN_NUMPAD_PERIOD, - "Key: Mode", //120 - Mode key for WootingTwo KB's - KEY_EN_NUMPAD_MINUS, - KEY_EN_NUMPAD_PLUS, - KEY_EN_UNUSED, - KEY_EN_NUMPAD_ENTER, - KEY_EN_UNUSED +static unsigned int matrix_map_80HE[6][17] = { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, NA, 10, 11, 12, 13, 14, 15, 16 }, + { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 }, + { 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, NA, 56, 57, 58 }, + { 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, NA, 77, NA, NA }, + { 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, NA, 97, 98, 99, NA }, + { 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, NA, 119, 120, 121 } }; -static const char *led_names_80HE[] = -{ - KEY_EN_ESCAPE, - KEY_EN_BACK_TICK, - KEY_EN_TAB, - KEY_EN_CAPS_LOCK, - KEY_EN_LEFT_SHIFT, - KEY_EN_LEFT_CONTROL, - KEY_EN_F1, - KEY_EN_1, - KEY_EN_Q, - KEY_EN_A, - KEY_EN_ISO_BACK_SLASH, //iso key - 10 - KEY_EN_LEFT_WINDOWS, - KEY_EN_F2, - KEY_EN_2, - KEY_EN_W, - KEY_EN_S, - KEY_EN_Z, - KEY_EN_LEFT_ALT, - KEY_EN_F3, - KEY_EN_3, - KEY_EN_E, //20 - KEY_EN_D, - KEY_EN_X, - KEY_EN_UNUSED, //space - KEY_EN_F4, - KEY_EN_4, - KEY_EN_R, - KEY_EN_F, - KEY_EN_C, - KEY_EN_UNUSED, //space - KEY_EN_F5, //30 - KEY_EN_5, - KEY_EN_T, - KEY_EN_G, - KEY_EN_V, - KEY_EN_UNUSED, //space - KEY_EN_F6, - KEY_EN_6, - KEY_EN_Y, - KEY_EN_H, - KEY_EN_B, //40 - KEY_EN_SPACE, - KEY_EN_F7, - KEY_EN_7, - KEY_EN_U, - KEY_EN_J, - KEY_EN_N, - KEY_EN_UNUSED, //space - KEY_EN_F8, - KEY_EN_8, - KEY_EN_I, //50 - KEY_EN_K, - KEY_EN_M, - KEY_EN_UNUSED, //space - KEY_EN_UNUSED, - KEY_EN_9, - KEY_EN_O, - KEY_EN_L, - KEY_EN_COMMA, - KEY_EN_UNUSED, //space - KEY_EN_F9, //60 - KEY_EN_0, - KEY_EN_P, - KEY_EN_SEMICOLON, - KEY_EN_PERIOD, - KEY_EN_RIGHT_ALT, - KEY_EN_F10, - KEY_EN_MINUS, - KEY_EN_LEFT_BRACKET, - KEY_EN_QUOTE, - KEY_EN_FORWARD_SLASH, //70 - KEY_EN_RIGHT_WINDOWS, - KEY_EN_F11, - KEY_EN_EQUALS, - KEY_EN_RIGHT_BRACKET, - KEY_EN_POUND, //iso only - KEY_EN_UNUSED, - KEY_EN_RIGHT_FUNCTION, - KEY_EN_F12, - KEY_EN_UNUSED, - KEY_EN_ANSI_BACK_SLASH, //80 - KEY_EN_UNUSED, - KEY_EN_UNUSED, - KEY_EN_RIGHT_CONTROL, - "Key: Mode", - KEY_EN_BACKSPACE, - KEY_EN_UNUSED, - KEY_EN_ANSI_ENTER, - KEY_EN_RIGHT_SHIFT, - KEY_EN_LEFT_ARROW, - KEY_EN_PRINT_SCREEN, //90 - KEY_EN_HOME, - KEY_EN_END, - KEY_EN_UNUSED, - KEY_EN_UP_ARROW, - KEY_EN_DOWN_ARROW, - KEY_EN_UNUSED, - KEY_EN_PAGE_UP, - KEY_EN_PAGE_DOWN, - KEY_EN_UNUSED, - KEY_EN_PAUSE_BREAK, //100 - Scroll lock for WootingTwo KB's - KEY_EN_RIGHT_ARROW +static const char *led_names_80HE[6][17] { + //Row 0 + { + KEY_EN_ESCAPE, + KEY_EN_F1, + KEY_EN_F2, + KEY_EN_F3, + KEY_EN_F4, + KEY_EN_F5, + KEY_EN_F6, + KEY_EN_F7, + KEY_EN_F8, + KEY_EN_UNUSED, + KEY_EN_F9, + KEY_EN_F10, + KEY_EN_F11, + KEY_EN_F12, + "Key: Mode", + KEY_EN_PRINT_SCREEN, + KEY_EN_PAUSE_BREAK, + }, + //row 1 + { + KEY_EN_BACK_TICK, + KEY_EN_1, + KEY_EN_2, + KEY_EN_3, + KEY_EN_4, + KEY_EN_5, + KEY_EN_6, + KEY_EN_7, + KEY_EN_8, + KEY_EN_9, + KEY_EN_0, + KEY_EN_MINUS, + KEY_EN_PLUS, + "Key: JIS Specific TODO", + KEY_EN_BACKSPACE, + KEY_EN_INSERT, + KEY_EN_HOME, + }, + //row 2 + { + KEY_EN_TAB, + KEY_EN_Q, + KEY_EN_W, + KEY_EN_E, + KEY_EN_R, + KEY_EN_T, + KEY_EN_Y, + KEY_EN_U, + KEY_EN_I, + KEY_EN_O, + KEY_EN_P, + KEY_EN_LEFT_BRACKET, + KEY_EN_RIGHT_BRACKET, + KEY_EN_UNUSED, + KEY_EN_BACK_SLASH, + KEY_EN_DELETE, + KEY_EN_END, + }, + //row 3 + { + KEY_EN_CAPS_LOCK, + KEY_EN_A, + KEY_EN_S, + KEY_EN_D, + KEY_EN_F, + KEY_EN_G, + KEY_EN_H, + KEY_EN_J, + KEY_EN_K, + KEY_EN_L, + KEY_EN_SEMICOLON, + KEY_EN_QUOTE, + KEY_EN_POUND, + KEY_EN_UNUSED, + KEY_EN_ANSI_ENTER, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + }, + //row 4 + { + KEY_EN_LEFT_SHIFT, + KEY_EN_ISO_BACK_SLASH, + KEY_EN_Z, + KEY_EN_X, + KEY_EN_C, + KEY_EN_V, + KEY_EN_B, + KEY_EN_N, + KEY_EN_M, + KEY_EN_COMMA, + KEY_EN_PERIOD, + KEY_EN_FORWARD_SLASH, + KEY_EN_UNUSED, + "Key: JIS Specific TODO", + KEY_EN_RIGHT_SHIFT, + KEY_EN_UP_ARROW, + KEY_EN_UNUSED, + }, + //row 5 + { + KEY_EN_LEFT_CONTROL, + KEY_EN_LEFT_WINDOWS, + KEY_EN_LEFT_ALT, + "Key: JIS Specific TODO", + "Spacebar LED 1", + "Spacebar LED 2", + KEY_EN_SPACE, + "Spacebar LED 3", + "Spacebar LED 4", + "Key: JIS Specific TODO", + KEY_EN_RIGHT_ALT, + KEY_EN_RIGHT_WINDOWS, + KEY_EN_RIGHT_FUNCTION, + KEY_EN_UNUSED, + KEY_EN_LEFT_ARROW, + KEY_EN_DOWN_ARROW, + KEY_EN_RIGHT_ARROW, + } +}; + +static unsigned int matrix_map_60[5][14] = { + { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 }, + { 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 }, + { 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 }, + { 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, NA, 97 }, + { 105, 106, 107, NA, 109, 110, 111, 112, 113, NA, 115, 116, 117, 118 } +}; + +static const char *led_names_60HE[5][14] { + //row 0 + { + KEY_EN_ESCAPE, + KEY_EN_1, + KEY_EN_2, + KEY_EN_3, + KEY_EN_4, + KEY_EN_5, + KEY_EN_6, + KEY_EN_7, + KEY_EN_8, + KEY_EN_9, + KEY_EN_0, + KEY_EN_MINUS, + KEY_EN_PLUS, + KEY_EN_BACKSPACE, + }, + //row 1 + { + KEY_EN_TAB, + KEY_EN_Q, + KEY_EN_W, + KEY_EN_E, + KEY_EN_R, + KEY_EN_T, + KEY_EN_Y, + KEY_EN_U, + KEY_EN_I, + KEY_EN_O, + KEY_EN_P, + KEY_EN_LEFT_BRACKET, + KEY_EN_RIGHT_BRACKET, + KEY_EN_BACK_SLASH, + }, + //row 2 + { + KEY_EN_CAPS_LOCK, + KEY_EN_A, + KEY_EN_S, + KEY_EN_D, + KEY_EN_F, + KEY_EN_G, + KEY_EN_H, + KEY_EN_J, + KEY_EN_K, + KEY_EN_L, + KEY_EN_SEMICOLON, + KEY_EN_QUOTE, + KEY_EN_POUND, + KEY_EN_ANSI_ENTER, + }, + //row 3 + { + KEY_EN_LEFT_SHIFT, + KEY_EN_ISO_BACK_SLASH, + KEY_EN_Z, + KEY_EN_X, + KEY_EN_C, + KEY_EN_V, + KEY_EN_B, + KEY_EN_N, + KEY_EN_M, + KEY_EN_COMMA, + KEY_EN_PERIOD, + KEY_EN_FORWARD_SLASH, + KEY_EN_UNUSED, + KEY_EN_RIGHT_SHIFT, + }, + //row 4 + { + KEY_EN_LEFT_CONTROL, + KEY_EN_LEFT_WINDOWS, + KEY_EN_LEFT_ALT, + KEY_EN_UNUSED, + "Spacebar LED 1", + "Spacebar LED 2", + KEY_EN_SPACE, + "Spacebar LED 3", + "Spacebar LED 4", + KEY_EN_UNUSED, + KEY_EN_RIGHT_ALT, + KEY_EN_MENU, + KEY_EN_RIGHT_CONTROL, + KEY_EN_RIGHT_FUNCTION, + } +}; + +static unsigned int matrix_map_3pad[5][7] = { + { 0, NA, 2, NA, 4, NA, 6 }, + { 21, NA, NA, NA, NA, NA, 27 }, + { 42, 43, NA, 45, NA, 47, 48 }, + { 63, NA, NA, NA, NA, NA, 69 }, + { NA, 85, 86, NA, 88, 89, NA } +}; + +static const char *led_names_3pad[5][7] { + //row 0 + { + //top, right to left + "Lightbar 14", + KEY_EN_UNUSED, + "Lightbar 13", + KEY_EN_UNUSED, + "Lightbar 12", + KEY_EN_UNUSED, + "Lightbar 11", + }, + //row 1 + { + "Lighbar 1", //left side, top led + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + "Lightbar 10",//right side, top led + }, + //row 2 + { + "Lightbar 2",//left side, middle led + "Keypad 1", + KEY_EN_UNUSED, + "Keypad 2", + KEY_EN_UNUSED, + "Keypad 3", + "Lightbar 9",//right side, middle led + }, + //row 3 + { + "Lightbar 3",//left side, bottom led + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + KEY_EN_UNUSED, + "Lightbar 8",//right side, bottom led + }, + //row 4 + { + //bottom leds, left to right + KEY_EN_UNUSED, + "Lightbar 4", + "Lightbar 5", + KEY_EN_UNUSED, + "Lightbar 6", + "Lightbar 7", + KEY_EN_UNUSED, + } }; /**------------------------------------------------------------------*\ @@ -297,7 +606,7 @@ static const char *led_names_80HE[] = @save :x: @direct :white_check_mark: @effects :x: - @detectors DetectWootingOneKeyboardControllers,DetectWootingTwoKeyboardControllers + @detectors DetectWootingV1KeyboardControllers,DetectWootingV2KeyboardControllers @comment \*-------------------------------------------------------------------*/ @@ -345,10 +654,78 @@ void RGBController_WootingKeyboard::SetupZones() /*---------------------------------------------------------*\ | Set up zones | \*---------------------------------------------------------*/ - uint8_t wooting_type = controller->GetWootingType(); - unsigned int total_led_count = zone_sizes[wooting_type]; + WOOTING_DEVICE_TYPE wooting_type = controller->GetWootingType(); + const char** led_names = nullptr; + unsigned int* matrix_map = nullptr; + size_t matrix_rows = 0; + size_t matrix_columns = 0; + + if(wooting_type == WOOTING_KB_TKL) + { + matrix_map = (unsigned int *)matrix_map_tkl; + led_names = (const char **)led_names_tkl; + matrix_rows = 6; + matrix_columns = 17; + } + else if(wooting_type == WOOTING_KB_80PER) + { + matrix_map = (unsigned int *)matrix_map_80HE; + led_names = (const char **)led_names_80HE; + matrix_rows = 6; + matrix_columns = 17; + } + else if(wooting_type == WOOTING_KB_60PER) + { + matrix_map = (unsigned int *)matrix_map_60; + led_names = (const char **)led_names_60HE; + matrix_rows = 5; + matrix_columns = 14; + } + else if(wooting_type == WOOTING_KB_3PAD) + { + matrix_map = (unsigned int *)matrix_map_3pad; + led_names = (const char **)led_names_3pad; + matrix_rows = 5; + matrix_columns = 7; + } + else // Fullsize and default + { + matrix_map = (unsigned int *)matrix_map_full; + led_names = (const char **)led_names_full; + matrix_rows = 6; + matrix_columns = 21; + } + + unsigned int* new_matrix = new unsigned int[matrix_rows * matrix_columns]; + unsigned int total_led_count = 0; + + for(size_t row = 0; row < matrix_rows; row++) + { + for(size_t col = 0; col < matrix_columns; col++) + { + size_t idx = row * matrix_columns + col; + unsigned int hardware_index = matrix_map[idx]; + + if(hardware_index == NA) + { + new_matrix[idx] = NA; + continue; + } + + led new_led; + new_led.name = led_names[idx]; + new_led.value = hardware_index; + + leds.push_back(new_led); + + // 3. The zone map now points to the LED's position in the vector + new_matrix[idx] = total_led_count; + total_led_count++; + } + } + + - LOG_DEBUG("%sCreating New Zone", WOOTING_CONTROLLER_NAME); zone new_zone; new_zone.name = name.append(" zone"); @@ -357,41 +734,12 @@ void RGBController_WootingKeyboard::SetupZones() new_zone.leds_max = total_led_count; new_zone.leds_count = total_led_count; new_zone.matrix_map = new matrix_map_type; - new_zone.matrix_map->height = WOOTING_RGB_ROWS; - - if(wooting_type == WOOTING_KB_TKL) - { - new_zone.matrix_map->width = WOOTING_ONE_RGB_COLUMNS; - new_zone.matrix_map->map = (unsigned int *)&matrix_map_tkl; - } - else if(wooting_type == WOOTING_80HE) - { - new_zone.matrix_map->width = WOOTING_ONE_RGB_COLUMNS; - new_zone.matrix_map->map = (unsigned int *)&matrix_map_80HE; - } - else - { - new_zone.matrix_map->width = WOOTING_TWO_RGB_COLUMNS; - new_zone.matrix_map->map = (unsigned int *)&matrix_map_full; - } + new_zone.matrix_map->height = (unsigned int)matrix_rows; + new_zone.matrix_map->width = (unsigned int)matrix_columns; + new_zone.matrix_map->map = new_matrix; zones.push_back(new_zone); - LOG_DEBUG("%sCreating LED array - total_led_count %03i", WOOTING_CONTROLLER_NAME, total_led_count); - - static const char **led_names = (wooting_type == WOOTING_80HE) ? led_names_80HE : led_names_default; - for (unsigned int led_idx = 0; led_idx < total_led_count; led_idx++) - { - led new_led; - - new_led.name = led_names[led_idx]; - - LOG_DEBUG("%sPushing LED %03i - %s into vector", WOOTING_CONTROLLER_NAME, led_idx, new_led.name.c_str()); - leds.push_back(new_led); - } - - LOG_DEBUG("%sLEDs created - Initialising Colours", WOOTING_CONTROLLER_NAME); - SetupColors(); } @@ -404,7 +752,15 @@ void RGBController_WootingKeyboard::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_WootingKeyboard::DeviceUpdateLEDs() { - controller->SendDirect(&colors[0], (uint8_t)colors.size()); + RGBColor framebuffer[WOOTING_RGB_ROWS * WOOTING_RGB_COLUMNS] = {0}; + + for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++) + { + unsigned int framebuffer_index = leds[led_idx].value; + framebuffer[framebuffer_index] = colors[led_idx]; + } + + controller->SendDirect(&framebuffer[0], WOOTING_RGB_ROWS * WOOTING_RGB_COLUMNS); } void RGBController_WootingKeyboard::UpdateZoneLEDs(int /*zone*/) diff --git a/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.h b/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.h index 2a4925260..e37c4d9bc 100644 --- a/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.h +++ b/Controllers/WootingKeyboardController/RGBController_WootingKeyboard.h @@ -3,7 +3,7 @@ | | | RGBController for Wooting keyboard | | | -| Diogo Trindade (diogotr7) 04 Mar 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | diff --git a/Controllers/WootingKeyboardController/WootingKeyboardController.cpp b/Controllers/WootingKeyboardController/WootingKeyboardController.cpp index 4f1fc5ad5..daef89f1d 100644 --- a/Controllers/WootingKeyboardController/WootingKeyboardController.cpp +++ b/Controllers/WootingKeyboardController/WootingKeyboardController.cpp @@ -56,28 +56,20 @@ std::string WootingKeyboardController::GetSerial() return(StringUtils::wstring_to_string(serial_string)); } -uint8_t WootingKeyboardController::GetWootingType() +WOOTING_DEVICE_TYPE WootingKeyboardController::GetWootingType() { return wooting_type; } +void WootingKeyboardController::SendInitialize() +{ + wooting_usb_send_feature(WOOTING_COLOR_INIT_COMMAND, 0,0,0,0); + + std::this_thread::sleep_for(std::chrono::milliseconds(50)); +} + bool WootingKeyboardController::wooting_usb_send_feature(uint8_t commandId, uint8_t parameter0, uint8_t parameter1, uint8_t parameter2, uint8_t parameter3) { - /*---------------------------------------------------------*\ - | Prevent sending unnecessary data to the Wootings if the | - | index exceedes it's capabilities | - \*---------------------------------------------------------*/ - if ((commandId == WOOTING_SINGLE_COLOR_COMMAND && parameter0 > key_code_limit) - || (commandId == WOOTING_SINGLE_RESET_COMMAND && parameter3 > key_code_limit)) - { - /*-----------------------------------------------------*\ - | This is not a USB error so let's return true. | - | wooting_rgb_direct_set_key would also behave | - | differently otherwise. | - \*-----------------------------------------------------*/ - return true; - } - uint8_t feature_buffer[WOOTING_COMMAND_SIZE] = { 0, 0xD0, 0xDA }; /*---------------------------------------------------------*\ diff --git a/Controllers/WootingKeyboardController/WootingKeyboardController.h b/Controllers/WootingKeyboardController/WootingKeyboardController.h index 0260091a1..d7363b794 100644 --- a/Controllers/WootingKeyboardController/WootingKeyboardController.h +++ b/Controllers/WootingKeyboardController/WootingKeyboardController.h @@ -4,6 +4,7 @@ | Driver for Wooting keyboard | | | | Chris M (Dr_No) 09 Jul 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | @@ -17,20 +18,20 @@ #include "LogManager.h" #define WOOTING_COMMAND_SIZE 8 -#define WOOTING_REPORT_SIZE 129 #define WOOTING_RAW_COLORS_REPORT 11 #define WOOTING_SINGLE_COLOR_COMMAND 30 #define WOOTING_SINGLE_RESET_COMMAND 31 #define WOOTING_RESET_ALL_COMMAND 32 #define WOOTING_COLOR_INIT_COMMAND 33 -#define WOOTING_ONE_KEY_CODE_LIMIT 95 -#define WOOTING_TWO_KEY_CODE_LIMIT 116 -#define RGB_RAW_BUFFER_SIZE 96 + #define WOOTING_RGB_ROWS 6 #define WOOTING_RGB_COLUMNS 21 + #define WOOTING_ONE_RGB_COLUMNS 17 #define WOOTING_TWO_RGB_COLUMNS 21 +#define WOOTING_60_RGB_COLUMNS 14 +#define WOOTING_3PAD_RGB_COLUMNS 7 /*---------------------------------------------------------*\ | Placeholder for compilation. Redefined by each subclass | @@ -41,7 +42,9 @@ enum WOOTING_DEVICE_TYPE { WOOTING_KB_TKL = 0, WOOTING_KB_FULL = 1, - WOOTING_80HE = 2 + WOOTING_KB_60PER = 2, + WOOTING_KB_3PAD = 3, + WOOTING_KB_80PER = 4, }; enum RGB_PARTS @@ -64,21 +67,17 @@ public: std::string vendor; std::string description; std::string location; - uint8_t wooting_type; - uint8_t key_code_limit; + WOOTING_DEVICE_TYPE wooting_type; std::string GetName(); std::string GetVendor(); std::string GetDescription(); std::string GetLocation(); std::string GetSerial(); - uint8_t GetWootingType(); + WOOTING_DEVICE_TYPE GetWootingType(); bool wooting_usb_send_feature(uint8_t command, uint8_t param0, uint8_t param1, uint8_t param2, uint8_t param3); virtual void SendDirect(RGBColor* colors, uint8_t color_count) = 0; - -private: - virtual void SendInitialize() = 0; - virtual bool wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* rgb_buffer) = 0; + virtual void SendInitialize(); }; diff --git a/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp b/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp index ff7c256c8..3fbf516c9 100644 --- a/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp +++ b/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp @@ -3,7 +3,7 @@ | | | Detector for Wooting keyboard | | | -| Diogo Trindade (diogotr7) 04 Mar 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | @@ -11,11 +11,15 @@ #include #include "Detector.h" -#include "WootingOneKeyboardController.h" -#include "WootingTwoKeyboardController.h" +#include "WootingV1KeyboardController.h" +#include "WootingV2KeyboardController.h" +#include "WootingV3KeyboardController.h" #include "RGBController_WootingKeyboard.h" #include "LogManager.h" +#define WOOTING_CONFIG_USAGE_PAGE_V2 0x1337 +#define WOOTING_CONFIG_USAGE_PAGE_V3 0xFF55 + /*-----------------------------------------------------*\ | Wooting vendor ID | \*-----------------------------------------------------*/ @@ -24,110 +28,159 @@ /*-----------------------------------------------------*\ | Keyboard product IDs | -| Gamepad Mode: X = Xbox | C = Classic | N = None | \*-----------------------------------------------------*/ -#define WOOTING_ONE_OLD_PID 0xFF01 -#define WOOTING_TWO_OLD_PID 0xFF02 -#define WOOTING_ONE_X_PID 0x1100 -#define WOOTING_ONE_C_PID 0x1101 -#define WOOTING_ONE_N_PID 0x1102 -#define WOOTING_TWO_X_PID 0x1200 -#define WOOTING_TWO_C_PID 0x1201 -#define WOOTING_TWO_N_PID 0x1202 -#define WOOTING_TWO_LE_X_PID 0x1210 -#define WOOTING_TWO_LE_C_PID 0x1211 -#define WOOTING_TWO_LE_N_PID 0x1212 -#define WOOTING_TWO_HE_X_PID 0x1220 -#define WOOTING_TWO_HE_C_PID 0x1221 -#define WOOTING_TWO_HE_N_PID 0x1222 -#define WOOTING_TWO_HE_ARM_X_PID 0x1230 -#define WOOTING_TWO_HE_ARM_C_PID 0x1231 -#define WOOTING_TWO_HE_ARM_N_PID 0x1232 -#define WOOTING_TWO_60_X_PID 0x1300 -#define WOOTING_TWO_60_C_PID 0x1301 -#define WOOTING_TWO_60_N_PID 0x1302 -#define WOOTING_TWO_60_HE_ARM_X_PID 0x1310 -#define WOOTING_TWO_60_HE_ARM_C_PID 0x1311 -#define WOOTING_TWO_60_HE_ARM_N_PID 0x1312 -#define WOOTING_TWO_UWU_RGB_X_PID 0x1510 -#define WOOTING_TWO_UWU_RGB_C_PID 0x1511 -#define WOOTING_TWO_UWU_RGB_N_PID 0x1512 -#define WOOTING_TWO_80HE_PID 0x1400 +#define WOOTING_ONE_LEGACY_PID 0xFF01 +#define WOOTING_TWO_LEGACY_PID 0xFF02 +#define WOOTING_ONE_PID 0x1100 +#define WOOTING_TWO_PID 0x1200 +#define WOOTING_TWO_LE_PID 0x1210 +#define WOOTING_TWO_HE_PID 0x1220 +#define WOOTING_TWO_HE_ARM_PID 0x1230 +#define WOOTING_60HE_PID 0x1300 +#define WOOTING_60HE_ARM_PID 0x1310 +#define WOOTING_60HE_PLUS_PID 0x1320 +#define WOOTING_60HE_V2_PID 0x1340 +#define WOOTING_80HE_PID 0x1400 +#define WOOTING_UWU_RGB_PID 0x1510 -void DetectWootingOneKeyboardControllers(hid_device_info* info, const std::string& name) +/*-----------------------------------------------------*\ +| Product ID helpers | +| XINP: Xbox input emulation enabled | +| DINP: Classic DirectInput emulation enabled | +| NONE: Controller emulation disabled | +\*-----------------------------------------------------*/ +#define XINP_PID(pid) (pid | 0x0000) +#define DINP_PID(pid) (pid | 0x0001) +#define NONE_PID(pid) (pid | 0x0002) + +void DetectWootingControllers(hid_device_info *info, const std::string &name) { - static const char* controller_name = "WootingONE"; + static const char *controller_name = "Wooting"; LOG_DEBUG("[%s] Interface %i\tPage %04X\tUsage %i\tPath %s", controller_name, info->interface_number, info->usage_page, info->usage, info->path); - hid_device* dev = hid_open_path(info->path); + hid_device *dev = hid_open_path(info->path); - if(dev) + if(!dev) + return; + + WOOTING_DEVICE_TYPE wooting_type; + uint16_t pid = info->product_id; + + if(pid == WOOTING_ONE_LEGACY_PID) { - // TODO: 60% Keymap for Wooting Two 60HE - uint8_t wooting_type = (info->product_id == WOOTING_ONE_OLD_PID) ? WOOTING_KB_TKL : WOOTING_KB_FULL; + wooting_type = WOOTING_KB_TKL; + } + else if(pid == WOOTING_TWO_LEGACY_PID) + { + wooting_type = WOOTING_KB_FULL; + } + else + { + //on modern devices, mask out the last nibble to get base PID + switch(pid & 0xFFF0) + { + case WOOTING_ONE_LEGACY_PID: + case WOOTING_ONE_PID: + wooting_type = WOOTING_KB_TKL; + break; + case WOOTING_TWO_LEGACY_PID: + case WOOTING_TWO_PID: + case WOOTING_TWO_LE_PID: + case WOOTING_TWO_HE_PID: + case WOOTING_TWO_HE_ARM_PID: + wooting_type = WOOTING_KB_FULL; + break; + case WOOTING_60HE_PID: + case WOOTING_60HE_ARM_PID: + case WOOTING_60HE_PLUS_PID: + case WOOTING_60HE_V2_PID: + wooting_type = WOOTING_KB_60PER; + break; + case WOOTING_80HE_PID: + wooting_type = WOOTING_KB_80PER; + break; + case WOOTING_UWU_RGB_PID: + wooting_type = WOOTING_KB_3PAD; + break; + default: + //default to largest keyboard if unknown + wooting_type = WOOTING_KB_FULL; + break; + } + } - LOG_DEBUG("[%s] Device type %i opened - creating Controller", controller_name, wooting_type); - WootingOneKeyboardController* controller = new WootingOneKeyboardController(dev, info->path, wooting_type, name); + LOG_INFO("[%s] Detected Wooting device type %i for device at path %s", controller_name, wooting_type, info->path); + + //V1 firmware used the ATMEL VID, and uses the V1 controller + if(info->vendor_id == WOOTING_OLD_VID && info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V2) + { + LOG_DEBUG("[%s] Old VID detected - creating V1 Controller", controller_name); + WootingV1KeyboardController *controller = new WootingV1KeyboardController(dev, info->path, wooting_type, name); LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name); - RGBController_WootingKeyboard* rgb_controller = new RGBController_WootingKeyboard(controller); + RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller); LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str()); ResourceManager::get()->RegisterRGBController(rgb_controller); + return; } -} -void DetectWootingTwoKeyboardControllers(hid_device_info* info, const std::string& name) -{ - static const char* controller_name = "WootingTWO"; - LOG_DEBUG("[%s] Interface %i\tPage %04X\tUsage %i\tPath %s", controller_name, info->interface_number, info->usage_page, info->usage, info->path); - - hid_device* dev = hid_open_path(info->path); - - if(dev) + //V2-V2.11 firmware uses the V2 protocol indicated by the V2 usage page + if(info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V2) { - uint8_t wooting_type; - switch(info->product_id) - { - case WOOTING_TWO_80HE_PID : wooting_type = WOOTING_80HE; break; - default : wooting_type = WOOTING_KB_FULL; break; - } + LOG_DEBUG("[%s] V2 usage page detected - creating V2 Controller", controller_name); + WootingV2KeyboardController *controller = new WootingV2KeyboardController(dev, info->path, wooting_type, name); - LOG_DEBUG("[%s] Device type %i opened - creating Controller", controller_name, wooting_type); - WootingTwoKeyboardController* controller = new WootingTwoKeyboardController(dev, info->path, wooting_type, name); - - LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name); - RGBController_WootingKeyboard* rgb_controller = new RGBController_WootingKeyboard(controller); + LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name); + RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller); LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str()); ResourceManager::get()->RegisterRGBController(rgb_controller); + return; } -} -REGISTER_HID_DETECTOR_PU("Wooting One (Legacy)", DetectWootingOneKeyboardControllers, WOOTING_OLD_VID, WOOTING_ONE_OLD_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two (Legacy)", DetectWootingOneKeyboardControllers, WOOTING_OLD_VID, WOOTING_TWO_OLD_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting One (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_ONE_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting One (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_ONE_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting One (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_ONE_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two LE (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_LE_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two LE (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_LE_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two LE (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_LE_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two HE (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two HE (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two HE (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two HE (ARM) (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_ARM_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two HE (ARM) (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_ARM_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two HE (ARM) (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_ARM_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two 60HE (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_60_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two 60HE (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_60_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two 60HE (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_60_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two 60HE (ARM) (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_60_HE_ARM_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two 60HE (ARM) (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_60_HE_ARM_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two 60HE (ARM) (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_60_HE_ARM_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two UwU RGB (Xbox)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_UWU_RGB_X_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two UwU RGB (Classic)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_UWU_RGB_C_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two UwU RGB (None)", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_UWU_RGB_N_PID, 0x1337, 1); -REGISTER_HID_DETECTOR_PU("Wooting Two 80HE", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_80HE_PID, 0x1337, 1); + //V2.12+ firmware uses the new report structure indicated by the V3 usage page + if(info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V3) + { + LOG_DEBUG("[%s] V3 usage page detected - creating V3 Controller", controller_name); + WootingV3KeyboardController *controller = new WootingV3KeyboardController(dev, info->path, wooting_type, name); + + LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name); + RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller); + + LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str()); + ResourceManager::get()->RegisterRGBController(rgb_controller); + return; + } + + hid_close(dev); + + LOG_TRACE("[%s] No compatible Wooting controller found for device at path %s", controller_name, info->path); +} +/*-----------------------------------------------------*\ +| Wooting keyboards use different PIDs based on which | +| gamepad emulation mode is selected. We can use their | +| base PID, and set the last nibble to get the modes. | +\*-----------------------------------------------------*/ +#define REGISTER_WOOTING_DETECTOR(name, vid, pid) \ + static HIDDeviceDetector detector_wooting_##vid##_##pid##_base(name, DetectWootingControllers, vid, NONE_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY); \ + static HIDDeviceDetector detector_wooting_##vid##_##pid##_xinp(name, DetectWootingControllers, vid, XINP_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY); \ + static HIDDeviceDetector detector_wooting_##vid##_##pid##_dinp(name, DetectWootingControllers, vid, DINP_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) + + +// Legacy devices with V1 firmware +REGISTER_HID_DETECTOR_P("Wooting One (Legacy)", DetectWootingControllers, WOOTING_OLD_VID, WOOTING_ONE_LEGACY_PID, WOOTING_CONFIG_USAGE_PAGE_V2); +REGISTER_HID_DETECTOR_P("Wooting Two (Legacy)", DetectWootingControllers, WOOTING_OLD_VID, WOOTING_TWO_LEGACY_PID, WOOTING_CONFIG_USAGE_PAGE_V2); + +// All other devices +REGISTER_WOOTING_DETECTOR("Wooting One", WOOTING_NEW_VID, WOOTING_ONE_PID ); +REGISTER_WOOTING_DETECTOR("Wooting Two", WOOTING_NEW_VID, WOOTING_TWO_PID ); +REGISTER_WOOTING_DETECTOR("Wooting Two Lekker Edition", WOOTING_NEW_VID, WOOTING_TWO_LE_PID ); +REGISTER_WOOTING_DETECTOR("Wooting Two HE", WOOTING_NEW_VID, WOOTING_TWO_HE_PID ); +REGISTER_WOOTING_DETECTOR("Wooting Two HE (ARM)", WOOTING_NEW_VID, WOOTING_TWO_HE_ARM_PID); +REGISTER_WOOTING_DETECTOR("Wooting 60HE", WOOTING_NEW_VID, WOOTING_60HE_PID ); +REGISTER_WOOTING_DETECTOR("Wooting 60HE (ARM)", WOOTING_NEW_VID, WOOTING_60HE_ARM_PID ); +REGISTER_WOOTING_DETECTOR("Wooting 60HE+", WOOTING_NEW_VID, WOOTING_60HE_PLUS_PID ); +REGISTER_WOOTING_DETECTOR("Wooting 60HEv2", WOOTING_NEW_VID, WOOTING_60HE_V2_PID ); +REGISTER_WOOTING_DETECTOR("Wooting 80HE", WOOTING_NEW_VID, WOOTING_80HE_PID ); +REGISTER_WOOTING_DETECTOR("Wooting UwU RGB", WOOTING_NEW_VID, WOOTING_UWU_RGB_PID ); diff --git a/Controllers/WootingKeyboardController/WootingOneKeyboardController/WootingOneKeyboardController.cpp b/Controllers/WootingKeyboardController/WootingV1KeyboardController/WootingV1KeyboardController.cpp similarity index 85% rename from Controllers/WootingKeyboardController/WootingOneKeyboardController/WootingOneKeyboardController.cpp rename to Controllers/WootingKeyboardController/WootingV1KeyboardController/WootingV1KeyboardController.cpp index d3326405b..ccc14f5f0 100644 --- a/Controllers/WootingKeyboardController/WootingOneKeyboardController/WootingOneKeyboardController.cpp +++ b/Controllers/WootingKeyboardController/WootingV1KeyboardController/WootingV1KeyboardController.cpp @@ -1,9 +1,9 @@ /*---------------------------------------------------------*\ -| WootingOneKeyboardController.cpp | +| WootingV1KeyboardController.cpp | | | -| Driver for Wooting One keyboard | +| Driver for Wooting keyboards with v1 firmware | | | -| Diogo Trindade (diogotr7) 04 Mar 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | @@ -11,13 +11,14 @@ #include #include "StringUtils.h" -#include "WootingOneKeyboardController.h" +#include "WootingV1KeyboardController.h" #undef WOOTING_CONTROLLER_NAME #define WOOTING_CONTROLLER_NAME "[WootingONE] " //0xFFFFFFFF indicates an unused entry in matrix #define NA 0xFFFFFFFF +#define RGB_RAW_BUFFER_SIZE 96 static const unsigned int rgb_led_index[WOOTING_RGB_ROWS][WOOTING_RGB_COLUMNS] = { @@ -53,13 +54,13 @@ static uint16_t getCrc16ccitt(const uint8_t* buffer, uint16_t size) return crc; } -WootingOneKeyboardController::WootingOneKeyboardController(hid_device* dev_handle, const char *path, uint8_t wooting_type, std::string dev_name) +WootingV1KeyboardController::WootingV1KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name) { dev = dev_handle; location = path; name = dev_name; this->wooting_type = wooting_type; - key_code_limit = (wooting_type == WOOTING_KB_TKL) ? WOOTING_ONE_KEY_CODE_LIMIT : WOOTING_TWO_KEY_CODE_LIMIT; + key_code_limit = WOOTING_TWO_KEY_CODE_LIMIT; /*---------------------------------------------------------*\ | Get device HID manufacturer and product strings | @@ -76,12 +77,12 @@ WootingOneKeyboardController::WootingOneKeyboardController(hid_device* dev_handl SendInitialize(); } -WootingOneKeyboardController::~WootingOneKeyboardController() +WootingV1KeyboardController::~WootingV1KeyboardController() { } -void WootingOneKeyboardController::SendDirect(RGBColor* colors, uint8_t colour_count) +void WootingV1KeyboardController::SendDirect(RGBColor* colors, uint8_t colour_count) { const uint8_t pwm_mem_map[48] = { @@ -97,9 +98,11 @@ void WootingOneKeyboardController::SendDirect(RGBColor* colors, uint8_t colour_c unsigned char buffer3[RGB_RAW_BUFFER_SIZE] = {0}; unsigned char buffer4[RGB_RAW_BUFFER_SIZE] = {0}; - for(std::size_t color_idx = 0; color_idx < colour_count; color_idx++) + for(std::size_t index = 0; index < colour_count; index++) { - unsigned char led_index = rgb_led_index[color_idx % 6][color_idx / 6]; + unsigned char row = index / WOOTING_RGB_COLUMNS; + unsigned char col = index % WOOTING_RGB_COLUMNS; + unsigned char led_index = rgb_led_index[row][col]; if(led_index > key_code_limit) { @@ -130,9 +133,9 @@ void WootingOneKeyboardController::SendDirect(RGBColor* colors, uint8_t colour_c } unsigned char buffer_index = pwm_mem_map[led_index % 24]; - buffer_pointer[buffer_index + 0x00] = RGBGetRValue(colors[color_idx]); - buffer_pointer[buffer_index + 0x10] = RGBGetGValue(colors[color_idx]); - buffer_pointer[buffer_index + 0x20] = RGBGetBValue(colors[color_idx]); + buffer_pointer[buffer_index + 0x00] = RGBGetRValue(colors[index]); + buffer_pointer[buffer_index + 0x10] = RGBGetGValue(colors[index]); + buffer_pointer[buffer_index + 0x20] = RGBGetBValue(colors[index]); } wooting_usb_send_buffer(RGB_PARTS::PART0, buffer0); @@ -145,14 +148,7 @@ void WootingOneKeyboardController::SendDirect(RGBColor* colors, uint8_t colour_c } } -void WootingOneKeyboardController::SendInitialize() -{ - wooting_usb_send_feature(WOOTING_COLOR_INIT_COMMAND, 0,0,0,0); - - std::this_thread::sleep_for(std::chrono::milliseconds(50)); -} - -bool WootingOneKeyboardController::wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* rgb_buffer) +bool WootingV1KeyboardController::wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* rgb_buffer) { unsigned char report_buffer[WOOTING_REPORT_SIZE] = {0}; diff --git a/Controllers/WootingKeyboardController/WootingOneKeyboardController/WootingOneKeyboardController.h b/Controllers/WootingKeyboardController/WootingV1KeyboardController/WootingV1KeyboardController.h similarity index 53% rename from Controllers/WootingKeyboardController/WootingOneKeyboardController/WootingOneKeyboardController.h rename to Controllers/WootingKeyboardController/WootingV1KeyboardController/WootingV1KeyboardController.h index e7040c092..ad058127a 100644 --- a/Controllers/WootingKeyboardController/WootingOneKeyboardController/WootingOneKeyboardController.h +++ b/Controllers/WootingKeyboardController/WootingV1KeyboardController/WootingV1KeyboardController.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------*\ -| WootingOneKeyboardController.h | +| WootingV1KeyboardController.h | | | -| Driver for Wooting One keyboard | +| Driver for Wooting keyboards with v1 firmware | | | -| Diogo Trindade (diogotr7) 04 Mar 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | @@ -13,15 +13,20 @@ #include "WootingKeyboardController.h" -class WootingOneKeyboardController : public WootingKeyboardController +#define WOOTING_REPORT_SIZE 129 +#define WOOTING_ONE_KEY_CODE_LIMIT 95 +#define WOOTING_TWO_KEY_CODE_LIMIT 116 + +class WootingV1KeyboardController : public WootingKeyboardController { public: - WootingOneKeyboardController(hid_device* dev_handle, const char *path, uint8_t wooting_type, std::string dev_name); - ~WootingOneKeyboardController(); + WootingV1KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name); + ~WootingV1KeyboardController(); + + uint8_t key_code_limit; void SendDirect(RGBColor* colors, uint8_t colour_count); private: - void SendInitialize(); bool wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* report_buffer); }; diff --git a/Controllers/WootingKeyboardController/WootingTwoKeyboardController/WootingTwoKeyboardController.cpp b/Controllers/WootingKeyboardController/WootingV2KeyboardController/WootingV2KeyboardController.cpp similarity index 51% rename from Controllers/WootingKeyboardController/WootingTwoKeyboardController/WootingTwoKeyboardController.cpp rename to Controllers/WootingKeyboardController/WootingV2KeyboardController/WootingV2KeyboardController.cpp index e373ba60b..1daa07a45 100644 --- a/Controllers/WootingKeyboardController/WootingTwoKeyboardController/WootingTwoKeyboardController.cpp +++ b/Controllers/WootingKeyboardController/WootingV2KeyboardController/WootingV2KeyboardController.cpp @@ -1,9 +1,10 @@ /*---------------------------------------------------------*\ -| WootingTwoKeyboardController.cpp | +| WootingV2KeyboardController.cpp | | | -| Driver for Wooting Two keyboard | +| Driver for Wooting keyboards with v2 firmware | | | | Chris M (Dr_No) 09 Jul 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | @@ -11,7 +12,7 @@ #include #include "StringUtils.h" -#include "WootingTwoKeyboardController.h" +#include "WootingV2KeyboardController.h" #define WOOTING_TWO_REPORT_SIZE 257 @@ -26,23 +27,12 @@ typedef uint16_t R5G6B5_color; #define RGB888ToRGBcolor16(r, g, b) ((R5G6B5_color)((red & 0xF8) << 8 | (green & 0xFC) << 3 | (b & 0xF8) >> 3)) #define RGB32ToRGBcolor16(color32) ((R5G6B5_color)((color32 & 0xF8) << 8 | (color32 & 0xFC00) >> 5 | (color32 & 0xF80000) >> 19)) -static unsigned int matrix_to_led_index_map_full[WOOTING_RGB_ROWS * WOOTING_TWO_RGB_COLUMNS] = -{ - 0, 21, 42, 63, 84, 105, 1, 22, 43, 64, 85, 106, 2, 23, 44, 65, 86, 107, 3, 24, 45, - 66, 87, NA, 4, 25, 46, 67, 88, NA, 5, 26, 47, 68, 89, NA, 6, 27, 48, 69, 90, 111, - 7, 28, 49, 70, 91, NA, 8, 29, 50, 71, 92, NA, 9, 30, 51, 72, 93, NA, 10, 31, 52, - 73, 94, 115, 11, 32, 53, 74, 95, 116, 12, 33, 54, 75, NA, 117, 13, 34, 55, 76, 97, 118, - 14, 35, 56, 77, 98, 119, 15, 36, 57, NA, 99, 120, 16, 37, 58, NA, 16, 121, 17, 38, 59, - 80, 101, NA, 18, 39, 60, 81, 102, 123, 19, 40, 61, 82, 103, 124, 20, 41, 62, NA, 104, NA -}; - -WootingTwoKeyboardController::WootingTwoKeyboardController(hid_device* dev_handle, const char *path, uint8_t wooting_type, std::string dev_name) +WootingV2KeyboardController::WootingV2KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name) { dev = dev_handle; location = path; name = dev_name; this->wooting_type = wooting_type; - key_code_limit = (wooting_type == WOOTING_KB_TKL) ? WOOTING_ONE_KEY_CODE_LIMIT : WOOTING_TWO_KEY_CODE_LIMIT; /*---------------------------------------------------------*\ | Get device HID manufacturer and product strings | @@ -59,38 +49,24 @@ WootingTwoKeyboardController::WootingTwoKeyboardController(hid_device* dev_handl SendInitialize(); } -WootingTwoKeyboardController::~WootingTwoKeyboardController() +WootingV2KeyboardController::~WootingV2KeyboardController() { } -void WootingTwoKeyboardController::SendDirect(RGBColor* colors, uint8_t color_count) +void WootingV2KeyboardController::SendDirect(RGBColor* colors, uint8_t color_count) { uint8_t rgb_buffer[WOOTING_TWO_REPORT_SIZE] = { 0, 0xD0, 0xDA, WOOTING_RAW_COLORS_REPORT}; for(std::size_t index = 0; index < color_count; index++) { - uint8_t buffer_index = 4 + (matrix_to_led_index_map_full[index] * 2); + size_t buffer_index = 4 + (index * 2); R5G6B5_color color16 = RGB32ToRGBcolor16(colors[index]); - LOG_TRACE("%sSetting LED %03i @ buffer %03i - RGB32 %08X RGB16 %04X", WOOTING_CONTROLLER_NAME, index, buffer_index, colors[index], color16); rgb_buffer[buffer_index] = color16 & 0xFF; rgb_buffer[buffer_index+1] = color16 >> 8; } - wooting_usb_send_buffer(RGB_PARTS::PART0, rgb_buffer); -} - -void WootingTwoKeyboardController::SendInitialize() -{ - wooting_usb_send_feature(WOOTING_COLOR_INIT_COMMAND, 0,0,0,0); - - std::this_thread::sleep_for(std::chrono::milliseconds(50)); -} - -bool WootingTwoKeyboardController::wooting_usb_send_buffer(RGB_PARTS /*part_number*/, uint8_t* report_buffer) -{ - uint16_t report_size = hid_write(dev, report_buffer, WOOTING_TWO_REPORT_SIZE); + uint16_t report_size = hid_write(dev, rgb_buffer, WOOTING_TWO_REPORT_SIZE); LOG_DEBUG("%sSend buffer returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_TWO_REPORT_SIZE); - return (report_size == WOOTING_TWO_REPORT_SIZE); } diff --git a/Controllers/WootingKeyboardController/WootingTwoKeyboardController/WootingTwoKeyboardController.h b/Controllers/WootingKeyboardController/WootingV2KeyboardController/WootingV2KeyboardController.h similarity index 56% rename from Controllers/WootingKeyboardController/WootingTwoKeyboardController/WootingTwoKeyboardController.h rename to Controllers/WootingKeyboardController/WootingV2KeyboardController/WootingV2KeyboardController.h index 6240b54c8..6e8e3b297 100644 --- a/Controllers/WootingKeyboardController/WootingTwoKeyboardController/WootingTwoKeyboardController.h +++ b/Controllers/WootingKeyboardController/WootingV2KeyboardController/WootingV2KeyboardController.h @@ -1,9 +1,10 @@ /*---------------------------------------------------------*\ -| WootingTwoKeyboardController.h | +| WootingV2KeyboardController.h | | | -| Driver for Wooting Two keyboard | +| Driver for Wooting keyboards with v2 firmware | | | | Chris M (Dr_No) 09 Jul 2021 | +| Diogo Trindade (diogotr7) 25 Dec 2025 | | | | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | @@ -13,15 +14,11 @@ #include "WootingKeyboardController.h" -class WootingTwoKeyboardController : public WootingKeyboardController +class WootingV2KeyboardController : public WootingKeyboardController { public: - WootingTwoKeyboardController(hid_device* dev_handle, const char *path, uint8_t wooting_type, std::string dev_name); - ~WootingTwoKeyboardController(); + WootingV2KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name); + ~WootingV2KeyboardController(); void SendDirect(RGBColor* colors, uint8_t colour_count); - -private: - void SendInitialize(); - bool wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* report_buffer); }; diff --git a/Controllers/WootingKeyboardController/WootingV3KeyboardController/WootingV3KeyboardController.cpp b/Controllers/WootingKeyboardController/WootingV3KeyboardController/WootingV3KeyboardController.cpp new file mode 100644 index 000000000..fe8eb1ca9 --- /dev/null +++ b/Controllers/WootingKeyboardController/WootingV3KeyboardController/WootingV3KeyboardController.cpp @@ -0,0 +1,76 @@ +/*---------------------------------------------------------*\ +| WootingV3KeyboardController.cpp | +| | +| Driver for Wooting keyboards with v3 firmware | +| | +| Diogo Trindade (diogotr7) 25 Dec 2025 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include +#include "StringUtils.h" +#include "WootingV3KeyboardController.h" + +#define WOOTING_V3_REPORT_SIZE 2046 + +#undef WOOTING_CONTROLLER_NAME +#define WOOTING_CONTROLLER_NAME "[WootingTWO] " + +//Indicates an unused entry in matrix +#define NA 0x7D + +//WootingTwo uses a 16bit color space +typedef uint16_t R5G6B5_color; +#define RGB888ToRGBcolor16(r, g, b) ((R5G6B5_color)((red & 0xF8) << 8 | (green & 0xFC) << 3 | (b & 0xF8) >> 3)) +#define RGB32ToRGBcolor16(color32) ((R5G6B5_color)((color32 & 0xF8) << 8 | (color32 & 0xFC00) >> 5 | (color32 & 0xF80000) >> 19)) + +WootingV3KeyboardController::WootingV3KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name) +{ + dev = dev_handle; + location = path; + name = dev_name; + this->wooting_type = wooting_type; + + /*---------------------------------------------------------*\ + | Get device HID manufacturer and product strings | + \*---------------------------------------------------------*/ + const int szTemp = 256; + wchar_t tmpName[szTemp]; + + hid_get_manufacturer_string(dev, tmpName, szTemp); + vendor = std::string(StringUtils::wstring_to_string(tmpName)); + + hid_get_product_string(dev, tmpName, szTemp); + description = std::string(StringUtils::wstring_to_string(tmpName)); + + SendInitialize(); +} + +WootingV3KeyboardController::~WootingV3KeyboardController() +{ + +} + +void WootingV3KeyboardController::SendDirect(RGBColor* colors, uint8_t color_count) +{ + uint8_t rgb_buffer[WOOTING_V3_REPORT_SIZE] = {0}; + rgb_buffer[0] = 4; + rgb_buffer[1] = 0xD1; + rgb_buffer[2] = 0xDA; + rgb_buffer[3] = WOOTING_RAW_COLORS_REPORT; + + for(std::size_t index = 0; index < color_count; index++) + { + size_t buffer_index = 4 + (index * 2); + R5G6B5_color color16 = RGB32ToRGBcolor16(colors[index]); + + rgb_buffer[buffer_index] = color16 & 0xFF; + rgb_buffer[buffer_index+1] = color16 >> 8; + } + + uint16_t report_size = hid_write(dev, rgb_buffer, WOOTING_V3_REPORT_SIZE); + LOG_DEBUG("%sSend buffer returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_V3_REPORT_SIZE); +} + diff --git a/Controllers/WootingKeyboardController/WootingV3KeyboardController/WootingV3KeyboardController.h b/Controllers/WootingKeyboardController/WootingV3KeyboardController/WootingV3KeyboardController.h new file mode 100644 index 000000000..cfbdb5e57 --- /dev/null +++ b/Controllers/WootingKeyboardController/WootingV3KeyboardController/WootingV3KeyboardController.h @@ -0,0 +1,23 @@ +/*---------------------------------------------------------*\ +| WootingV3KeyboardController.h | +| | +| Driver for Wooting keyboards with v3 firmware | +| | +| Diogo Trindade (diogotr7) 25 Dec 2025 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include "WootingKeyboardController.h" + +class WootingV3KeyboardController : public WootingKeyboardController +{ +public: + WootingV3KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name); + ~WootingV3KeyboardController(); + + void SendDirect(RGBColor* colors, uint8_t colour_count); +};