Initial support for RedSquare Keyrox TKL Classic keyboard
This commit is contained in:
parent
01d5430781
commit
8b4b2bacbc
6 changed files with 562 additions and 1 deletions
|
|
@ -0,0 +1,270 @@
|
|||
/*-------------------------------------------------------*\
|
||||
| RGBController_RedSquareKeyroxTKLClassic.cpp |
|
||||
| |
|
||||
| Driver for Red Square Keyrox USB Controller |
|
||||
| Based on Keyrox TKL Controller by cafeed28 |
|
||||
| |
|
||||
| vlack 3 May 2023 |
|
||||
\*-------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_RedSquareKeyroxTKLClassic.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Keyrox
|
||||
@category Keyboard
|
||||
@type USB
|
||||
@save :robot:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectRedSquareKeyroxTKLClassic
|
||||
@comment Also named Dark Project KD87a
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
int value;
|
||||
int flags;
|
||||
} keyrox_effect;
|
||||
|
||||
/*--------------------*\
|
||||
| Keyrox TKL Classic |
|
||||
\*--------------------*/
|
||||
layout_values keyrox_tkl_offset_values =
|
||||
{
|
||||
{
|
||||
/* ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 PRSC SCLK PSBK */
|
||||
7, 13, 16, 19, 22, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58,
|
||||
/* BKTK 1 2 3 4 5 6 7 8 9 0 - = BSPC INS HOME PGUP */
|
||||
83, 86, 89, 92, 95, 98, 101, 104, 107, 110, 113, 116, 119, 135, 138, 141, 144,
|
||||
/* TAB Q W E R T Y U I O P [ ] \ DEL END PGDN */
|
||||
159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 199, 202, 205, 211, 214, 217, 220,
|
||||
/* CPLK A S D F G H J K L ; " ENTR */
|
||||
235, 241, 244, 247, 250, 263, 266, 269, 272, 275, 278, 281, 287,
|
||||
/* LSFT Z X C V B N M , . / RSFT ARWU */
|
||||
311, 327, 330, 333, 336, 339, 342, 345, 348, 351, 354, 363, 369,
|
||||
/* LCTL LWIN LALT SPC RALT RFNC RMNU RCTL ARWR ARWD ARWR */
|
||||
397, 400, 403, 415, 427, 430, 433, 436, 442, 455, 458
|
||||
},
|
||||
{
|
||||
/* Add more regional layout fixes here */
|
||||
}
|
||||
};
|
||||
|
||||
RGBController_RedSquareKeyroxTKLClassic::RGBController_RedSquareKeyroxTKLClassic(RedSquareKeyroxTKLClassicController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Red Square Keyrox TKL Classic";
|
||||
vendor = "Red Square";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = name;
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
int BASE_EFFECT_FLAGS = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
|
||||
const int EFFECTS_COUNT = 14;
|
||||
keyrox_effect keyrox_effects[EFFECTS_COUNT] =
|
||||
{
|
||||
{
|
||||
"Static",
|
||||
CLASSIC_CONST_MODE_VALUE,
|
||||
MODE_FLAG_HAS_MODE_SPECIFIC_COLOR
|
||||
},
|
||||
{
|
||||
"Direct",
|
||||
CLASSIC_CUSTOM_MODE_VALUE,
|
||||
MODE_FLAG_HAS_PER_LED_COLOR
|
||||
},
|
||||
{
|
||||
"Wave",
|
||||
CLASSIC_WAVE_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_DIRECTION_HV
|
||||
},
|
||||
{
|
||||
"Breathing",
|
||||
CLASSIC_FADE_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED
|
||||
},
|
||||
{
|
||||
"Radar",
|
||||
CLASSIC_RADAR_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR // round animation
|
||||
},
|
||||
{
|
||||
"Star (Interactive)",
|
||||
CLASSIC_STAR_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED
|
||||
},
|
||||
{
|
||||
"Line (Interactive)",
|
||||
CLASSIC_LINE_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_HV
|
||||
},
|
||||
{
|
||||
"Ripple (Interactive)",
|
||||
CLASSIC_RIPPLE_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED
|
||||
},
|
||||
{
|
||||
"Stars",
|
||||
CLASSIC_STARS_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED
|
||||
},
|
||||
{
|
||||
"Cross (Interactive)",
|
||||
CLASSIC_CROSS_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED
|
||||
},
|
||||
{
|
||||
"Horizontal bars (Interactive)",
|
||||
CLASSIC_WTF_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_DIRECTION_UD
|
||||
},
|
||||
{
|
||||
"Ripple random",
|
||||
CLASSIC_RIPPLE_RANDOM_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED
|
||||
},
|
||||
{
|
||||
"Running line",
|
||||
CLASSIC_RUNNING_LINE_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR // round direction
|
||||
},
|
||||
{
|
||||
"Fireworks (Interactive)",
|
||||
CLASSIC_FIREWORK_MODE_VALUE,
|
||||
BASE_EFFECT_FLAGS | MODE_FLAG_HAS_SPEED
|
||||
},
|
||||
};
|
||||
|
||||
for(int i = 0; i < EFFECTS_COUNT; i++)
|
||||
{
|
||||
mode m;
|
||||
m.name = keyrox_effects[i].name;
|
||||
m.value = keyrox_effects[i].value;
|
||||
m.flags = keyrox_effects[i].flags | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
|
||||
if(m.flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR && m.value != CLASSIC_CONST_MODE_VALUE)
|
||||
{
|
||||
// background and foreground
|
||||
m.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
m.colors_min = 2;
|
||||
m.colors_max = 2;
|
||||
|
||||
m.colors.resize(2);
|
||||
m.colors.at(0) = ToRGBColor(255, 255, 255);
|
||||
m.colors.at(1) = ToRGBColor(0, 0, 0);
|
||||
}
|
||||
else if(m.flags & MODE_FLAG_HAS_PER_LED_COLOR)
|
||||
{
|
||||
m.color_mode = MODE_COLORS_PER_LED;
|
||||
}
|
||||
else
|
||||
{
|
||||
// foreground only
|
||||
m.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
m.colors_min = 1;
|
||||
m.colors_max = 1;
|
||||
|
||||
m.colors.resize(1);
|
||||
m.colors.at(0) = ToRGBColor(255, 255, 255);
|
||||
}
|
||||
|
||||
if(m.flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
m.speed_min = CLASSIC_KEYROX_SPEED_MIN;
|
||||
m.speed_max = CLASSIC_KEYROX_SPEED_MAX;
|
||||
m.speed = (CLASSIC_KEYROX_SPEED_MAX - CLASSIC_KEYROX_SPEED_MIN) / 2;
|
||||
}
|
||||
|
||||
if(m.flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
m.brightness_min = CLASSIC_KEYROX_BRIGHTNESS_MIN;
|
||||
m.brightness_max = CLASSIC_KEYROX_BRIGHTNESS_MAX;
|
||||
m.brightness = m.brightness_max;
|
||||
}
|
||||
|
||||
modes.push_back(m);
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_RedSquareKeyroxTKLClassic::~RGBController_RedSquareKeyroxTKLClassic()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_RedSquareKeyroxTKLClassic::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create the keyboard zone usiung Keyboard Layout Manager |
|
||||
\*---------------------------------------------------------*/
|
||||
zone new_zone;
|
||||
new_zone.name = ZONE_EN_KEYBOARD;
|
||||
new_zone.type = ZONE_TYPE_MATRIX;
|
||||
|
||||
KeyboardLayoutManager new_kb(KEYBOARD_LAYOUT_ANSI_QWERTY, KEYBOARD_SIZE_TKL, keyrox_tkl_offset_values);
|
||||
|
||||
matrix_map_type * new_map = new matrix_map_type;
|
||||
new_zone.matrix_map = new_map;
|
||||
new_zone.matrix_map->height = KEYROX_TKL_CLASSIC_HEIGHT;
|
||||
new_zone.matrix_map->width = KEYROX_TKL_CLASSIC_WIDTH;
|
||||
|
||||
new_zone.matrix_map->map = new unsigned int[new_map->height * new_map->width];
|
||||
new_zone.leds_count = new_kb.GetKeyCount();
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Matrix map still uses declared zone rows and columns |
|
||||
| as the packet structure depends on the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
new_kb.GetKeyMap(new_map->map, KEYBOARD_MAP_FILL_TYPE_COUNT, new_map->height, new_map->width);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create LEDs for the Matrix zone |
|
||||
| Place keys in the layout to populate the matrix |
|
||||
\*---------------------------------------------------------*/
|
||||
for(size_t led_idx = 0; led_idx < new_zone.leds_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
|
||||
new_led.name = new_kb.GetKeyNameAt(led_idx);
|
||||
new_led.value = new_kb.GetKeyValueAt(led_idx);
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_RedSquareKeyroxTKLClassic::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_RedSquareKeyroxTKLClassic::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLEDsData(colors, leds);
|
||||
}
|
||||
|
||||
void RGBController_RedSquareKeyroxTKLClassic::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RedSquareKeyroxTKLClassic::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RedSquareKeyroxTKLClassic::DeviceUpdateMode()
|
||||
{
|
||||
controller->SetMode(modes[active_mode]);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*---------------------------------------------*\
|
||||
| RGBController_RedSquareKeyroxTKLClassic.h |
|
||||
| |
|
||||
| Driver for Red Square Keyrox USB Controller |
|
||||
| |
|
||||
| vlack 3 May 2023 |
|
||||
\*---------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "KeyboardLayoutManager.h"
|
||||
#include "RedSquareKeyroxTKLClassicController.h"
|
||||
|
||||
#define KEYROX_TKL_CLASSIC_WIDTH 17
|
||||
#define KEYROX_TKL_CLASSIC_HEIGHT 6
|
||||
|
||||
class RGBController_RedSquareKeyroxTKLClassic : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RedSquareKeyroxTKLClassic(RedSquareKeyroxTKLClassicController* controller_ptr);
|
||||
~RGBController_RedSquareKeyroxTKLClassic();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
RedSquareKeyroxTKLClassicController* controller;
|
||||
};
|
||||
|
|
@ -1,18 +1,22 @@
|
|||
#include "Detector.h"
|
||||
#include "RedSquareKeyroxController.h"
|
||||
#include "RedSquareKeyroxTKLClassicController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RedSquareKeyrox.h"
|
||||
#include "RGBController_RedSquareKeyroxTKLClassic.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Red Square vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define RED_SQUARE_VID 0x1A2C
|
||||
#define RED_SQUARE_KEYROX_TKL_CLASSIC_VID 0x0416
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Red Square Keyrox TKL product ID |
|
||||
| Red Square product ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define RED_SQUARE_KEYROX_TKL_PID 0x1511
|
||||
#define RED_SQUARE_KEYROX_TKL_CLASSIC_PID 0xC345
|
||||
|
||||
void DetectRedSquareKeyroxTKL(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
|
|
@ -27,5 +31,19 @@ void DetectRedSquareKeyroxTKL(hid_device_info* info, const std::string& name)
|
|||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
void DetectRedSquareKeyroxTKLClassic(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
RedSquareKeyroxTKLClassicController* controller = new RedSquareKeyroxTKLClassicController(dev, *info);
|
||||
RGBController_RedSquareKeyroxTKLClassic* rgb_controller = new RGBController_RedSquareKeyroxTKLClassic(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_PID, 3, 0xFF00, 2);
|
||||
REGISTER_HID_DETECTOR_I("Red Square Keyrox TKL Classic", DetectRedSquareKeyroxTKLClassic, RED_SQUARE_KEYROX_TKL_CLASSIC_VID, RED_SQUARE_KEYROX_TKL_CLASSIC_PID, 2);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,161 @@
|
|||
/*-------------------------------------------------------*\
|
||||
| RedSquareKeyroxTKLClassicController.cpp |
|
||||
| |
|
||||
| Driver for Red Square Keyrox USB Controller |
|
||||
| Based on Keyrox TKL Controller by cafeed28 |
|
||||
| |
|
||||
| vlack 3 May 2023 |
|
||||
\*-------------------------------------------------------*/
|
||||
|
||||
#include "LogManager.h"
|
||||
#include "RedSquareKeyroxTKLClassicController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RedSquareKeyroxTKLClassicController::RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
}
|
||||
|
||||
RedSquareKeyroxTKLClassicController::~RedSquareKeyroxTKLClassicController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string RedSquareKeyroxTKLClassicController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string RedSquareKeyroxTKLClassicController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_wchar[128];
|
||||
hid_get_serial_number_string(dev, serial_wchar, 128);
|
||||
std::wstring serial_wstring(serial_wchar);
|
||||
|
||||
std::string serial_string;
|
||||
std::transform(serial_wstring.begin(), serial_wstring.end(), std::back_inserter(serial_string), [] (wchar_t i)
|
||||
{
|
||||
return (char)i;
|
||||
});
|
||||
|
||||
return serial_string;
|
||||
}
|
||||
|
||||
int RedSquareKeyroxTKLClassicController::GetDirection(int direction)
|
||||
{
|
||||
switch(direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
return 0x00;
|
||||
case MODE_DIRECTION_RIGHT:
|
||||
return 0x01;
|
||||
case MODE_DIRECTION_UP:
|
||||
return 0x02;
|
||||
case MODE_DIRECTION_DOWN:
|
||||
return 0x03;
|
||||
case MODE_DIRECTION_HORIZONTAL: // actually direction out
|
||||
return 0x04;
|
||||
case MODE_DIRECTION_VERTICAL: // actually direction in
|
||||
return 0x05;
|
||||
default:
|
||||
return 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
int RedSquareKeyroxTKLClassicController::GetDirectionRound(int direction)
|
||||
{
|
||||
switch(direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT: // actually anticlockwise
|
||||
return 0x07;
|
||||
case MODE_DIRECTION_RIGHT: // actually clockwise
|
||||
return 0x06;
|
||||
default:
|
||||
return 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void RedSquareKeyroxTKLClassicController::SetMode(mode m)
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| Mode set command |
|
||||
\*---------------------------------------------*/
|
||||
|
||||
unsigned char usb_buf[CLASSIC_PACKET_DATA_LENGTH];
|
||||
memset(usb_buf, 0x00, CLASSIC_PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0] = 0x01;
|
||||
usb_buf[1] = 0x07;
|
||||
usb_buf[6] = m.value;
|
||||
usb_buf[7] = m.brightness; // brightness
|
||||
usb_buf[8] = m.speed; // speed
|
||||
|
||||
if(m.colors_max == 1 || m.colors_max == 2)
|
||||
{
|
||||
usb_buf[9] = RGBGetRValue(m.colors[0]); // front R
|
||||
usb_buf[10] = RGBGetGValue(m.colors[0]); // front G
|
||||
usb_buf[11] = RGBGetBValue(m.colors[0]); // front B
|
||||
}
|
||||
|
||||
if(m.colors_max == 2 && m.color_mode != MODE_COLORS_RANDOM)
|
||||
{
|
||||
usb_buf[12] = RGBGetRValue(m.colors[1]); // back R
|
||||
usb_buf[13] = RGBGetGValue(m.colors[1]); // back G
|
||||
usb_buf[14] = RGBGetBValue(m.colors[1]); // back B
|
||||
}
|
||||
|
||||
if(m.value == CLASSIC_RADAR_MODE_VALUE || m.value == CLASSIC_RUNNING_LINE_MODE_VALUE)
|
||||
{
|
||||
usb_buf[15] = GetDirectionRound(m.direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
usb_buf[15] = GetDirection(m.direction);
|
||||
}
|
||||
|
||||
usb_buf[16] = m.color_mode == MODE_COLORS_RANDOM;
|
||||
|
||||
hid_write(dev, usb_buf, CLASSIC_PACKET_DATA_LENGTH);
|
||||
// sleep is necessary
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
|
||||
void RedSquareKeyroxTKLClassicController::SetLEDsData(std::vector<RGBColor> colors, std::vector<led> leds)
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| LEDs data set command |
|
||||
\*---------------------------------------------*/
|
||||
|
||||
unsigned char usb_buf[CLASSIC_PACKET_DATA_LENGTH * 8];
|
||||
memset(usb_buf, 0x00, CLASSIC_PACKET_DATA_LENGTH * 8);
|
||||
|
||||
for(unsigned int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
int offset = leds[i].value;
|
||||
usb_buf[offset - 1] = RGBGetRValue(colors[i]);
|
||||
usb_buf[offset] = RGBGetGValue(colors[i]);
|
||||
usb_buf[offset + 1] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char packet[CLASSIC_PACKET_DATA_LENGTH];
|
||||
memset(packet, 0x00, CLASSIC_PACKET_DATA_LENGTH);
|
||||
|
||||
packet[0] = 0x01;
|
||||
packet[1] = 0x0F;
|
||||
packet[4] = i; // package number
|
||||
packet[5] = i == 7 ? 0x12 : 0x36; // package size
|
||||
|
||||
for (int x = 6; x < CLASSIC_PACKET_DATA_LENGTH; x++)
|
||||
{
|
||||
packet[x] = usb_buf[CLASSIC_PACKET_DATA_LENGTH * i + x];
|
||||
}
|
||||
hid_write(dev, packet, CLASSIC_PACKET_DATA_LENGTH);
|
||||
}
|
||||
|
||||
// sleep is necessary
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*---------------------------------------------*\
|
||||
| RedSquareKeyroxTKLClassicController.h |
|
||||
| |
|
||||
| Driver for Red Square Keyrox USB Controller |
|
||||
| |
|
||||
| vlack 3 May 2023 |
|
||||
\*---------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#define CLASSIC_PACKET_DATA_LENGTH 64
|
||||
|
||||
/*---------------------------------------*\
|
||||
| Modes |
|
||||
\*---------------------------------------*/
|
||||
enum
|
||||
{
|
||||
CLASSIC_CONST_MODE_VALUE = 0x00, // static
|
||||
CLASSIC_BREATHE_MODE_VALUE = 0x01, // breath
|
||||
CLASSIC_WAVE_MODE_VALUE = 0x02, // wave
|
||||
CLASSIC_FADE_MODE_VALUE = 0x03, // neon
|
||||
CLASSIC_RADAR_MODE_VALUE = 0x04, // radar
|
||||
CLASSIC_STAR_MODE_VALUE = 0x06, // интерактив
|
||||
CLASSIC_LINE_MODE_VALUE = 0x07, // сияние
|
||||
CLASSIC_RIPPLE_MODE_VALUE = 0x08, // рябь интерактив
|
||||
CLASSIC_STARS_MODE_VALUE = 0x09, // мерцание
|
||||
CLASSIC_CUSTOM_MODE_VALUE = 0x0A,
|
||||
CLASSIC_CROSS_MODE_VALUE = 0x0B, // скрещивание
|
||||
CLASSIC_WTF_MODE_VALUE = 0x0C, // быстрый отклик
|
||||
CLASSIC_RIPPLE_RANDOM_MODE_VALUE = 0x0E, // рябь
|
||||
CLASSIC_RUNNING_LINE_MODE_VALUE = 0x0F, // бегущая строка
|
||||
CLASSIC_FIREWORK_MODE_VALUE = 0x10, // firework
|
||||
};
|
||||
|
||||
/*-----------------------------*\
|
||||
| Other settings |
|
||||
\*-----------------------------*/
|
||||
enum
|
||||
{
|
||||
CLASSIC_KEYROX_BRIGHTNESS_MIN = 0x00,
|
||||
CLASSIC_KEYROX_BRIGHTNESS_MAX = 0x04,
|
||||
CLASSIC_KEYROX_SPEED_MIN = 0x00,
|
||||
CLASSIC_KEYROX_SPEED_MAX = 0x04,
|
||||
};
|
||||
|
||||
|
||||
class RedSquareKeyroxTKLClassicController
|
||||
{
|
||||
public:
|
||||
RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info);
|
||||
~RedSquareKeyroxTKLClassicController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
int GetDirection(int direction);
|
||||
int GetDirectionRound(int direction);
|
||||
|
||||
void SetMode(mode m);
|
||||
void SetLEDsData(std::vector<RGBColor> colors, std::vector<led> leds);
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
|
||||
private:
|
||||
std::string location;
|
||||
std::string serial_number;
|
||||
std::vector<unsigned int> led_sequence_positions;
|
||||
};
|
||||
|
|
@ -611,7 +611,9 @@ HEADERS +=
|
|||
Controllers/RedragonController/RGBController_RedragonMouse.h \
|
||||
Controllers/RedragonController/RedragonMouseController.h \
|
||||
Controllers/RedSquareKeyroxController/RedSquareKeyroxController.h \
|
||||
Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController.h \
|
||||
Controllers/RedSquareKeyroxController/RGBController_RedSquareKeyrox.h \
|
||||
Controllers/RedSquareKeyroxController/RGBController_RedSquareKeyroxTKLClassic.h \
|
||||
Controllers/RoccatController/RGBController_RoccatBurst.h \
|
||||
Controllers/RoccatController/RGBController_RoccatElo.h \
|
||||
Controllers/RoccatController/RGBController_RoccatHordeAimo.h \
|
||||
|
|
@ -1264,7 +1266,9 @@ SOURCES +=
|
|||
Controllers/RedragonController/RedragonMouseController.cpp \
|
||||
Controllers/RedSquareKeyroxController/RedSquareKeyroxController.cpp \
|
||||
Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp \
|
||||
Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController.cpp \
|
||||
Controllers/RedSquareKeyroxController/RGBController_RedSquareKeyrox.cpp \
|
||||
Controllers/RedSquareKeyroxController/RGBController_RedSquareKeyroxTKLClassic.cpp \
|
||||
Controllers/RoccatController/RGBController_RoccatBurst.cpp \
|
||||
Controllers/RoccatController/RGBController_RoccatElo.cpp \
|
||||
Controllers/RoccatController/RGBController_RoccatHordeAimo.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue