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,135 @@
/*---------------------------------------------------------*\
| LuxaforController.cpp |
| |
| Driver for Luxafor devices |
| |
| Adam Honse (calcprogrammer1@gmail.com) 05 Sep 2024 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "LuxaforController.h"
#include "StringUtils.h"
LuxaforController::LuxaforController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
LuxaforController::~LuxaforController()
{
hid_close(dev);
}
std::string LuxaforController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string LuxaforController::GetNameString()
{
return(name);
}
std::string LuxaforController::GetSerialString()
{
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));
}
void LuxaforController::SendPacket(unsigned char mode, unsigned char led, unsigned char red, unsigned char grn, unsigned char blu, unsigned char type)
{
unsigned char usb_buf[9];
memset(usb_buf, 0, sizeof(usb_buf));
switch(mode)
{
/*-------------------------------------------------*\
| For Direct, Fade, and Strobe, the packet format: |
| 0: Report ID (Always 0) |
| 1: Mode (1: Direct, 2: Fade, 3: Strobe) |
| 2: LED Index |
| 3: Red |
| 4: Green |
| 5: Blue |
| 6: Changing Time (Fade) / Speed (Strobe) |
| 7: Unused |
| 8: Repeat (Strobe) |
\*-------------------------------------------------*/
case LUXAFOR_MODE_DIRECT:
case LUXAFOR_MODE_FADE:
case LUXAFOR_MODE_STROBE:
usb_buf[0] = 0x00;
usb_buf[1] = mode;
usb_buf[2] = led;
usb_buf[3] = red;
usb_buf[4] = grn;
usb_buf[5] = blu;
usb_buf[6] = 100;
usb_buf[7] = 0;
usb_buf[8] = (mode == LUXAFOR_MODE_STROBE) ? 255 : 0;
break;
/*-------------------------------------------------*\
| For Wave, the packet format: |
| 0: Report ID (Always 0) |
| 1: Mode (4: Wave) |
| 2: Wave Type (1-5) |
| 3: Red |
| 4: Green |
| 5: Blue |
| 6: Unused |
| 7: Repeat |
| 8: Speed |
\*-------------------------------------------------*/
case LUXAFOR_MODE_WAVE:
usb_buf[0] = 0x00;
usb_buf[1] = mode;
usb_buf[2] = type;
usb_buf[3] = red;
usb_buf[4] = grn;
usb_buf[5] = blu;
usb_buf[6] = 0;
usb_buf[7] = 255;
usb_buf[8] = 100;
break;
/*-------------------------------------------------*\
| For Pattern, the packet format: |
| 0: Report ID (Always 0) |
| 1: Mode (6: Pattern) |
| 2: Pattern Number (1-8) |
| 3: Repeat |
| 4: Unused |
| 5: Unused |
| 6: Unused |
| 7: Unused |
| 8: Unused |
\*-------------------------------------------------*/
case LUXAFOR_MODE_PATTERN:
usb_buf[0] = 0x00;
usb_buf[1] = mode;
usb_buf[2] = type;
usb_buf[3] = 255;
usb_buf[4] = 0;
usb_buf[5] = 0;
usb_buf[6] = 0;
usb_buf[7] = 0;
usb_buf[8] = 0;
break;
}
hid_write(dev, usb_buf, sizeof(usb_buf));
}
@@ -0,0 +1,60 @@
/*---------------------------------------------------------*\
| LuxaforController.h |
| |
| Driver for Luxafor devices |
| |
| Adam Honse (calcprogrammer1@gmail.com) 05 Sep 2024 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
enum
{
LUXAFOR_LED_FIRST = 1,
LUXAFOR_LED_ALL = 255,
};
enum
{
LUXAFOR_MODE_DIRECT = 1,
LUXAFOR_MODE_FADE = 2,
LUXAFOR_MODE_STROBE = 3,
LUXAFOR_MODE_WAVE = 4,
LUXAFOR_MODE_PATTERN = 6,
};
enum
{
LUXAFOR_PATTERN_TRAFFIC_LIGHTS = 1,
LUXAFOR_PATTERN_2 = 2,
LUXAFOR_PATTERN_3 = 3,
LUXAFOR_PATTERN_4 = 4,
LUXAFOR_PATTERN_POLICE = 5,
LUXAFOR_PATTERN_6 = 6,
LUXAFOR_PATTERN_7 = 7,
LUXAFOR_PATTERN_8 = 8,
};
class LuxaforController
{
public:
LuxaforController(hid_device* dev_handle, const char* path, std::string dev_name);
~LuxaforController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SendPacket(unsigned char mode, unsigned char led, unsigned char red, unsigned char grn, unsigned char blu, unsigned char type);
private:
hid_device* dev;
std::string location;
std::string name;
};
@@ -0,0 +1,39 @@
/*---------------------------------------------------------*\
| LuxaforControllerDetect.cpp |
| |
| Detector for Luxafor devices |
| |
| Adam Honse (calcprogrammer1@gmail.com) 05 Sep 2024 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "Detector.h"
#include "LuxaforController.h"
#include "RGBController_Luxafor.h"
/*---------------------------------------------------------*\
| Luxafor USB Vendor ID |
\*---------------------------------------------------------*/
#define LUXAFOR_VID 0x04D8
/*---------------------------------------------------------*\
| Luxafor USB Product ID |
\*---------------------------------------------------------*/
#define LUXAFOR_FLAG_PID 0xF372
void DetectLuxaforControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
LuxaforController* controller = new LuxaforController(dev, info->path, name);
RGBController_Luxafor* rgb_controller = new RGBController_Luxafor(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR( "Luxafor Flag", DetectLuxaforControllers, LUXAFOR_VID, LUXAFOR_FLAG_PID );
@@ -0,0 +1,239 @@
/*---------------------------------------------------------*\
| RGBController_Luxafor.cpp |
| |
| RGBController for Luxafor devices |
| |
| Adam Honse (calcprogrammer1@gmail.com) 05 Sep 2024 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_Luxafor.h"
RGBController_Luxafor::RGBController_Luxafor(LuxaforController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetNameString();
type = DEVICE_TYPE_ACCESSORY;
vendor = "Luxafor";
description = "Luxafor Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.value = LUXAFOR_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
// mode Fade;
// Fade.name = "Fade";
// Fade.value = LUXAFOR_MODE_FADE;
// Fade.flags = MODE_FLAG_HAS_PER_LED_COLOR;
// Fade.color_mode = MODE_COLORS_PER_LED;
// modes.push_back(Fade);
// mode Strobe;
// Strobe.name = "Strobe";
// Strobe.value = LUXAFOR_MODE_STROBE;
// Strobe.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
// Strobe.color_mode = MODE_COLORS_MODE_SPECIFIC;
// Strobe.colors_min = 1;
// Strobe.colors_max = 1;
// Strobe.colors.resize(1);
// modes.push_back(Strobe);
// mode Wave;
// Wave.name = "Wave";
// Wave.value = LUXAFOR_MODE_WAVE;
// Wave.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
// Wave.color_mode = MODE_COLORS_MODE_SPECIFIC;
// Wave.colors_min = 1;
// Wave.colors_max = 1;
// Wave.colors.resize(1);
// modes.push_back(Wave);
mode TrafficLights;
TrafficLights.name = "Traffic Lights";
TrafficLights.value = LUXAFOR_MODE_PATTERN_TRAFFIC_LIGHTS;
TrafficLights.flags = 0;
TrafficLights.color_mode = MODE_COLORS_NONE;
modes.push_back(TrafficLights);
mode Pattern2;
Pattern2.name = "Pattern 2";
Pattern2.value = LUXAFOR_MODE_PATTERN_2;
Pattern2.flags = 0;
Pattern2.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern2);
mode Pattern3;
Pattern3.name = "Pattern 3";
Pattern3.value = LUXAFOR_MODE_PATTERN_3;
Pattern3.flags = 0;
Pattern3.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern3);
mode Pattern4;
Pattern4.name = "Pattern 4";
Pattern4.value = LUXAFOR_MODE_PATTERN_4;
Pattern4.flags = 0;
Pattern4.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern4);
mode Police;
Police.name = "Police";
Police.value = LUXAFOR_MODE_PATTERN_POLICE;
Police.flags = 0;
Police.color_mode = MODE_COLORS_NONE;
modes.push_back(Police);
mode Pattern6;
Pattern6.name = "Pattern 6";
Pattern6.value = LUXAFOR_MODE_PATTERN_6;
Pattern6.flags = 0;
Pattern6.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern6);
mode Pattern7;
Pattern7.name = "Pattern 7";
Pattern7.value = LUXAFOR_MODE_PATTERN_7;
Pattern7.flags = 0;
Pattern7.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern7);
mode Pattern8;
Pattern8.name = "Pattern 8";
Pattern8.value = LUXAFOR_MODE_PATTERN_8;
Pattern8.flags = 0;
Pattern8.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern8);
SetupZones();
}
RGBController_Luxafor::~RGBController_Luxafor()
{
}
void RGBController_Luxafor::SetupZones()
{
/*-----------------------------------------------------*\
| The Luxafor Flag has 2 zones |
| * Flag (3 LEDs) |
| * Rear (3 LEDs) |
| The LED index starts at 1. Sending 255 for the LED ID |
| sets all LEDs at once. |
\*-----------------------------------------------------*/
unsigned int led_value = LUXAFOR_LED_FIRST;
zone flag_zone;
flag_zone.name = "Flag";
flag_zone.type = ZONE_TYPE_SINGLE;
flag_zone.leds_min = 3;
flag_zone.leds_max = 3;
flag_zone.leds_count = 3;
flag_zone.matrix_map = NULL;
zones.push_back(flag_zone);
for(std::size_t led_idx = 0; led_idx < flag_zone.leds_count; led_idx++)
{
led luxafor_led;
luxafor_led.name = "Flag LED";
luxafor_led.value = led_value;
leds.push_back(luxafor_led);
led_value++;
}
zone rear_zone;
rear_zone.name = "Rear";
rear_zone.type = ZONE_TYPE_SINGLE;
rear_zone.leds_min = 3;
rear_zone.leds_max = 3;
rear_zone.leds_count = 3;
rear_zone.matrix_map = NULL;
zones.push_back(rear_zone);
for(std::size_t led_idx = 0; led_idx < rear_zone.leds_count; led_idx++)
{
led luxafor_led;
luxafor_led.name = "Rear LED";
luxafor_led.value = led_value;
leds.push_back(luxafor_led);
led_value++;
}
SetupColors();
}
void RGBController_Luxafor::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*-----------------------------------------------------*\
| This device does not support resizing zones |
\*-----------------------------------------------------*/
}
void RGBController_Luxafor::DeviceUpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
UpdateZoneLEDs((int)zone_idx);
}
}
void RGBController_Luxafor::UpdateZoneLEDs(int zone)
{
for(unsigned int led_idx = 0; led_idx < zones[zone].leds_count; led_idx++)
{
UpdateSingleLED((int)(zones[zone].start_idx + led_idx));
}
}
void RGBController_Luxafor::UpdateSingleLED(int led)
{
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SendPacket((modes[active_mode].value & 0xFF), leds[led].value, red, grn, blu, 0);
}
}
void RGBController_Luxafor::DeviceUpdateMode()
{
switch(modes[active_mode].color_mode)
{
case MODE_COLORS_PER_LED:
DeviceUpdateLEDs();
break;
case MODE_COLORS_MODE_SPECIFIC:
{
unsigned char red = RGBGetRValue(colors[modes[active_mode].colors[0]]);
unsigned char grn = RGBGetGValue(colors[modes[active_mode].colors[0]]);
unsigned char blu = RGBGetBValue(colors[modes[active_mode].colors[0]]);
controller->SendPacket((modes[active_mode].value & 0xFF), LUXAFOR_LED_ALL, red, grn, blu, 0);
}
break;
case MODE_COLORS_NONE:
controller->SendPacket((modes[active_mode].value & 0xFF), LUXAFOR_LED_ALL, 0, 0, 0, (modes[active_mode].value >> 8));
break;
}
}
void RGBController_Luxafor::DeviceSaveMode()
{
/*-----------------------------------------------------*\
| This device does not support saving |
\*-----------------------------------------------------*/
}
@@ -0,0 +1,52 @@
/*---------------------------------------------------------*\
| RGBController_Luxafor.h |
| |
| RGBController for Luxafor devices |
| |
| Adam Honse (calcprogrammer1@gmail.com) 05 Sep 2024 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "LuxaforController.h"
#include "RGBController.h"
/*---------------------------------------------------------*\
| Additional "pseudo-modes" which combine pattern mode with |
| the pattern to use. |
\*---------------------------------------------------------*/
enum
{
LUXAFOR_MODE_PATTERN_TRAFFIC_LIGHTS = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_TRAFFIC_LIGHTS << 8),
LUXAFOR_MODE_PATTERN_2 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_2 << 8),
LUXAFOR_MODE_PATTERN_3 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_3 << 8),
LUXAFOR_MODE_PATTERN_4 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_4 << 8),
LUXAFOR_MODE_PATTERN_POLICE = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_POLICE << 8),
LUXAFOR_MODE_PATTERN_6 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_6 << 8),
LUXAFOR_MODE_PATTERN_7 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_7 << 8),
LUXAFOR_MODE_PATTERN_8 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_8 << 8),
};
class RGBController_Luxafor : public RGBController
{
public:
RGBController_Luxafor(LuxaforController* controller_ptr);
~RGBController_Luxafor();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();
private:
LuxaforController* controller;
};