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,126 @@
/*---------------------------------------------------------*\
| RGBController_Tecknet.cpp |
| |
| RGBController for Tecknet devices |
| |
| Chris M (Dr_No) 29 Jul 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_Tecknet.h"
/**------------------------------------------------------------------*\
@name Tecknet Mouse
@category Mouse
@type USB
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectTecknetControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_Tecknet::RGBController_Tecknet(TecknetController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "Tecknet";
type = DEVICE_TYPE_MOUSE;
description = controller->GetDeviceName();
serial = controller->GetSerial();
location = controller->GetLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = TECKNET_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Direct.color_mode = MODE_COLORS_PER_LED;
Direct.speed_min = TECKNET_SPEED_OFF;
Direct.speed_max = TECKNET_SPEED_OFF;
Direct.speed = TECKNET_SPEED_OFF;
modes.push_back(Direct);
mode Off;
Off.name = "Off";
Off.value = TECKNET_MODE_OFF;
Off.color_mode = MODE_COLORS_NONE;
Off.speed_min = TECKNET_SPEED_OFF;
Off.speed_max = TECKNET_SPEED_OFF;
Off.speed = TECKNET_SPEED_OFF;
modes.push_back(Off);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = TECKNET_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.speed_min = TECKNET_SPEED_SLOW;
Breathing.speed_max = TECKNET_SPEED_FAST;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed = TECKNET_SPEED_NORMAL;
modes.push_back(Breathing);
SetupZones();
}
RGBController_Tecknet::~RGBController_Tecknet()
{
delete controller;
}
void RGBController_Tecknet::SetupZones()
{
zone Tecknet_zone;
Tecknet_zone.name = "Logo";
Tecknet_zone.type = ZONE_TYPE_SINGLE;
Tecknet_zone.leds_min = 1;
Tecknet_zone.leds_max = 1;
Tecknet_zone.leds_count = 1;
Tecknet_zone.matrix_map = NULL;
zones.push_back(Tecknet_zone);
led Tecknet_led;
Tecknet_led.name = "Logo";
leds.push_back(Tecknet_led);
SetupColors();
}
void RGBController_Tecknet::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| Not implemented for this device |
\*---------------------------------------------------------*/
}
void RGBController_Tecknet::DeviceUpdateLEDs()
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
controller->SetColor(red, grn, blu);
}
void RGBController_Tecknet::UpdateZoneLEDs(int zone)
{
RGBColor color = colors[zone];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
controller->SetColor(red, grn, blu);
}
void RGBController_Tecknet::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
void RGBController_Tecknet::DeviceUpdateMode()
{
//If active_mode is "Off" then set brightness to off otherwise high
unsigned char brightness = (active_mode == TECKNET_MODE_OFF) ? TECKNET_BRIGHTNESS_OFF : TECKNET_BRIGHTNESS_HIGH;
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, brightness);
}
@@ -0,0 +1,34 @@
/*---------------------------------------------------------*\
| RGBController_Tecknet.h |
| |
| RGBController for Tecknet devices |
| |
| Chris M (Dr_No) 29 Jul 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "TecknetController.h"
class RGBController_Tecknet : public RGBController
{
public:
RGBController_Tecknet(TecknetController* controller_ptr);
~RGBController_Tecknet();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
TecknetController* controller;
};
@@ -0,0 +1,114 @@
/*---------------------------------------------------------*\
| TecknetController.cpp |
| |
| Driver for Tecknet devices |
| |
| Chris M (Dr_No) 29 Jul 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "StringUtils.h"
#include "TecknetController.h"
static unsigned char tecknet_colour_mode_data[][16] =
{
{ 0x02, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00 }, // Direct
{ 0x02, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00 }, // Breathing
};
static unsigned char tecknet_speed_mode_data[][9] =
{
{ 0x00, 0x00, 0x00, 0x00 }, // Direct
{ 0x00, 0x06, 0x03, 0x01 }, // Breathing
};
TecknetController::TecknetController(hid_device* dev_handle, char *_path)
{
dev = dev_handle;
location = _path;
/*---------------------------------------------------------*\
| Get device name from HID manufacturer and product strings |
\*---------------------------------------------------------*/
wchar_t name_string[HID_MAX_STR];
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
device_name = StringUtils::wstring_to_string(name_string);
hid_get_product_string(dev, name_string, HID_MAX_STR);
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
current_mode = TECKNET_MODE_DIRECT;
current_speed = TECKNET_SPEED_NORMAL;
current_brightness = TECKNET_BRIGHTNESS_HIGH;
}
TecknetController::~TecknetController()
{
hid_close(dev);
}
std::string TecknetController::GetDeviceName()
{
return device_name;
}
std::string TecknetController::GetSerial()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
return(StringUtils::wstring_to_string(serial_string));
}
std::string TecknetController::GetLocation()
{
return("HID: " + location);
}
void TecknetController::SetMode(unsigned char mode, unsigned char speed, unsigned char brightness)
{
current_mode = mode;
current_speed = speed;
current_brightness = brightness;
SendUpdate();
}
void TecknetController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
//The Tecknet mouse expects inverted colours in sent packets
current_red = 255 - red;
current_green = 255 - green;
current_blue = 255 - blue;
SendUpdate();
}
void TecknetController::SendUpdate()
{
unsigned char buffer[TECKNET_PACKET_LENGTH] = { 0x00 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
for(std::size_t i = 0; i < TECKNET_COLOUR_MODE_DATA_SIZE; i++)
{
buffer[i] = tecknet_colour_mode_data[current_mode][i];
}
//Set the relevant colour info
buffer[TECKNET_RED_BYTE] = current_red;
buffer[TECKNET_GREEN_BYTE] = current_green;
buffer[TECKNET_BLUE_BYTE] = current_blue;
buffer[TECKNET_BRIGHTNESS_BYTE] = current_brightness;
buffer[TECKNET_SPEED_BYTE] = tecknet_speed_mode_data[current_mode][current_speed];
hid_send_feature_report(dev, buffer, buffer_size);
}
@@ -0,0 +1,81 @@
/*---------------------------------------------------------*\
| TecknetController.h |
| |
| Driver for Tecknet devices |
| |
| Chris M (Dr_No) 29 Jul 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
#define HID_MAX_STR 255
#define TECKNET_COLOUR_MODE_DATA_SIZE (sizeof(tecknet_colour_mode_data[0]) / sizeof(tecknet_colour_mode_data[0][0]))
#define TECKNET_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
#define TECKNET_PACKET_LENGTH 0x10 //16 bytes
enum
{
TECKNET_RED_BYTE = 2,
TECKNET_GREEN_BYTE = 3,
TECKNET_BLUE_BYTE = 4,
TECKNET_BRIGHTNESS_BYTE = 5,
TECKNET_SPEED_BYTE = 6
};
enum
{
TECKNET_MODE_OFF = 0xFF, //LEDs Off
TECKNET_MODE_DIRECT = 0x00, //Direct Mode
TECKNET_MODE_BREATHING = 0x01, //Breathing Mode
};
enum
{
TECKNET_BRIGHTNESS_OFF = 0x00,
TECKNET_BRIGHTNESS_LOW = 0x01,
TECKNET_BRIGHTNESS_MED = 0x02,
TECKNET_BRIGHTNESS_HIGH = 0x03
};
enum
{
TECKNET_SPEED_OFF = 0x00, // Breathe Off
TECKNET_SPEED_SLOW = 0x01, // Breathe Slow speed
TECKNET_SPEED_NORMAL = 0x02, // Breathe Normal speed
TECKNET_SPEED_FAST = 0x03, // Breathe Fast speed
};
class TecknetController
{
public:
TecknetController(hid_device *dev_handle, char *_path);
~TecknetController();
std::string GetDeviceName();
std::string GetSerial();
std::string GetLocation();
void SetMode(unsigned char mode, unsigned char speed, unsigned char brightness);
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
private:
std::string device_name;
std::string location;
hid_device* dev;
unsigned char current_mode;
unsigned char current_speed;
unsigned char current_brightness;
unsigned char current_red;
unsigned char current_green;
unsigned char current_blue;
void SendUpdate();
};
@@ -0,0 +1,47 @@
/*---------------------------------------------------------*\
| TecknetControllerDetect.cpp |
| |
| Detector for Tecknet devices |
| |
| Chris M (Dr_No) 29 Jul 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <hidapi.h>
#include "Detector.h"
#include "TecknetController.h"
#include "RGBController_Tecknet.h"
#define TECKNET_VID 0x04D9
#define TECKNET_M0008_PID 0xFC05
#define TECKNET_M0008_U 0x01 //Usage 01
#define TECKNET_M0008_UPG 0xFFA0 //Vendor Defined Usage Page
/******************************************************************************************\
* *
* DetectTecknetControllers *
* *
* Tests the USB address to see if any Tecknet Controllers. *
* *
\******************************************************************************************/
void DetectTecknetControllers(hid_device_info* info, const std::string&)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
TecknetController* controller = new TecknetController(dev, info->path);
RGBController_Tecknet* rgb_controller = new RGBController_Tecknet(controller);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
} /* DetectTecknetControllers) */
#ifdef USE_HID_USAGE
REGISTER_HID_DETECTOR_PU("Tecknet M008", DetectTecknetControllers, TECKNET_VID, TECKNET_M0008_PID, TECKNET_M0008_UPG, TECKNET_M0008_U);
#else
REGISTER_HID_DETECTOR_I("Tecknet M008", DetectTecknetControllers, TECKNET_VID, TECKNET_M0008_PID, 0);
#endif