Initial commit for the Dark Project KD3B Keyboard to resolve #2292
* Creating detector class and adding entry for the Dark Project KD3B VID & PID * Registered detectors * Creating DarkProjectKeyboardController class * Creating RGBController_DarkProjectKeyboard class * Added UDEV rule to 60-openrgb.rules
This commit is contained in:
parent
42b95509ac
commit
e9eca70e72
6 changed files with 464 additions and 0 deletions
29
Controllers/DarkProject/DarkProjectControllerDetect.cpp
Normal file
29
Controllers/DarkProject/DarkProjectControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "Detector.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
#include "RGBController_DarkProjectKeyboard.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Dark Project vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define DARKPROJECT_VID 0x195D
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define KD3B_V2_PID 0x2061
|
||||
|
||||
void DetectDarkProjectKeyboardControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
DarkProjectKeyboardController* controller = new DarkProjectKeyboardController(dev, info->path);
|
||||
RGBController_DarkProjectKeyboard* rgb_controller = new RGBController_DarkProjectKeyboard(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Dark Project KD3B V2", DetectDarkProjectKeyboardControllers, DARKPROJECT_VID, KD3B_V2_PID, 2, 0xFFC2, 4);
|
||||
108
Controllers/DarkProject/DarkProjectKeyboardController.cpp
Normal file
108
Controllers/DarkProject/DarkProjectKeyboardController.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| DarkProjectKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for DarkProjectKeyboard USB Controller |
|
||||
| |
|
||||
| Chris M (DrNo) 8 Apr 2022 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "LogManager.h"
|
||||
#include "DarkProjectKeyboardController.h"
|
||||
|
||||
static uint8_t packet_map[88] =
|
||||
{
|
||||
/*00 ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 */
|
||||
5, 11, 17, 23, 29, 35, 41, 47, 53, 59,
|
||||
|
||||
/*10 F10 F11 F12 PRT SLK PBK ` 1 2 3 */
|
||||
65, 71, 77, 83, 89, 95, 0, 6, 12, 18,
|
||||
|
||||
/*20 4 5 6 7 8 9 0 - = BSP */
|
||||
24, 30, 36, 42, 48, 54, 60, 66, 72, 78,
|
||||
|
||||
/*30 INS HME PUP TAB Q W E R T Y */
|
||||
84, 90, 96, 1, 7, 13, 19, 25, 31, 37,
|
||||
|
||||
/*40 U I O P [ ] \ DEL END PDN */
|
||||
43, 49, 55, 61, 67, 73, 79, 85, 91, 97,
|
||||
|
||||
/*50 CAP A S D F G H J K L */
|
||||
2, 8, 14, 20, 26, 32, 38, 44, 50, 56,
|
||||
|
||||
/*60 ; ' ENT LSH Z X C V B N */
|
||||
62, 68, 80, 3, 15, 21, 27, 33, 39, 45,
|
||||
|
||||
/*70 M , . / RSH UP LCTL LWIN LALT SPC */
|
||||
51, 57, 63, 69, 81, 93, 4, 10, 16, 34,
|
||||
|
||||
/*80 RALT RFNC MENU RCTL LFT DWN RGT */
|
||||
52, 58, 64, 76, 88, 94, 100
|
||||
|
||||
/* Missing Indexes 9, 22, 28, 40, 46, 70, 74, 75, 82, 86, 87, 92, 98, 99, 101 */
|
||||
};
|
||||
|
||||
DarkProjectKeyboardController::DarkProjectKeyboardController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
DarkProjectKeyboardController::~DarkProjectKeyboardController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string DarkProjectKeyboardController::GetDeviceName()
|
||||
{
|
||||
const int szTemp = HID_MAX_STR;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
std::string name = std::string(wName.begin(), wName.end());
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string DarkProjectKeyboardController::GetSerial()
|
||||
{
|
||||
const int szTemp = HID_MAX_STR;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_serial_number_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
std::string serial = std::string(wName.begin(), wName.end());
|
||||
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string DarkProjectKeyboardController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void DarkProjectKeyboardController::SetLedsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
uint8_t RGbuffer[DARKPROJECTKEYBOARD_PACKET_SIZE] = { 0x08, 0x07, 0x00, 0x00, 0x00 };
|
||||
uint8_t BAbuffer[DARKPROJECTKEYBOARD_PACKET_SIZE] = { 0x08, 0x07, 0x00, 0x01, 0x00 };
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
| packet_map is the index of the Key from full_matrix_map and |
|
||||
| the value is the position in the direct packet buffer |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for(size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
RGBColor key = colors[i];
|
||||
uint16_t offset = packet_map[i];
|
||||
|
||||
RGbuffer[DARKPROJECTKEYBOARD_RED_BLUE_BYTE + offset] = RGBGetRValue(key);
|
||||
RGbuffer[DARKPROJECTKEYBOARD_GREEN_BYTE + offset] = RGBGetGValue(key);
|
||||
BAbuffer[DARKPROJECTKEYBOARD_RED_BLUE_BYTE + offset] = RGBGetBValue(key);
|
||||
}
|
||||
|
||||
hid_write(dev, RGbuffer, DARKPROJECTKEYBOARD_PACKET_SIZE);
|
||||
hid_write(dev, BAbuffer, DARKPROJECTKEYBOARD_PACKET_SIZE);
|
||||
}
|
||||
|
||||
49
Controllers/DarkProject/DarkProjectKeyboardController.h
Normal file
49
Controllers/DarkProject/DarkProjectKeyboardController.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| DarkProjectKeyboardController.h |
|
||||
| |
|
||||
| Driver for DarkProjectKeyboard USB Controller |
|
||||
| |
|
||||
| Chris M (DrNo) 8 Apr 2022 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
#define NA 0xFFFFFFFF
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
#define DARKPROJECTKEYBOARD_PACKET_SIZE 256
|
||||
#define DARKPROKECTKEYBOARD_TKL_KEYCOUNT 87
|
||||
|
||||
enum
|
||||
{
|
||||
DARKPROJECTKEYBOARD_MODE_DIRECT = 0x01, //Direct Led Control - Independently set LEDs in zone
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DARKPROJECTKEYBOARD_REPORT_BYTE = 1,
|
||||
DARKPROJECTKEYBOARD_COMMAND_BYTE = 2,
|
||||
DARKPROJECTKEYBOARD_RED_BLUE_BYTE = 5,
|
||||
DARKPROJECTKEYBOARD_GREEN_BYTE = 107
|
||||
};
|
||||
|
||||
class DarkProjectKeyboardController
|
||||
{
|
||||
public:
|
||||
DarkProjectKeyboardController(hid_device* dev_handle, const char* path);
|
||||
~DarkProjectKeyboardController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
void SetLedsDirect(std::vector<RGBColor> colors);
|
||||
private:
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
};
|
||||
239
Controllers/DarkProject/RGBController_DarkProjectKeyboard.cpp
Normal file
239
Controllers/DarkProject/RGBController_DarkProjectKeyboard.cpp
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_DarkProjectKeyboard.cpp |
|
||||
| |
|
||||
| Driver for DarkProjectKeyboard USB Controller |
|
||||
| |
|
||||
| Chris M (DrNo) 8 Apr 2022 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "RGBController_DarkProjectKeyboard.h"
|
||||
|
||||
static unsigned int matrix_map[6][18] =
|
||||
{
|
||||
{ 0, NA, 1, 2, 3, 4, 5, 6, 7, 8, NA, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, NA, 30, 31, 32 },
|
||||
{ 33, NA, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 },
|
||||
{ 50, NA, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, NA, 62, NA, NA, NA },
|
||||
{ 63, NA, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, NA, 74, NA, NA, 75, NA },
|
||||
{ 76, 77, 78, NA, NA, NA, 79, NA, NA, NA, 80, 81, NA, 82, 83, 84, 85, 86 }
|
||||
};
|
||||
|
||||
static const char *led_names[] =
|
||||
{
|
||||
KEY_EN_ESCAPE, //00
|
||||
KEY_EN_F1,
|
||||
KEY_EN_F2,
|
||||
KEY_EN_F3,
|
||||
KEY_EN_F4,
|
||||
KEY_EN_F5,
|
||||
KEY_EN_F6,
|
||||
KEY_EN_F7,
|
||||
KEY_EN_F8,
|
||||
KEY_EN_F9,
|
||||
KEY_EN_F10, //10
|
||||
KEY_EN_F11,
|
||||
KEY_EN_F12,
|
||||
KEY_EN_PRINT_SCREEN,
|
||||
KEY_EN_SCROLL_LOCK,
|
||||
KEY_EN_PAUSE_BREAK,
|
||||
|
||||
KEY_EN_BACK_TICK,
|
||||
KEY_EN_1,
|
||||
KEY_EN_2,
|
||||
KEY_EN_3,
|
||||
KEY_EN_4, //20
|
||||
KEY_EN_5,
|
||||
KEY_EN_6,
|
||||
KEY_EN_7,
|
||||
KEY_EN_8,
|
||||
KEY_EN_9,
|
||||
KEY_EN_0,
|
||||
KEY_EN_MINUS,
|
||||
KEY_EN_EQUALS,
|
||||
KEY_EN_BACKSPACE,
|
||||
KEY_EN_INSERT, //30
|
||||
KEY_EN_HOME,
|
||||
KEY_EN_PAGE_UP,
|
||||
|
||||
KEY_EN_TAB,
|
||||
KEY_EN_Q,
|
||||
KEY_EN_W,
|
||||
KEY_EN_E,
|
||||
KEY_EN_R,
|
||||
KEY_EN_T,
|
||||
KEY_EN_Y,
|
||||
KEY_EN_U, //40
|
||||
KEY_EN_I,
|
||||
KEY_EN_O,
|
||||
KEY_EN_P,
|
||||
KEY_EN_LEFT_BRACKET,
|
||||
KEY_EN_RIGHT_BRACKET,
|
||||
KEY_EN_ANSI_BACK_SLASH,
|
||||
KEY_EN_DELETE,
|
||||
KEY_EN_END,
|
||||
KEY_EN_PAGE_DOWN,
|
||||
|
||||
KEY_EN_CAPS_LOCK, //50
|
||||
KEY_EN_A,
|
||||
KEY_EN_S,
|
||||
KEY_EN_D,
|
||||
KEY_EN_F,
|
||||
KEY_EN_G,
|
||||
KEY_EN_H,
|
||||
KEY_EN_J,
|
||||
KEY_EN_K,
|
||||
KEY_EN_L,
|
||||
KEY_EN_SEMICOLON, //60
|
||||
KEY_EN_QUOTE,
|
||||
KEY_EN_ANSI_ENTER,
|
||||
|
||||
KEY_EN_LEFT_SHIFT,
|
||||
KEY_EN_Z,
|
||||
KEY_EN_X,
|
||||
KEY_EN_C,
|
||||
KEY_EN_V,
|
||||
KEY_EN_B,
|
||||
KEY_EN_N,
|
||||
KEY_EN_M, //70
|
||||
KEY_EN_COMMA,
|
||||
KEY_EN_PERIOD,
|
||||
KEY_EN_FORWARD_SLASH,
|
||||
KEY_EN_RIGHT_SHIFT,
|
||||
KEY_EN_UP_ARROW,
|
||||
|
||||
KEY_EN_LEFT_CONTROL,
|
||||
KEY_EN_LEFT_WINDOWS,
|
||||
KEY_EN_LEFT_ALT,
|
||||
KEY_EN_SPACE,
|
||||
KEY_EN_RIGHT_ALT, //80
|
||||
KEY_EN_RIGHT_FUNCTION,
|
||||
KEY_EN_MENU,
|
||||
KEY_EN_RIGHT_CONTROL,
|
||||
KEY_EN_LEFT_ARROW,
|
||||
KEY_EN_DOWN_ARROW,
|
||||
KEY_EN_RIGHT_ARROW
|
||||
};
|
||||
|
||||
/**
|
||||
@name Dark Project Keyboard
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :x:
|
||||
@detectors DetectDarkProjectKeyboardControllers
|
||||
@comment The Dark Project keyboard controller currently supports
|
||||
the full size KD3B Version 2 (ANSI layout).
|
||||
*/
|
||||
|
||||
RGBController_DarkProjectKeyboard::RGBController_DarkProjectKeyboard(DarkProjectKeyboardController *controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Dark Project Keyboard";
|
||||
vendor = "Dark Project";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = controller->GetDeviceName();
|
||||
serial = controller->GetSerial();
|
||||
location = controller->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = DARKPROJECTKEYBOARD_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_DarkProjectKeyboard::~RGBController_DarkProjectKeyboard()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_DarkProjectKeyboard::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Create the Keyboard zone and add the matix map |
|
||||
\*-------------------------------------------------*/
|
||||
zone KB_zone;
|
||||
KB_zone.name = "Keyboard Zone";
|
||||
KB_zone.type = ZONE_TYPE_MATRIX;
|
||||
KB_zone.leds_min = DARKPROKECTKEYBOARD_TKL_KEYCOUNT;
|
||||
KB_zone.leds_max = DARKPROKECTKEYBOARD_TKL_KEYCOUNT;
|
||||
KB_zone.leds_count = DARKPROKECTKEYBOARD_TKL_KEYCOUNT;
|
||||
|
||||
KB_zone.matrix_map = new matrix_map_type;
|
||||
KB_zone.matrix_map->height = 6;
|
||||
KB_zone.matrix_map->width = 18;
|
||||
KB_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
zones.push_back(KB_zone);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
for(unsigned int led_index = 0; led_index < zones[zone_index].leds_count; led_index++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_index];
|
||||
new_led.value = led_index;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_DarkProjectKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
|
||||
void RGBController_DarkProjectKeyboard::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLedsDirect(colors);
|
||||
}
|
||||
|
||||
void RGBController_DarkProjectKeyboard::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
std::vector<RGBColor> colour;
|
||||
for(size_t i = 0; i < zones[zone].leds_count; i++)
|
||||
{
|
||||
colour.push_back(zones[zone].colors[i]);
|
||||
}
|
||||
|
||||
controller->SetLedsDirect(colour);
|
||||
}
|
||||
|
||||
void RGBController_DarkProjectKeyboard::UpdateSingleLED(int led)
|
||||
{
|
||||
std::vector<RGBColor> colour;
|
||||
colour.push_back(colors[led]);
|
||||
|
||||
controller->SetLedsDirect(colour);
|
||||
}
|
||||
|
||||
void RGBController_DarkProjectKeyboard::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_DarkProjectKeyboard::DeviceUpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device only supports `Direct` mode |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
34
Controllers/DarkProject/RGBController_DarkProjectKeyboard.h
Normal file
34
Controllers/DarkProject/RGBController_DarkProjectKeyboard.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_DarkProjectKeyboard.h |
|
||||
| |
|
||||
| Driver for DarkProjectKeyboard USB Controller |
|
||||
| |
|
||||
| Chris M (DrNo) 8 Apr 2022 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "DarkProjectKeyboardController.h"
|
||||
#include <vector>
|
||||
|
||||
class RGBController_DarkProjectKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_DarkProjectKeyboard(DarkProjectKeyboardController* controller_ptr);
|
||||
~RGBController_DarkProjectKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
DarkProjectKeyboardController* controller;
|
||||
};
|
||||
|
|
@ -303,6 +303,8 @@ HEADERS +=
|
|||
Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.h \
|
||||
Controllers/CrucialController/CrucialController.h \
|
||||
Controllers/CrucialController/RGBController_Crucial.h \
|
||||
Controllers/DarkProject/DarkProjectKeyboardController.h \
|
||||
Controllers/DarkProject/RGBController_DarkProjectKeyboard.h \
|
||||
Controllers/DasKeyboardController/DasKeyboardController.h \
|
||||
Controllers/DasKeyboardController/RGBController_DasKeyboard.h \
|
||||
Controllers/DuckyKeyboardController/DuckyKeyboardController.h \
|
||||
|
|
@ -732,6 +734,9 @@ SOURCES +=
|
|||
Controllers/CrucialController/CrucialControllerDetect.cpp \
|
||||
Controllers/CrucialController/RGBController_Crucial.cpp \
|
||||
Controllers/DebugController/DebugControllerDetect.cpp \
|
||||
Controllers/DarkProject/DarkProjectControllerDetect.cpp \
|
||||
Controllers/DarkProject/DarkProjectKeyboardController.cpp \
|
||||
Controllers/DarkProject/RGBController_DarkProjectKeyboard.cpp \
|
||||
Controllers/DasKeyboardController/DasKeyboardController.cpp \
|
||||
Controllers/DasKeyboardController/DasKeyboardControllerDetect.cpp \
|
||||
Controllers/DasKeyboardController/RGBController_DasKeyboard.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue