Rename RedragonK556Controller to EVisionKeyboardController
This commit is contained in:
parent
8492a8c76e
commit
0089852395
8 changed files with 339 additions and 312 deletions
|
|
@ -0,0 +1,260 @@
|
|||
/*-----------------------------------------*\
|
||||
| EVisionKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for EVision RGB keyboard lighting |
|
||||
| controller |
|
||||
| |
|
||||
| EVision is used by Redragon, Glorious, |
|
||||
| Ajazz, Tecware, and many other brands |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/15/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "EVisionKeyboardController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
EVisionKeyboardController::EVisionKeyboardController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
EVisionKeyboardController::~EVisionKeyboardController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string EVisionKeyboardController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string EVisionKeyboardController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SetKeyboardColors
|
||||
(
|
||||
unsigned char * color_data,
|
||||
unsigned int size
|
||||
)
|
||||
{
|
||||
unsigned int packet_size = 0;
|
||||
unsigned int packet_offset = 0;
|
||||
|
||||
while(size > 0)
|
||||
{
|
||||
if(size >= EVISION_KB_MAX_PACKET_SIZE)
|
||||
{
|
||||
packet_size = EVISION_KB_MAX_PACKET_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet_size = size;
|
||||
}
|
||||
|
||||
SendKeyboardData
|
||||
(
|
||||
&color_data[packet_offset],
|
||||
packet_size,
|
||||
packet_offset
|
||||
);
|
||||
|
||||
size -= packet_size;
|
||||
packet_offset += packet_size;
|
||||
}
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SendKeyboardMode
|
||||
(
|
||||
unsigned char mode
|
||||
)
|
||||
{
|
||||
SendKeyboardParameter(EVISION_KB_PARAMETER_MODE, 1, &mode);
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SendKeyboardModeEx
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char random_flag,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char parameter_data[8];
|
||||
|
||||
parameter_data[0] = mode;
|
||||
parameter_data[1] = brightness;
|
||||
parameter_data[2] = speed;
|
||||
parameter_data[3] = direction;
|
||||
parameter_data[4] = random_flag;
|
||||
parameter_data[5] = red;
|
||||
parameter_data[6] = green;
|
||||
parameter_data[7] = blue;
|
||||
|
||||
SendKeyboardParameter(0, 8, parameter_data);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void EVisionKeyboardController::ComputeChecksum
|
||||
(
|
||||
char usb_buf[64]
|
||||
)
|
||||
{
|
||||
unsigned short checksum = 0;
|
||||
|
||||
for(unsigned int byte_idx = 0x03; byte_idx < 64; byte_idx++)
|
||||
{
|
||||
checksum += usb_buf[byte_idx];
|
||||
}
|
||||
|
||||
usb_buf[0x01] = checksum & 0xFF;
|
||||
usb_buf[0x02] = checksum >> 8;
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SendKeyboardBegin()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard Begin (0x01) packet |
|
||||
| Note: Not computing checksum as packet contents are |
|
||||
| fixed |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x01] = EVISION_KB_COMMAND_BEGIN;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = EVISION_KB_COMMAND_BEGIN;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SendKeyboardEnd()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard End (0x02) packet |
|
||||
| Note: Not computing checksum as packet contents are |
|
||||
| fixed |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x01] = EVISION_KB_COMMAND_END;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = EVISION_KB_COMMAND_END;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SendKeyboardData
|
||||
(
|
||||
unsigned char * data,
|
||||
unsigned char data_size,
|
||||
unsigned short data_offset
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard Color Data (0x11) packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x03] = 0x11;
|
||||
|
||||
usb_buf[0x04] = data_size;
|
||||
usb_buf[0x05] = data_offset & 0x00FF;
|
||||
usb_buf[0x06] = data_offset >> 8;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x08], data, data_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Compute Checksum |
|
||||
\*-----------------------------------------------------*/
|
||||
ComputeChecksum(usb_buf);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void EVisionKeyboardController::SendKeyboardParameter
|
||||
(
|
||||
unsigned char parameter,
|
||||
unsigned char parameter_size,
|
||||
unsigned char* parameter_data
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Keyboard Parameter (0x06) packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x04;
|
||||
usb_buf[0x03] = EVISION_KB_COMMAND_SET_PARAMETER;
|
||||
usb_buf[0x04] = parameter_size;
|
||||
usb_buf[0x05] = parameter;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x08], parameter_data, parameter_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Compute Checksum |
|
||||
\*-----------------------------------------------------*/
|
||||
ComputeChecksum(usb_buf);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
/*-----------------------------------------*\
|
||||
| EVisionKeyboardController.h |
|
||||
| |
|
||||
| Definitions and types for EVision RGB |
|
||||
| keyboard lighting controller |
|
||||
| |
|
||||
| EVision is used by Redragon, Glorious, |
|
||||
| Ajazz, Tecware, and many other brands |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/15/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define EVISION_KB_MAX_PACKET_SIZE ( 0x36 )/* max packet size for color*/
|
||||
/* update packets */
|
||||
enum
|
||||
{
|
||||
EVISION_KB_COMMAND_BEGIN = 0x01, /* Begin packet command */
|
||||
EVISION_KB_COMMAND_END = 0x02, /* End packet command */
|
||||
EVISION_KB_COMMAND_SET_PARAMETER = 0x06, /* Set parameter command */
|
||||
EVISION_KB_COMMAND_READ_CUSTOM_COLOR_DATA = 0x10, /* Read custom color data */
|
||||
EVISION_KB_COMMAND_WRITE_CUSTOM_COLOR_DATA = 0x11, /* Write custom color data */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVISION_KB_PARAMETER_MODE = 0x00, /* Mode parameter */
|
||||
EVISION_KB_PARAMETER_BRIGHTNESS = 0x01, /* Brightness parameter */
|
||||
EVISION_KB_PARAMETER_SPEED = 0x02, /* Speed parameter */
|
||||
EVISION_KB_PARAMETER_DIRECTION = 0x03, /* Direction parameter */
|
||||
EVISION_KB_PARAMETER_RANDOM_COLOR_FLAG = 0x04, /* Random color parameter */
|
||||
EVISION_KB_PARAMETER_MODE_COLOR = 0x05, /* Mode color (RGB) */
|
||||
EVISION_KB_PARAMETER_POLLING_RATE = 0x0F, /* Polling rate */
|
||||
EVISION_KB_PARAMETER_SURMOUNT_MODE_COLOR = 0x11, /* Surmount mode color */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVISION_KB_MODE_COLOR_WAVE_SHORT = 0x01, /* "Go with the stream" */
|
||||
EVISION_KB_MODE_COLOR_WAVE_LONG = 0x02, /* "Clouds fly" */
|
||||
EVISION_KB_MODE_COLOR_WHEEL = 0x03, /* "Winding paths" */
|
||||
EVISION_KB_MODE_SPECTRUM_CYCLE = 0x04, /* "The trial of light" */
|
||||
EVISION_KB_MODE_BREATHING = 0x05, /* "Breathing" */
|
||||
EVISION_KB_MODE_STATIC = 0x06, /* "Normally on" */
|
||||
EVISION_KB_MODE_REACTIVE = 0x07, /* "Pass without trace" */
|
||||
EVISION_KB_MODE_REACTIVE_RIPPLE = 0x08, /* "Ripple graff" */
|
||||
EVISION_KB_MODE_REACTIVE_LINE = 0x09, /* "Fast run without trace" */
|
||||
EVISION_KB_MODE_STARLIGHT_FAST = 0x0A, /* "Swift action" */
|
||||
EVISION_KB_MODE_BLOOMING = 0x0B, /* "Flowers blooming" */
|
||||
EVISION_KB_MODE_RAINBOW_WAVE_VERTICAL = 0x0C, /* "Snow winter jasmine" */
|
||||
EVISION_KB_MODE_HURRICANE = 0x0D, /* "Hurricane" */
|
||||
EVISION_KB_MODE_ACCUMULATE = 0x0E, /* "Accumulate" */
|
||||
EVISION_KB_MODE_STARLIGHT_SLOW = 0x0F, /* "Digital times" */
|
||||
EVISION_KB_MODE_VISOR = 0x10, /* "Both ways" */
|
||||
EVISION_KB_MODE_SURMOUNT = 0x11, /* "Surmount" */
|
||||
EVISION_KB_MODE_RAINBOW_WAVE_CIRCLE = 0x12, /* "Fast and the Furious" */
|
||||
EVISION_KB_MODE_CUSTOM = 0x14, /* "Coastal" */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVISION_KB_BRIGHTNESS_LOWEST = 0x00, /* Lowest brightness (off) */
|
||||
EVISION_KB_BRIGHTNESS_HIGHEST = 0x05, /* Highest brightness */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVISION_KB_SPEED_SLOWEST = 0x05, /* Slowest speed setting */
|
||||
EVISION_KB_SPEED_NORMAL = 0x03, /* Normal speed setting */
|
||||
EVISION_KB_SPEED_FASTEST = 0x00, /* Fastest speed setting */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVISION_KB_SURMOUNT_MODE_COLOR_RED = 0x01, /* Red surmount color */
|
||||
EVISION_KB_SURMOUNT_MODE_COLOR_YELLOW = 0x02, /* Yellow surmount color */
|
||||
EVISION_KB_SURMOUNT_MODE_COLOR_GREEN = 0x03, /* Green surmount color */
|
||||
EVISION_KB_SURMOUNT_MODE_COLOR_BLUE = 0x04, /* Blue surmount color */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVISION_KB_POLLING_RATE_125HZ = 0x00, /* 125Hz polling rate */
|
||||
EVISION_KB_POLLING_RATE_250HZ = 0x01, /* 250Hz polling rate */
|
||||
EVISION_KB_POLLING_RATE_500HZ = 0x02, /* 500Hz polling rate */
|
||||
EVISION_KB_POLLING_RATE_1000HZ = 0x03, /* 1000Hz polling rate */
|
||||
};
|
||||
|
||||
class EVisionKeyboardController
|
||||
{
|
||||
public:
|
||||
EVisionKeyboardController(hid_device* dev_handle, const char* path);
|
||||
~EVisionKeyboardController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetKeyboardColors
|
||||
(
|
||||
unsigned char * color_data,
|
||||
unsigned int size
|
||||
);
|
||||
|
||||
void SendKeyboardBegin();
|
||||
|
||||
void SendKeyboardMode
|
||||
(
|
||||
unsigned char mode
|
||||
);
|
||||
|
||||
void SendKeyboardModeEx
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char random_flag,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendKeyboardData
|
||||
(
|
||||
unsigned char * data,
|
||||
unsigned char data_size,
|
||||
unsigned short data_offset
|
||||
);
|
||||
|
||||
void SendKeyboardEnd();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
|
||||
void ComputeChecksum
|
||||
(
|
||||
char usb_buf[64]
|
||||
);
|
||||
|
||||
void SendKeyboardParameter
|
||||
(
|
||||
unsigned char parameter,
|
||||
unsigned char parameter_size,
|
||||
unsigned char* parameter_data
|
||||
);
|
||||
};
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#include "Detector.h"
|
||||
#include "EVisionKeyboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_EVisionKeyboard.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define EVISION_KEYBOARD_VID 0x0C45
|
||||
#define EVISION_KEYBOARD_USAGE_PAGE 0xFF1C
|
||||
#define REDRAGON_K550_PID 0x5204
|
||||
#define REDRAGON_K552_PID 0x5104
|
||||
#define REDRAGON_K556_PID 0x5004
|
||||
#define TECWARE_PHANTOM_ELITE_PID 0x652F
|
||||
#define WARRIOR_KANE_TC235 0x8520
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectEVisionKeyboards *
|
||||
* *
|
||||
* Tests the USB address to see if an EVision RGB Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectEVisionKeyboards(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
EVisionKeyboardController* controller = new EVisionKeyboardController(dev, info->path);
|
||||
RGBController_EVisionKeyboard* rgb_controller = new RGBController_EVisionKeyboard(controller);
|
||||
rgb_controller->name = "EVision Keyboard";
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IP("EVision Keyboard 5204", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, REDRAGON_K550_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
|
||||
REGISTER_HID_DETECTOR_IP("EVision Keyboard 5104", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, REDRAGON_K552_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
|
||||
REGISTER_HID_DETECTOR_IP("EVision Keyboard 5004", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, REDRAGON_K556_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
|
||||
REGISTER_HID_DETECTOR_IP("EVision Keyboard 652F", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
|
||||
REGISTER_HID_DETECTOR_IP("EVision Keyboard 8520", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, EVISION_KEYBOARD_USAGE_PAGE);
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_EVisionKeyboard.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for EVision RGB |
|
||||
| Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_EVisionKeyboard.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][23] =
|
||||
{ { 0, NA, 1, 2, 3, 4, NA, 5, 6, 7, 8, NA, 9, 10, 11, 12, 14, 15, 16, NA, NA, NA, NA },
|
||||
{ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, NA, 32, 33, 34, NA, 35, 36, 37, 38, 39, 40, 41 },
|
||||
{ 42, NA, 43, 44, 45, 46, NA, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 },
|
||||
{ 63, NA, 64, 65, 66, 67, NA, 68, 69, 70, 71, 72, 73, 74, 76, NA, NA, NA, NA, 80, 81, 82, NA },
|
||||
{ 84, NA, 86, 87, 88, 89, NA, 90, NA, 91, 92, 93, 94, 95, 97, NA, NA, 99, NA, 101, 102, 103, 104 },
|
||||
{ 105, 106, 107, NA, NA, NA, NA, 108, NA, NA, NA, NA, 109, 110, 111, 113, 119, 120, 121, 123, NA, 124, NA } };
|
||||
|
||||
RGBController_EVisionKeyboard::RGBController_EVisionKeyboard(EVisionKeyboardController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "EVision Keyboard Device";
|
||||
vendor = "EVision";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "EVision Keyboard Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Custom;
|
||||
Custom.name = "Custom";
|
||||
Custom.value = EVISION_KB_MODE_CUSTOM;
|
||||
Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Custom.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Custom);
|
||||
|
||||
mode ColorWave;
|
||||
ColorWave.name = "Color Wave";
|
||||
ColorWave.value = EVISION_KB_MODE_COLOR_WAVE_LONG;
|
||||
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorWave.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
ColorWave.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
ColorWave.speed = EVISION_KB_SPEED_NORMAL;
|
||||
ColorWave.colors_min = 1;
|
||||
ColorWave.colors_max = 1;
|
||||
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorWave.colors.resize(1);
|
||||
modes.push_back(ColorWave);
|
||||
|
||||
mode ColorWheel;
|
||||
ColorWheel.name = "Color Wheel";
|
||||
ColorWheel.value = EVISION_KB_MODE_COLOR_WHEEL;
|
||||
ColorWheel.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ColorWheel.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
ColorWheel.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
ColorWheel.speed = EVISION_KB_SPEED_NORMAL;
|
||||
ColorWheel.colors_min = 1;
|
||||
ColorWheel.colors_max = 1;
|
||||
ColorWheel.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorWheel.colors.resize(1);
|
||||
modes.push_back(ColorWheel);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = EVISION_KB_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
SpectrumCycle.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = EVISION_KB_SPEED_NORMAL;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = EVISION_KB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
Breathing.speed = EVISION_KB_SPEED_NORMAL;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Hurricane;
|
||||
Hurricane.name = "Hurricane";
|
||||
Hurricane.value = EVISION_KB_MODE_HURRICANE;
|
||||
Hurricane.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Hurricane.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
Hurricane.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
Hurricane.speed = EVISION_KB_SPEED_NORMAL;
|
||||
Hurricane.colors_min = 1;
|
||||
Hurricane.colors_max = 1;
|
||||
Hurricane.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Hurricane.colors.resize(1);
|
||||
modes.push_back(Hurricane);
|
||||
|
||||
mode Accumulate;
|
||||
Accumulate.name = "Accumulate";
|
||||
Accumulate.value = EVISION_KB_MODE_ACCUMULATE;
|
||||
Accumulate.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Accumulate.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
Accumulate.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
Accumulate.speed = EVISION_KB_SPEED_NORMAL;
|
||||
Accumulate.colors_min = 1;
|
||||
Accumulate.colors_max = 1;
|
||||
Accumulate.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Accumulate.colors.resize(1);
|
||||
modes.push_back(Accumulate);
|
||||
|
||||
mode Starlight;
|
||||
Starlight.name = "Starlight";
|
||||
Starlight.value = EVISION_KB_MODE_STARLIGHT_FAST;
|
||||
Starlight.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Starlight.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
Starlight.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
Starlight.speed = EVISION_KB_SPEED_NORMAL;
|
||||
Starlight.colors_min = 1;
|
||||
Starlight.colors_max = 1;
|
||||
Starlight.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Starlight.colors.resize(1);
|
||||
modes.push_back(Starlight);
|
||||
|
||||
mode Visor;
|
||||
Visor.name = "Visor";
|
||||
Visor.value = EVISION_KB_MODE_VISOR;
|
||||
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Visor.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
Visor.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
Visor.speed = EVISION_KB_SPEED_NORMAL;
|
||||
Visor.colors_min = 1;
|
||||
Visor.colors_max = 1;
|
||||
Visor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Visor.colors.resize(1);
|
||||
modes.push_back(Visor);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = EVISION_KB_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode RainbowCircle;
|
||||
RainbowCircle.name = "Rainbow Circle";
|
||||
RainbowCircle.value = EVISION_KB_MODE_RAINBOW_WAVE_CIRCLE;
|
||||
RainbowCircle.flags = 0;
|
||||
RainbowCircle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(RainbowCircle);
|
||||
|
||||
mode Blooming;
|
||||
Blooming.name = "Blooming";
|
||||
Blooming.value = EVISION_KB_MODE_BLOOMING;
|
||||
Blooming.flags = MODE_FLAG_HAS_SPEED;
|
||||
Blooming.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
Blooming.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
Blooming.speed = EVISION_KB_SPEED_NORMAL;
|
||||
Blooming.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Blooming);
|
||||
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
Reactive.value = EVISION_KB_MODE_REACTIVE;
|
||||
Reactive.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Reactive.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
Reactive.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
Reactive.speed = EVISION_KB_SPEED_NORMAL;
|
||||
Reactive.colors_min = 1;
|
||||
Reactive.colors_max = 1;
|
||||
Reactive.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Reactive.colors.resize(1);
|
||||
modes.push_back(Reactive);
|
||||
|
||||
mode ReactiveRipple;
|
||||
ReactiveRipple.name = "Reactive Ripple";
|
||||
ReactiveRipple.value = EVISION_KB_MODE_REACTIVE_RIPPLE;
|
||||
ReactiveRipple.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ReactiveRipple.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
ReactiveRipple.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
ReactiveRipple.speed = EVISION_KB_SPEED_NORMAL;
|
||||
ReactiveRipple.colors_min = 1;
|
||||
ReactiveRipple.colors_max = 1;
|
||||
ReactiveRipple.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ReactiveRipple.colors.resize(1);
|
||||
modes.push_back(ReactiveRipple);
|
||||
|
||||
mode ReactiveLine;
|
||||
ReactiveLine.name = "Reactive Line";
|
||||
ReactiveLine.value = EVISION_KB_MODE_REACTIVE_LINE;
|
||||
ReactiveLine.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
ReactiveLine.speed_min = EVISION_KB_SPEED_SLOWEST;
|
||||
ReactiveLine.speed_max = EVISION_KB_SPEED_FASTEST;
|
||||
ReactiveLine.speed = EVISION_KB_SPEED_NORMAL;
|
||||
ReactiveLine.colors_min = 1;
|
||||
ReactiveLine.colors_max = 1;
|
||||
ReactiveLine.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ReactiveLine.colors.resize(1);
|
||||
modes.push_back(ReactiveLine);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_EVisionKeyboard::~RGBController_EVisionKeyboard()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_EVisionKeyboard::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Keyboard";
|
||||
new_zone.type = ZONE_TYPE_MATRIX;
|
||||
new_zone.leds_min = 126;
|
||||
new_zone.leds_max = 126;
|
||||
new_zone.leds_count = 126;
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 6;
|
||||
new_zone.matrix_map->width = 23;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
for(int led_idx = 0; led_idx < 126; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
|
||||
new_led.name = "Keyboard LED ";
|
||||
new_led.name.append(std::to_string(led_idx));
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_EVisionKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_EVisionKeyboard::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char color_data[7*0x36];
|
||||
|
||||
for(int led_idx = 0; led_idx < 126; led_idx++)
|
||||
{
|
||||
color_data[(3 * led_idx) + 0] = RGBGetRValue(colors[led_idx]);
|
||||
color_data[(3 * led_idx) + 1] = RGBGetGValue(colors[led_idx]);
|
||||
color_data[(3 * led_idx) + 2] = RGBGetBValue(colors[led_idx]);
|
||||
}
|
||||
|
||||
controller->SetKeyboardColors
|
||||
(
|
||||
color_data,
|
||||
0x36 * 7
|
||||
);
|
||||
}
|
||||
|
||||
void RGBController_EVisionKeyboard::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_EVisionKeyboard::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_EVisionKeyboard::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_EVisionKeyboard::DeviceUpdateMode()
|
||||
{
|
||||
unsigned char red = 0x00;
|
||||
unsigned char grn = 0x00;
|
||||
unsigned char blu = 0x00;
|
||||
unsigned char random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
|
||||
if(modes[active_mode].colors.size() > 0)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
controller->SendKeyboardModeEx
|
||||
(
|
||||
modes[active_mode].value,
|
||||
EVISION_KB_BRIGHTNESS_HIGHEST,
|
||||
modes[active_mode].speed,
|
||||
0,
|
||||
random,
|
||||
red,
|
||||
grn,
|
||||
blu
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_EVisionKeyboard.h |
|
||||
| |
|
||||
| Generic RGB Interface for EVision RGB |
|
||||
| Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "EVisionKeyboardController.h"
|
||||
|
||||
class RGBController_EVisionKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_EVisionKeyboard(EVisionKeyboardController* controller_ptr);
|
||||
~RGBController_EVisionKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
EVisionKeyboardController* controller;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue