mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-04 12:43:39 -04:00
Add zones and LEDs to Corsair keyboard controller, but keys don't line up with zones yet
This commit is contained in:
@@ -9,6 +9,15 @@
|
||||
|
||||
#include "CorsairKeyboardController.h"
|
||||
|
||||
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
|
||||
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
|
||||
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
|
||||
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
|
||||
136, 137, 139, 140, 141};
|
||||
|
||||
static void send_usb_msg(hid_device* dev, char * data_pkt)
|
||||
{
|
||||
char usb_pkt[65];
|
||||
@@ -48,6 +57,11 @@ void CorsairKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
char grn_val[144];
|
||||
char blu_val[144];
|
||||
|
||||
memset(data_pkt, 0x00, sizeof( data_pkt ));
|
||||
memset(red_val, 0x00, sizeof( red_val ));
|
||||
memset(grn_val, 0x00, sizeof( grn_val ));
|
||||
memset(blu_val, 0x00, sizeof( blu_val ));
|
||||
|
||||
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
RGBColor color = colors[color_idx];
|
||||
@@ -63,9 +77,9 @@ void CorsairKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
grn = 7 - grn;
|
||||
blu = 7 - blu;
|
||||
|
||||
red_val[color_idx] = red;
|
||||
grn_val[color_idx] = grn;
|
||||
blu_val[color_idx] = blu;
|
||||
red_val[keys[color_idx]] = red;
|
||||
grn_val[keys[color_idx]] = grn;
|
||||
blu_val[keys[color_idx]] = blu;
|
||||
}
|
||||
|
||||
// Perform USB control message to keyboard
|
||||
|
||||
@@ -9,6 +9,134 @@
|
||||
|
||||
#include "RGBController_CorsairKeyboard.h"
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
"Media Keys"
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104,
|
||||
7
|
||||
};
|
||||
|
||||
static const char* led_names[] =
|
||||
{
|
||||
"Key: Escape", //0
|
||||
"Key: `", //1
|
||||
"Key: Tab", //2
|
||||
"Key: Caps Lock", //3
|
||||
"Key: Left Shift", //4
|
||||
"Key: Left Control", //5
|
||||
"Key: F12", //6
|
||||
"Key: =", //7
|
||||
"Key: Lock", //8
|
||||
"Key: Number Pad 7", //9
|
||||
"Key: F1", //12
|
||||
"Key: 1", //13
|
||||
"Key: Q", //14
|
||||
"Key: A", //15
|
||||
"Key: Left Windows", //17
|
||||
"Key: Print Screen", //18
|
||||
"Media Mute", //20
|
||||
"Key: Number Pad 8", //21
|
||||
"Key: F2", //24
|
||||
"Key: 2", //25
|
||||
"Key: W", //26
|
||||
"Key: S", //27
|
||||
"Key: Z", //28
|
||||
"Key: Left Alt", //29
|
||||
"Key: Scroll Lock", //30
|
||||
"Key: Backspace", //31
|
||||
"Media Stop", //32
|
||||
"Key: Number Pad 9", //33
|
||||
"Key: F3", //36
|
||||
"Key: 3", //37
|
||||
"Key: E", //38
|
||||
"Key: D", //39
|
||||
"Key: X", //40
|
||||
"Key: Pause/Break", //42
|
||||
"Key: Delete", //43
|
||||
"Media Previous", //44
|
||||
"Key: F4", //48
|
||||
"Key: 4", //49
|
||||
"Key: R", //50
|
||||
"Key: F", //51
|
||||
"Key: C", //52
|
||||
"Key: Space", //53
|
||||
"Key: Insert", //54
|
||||
"Key: End", //55
|
||||
"Media Play/Pause", //56
|
||||
"Key: Number Pad 4", //57
|
||||
"Key: F5", //60
|
||||
"Key: 5", //61
|
||||
"Key: T", //62
|
||||
"Key: G", //63
|
||||
"Key: V", //64
|
||||
"Key: Home", //66
|
||||
"Key: Page Down", //67
|
||||
"Media Next", //68
|
||||
"Key: Number Pad 5", //69
|
||||
"Key: F6", //72
|
||||
"Key: 6", //73
|
||||
"Key: Y", //74
|
||||
"Key: H", //75
|
||||
"Key: B", //76
|
||||
"Key: Page Up", //78
|
||||
"Key: Right Shift", //79
|
||||
"Key: Num Lock", //80
|
||||
"Key: Number Pad 6", //81
|
||||
"Key: F7", //84
|
||||
"Key: 7", //85
|
||||
"Key: U", //86
|
||||
"Key: J", //87
|
||||
"Key: N", //88
|
||||
"Key: Right Alt", //89
|
||||
"Key: ]", //90
|
||||
"Key: Right Control", //91
|
||||
"Key: Number Pad /", //92
|
||||
"Key: Number Pad 1", //93
|
||||
"Key: F8", //96
|
||||
"Key: 8", //97
|
||||
"Key: I", //98
|
||||
"Key: K", //99
|
||||
"Key: M", //100
|
||||
"Key: Right Windows", //101
|
||||
"Key: \\", //102
|
||||
"Key: Up Arrow", //103
|
||||
"Key: Number Pad *", //104
|
||||
"Key: Number Pad 2", //105
|
||||
"Key: F9", //108
|
||||
"Key: 9", //109
|
||||
"Key: O", //110
|
||||
"Key: L", //111
|
||||
"Key: ,", //112
|
||||
"Key: Context", //113
|
||||
"Key: Left Arrow", //115
|
||||
"Key: Number Pad -", //116
|
||||
"Key: Number Pad 3", //117
|
||||
"Key: F10", //120
|
||||
"Key: 0", //121
|
||||
"Key: P", //122
|
||||
"Key: ;", //123
|
||||
"Key: .", //124
|
||||
"Key: Enter", //126
|
||||
"Key: Down Arrow", //127
|
||||
"Key: Number Pad +", //128
|
||||
"Key: Number Pad 0", //129
|
||||
"Key: F11", //132
|
||||
"Key: -", //133
|
||||
"Key: [", //134
|
||||
"Key: '", //135
|
||||
"Key: /", //136
|
||||
"Key: Brightness", //137
|
||||
"Key: Right Arrow", //139
|
||||
"Key: Number Pad Enter",//140
|
||||
"Key: Number Pad .", //141
|
||||
"Key: F12"
|
||||
};
|
||||
|
||||
RGBController_CorsairKeyboard::RGBController_CorsairKeyboard(CorsairKeyboardController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
@@ -16,9 +144,30 @@ RGBController_CorsairKeyboard::RGBController_CorsairKeyboard(CorsairKeyboardCont
|
||||
name = "Corsair RGB Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
|
||||
for(int i = 0; i < 144; i++)
|
||||
colors.resize(111);
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 2; zone_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
zone new_zone;
|
||||
new_zone.name.append(zone_names[zone_idx]);
|
||||
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for(unsigned int led_count = 0; led_count < zone_sizes[zone_idx]; led_count++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name.append(led_names[led_idx]);
|
||||
leds.push_back(new_led);
|
||||
|
||||
new_zone_map.push_back(led_idx);
|
||||
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone.map.push_back(new_zone_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user