Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,100 @@
/*---------------------------------------------------------*\
| DygmaRaiseController.cpp |
| |
| Driver for Dygma Raise keyboard |
| |
| Timo Schlegel (@eispalast) Dec 12 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "DygmaRaiseController.h"
using namespace std::chrono_literals;
static int val_char_len(int number)
{
if(number < 10)
{
return 1;
}
else if
(number < 100)
{
return 2;
}
else
{
return 3;
}
}
DygmaRaiseController::DygmaRaiseController()
{
}
DygmaRaiseController::~DygmaRaiseController()
{
serialport->serial_close();
delete serialport;
}
void DygmaRaiseController::Initialize(char* port)
{
port_name = port;
serialport = new serial_port(port_name.c_str(), DYGMA_RAISE_BAUD);
}
std::string DygmaRaiseController::GetDeviceLocation()
{
return("COM: " + port_name);
}
void DygmaRaiseController::SendDirect(std::vector<RGBColor>colors, size_t led_num)
{
char serial_buf[MAX_LEN];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(serial_buf,0x00,sizeof(serial_buf));
/*-----------------------------------------------------*\
| Set up led theme packet |
\*-----------------------------------------------------*/
snprintf(serial_buf, MAX_LEN, "led.theme");
int actual_length=9;
/*-----------------------------------------------------*\
| Fill packet with color values |
\*-----------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < led_num; led_idx++)
{
int r = RGBGetRValue(colors[led_idx]);
int g = RGBGetGValue(colors[led_idx]);
int b = RGBGetBValue(colors[led_idx]);
snprintf(serial_buf + actual_length, MAX_LEN - actual_length, " %d", r);
actual_length += val_char_len(r) + 1;
snprintf(serial_buf + actual_length, MAX_LEN - actual_length, " %d", g);
actual_length += val_char_len(g) + 1;
snprintf(serial_buf + actual_length, MAX_LEN - actual_length, " %d", b);
actual_length += val_char_len(b) + 1;
}
/*-----------------------------------------------------*\
| Add the final newline |
\*-----------------------------------------------------*/
snprintf(serial_buf + actual_length, MAX_LEN - actual_length, "\n");
actual_length++;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
serialport->serial_write(serial_buf, actual_length);
}
@@ -0,0 +1,38 @@
/*---------------------------------------------------------*\
| DygmaRaiseController.h |
| |
| Driver for Dygma Raise keyboard |
| |
| Timo Schlegel (@eispalast) Dec 12 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <vector>
#include "RGBController.h"
#include "serial_port.h"
#define DYGMA_RAISE_VID 0x1209
#define DYGMA_RAISE_PID 0x2201
#define DYGMA_RAISE_BAUD 115200
#define MAX_LEN (4*3*132+9) //max. 4 Bytes per led channel * 3 channels * 132 leds + codeword led.theme
class DygmaRaiseController
{
public:
DygmaRaiseController();
~DygmaRaiseController();
void Initialize(char* port);
std::string GetDeviceLocation();
void SendDirect(std::vector<RGBColor>colors, size_t led_num);
private:
std::string location;
std::string port_name;
serial_port * serialport = nullptr;
};
@@ -0,0 +1,52 @@
/*---------------------------------------------------------*\
| DygmaRaiseControllerDetect.cpp |
| |
| Detector for Dygma Raise keyboard |
| |
| Timo Schlegel (@eispalast) Dec 12 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "Detector.h"
#include "DygmaRaiseController.h"
#include "RGBController_DygmaRaise.h"
#include "find_usb_serial_port.h"
#include <vector>
#define DYGMA_RAISE_VID 0x1209
#define DYGMA_RAISE_PID 0x2201
/******************************************************************************************\
* *
* DetectDygmaRaiseControllers *
* *
* Tests the USB address to see if a DygmaRaise keyboard exists there. *
* Then opens a serial port to communicate with the KB *
* *
\******************************************************************************************/
void DetectDygmaRaiseControllers()
{
std::vector<std::string *> ports = find_usb_serial_port(DYGMA_RAISE_VID, DYGMA_RAISE_PID);
for(std::size_t i = 0; i < ports.size(); i++)
{
if(*ports[i] != "")
{
DygmaRaiseController* controller = new DygmaRaiseController();
controller->Initialize((char *)ports[i]->c_str());
RGBController_DygmaRaise* rgb_controller = new RGBController_DygmaRaise(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}
REGISTER_DETECTOR("Dygma Raise", DetectDygmaRaiseControllers);
/*---------------------------------------------------------------------------------------------------------*\
| Entries for dynamic UDEV rules |
| |
| DUMMY_DEVICE_DETECTOR("Dygma Raise", DetectDygmaRaiseControllers, 0x1209, 0x2201 ) |
\*---------------------------------------------------------------------------------------------------------*/
@@ -0,0 +1,257 @@
/*---------------------------------------------------------*\
| RGBController_DygmaRaise.cpp |
| |
| RGBController for Dygma Raise keyboard |
| |
| Timo Schlegel (@eispalast) Dec 12 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBControllerKeyNames.h"
#include "RGBController_DygmaRaise.h"
#define NA 0xFFFFFFFF
#define LED_REAL_COUNT ((6*14)+(12*14))
#define LED_COUNT (LED_REAL_COUNT - 121)
static unsigned int kb_matrix_map_ISO[6][14] =
{ { 0, 1, 2, 3, 4, 5, 6, 39, 38, 37, 36, 35, 34, 33 },
{ 7, 8, 9, 10, 11, 12, 47, 46, 45, 44, 43, 42, 41, 40 },
{ 13, 14, 15, 16, 17, 18, 54, 53, 52, 51, 50, 49, 48, NA },
{ 19, 20, 21, 22, 23, 24, 25, 60, 59, 58, 57, 56, 55, NA },
{ 26, 27, 28, NA, 29, 30, NA, 66, 65, NA, 64, 63, 62, 61 },
{ NA, NA, NA, NA, 31, 32, NA, 68, 67, NA, NA, NA, NA, NA } };
static unsigned int underglow_matrix[11][14] =
{ { 2, 3, 4, 5, 6, 7, NA, 38, 37, 36, 35, 34, 33, 32 },
{ 1, NA, NA, NA, NA, 8, NA, 39, NA, NA, NA, NA, NA, 31 },
{ 0, NA, NA, NA, NA, 9, NA, 40, NA, NA, NA, NA, NA, 30 },
{ 29, NA, NA, NA, NA, 10, NA, 41, NA, NA, NA, NA, NA, 61 },
{ 28, NA, NA, NA, NA, 11, NA, 42, NA, NA, NA, NA, NA, 60 },
{ 27, NA, NA, NA, NA, 12, NA, 43, NA, NA, NA, NA, NA, 59 },
{ 26, NA, NA, NA, NA, 13, NA, 44, NA, NA, NA, NA, NA, 58 },
{ 25, NA, NA, NA, NA, 14, NA, 45, NA, NA, NA, NA, NA, 57 },
{ 24, NA, NA, NA, NA, 15, NA, 46, NA, NA, NA, NA, NA, 56 },
{ 23, NA, NA, NA, NA, 16, NA, 47, NA, NA, NA, NA, NA, 55 },
{ 22, 21, 20, 19, 18, 17, NA, 48, 49, 50, 51, 52, 53, 54, } };
static const char* zone_names[] =
{
ZONE_EN_KEYBOARD,
"Underglow",
"Neuron",
};
static zone_type zone_types[] =
{
ZONE_TYPE_MATRIX,
ZONE_TYPE_MATRIX,
ZONE_TYPE_SINGLE,
};
static const unsigned int zone_sizes[] =
{
69,
62,
1,
};
static const char* led_names[] =
{
KEY_EN_ESCAPE,
KEY_EN_1,
KEY_EN_2,
KEY_EN_3,
KEY_EN_4,
KEY_EN_5,
KEY_EN_6,
KEY_EN_TAB,
KEY_EN_Q,
KEY_EN_W,
KEY_EN_E,
KEY_EN_R,
KEY_EN_T,
KEY_EN_CAPS_LOCK,
KEY_EN_A,
KEY_EN_S,
KEY_EN_D,
KEY_EN_F,
KEY_EN_G,
KEY_EN_LEFT_SHIFT,
KEY_EN_ISO_BACK_SLASH,
KEY_EN_Z,
KEY_EN_X,
KEY_EN_C,
KEY_EN_V,
KEY_EN_B,
KEY_EN_LEFT_CONTROL,
KEY_EN_LEFT_WINDOWS,
KEY_EN_LEFT_ALT,
"Key: T1",
"Key: T2",
"Key: T3",
"Key: T4",
KEY_EN_BACKSPACE,
KEY_EN_EQUALS,
KEY_EN_MINUS,
KEY_EN_0,
KEY_EN_9,
KEY_EN_8,
KEY_EN_7,
KEY_EN_ANSI_ENTER,
KEY_EN_RIGHT_BRACKET,
KEY_EN_LEFT_BRACKET,
KEY_EN_P,
KEY_EN_O,
KEY_EN_I,
KEY_EN_U,
KEY_EN_Y,
KEY_EN_POUND,
KEY_EN_QUOTE,
KEY_EN_SEMICOLON,
KEY_EN_L,
KEY_EN_K,
KEY_EN_J,
KEY_EN_H,
KEY_EN_RIGHT_SHIFT,
KEY_EN_FORWARD_SLASH,
KEY_EN_PERIOD,
KEY_EN_COMMA,
KEY_EN_M,
KEY_EN_N,
KEY_EN_RIGHT_CONTROL,
KEY_EN_RIGHT_WINDOWS,
KEY_EN_RIGHT_FUNCTION,
KEY_EN_RIGHT_ALT,
"Key: T6",
"Key: T5",
"Key: T8",
"Key: T7",
};
/**------------------------------------------------------------------*\
@name Dygma Raise Keyboard
@category Keyboard
@type Serial
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectDygmaRaiseControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_DygmaRaise::RGBController_DygmaRaise(DygmaRaiseController* controller_ptr)
{
controller = controller_ptr;
name = "Raise";
vendor = "Dygma";
type = DEVICE_TYPE_KEYBOARD;
description = "Dygma Raise Split Mech KB";
location = controller->GetDeviceLocation();
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_DygmaRaise::~RGBController_DygmaRaise()
{
delete controller;
}
void RGBController_DygmaRaise::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
for(size_t i=0; i<3; i++)
{
zone new_zone;
new_zone.name = zone_names[i];
new_zone.type = zone_types[i];
new_zone.leds_min = zone_sizes[i];
new_zone.leds_max = zone_sizes[i];
new_zone.leds_count = zone_sizes[i];
if(i==0)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 14;
new_zone.matrix_map->map = (unsigned int *)&kb_matrix_map_ISO;
}
else if(i==1)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 11;
new_zone.matrix_map->width = 14;
new_zone.matrix_map->map = (unsigned int *)&underglow_matrix;
}
zones.push_back(new_zone);
}
/*---------------------------------------------------------*\
| Set up keyboard LEDs |
\*---------------------------------------------------------*/
for(unsigned int led_idx = 0; led_idx < zone_sizes[0]; led_idx++)
{
led new_led;
new_led.name = led_names[led_idx];
leds.push_back(new_led);
}
/*---------------------------------------------------------*\
| Set up underglow LEDs |
\*---------------------------------------------------------*/
for(unsigned int led_idx = 0; led_idx < zone_sizes[1]; led_idx++)
{
led new_led;
new_led.name = "Underglow";
leds.push_back(new_led);
}
/*---------------------------------------------------------*\
| Set up Neuron LED |
\*---------------------------------------------------------*/
led new_led;
new_led.name = "Neuron";
leds.push_back(new_led);
SetupColors();
}
void RGBController_DygmaRaise::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_DygmaRaise::DeviceUpdateLEDs()
{
controller->SendDirect(colors,leds.size());
}
void RGBController_DygmaRaise::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_DygmaRaise::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_DygmaRaise::DeviceUpdateMode()
{
}
@@ -0,0 +1,34 @@
/*---------------------------------------------------------*\
| RGBController_DygmaRaise.h |
| |
| RGBController for Dygma Raise keyboard |
| |
| Timo Schlegel (@eispalast) Dec 12 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "DygmaRaiseController.h"
class RGBController_DygmaRaise : public RGBController
{
public:
RGBController_DygmaRaise(DygmaRaiseController* controller_ptr);
~RGBController_DygmaRaise();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
DygmaRaiseController* controller;
};