Add Corsair K100 keyboard support (direct mode)
Commits squashed and amended for code style by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
e6dd1e4ef4
commit
02ca3f32a0
7 changed files with 599 additions and 2 deletions
|
|
@ -189,6 +189,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c23", TAG+="uacces
|
|||
# Corsair K70 RGB MK2 LP #
|
||||
# Corsair K95 RGB #
|
||||
# Corsair K95 Platinum #
|
||||
# Corsair K100 #
|
||||
# Corsair Strafe #
|
||||
# Corsair Strafe MK2 #
|
||||
# #
|
||||
|
|
@ -223,6 +224,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b11", TAG+="uacces
|
|||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b2d", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b20", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b48", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b7c", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b34", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b74", TAG+="uaccess"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,136 @@
|
|||
/*-----------------------------------------*\
|
||||
| CorsairK100Controller.cpp |
|
||||
| |
|
||||
| Driver for Corsair K100 Keyboard |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairK100Controller.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
static unsigned int keys_k100[] = {0x25, 0x31, 0x27, 0x35, 0x66, 0x65, 0x41, 0x2A, 0x6E, 0x5B, 0x36, 0x1A, 0x10, 0x00, 0x68, 0x42,
|
||||
0x62, 0x5C, 0x37, 0x1B, 0x16, 0x12, 0x19, 0x67, 0x43, 0x26, 0x77, 0x5D, 0x38, 0x1C, 0x04, 0x03,
|
||||
0x17, 0x44, 0x48, 0x7A, 0x39, 0x1D, 0x11, 0x05, 0x02, 0x28, 0x45, 0x49, 0x78, 0x58, 0x3A, 0x1E,
|
||||
0x13, 0x06, 0x15, 0x46, 0x4A, 0x79, 0x59, 0x3B, 0x1F, 0x18, 0x07, 0x01, 0x47, 0x6A, 0x4F, 0x5A,
|
||||
0x3C, 0x20, 0x14, 0x09, 0x0D, 0x6B, 0x2C, 0x69, 0x50, 0x55, 0x3D, 0x21, 0x08, 0x0A, 0x0C, 0x76,
|
||||
0x2D, 0x4E, 0x51, 0x56, 0x3E, 0x22, 0x0E, 0x0B, 0x32, 0x61, 0x4C, 0x52, 0x57, 0x3F, 0x23, 0x0F,
|
||||
0x2F, 0x33, 0x24, 0x4D, 0x53, 0x5E, 0x40, 0x29, 0x2B, 0x30, 0x34, /*Brightness,*/
|
||||
0x4B, 0x54, 0x5F, 114 , 99, 0x7C, //114 and 99 is not conformed it just a guess
|
||||
0x7F, 0x80, 0x81, 0x82, 0x83, 0x84,//Macro
|
||||
0xA6, 0xA5, 0xA4, 0xA3, 0xA2, 0xA1, 0xA0, 0x9F, 0x9E, 0x9D, 0x9C, 0x86, 0x87, 0x88, 0x89, 0x8A,
|
||||
0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A,
|
||||
0x9B, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,0xB0, 0xB1, //Light Bar
|
||||
0x85, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9,//Nameplate
|
||||
0xBA, 0xBB, 0xBC/*Logo*/};
|
||||
|
||||
CorsairK100Controller::CorsairK100Controller(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
keyboard_type = CORSAIR_TYPE_K100;
|
||||
|
||||
LightingControl();
|
||||
}
|
||||
CorsairK100Controller::~CorsairK100Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CorsairK100Controller::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string CorsairK100Controller::GetFirmwareString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CorsairK100Controller::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
void CorsairK100Controller::SetName(std::string device_name)
|
||||
{
|
||||
name = device_name;
|
||||
}
|
||||
|
||||
CorsairKeyboardType CorsairK100Controller::GetKeyboardType()
|
||||
{
|
||||
return keyboard_type;
|
||||
}
|
||||
|
||||
std::string CorsairK100Controller::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void CorsairK100Controller::LightingControl()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x01] = 0x08;
|
||||
usb_buf[0x02] = 0x05;
|
||||
usb_buf[0x03] = 0x01;
|
||||
|
||||
hid_write(dev, (unsigned char *)usb_buf, 5);
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
int res = hid_read_timeout(dev, usb_buf, 50, 1000);
|
||||
|
||||
if (res == 0 || usb_buf[1] != 0x05)
|
||||
{
|
||||
LOG_INFO("[Corsair-K100] This device did not allow to take control over it.");
|
||||
keyboard_type = CORSAIR_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairK100Controller::SetLEDs(std::vector<RGBColor>colors)
|
||||
{
|
||||
switch(keyboard_type)
|
||||
{
|
||||
case CORSAIR_TYPE_K100:
|
||||
SetLEDsKeyboardFull(colors);
|
||||
break;
|
||||
|
||||
case CORSAIR_TYPE_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairK100Controller::SetLEDsKeyboardFull(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[600];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x08;
|
||||
usb_buf[0x02] = 0x06;
|
||||
usb_buf[0x03] = 0x01;
|
||||
usb_buf[0x04] = 0x45;
|
||||
usb_buf[0x05] = 0x02;
|
||||
usb_buf[0x08] = 0x12;
|
||||
|
||||
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
RGBColor color = colors[color_idx];
|
||||
usb_buf[0x16 + keys_k100[color_idx]*3] = RGBGetRValue(color);
|
||||
usb_buf[0x17 + keys_k100[color_idx]*3] = RGBGetGValue(color);
|
||||
usb_buf[0x18 + keys_k100[color_idx]*3] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
hid_write(dev, (unsigned char *)usb_buf, 600);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*-----------------------------------------*\
|
||||
| CorsairK100Controller.h |
|
||||
| |
|
||||
| Driver for Corsair K100 Keyboard |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#ifndef CORSAIRK100CONTROLLER_H
|
||||
#define CORSAIRK100CONTROLLER_H
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CORSAIR_TYPE_UNKNOWN = 0,
|
||||
CORSAIR_TYPE_K100 = 1
|
||||
} CorsairKeyboardType;
|
||||
|
||||
class CorsairK100Controller
|
||||
{
|
||||
public:
|
||||
CorsairK100Controller(hid_device* dev_handle, const char* path);
|
||||
~CorsairK100Controller();
|
||||
CorsairKeyboardType GetKeyboardType();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFirmwareString();
|
||||
std::string GetName();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
void SetLEDsKeyboardLimited(std::vector<RGBColor> colors);
|
||||
void SetName(std::string device_name);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
std::string firmware_version;
|
||||
std::string location;
|
||||
std::string name;
|
||||
device_type type;
|
||||
CorsairKeyboardType keyboard_type;
|
||||
|
||||
void LightingControl();
|
||||
void SetLEDsKeyboardFull(std::vector<RGBColor> colors);
|
||||
};
|
||||
|
||||
#endif // CORSAIRK100CONTROLLER_H
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
#include "Detector.h"
|
||||
#include "CorsairPeripheralController.h"
|
||||
#include "CorsairK100Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairPeripheral.h"
|
||||
#include "RGBController_CorsairK100.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -60,6 +62,33 @@
|
|||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_ST100_PID 0x0A34
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Corsair K100 Keyboard product ID |
|
||||
| This keyboard uses a separate driver |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_K100_PID 0x1B7C
|
||||
|
||||
void DetectCorsairK100Controllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
CorsairK100Controller* controller = new CorsairK100Controller(dev, info->path);
|
||||
controller->SetName(name);
|
||||
|
||||
if(controller->GetKeyboardType() != CORSAIR_TYPE_UNKNOWN)
|
||||
{
|
||||
RGBController_CorsairK100* rgb_controller = new RGBController_CorsairK100(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
}
|
||||
} /* DetectCorsairPeripheralControllers() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairPeripheralControllers *
|
||||
|
|
@ -67,11 +96,11 @@
|
|||
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairPeripheralControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
CorsairPeripheralController* controller = new CorsairPeripheralController(dev, info->path);
|
||||
controller->SetName(name);
|
||||
|
|
@ -134,3 +163,8 @@ REGISTER_HID_DETECTOR_P("Corsair ST100 RGB", DetectCorsairPeriphe
|
|||
#else
|
||||
REGISTER_HID_DETECTOR_I("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0);
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Corsair K100 Keyboard |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K100", DetectCorsairK100Controllers, CORSAIR_VID, CORSAIR_K100_PID, 1, 0xFF42);
|
||||
|
|
@ -0,0 +1,338 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairK100.cpp |
|
||||
| |
|
||||
| Driver for Corsair K100 Keyboard |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairK100.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map_k100[7][24] =
|
||||
{ { NA, 112, NA, 8, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 16, NA, NA, NA,},
|
||||
{ 113, 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 },
|
||||
{ 114, 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 },
|
||||
{ 115, 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 },
|
||||
{ 116, 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, 111, NA, NA, NA, 45, 54, 63, NA },
|
||||
{ 117, 4, 110, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 108 },
|
||||
{ 118, 5, 14, 23, NA, NA, NA, NA, 41, NA, NA, NA, NA, 69, 79, 89, 71, 90, 99, 107, 101, NA, 109, NA } };
|
||||
|
||||
static const char* led_names_k100[] =
|
||||
{
|
||||
"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
|
||||
"Key: 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
|
||||
"Key: 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
|
||||
"Key: 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
|
||||
"Key: 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
|
||||
"Key: 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: \\ (ANSI)", //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: Menu", //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: / (ISO)",
|
||||
"Key: \\ (ISO)",
|
||||
"Key: Preset",
|
||||
"Key: G1",
|
||||
"Key: G2",
|
||||
"Key: G3",
|
||||
"Key: G4",
|
||||
"Key: G5",
|
||||
"Key: G6",
|
||||
};
|
||||
static const char* led_names_lightbar[] =
|
||||
{
|
||||
"Underglow 1",
|
||||
"Underglow 2",
|
||||
"Underglow 3",
|
||||
"Underglow 4",
|
||||
"Underglow 5",
|
||||
"Underglow 6",
|
||||
"Underglow 7",
|
||||
"Underglow 8",
|
||||
"Underglow 9",
|
||||
"Underglow 10",
|
||||
"Underglow 11",
|
||||
"Underglow 12",
|
||||
"Underglow 13",
|
||||
"Underglow 14",
|
||||
"Underglow 15",
|
||||
"Underglow 16",
|
||||
"Underglow 17",
|
||||
"Underglow 18",
|
||||
"Underglow 19",
|
||||
"Underglow 20",
|
||||
"Underglow 21",
|
||||
"Underglow 22",
|
||||
"Underglow 23",
|
||||
"Underglow 24",
|
||||
"Underglow 25",
|
||||
"Underglow 26",
|
||||
"Underglow 27",
|
||||
"Underglow 28",
|
||||
"Underglow 29",
|
||||
"Underglow 30",
|
||||
"Underglow 31",
|
||||
"Underglow 32",
|
||||
"Underglow 33",
|
||||
"Underglow 34",
|
||||
"Underglow 35",
|
||||
"Underglow 36",
|
||||
"Underglow 37",
|
||||
"Underglow 38",
|
||||
"Underglow 39",
|
||||
"Underglow 40",
|
||||
"Underglow 41",
|
||||
"Underglow 42",
|
||||
"Underglow 43",
|
||||
"Underglow 44",
|
||||
};
|
||||
static const char* led_names_nameplate[] =
|
||||
{
|
||||
"Nameplate 1",
|
||||
"Nameplate 2",
|
||||
"Nameplate 3",
|
||||
"Nameplate 4",
|
||||
"Nameplate 5",
|
||||
"Nameplate 6",
|
||||
"Nameplate 7",
|
||||
"Nameplate 8",
|
||||
"Nameplate 9",
|
||||
};
|
||||
static const char* led_names_logo[] =
|
||||
{
|
||||
"Logo",
|
||||
"Logo",
|
||||
"Logo",
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
const unsigned int size;
|
||||
const zone_type type;
|
||||
const char** led_names;
|
||||
matrix_map_type* matrix;
|
||||
} led_zone_layout;
|
||||
|
||||
RGBController_CorsairK100::RGBController_CorsairK100(CorsairK100Controller* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetName();
|
||||
vendor = "Corsair";
|
||||
description = "Corsair K100 Keyboard Device";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
version = corsair->GetFirmwareString();
|
||||
location = corsair->GetDeviceLocation();
|
||||
serial = corsair->GetSerialString();
|
||||
|
||||
logical_layout = corsair->GetKeyboardType();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CorsairK100::~RGBController_CorsairK100()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].type == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete corsair;
|
||||
}
|
||||
|
||||
void RGBController_CorsairK100::SetupZones()
|
||||
{
|
||||
std::vector<led_zone_layout> selected_zone;
|
||||
|
||||
switch(logical_layout)
|
||||
{
|
||||
case CORSAIR_TYPE_K100:
|
||||
selected_zone.push_back({"Keyboard", 119, ZONE_TYPE_MATRIX, led_names_k100, new matrix_map_type{7, 24, (unsigned int *)&matrix_map_k100}});
|
||||
selected_zone.push_back({"Underglow", 44, ZONE_TYPE_LINEAR, led_names_lightbar});
|
||||
selected_zone.push_back({"Nameplate", 9, ZONE_TYPE_LINEAR, led_names_nameplate});
|
||||
selected_zone.push_back({"Logo", 3, ZONE_TYPE_LINEAR, led_names_logo});
|
||||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_idx = 0; zone_idx < selected_zone.size(); zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = selected_zone[zone_idx].name;
|
||||
new_zone.type = selected_zone[zone_idx].type;
|
||||
new_zone.leds_min = selected_zone[zone_idx].size;
|
||||
new_zone.leds_max = selected_zone[zone_idx].size;
|
||||
new_zone.leds_count = selected_zone[zone_idx].size;
|
||||
|
||||
if (new_zone.type == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = selected_zone[zone_idx].matrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < selected_zone[zone_idx].size; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = selected_zone[zone_idx].led_names[led_idx];
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairK100::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairK100::DeviceUpdateLEDs()
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairK100::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairK100::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairK100::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairK100::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairK100.cpp |
|
||||
| |
|
||||
| Driver for Corsair K100 Keyboard |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#ifndef RGBCONTROLLER_CORSAIRK100_H
|
||||
#define RGBCONTROLLER_CORSAIRK100_H
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CorsairK100Controller.h"
|
||||
|
||||
class RGBController_CorsairK100 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairK100(CorsairK100Controller* corsair_ptr);
|
||||
~RGBController_CorsairK100();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void SetCustomMode();
|
||||
|
||||
private:
|
||||
CorsairK100Controller* corsair;
|
||||
CorsairKeyboardType logical_layout;
|
||||
};
|
||||
|
||||
#endif // RGBCONTROLLER_CORSAIRK100_H
|
||||
|
|
@ -242,7 +242,9 @@ HEADERS +=
|
|||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \
|
||||
Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.h \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.h \
|
||||
Controllers/CorsairPeripheralController/CorsairK100Controller.h \
|
||||
Controllers/CorsairPeripheralController/RGBController_CorsairPeripheral.h \
|
||||
Controllers/CorsairPeripheralController/RGBController_CorsairK100.h \
|
||||
Controllers/CorsairVengeanceController/CorsairVengeanceController.h \
|
||||
Controllers/CorsairVengeanceController/RGBController_CorsairVengeance.h \
|
||||
Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h \
|
||||
|
|
@ -576,7 +578,9 @@ SOURCES +=
|
|||
Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.cpp \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralControllerDetect.cpp \
|
||||
Controllers/CorsairPeripheralController/CorsairK100Controller.cpp \
|
||||
Controllers/CorsairPeripheralController/RGBController_CorsairPeripheral.cpp \
|
||||
Controllers/CorsairPeripheralController/RGBController_CorsairK100.cpp \
|
||||
Controllers/CorsairVengeanceController/CorsairVengeanceController.cpp \
|
||||
Controllers/CorsairVengeanceController/CorsairVengeanceControllerDetect.cpp \
|
||||
Controllers/CorsairVengeanceController/RGBController_CorsairVengeance.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue