Skip to content

Commit b0ed268

Browse files
committed
Initial commit for the EVGA Z20 Keyboard to resolve #2157
* Cleaned up cherry picked commit from @Elteeb96 * Added UDEV rule to 60-openrgb.rules
1 parent 452ea9e commit b0ed268

File tree

5 files changed

+119
-83
lines changed

5 files changed

+119
-83
lines changed

60-openrgb.rules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="5750", TAG+="uacces
333333
#---------------------------------------------------------------#
334334
SUBSYSTEMS=="usb", ATTR{idVendor}=="3842", ATTR{idProduct}=="2608", TAG+="uaccess", TAG+="EVGA_ANSI_Z15"
335335
SUBSYSTEMS=="usb", ATTR{idVendor}=="3842", ATTR{idProduct}=="260e", TAG+="uaccess", TAG+="EVGA_ISO_Z15"
336+
SUBSYSTEMS=="usb", ATTR{idVendor}=="3842", ATTR{idProduct}=="260a", TAG+="uaccess", TAG+="EVGA_ANSI_Z20"
336337

337338
#---------------------------------------------------------------#
338339
# Holtek Devices #

Controllers/EVGAUSBController/EVGAKeyboardController.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "EVGAKeyboardController.h"
1111

12-
static uint8_t packet_map[EVGA_KEYBOARD_FULL_SIZE_KEYCOUNT + EVGA_KEYBOARD_Z20_EXTRA] =
12+
static uint8_t packet_map[EVGA_KEYBOARD_FULL_SIZE_KEYCOUNT + EVGA_KEYBOARD_Z20_EXTRA_KEYS] =
1313
{
1414
/*00 ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 */
1515
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
@@ -41,23 +41,27 @@ static uint8_t packet_map[EVGA_KEYBOARD_FULL_SIZE_KEYCOUNT + EVGA_KEYBOARD_Z20_E
4141
/*90 NM- NM+ NETR NM1 NM2 NM3 NM4 NM5 NM6 NM7 */
4242
42, 64, 101, 98, 99, 100, 79, 80, 81, 61,
4343

44-
/*100 NM8 NM9 NM0 NM. PRV PLY NXT MTE */
45-
62, 63, 114, 115, 18, 19, 20, 118
46-
/*Macros+ GM M1 M2 M3 M4 M5 */
47-
, 0, 21, 43, 65, 82, 102,
48-
/*Left Lights L1 L2 L3 L4 L5 L6 L7 L8 L9 */
49-
160, 161, 162, 163, 164, 165, 166, 167, 168,
50-
/*Right Lights R1 R2 R3 R4 R5 R6 R7 R8 R9 */
51-
176, 177, 178, 179, 180, 181, 182, 183, 184
44+
/*100 NM8 NM9 NM0 NM. PRV PLY NXT MTE R1 R2 */
45+
62, 63, 114, 115, 18, 19, 20, 118, 176, 177,
46+
47+
/*110 R3 R4 R5 R6 R7 R8 R9 L1 L2 L3 */
48+
178, 179, 180, 181, 182, 183, 184, 160, 161, 162,
49+
50+
/*120 L4 L5 L6 L7 L8 L9 GM M1 M2 M3 */
51+
163, 164, 165, 166, 167, 168, 0, 21, 43, 65,
52+
53+
/*130 M4 M5 */
54+
82, 102
5255
};
5356

54-
EVGAKeyboardController::EVGAKeyboardController(hid_device* dev_handle, const char* path)
57+
EVGAKeyboardController::EVGAKeyboardController(hid_device* dev_handle, const char* path, uint16_t kb_pid)
5558
{
5659
const uint8_t sz = HID_MAX_STR;
5760
wchar_t tmp[sz];
5861

5962
dev = dev_handle;
6063
location = path;
64+
pid = kb_pid;
6165

6266
hid_get_manufacturer_string(dev, tmp, sz);
6367
std::wstring w_tmp = std::wstring(tmp);
@@ -97,6 +101,11 @@ std::string EVGAKeyboardController::GetLocation()
97101
return("HID: " + location);
98102
}
99103

104+
uint16_t EVGAKeyboardController::GetPid()
105+
{
106+
return pid;
107+
}
108+
100109
void EVGAKeyboardController::SetLedsDirect(std::vector<RGBColor> colors)
101110
{
102111
uint8_t buffer[EVGA_KEYBOARD_CONTROLLER_ID_6_SIZE] = { 0x06, 0xEA, 0x02, 0x01 };

Controllers/EVGAUSBController/EVGAKeyboardController.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
#define EVGA_KEYBOARD_CONTROLLER_ID_4_SIZE 17
2222
#define EVGA_KEYBOARD_CONTROLLER_ID_6_SIZE 792
2323
#define EVGA_KEYBOARD_CONTROLLER_ID_7_SIZE 136
24-
#define EVGA_KEYBOARD_CONTROLLER_ID_Z20_4_SIZE 35
25-
#define EVGA_KEYBOARD_CONTROLLER_ID_Z20_6_SIZE 828
26-
#define EVGA_KEYBOARD_CONTROLLER_ID_Z20_7_SIZE 187
2724
#define EVGA_KEYBOARD_CONTROLLER_INTERRUPT_TIMEOUT 250
2825

2926
#define EVGA_KEYBOARD_CONTROLLER_BRIGHTNESS_MIN 0
3027
#define EVGA_KEYBOARD_CONTROLLER_BRIGHTNESS_MAX 255
3128
#define EVGA_KEYBOARD_FULL_SIZE_KEYCOUNT 108
32-
#define EVGA_KEYBOARD_Z20_EXTRA 24
29+
#define EVGA_KEYBOARD_Z20_EXTRA_KEYS 24
30+
#define EVGA_KEYBOARD_Z20_EXTRA_ZONES 3
3331

3432
static const uint8_t direction_map[8][4] =
3533
{
@@ -91,7 +89,7 @@ enum EVGA_Keyboard_Controller_Speed
9189
class EVGAKeyboardController
9290
{
9391
public:
94-
EVGAKeyboardController(hid_device* dev_handle, const char* path);
92+
EVGAKeyboardController(hid_device* dev_handle, const char* path, uint16_t kb_pid);
9593
~EVGAKeyboardController();
9694

9795
std::string GetDeviceName();
@@ -106,10 +104,12 @@ class EVGAKeyboardController
106104
void SetSleepTime();
107105
void GetStatus(mode *mode);
108106
uint8_t GetMode();
107+
uint16_t GetPid();
109108
private:
110109
std::string device_name;
111110
std::string location;
112111
hid_device* dev;
112+
uint16_t pid;
113113

114114
void NFIPacket();
115115
void FillColours(uint8_t * buffer, uint8_t brightness, std::vector<RGBColor> colors);

Controllers/EVGAUSBController/EVGAUSBControllerDetect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void DetectEVGAKeyboardControllers(hid_device_info* info, const std::string& nam
2424

2525
if(dev)
2626
{
27-
EVGAKeyboardController* controller = new EVGAKeyboardController(dev, info->path);
27+
EVGAKeyboardController* controller = new EVGAKeyboardController(dev, info->path, info->product_id);
2828
RGBController_EVGAKeyboard* rgb_controller = new RGBController_EVGAKeyboard(controller);
2929
rgb_controller->name = name;
3030

Controllers/EVGAUSBController/RGBController_EVGAKeyboard.cpp

Lines changed: 93 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,26 @@
1414

1515
static unsigned int full_matrix_map[6][21] =
1616
{
17-
{ 0, NA, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 104, 105, 106, 107},
18-
{ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 87, 88, 89, 90},
19-
{ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 99, 100, 101, 91},
20-
{ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, NA, NA, NA, NA, 96, 97, 98, NA},
21-
{ 63, NA, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, NA, NA, 75, NA, 93, 94, 95, 92},
22-
{ 76, 77, 78, NA, NA, NA, 79, NA, NA, NA, 80, 81, 82, 83, 84, 85, 86, 102, NA, 103, NA}
17+
{ 0, NA, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 104, 105, 106, 107 },
18+
{ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 87, 88, 89, 90 },
19+
{ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 99, 100, 101, 91 },
20+
{ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, NA, NA, NA, NA, 96, 97, 98, NA },
21+
{ 63, NA, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, NA, NA, 75, NA, 93, 94, 95, 92 },
22+
{ 76, 77, 78, NA, NA, NA, 79, NA, NA, NA, 80, 81, 82, 83, 84, 85, 86, 102, NA, 103, NA }
2323
};
2424

25-
static unsigned int Z20_right_side_matrix[1][9] =
25+
static unsigned int Z20_extra_zones[EVGA_KEYBOARD_Z20_EXTRA_ZONES][9] =
2626
{
27-
{ 116, 118, 120, 122, 124, 126, 128, 130, 132}
27+
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }, //Index 108
28+
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }, //Index 117
29+
{ 0, 1, 2, 3, 4, 5, NA, NA, NA } //Index 126
2830
};
2931

30-
static unsigned int Z20_left_side_matrix[1][9] =
32+
const char* Z20_zone_names[EVGA_KEYBOARD_Z20_EXTRA_ZONES] =
3133
{
32-
{ 115, 117, 119, 121, 123, 125, 127, 129, 131}
33-
};
34-
35-
static unsigned int Z20_macro_matrix[1][6] =
36-
{
37-
{109, 110, 111, 112, 113, 114}
34+
"Right Side LEDs",
35+
"Left Side LEDs",
36+
"Macro Keys"
3837
};
3938

4039
static const char *led_names[] =
@@ -154,16 +153,46 @@ static const char *led_names[] =
154153
KEY_EN_MEDIA_PLAY_PAUSE,
155154
KEY_EN_MEDIA_NEXT,
156155
KEY_EN_MEDIA_MUTE,
157-
},
158-
{
159-
"Key: Feature Button", "Key: Macro 1", "Key: Macro 2", "Key: Macro 3", "Key: Macro 4", "Key: Macro 5"
160-
},
161-
{
162-
"Key: Number Pad 1", "Key: Number Pad 2", "Key: Number Pad 3", "Key: Number Pad 4", "Key: Number Pad 5", "Key: Number Pad 6", "Key: Number Pad 7", "Key: Number Pad 8", "Key: Number Pad 9"},
163-
{
164-
"Key: Number Pad 1", "Key: Number Pad 2", "Key: Number Pad 3", "Key: Number Pad 4", "Key: Number Pad 5", "Key: Number Pad 6", "Key: Number Pad 7", "Key: Number Pad 8", "Key: Number Pad 9"},
156+
157+
"Key: Right LED 1",
158+
"Key: Right LED 2",
159+
"Key: Right LED 3", //110
160+
"Key: Right LED 4",
161+
"Key: Right LED 5",
162+
"Key: Right LED 6",
163+
"Key: Right LED 7",
164+
"Key: Right LED 8",
165+
"Key: Right LED 9",
166+
167+
"Key: Left LED 1",
168+
"Key: Left LED 2",
169+
"Key: Left LED 3",
170+
"Key: Left LED 4", //120
171+
"Key: Left LED 5",
172+
"Key: Left LED 6",
173+
"Key: Left LED 7",
174+
"Key: Left LED 8",
175+
"Key: Left LED 9",
176+
177+
"Key: Feature Button",
178+
"Key: Macro 1",
179+
"Key: Macro 2",
180+
"Key: Macro 3",
181+
"Key: Macro 4", //130
182+
"Key: Macro 5",
165183
};
166184

185+
/**
186+
@name EVGA USB Keyboard
187+
@type USB
188+
@save :x:
189+
@direct :white_check_mark:
190+
@effects :white_check_mark:
191+
@detectors DetectEVGAKeyboardControllers
192+
@comment The EVGA USB keyboard controller currently supports
193+
the Z15 (both ISO & ANSI) as well as the Z20 ANSI keyboards
194+
*/
195+
167196
RGBController_EVGAKeyboard::RGBController_EVGAKeyboard(EVGAKeyboardController* controller_ptr)
168197
{
169198
/*-----------------------------------------------------*\
@@ -364,7 +393,8 @@ RGBController_EVGAKeyboard::~RGBController_EVGAKeyboard()
364393
void RGBController_EVGAKeyboard::SetupZones()
365394
{
366395
/*-------------------------------------------------*\
367-
| Clear any existing color/LED configuration |
396+
| Set up the base configuration common to |
397+
| Z15 and Z20 |
368398
\*-------------------------------------------------*/
369399
zone KB_zone;
370400
KB_zone.name = "Keyboard Zone";
@@ -378,63 +408,59 @@ void RGBController_EVGAKeyboard::SetupZones()
378408
KB_zone.matrix_map->width = 21;
379409
KB_zone.matrix_map->map = (unsigned int *)&full_matrix_map;
380410
zones.push_back(KB_zone);
381-
if(controller->GetDeviceName() == "EVGA Corporation EVGA Z20 Elite Gaming Keyboard"){
382-
zone KB_right_sidelights;
383-
KB_right_sidelights.name = "Right Side Lights";
384-
KB_right_sidelights.type = 1;
385-
KB_right_sidelights.leds_min = 9;
386-
KB_right_sidelights.leds_max = 9;
387-
KB_right_sidelights.leds_count = 9;
388-
KB_right_sidelights.matrix_map = new matrix_map_type;
389-
390-
zone KB_left_sidelights;
391-
KB_left_sidelights.name = "Left Side Lights";
392-
KB_left_sidelights.type = 1;
393-
KB_left_sidelights.leds_min = 9;
394-
KB_left_sidelights.leds_max = 9;
395-
KB_left_sidelights.leds_count = 9;
396-
KB_left_sidelights.matrix_map = new matrix_map_type;
397-
398-
zone KB_macros;
399-
KB_macros.name = "Macros";
400-
KB_macros.type = 1;
401-
KB_macros.leds_min = 6;
402-
KB_macros.leds_max = 6;
403-
KB_macros.leds_count = 6;
404-
KB_macros.matrix_map = new matrix_map_type;
405-
406-
KB_right_sidelights.matrix_map->height = 1;
407-
KB_right_sidelights.matrix_map->width = 9;
408-
KB_right_sidelights.matrix_map->map = (unsigned int *)&Z20_right_side_matrix;
409-
410-
KB_left_sidelights.matrix_map->height = 1;
411-
KB_left_sidelights.matrix_map->width = 9;
412-
KB_left_sidelights.matrix_map->map = (unsigned int *)&Z20_right_side_matrix;
413-
414-
KB_macros.matrix_map->height = 1;
415-
KB_macros.matrix_map->width = 6;
416-
KB_macros.matrix_map->map = (unsigned int *)&Z20_macro_matrix;
417-
418-
zones.push_back(KB_macros);
419-
zones.push_back(KB_left_sidelights);
420-
zones.push_back(KB_right_sidelights);
411+
412+
/*-------------------------------------------------*\
413+
| Add configuration for the Z20 |
414+
\*-------------------------------------------------*/
415+
if(controller->GetPid() == 0x260A)
416+
{
417+
418+
for(uint8_t i = 0; i < EVGA_KEYBOARD_Z20_EXTRA_ZONES; i++)
419+
{
420+
uint8_t zone_size = sizeof(Z20_extra_zones[i]) / sizeof(Z20_extra_zones[i][0]);
421+
422+
for(uint8_t count = 0; count < zone_size; count++)
423+
{
424+
if(Z20_extra_zones[i][count] == NA)
425+
{
426+
zone_size = count;
427+
break;
428+
}
429+
}
430+
431+
zone new_zone;
432+
new_zone.name = Z20_zone_names[i];
433+
new_zone.type = ZONE_TYPE_MATRIX;
434+
new_zone.leds_min = zone_size;
435+
new_zone.leds_max = zone_size;
436+
new_zone.leds_count = zone_size;
437+
438+
new_zone.matrix_map = new matrix_map_type;
439+
new_zone.matrix_map->height = 1;
440+
new_zone.matrix_map->width = zone_size;
441+
new_zone.matrix_map->map = (unsigned int *)&Z20_extra_zones[i];
442+
zones.push_back(new_zone);
443+
}
421444
}
445+
422446
/*-------------------------------------------------*\
423447
| Clear any existing color/LED configuration |
424448
\*-------------------------------------------------*/
425449
leds.clear();
426450
colors.clear();
427451

428452
/*---------------------------------------------------------*\
429-
| Set up zones |
453+
| Set up leds |
430454
\*---------------------------------------------------------*/
431455
for(std::size_t zone_index = 0; zone_index < zones.size(); zone_index++)
432456
{
457+
int zone_offset = leds.size();
458+
433459
for(unsigned int led_index = 0; led_index < zones[zone_index].leds_count; led_index++)
434460
{
435461
led new_led;
436-
new_led.name = led_names[led_index];
437-
new_led.value = led_index;
462+
new_led.value = led_index + zone_offset;
463+
new_led.name = led_names[new_led.value];
438464
leds.push_back(new_led);
439465
}
440466
}

0 commit comments

Comments
 (0)