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,85 @@
/*---------------------------------------------------------*\
| BlinkController.cpp |
| |
| Driver for ThingM Blink |
| |
| Eric S (edbgon) 01 Oct 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "BlinkController.h"
#include "StringUtils.h"
BlinkController::BlinkController(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));
}
BlinkController::~BlinkController()
{
if(dev)
{
hid_close(dev);
}
}
std::string BlinkController::GetDeviceName()
{
return device_name;
}
std::string BlinkController::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 BlinkController::GetLocation()
{
return("HID: " + location);
}
void BlinkController::SendUpdate(unsigned char led, unsigned char red, unsigned char green, unsigned char blue, unsigned int speed)
{
unsigned char buffer[BLINK_PACKET_SIZE] = { 0x00 };
memset(buffer, 0x00, BLINK_PACKET_SIZE);
buffer[0x00] = 0x01;
buffer[0x01] = 0x63;
buffer[0x02] = red;
buffer[0x03] = green;
buffer[0x04] = blue;
if(speed > 0)
{
buffer[0x05] = (speed & 0xff00) >> 8;
buffer[0x06] = speed & 0x00ff;
}
buffer[0x07] = led;
hid_send_feature_report(dev, buffer, BLINK_PACKET_SIZE);
}
@@ -0,0 +1,54 @@
/*---------------------------------------------------------*\
| BlinkController.h |
| |
| Driver for ThingM Blink |
| |
| Eric S (edbgon) 01 Oct 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <array>
#include <string>
#include <hidapi.h>
#define BLINK_PACKET_SIZE 9 //Includes extra first byte for non HID Report packets
#define BLINK_MODE_OFF 0
#define BLINK_MODE_DIRECT 1
#define BLINK_MODE_FADE 2
#define HID_MAX_STR 255
class BlinkController
{
public:
BlinkController(hid_device* dev_handle, char *_path);
~BlinkController();
std::string GetDeviceName();
std::string GetSerial();
std::string GetLocation();
unsigned char GetLedRed();
unsigned char GetLedGreen();
unsigned char GetLedBlue();
unsigned char GetLedSpeed();
unsigned char GetBrightness();
void SendUpdate(unsigned char led, unsigned char red, unsigned char green, unsigned char blue, unsigned int speed);
private:
std::string device_name;
std::string serial;
std::string location;
hid_device* dev;
unsigned char current_red;
unsigned char current_green;
unsigned char current_blue;
void SendUpdate();
};
@@ -0,0 +1,131 @@
/*---------------------------------------------------------*\
| RGBController_BlinkController.cpp |
| |
| RGBController for ThingM Blink |
| |
| Eric S (edbgon) 01 Oct 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_BlinkController.h"
/**------------------------------------------------------------------*\
@name ThingM Blink
@category LEDStrip
@type USB
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectThingMBlink
@comment
\*-------------------------------------------------------------------*/
RGBController_BlinkController::RGBController_BlinkController(BlinkController* controller_ptr)
{
controller = controller_ptr;
name = "Blink";
vendor = "ThingM";
type = DEVICE_TYPE_LEDSTRIP;
description = controller->GetDeviceName();
serial = controller->GetSerial();
location = controller->GetLocation();
mode Off;
Off.name = "Off";
Off.flags = 0;
Off.value = BLINK_MODE_OFF;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Direct;
Direct.name = "Direct";
Direct.value = BLINK_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
Direct.colors_min = 1;
Direct.colors_max = 1;
Direct.colors.resize(1);
modes.push_back(Direct);
mode Fade;
Fade.name = "Fade";
Fade.value = BLINK_MODE_FADE;
Fade.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED;
Fade.color_mode = MODE_COLORS_PER_LED;
Fade.speed_min = 0xFFFF;
Fade.speed = 0x0000;
Fade.speed_max = 0x0000;
Fade.colors_min = 1;
Fade.colors_max = 1;
Fade.colors.resize(1);
modes.push_back(Fade);
SetupZones();
active_mode = 1;
}
RGBController_BlinkController::~RGBController_BlinkController()
{
delete controller;
}
void RGBController_BlinkController::SetupZones()
{
zone Blink_zone;
Blink_zone.name = "blink(1) mk2";
Blink_zone.type = ZONE_TYPE_SINGLE;
Blink_zone.leds_min = 2;
Blink_zone.leds_max = 2;
Blink_zone.leds_count = 2;
Blink_zone.matrix_map = NULL;
zones.push_back(Blink_zone);
led Blink_led;
Blink_led.name = "LED A";
Blink_led.value = 1;
leds.push_back(Blink_led);
Blink_led.name = "LED B";
Blink_led.value = 2;
leds.push_back(Blink_led);
SetupColors();
}
void RGBController_BlinkController::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_BlinkController::DeviceUpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
UpdateSingleLED((int)led);
}
}
void RGBController_BlinkController::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_BlinkController::UpdateSingleLED(int led)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SendUpdate(leds[led].value, red, grn, blu, modes[active_mode].speed);
}
void RGBController_BlinkController::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}
@@ -0,0 +1,34 @@
/*---------------------------------------------------------*\
| RGBController_BlinkController.h |
| |
| RGBController for ThingM Blink |
| |
| Eric S (edbgon) 01 Oct 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "BlinkController.h"
class RGBController_BlinkController : public RGBController
{
public:
RGBController_BlinkController(BlinkController* controller_ptr);
~RGBController_BlinkController();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
BlinkController* controller;
};
@@ -0,0 +1,41 @@
/*---------------------------------------------------------*\
| ThingMControllerDetect.cpp |
| |
| Detector for ThingM Blink |
| |
| Eric S (edbgon) 01 Oct 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <hidapi.h>
#include "Detector.h"
#include "BlinkController.h"
#include "RGBController_BlinkController.h"
#define THINGM_VID 0x27B8
#define THINGM_BLINK_PID 0x01ED
/******************************************************************************************\
* *
* DetectThingMControllers *
* *
* Tests the USB address to see if any CoolerMaster controllers exists there. *
* *
\******************************************************************************************/
void DetectThingMBlink(hid_device_info* info, const std::string&)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
BlinkController* controller = new BlinkController(dev, info->path);
RGBController_BlinkController* rgb_controller = new RGBController_BlinkController(controller);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_PU("ThingM blink(1) mk2", DetectThingMBlink, THINGM_VID, THINGM_BLINK_PID, 0xFF00, 0x01);