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,183 @@
/*---------------------------------------------------------*\
| AlienwareAW3423DWFController.cpp |
| |
| Driver for the Alienware AW3423DWF monitor |
| |
| Ferréol DUBOIS COLI (Fefe_du_973) 23 Jan 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <bitset>
#include <chrono>
#include <cstring>
#include <thread>
#include "AlienwareAW3423DWFController.h"
#include "StringUtils.h"
AlienwareAW3423DWFController::AlienwareAW3423DWFController(hid_device *dev_handle, const char *path) : dev(dev_handle), location(path){}
void AlienwareAW3423DWFController::SendControlPacket(const unsigned char *data, size_t length)
{
unsigned char buffer[256] = {0x00};
memcpy(buffer + 1, data, length);
hid_write(dev, buffer, length + 1);
}
std::vector<unsigned char> AlienwareAW3423DWFController::GetReportResponse()
{
uint8_t buffer[193];
memset(buffer, 0, 193);
hid_get_input_report(dev, buffer, 193);
return std::vector<unsigned char>(buffer + 1, buffer + 18);
}
void AlienwareAW3423DWFController::PerformLogin()
{
unsigned char init_packet[64] =
{
0x40, 0xE1, 0x01
};
SendControlPacket(init_packet, 4);
std::vector<unsigned char> response = GetReportResponse();
std::vector<unsigned char> key = GenerateKey(response);
unsigned char login_packet[192] = {0x00};
login_packet[0] = 0x40;
login_packet[1] = 0xE1;
login_packet[2] = 0x02;
memcpy(login_packet + 64, key.data(), key.size());
SendControlPacket(login_packet, 192);
}
void AlienwareAW3423DWFController::SendColor(unsigned char led_id, unsigned char r, unsigned char g, unsigned char b)
{
unsigned char led_id_2 = (led_id == 0x01) ? 0xf6 : (led_id == 0x02) ? 0xf5
: (led_id == 0x08) ? 0xff
: 0xfc;
PerformLogin();
unsigned char color_packet[192] = {0x00};
color_packet[0] = 0x40;
color_packet[1] = 0xC6;
color_packet[6] = 0x0A;
color_packet[8] = 0x6E;
color_packet[10] = 0x82;
color_packet[64] = 0x51;
color_packet[65] = 0x87;
color_packet[66] = 0xD0;
color_packet[67] = 0x04;
color_packet[68] = led_id;
color_packet[69] = r;
color_packet[70] = g;
color_packet[71] = b;
color_packet[72] = 0x64;
color_packet[73] = led_id_2;
SendControlPacket(color_packet, 192);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
std::vector<unsigned char> AlienwareAW3423DWFController::GenerateKey(
const std::vector<unsigned char> &response)
{
std::vector<unsigned char> syn_key(8, 0);
const std::vector<unsigned char> oem_key = {
0xf5, 0x3f, 0xc1, 0x39, 0x44, 0x3a, 0x31, 0x79, 0x0d, 0xb1, 0x82, 0x76
};
size_t sk_idx = 0, ok_idx = 0;
while(ok_idx < oem_key.size() && sk_idx < 8)
{
unsigned char ok_sub_len = (oem_key[ok_idx] & 1) + ((oem_key[ok_idx] & 0x10) >> 4);
for(unsigned int i = 0; i < ok_sub_len && sk_idx < 8; i++)
{
syn_key[sk_idx] = oem_key[ok_idx + 1] ^ oem_key[ok_idx];
ok_idx++;
sk_idx++;
}
ok_idx++;
}
std::vector<unsigned char> out_buffer;
uint16_t v15 = static_cast<uint16_t>(response[15]) |
(static_cast<uint16_t>(response[0]) << 8);
bool parity_odd = (std::bitset<16>(v15).count() % 2 != 0);
if(parity_odd)
{
size_t end = std::min<size_t>(8, response.size());
out_buffer = std::vector<unsigned char>(response.begin(), response.begin() + end);
if(response.size() > 14)
{
unsigned char idx = response[14] & 0x07;
if((idx + 8) < (unsigned char)response.size())
{
out_buffer[idx] ^= response[idx + 8];
}
}
}
else
{
size_t start = std::min<size_t>(8, response.size());
size_t end = std::min<size_t>(start + 8, response.size());
out_buffer = std::vector<unsigned char>(response.begin() + start, response.begin() + end);
if(response.size() > 6)
{
unsigned char idx = response[6] & 0x07;
if(idx < response.size())
{
out_buffer[idx] ^= response[idx];
}
}
}
for(size_t i = 0; i < 8 && i < out_buffer.size(); i++)
{
syn_key[i] ^= out_buffer[i];
}
return syn_key;
}
AlienwareAW3423DWFController::~AlienwareAW3423DWFController()
{
if(dev)
{
hid_close(dev);
dev = nullptr;
}
}
std::string AlienwareAW3423DWFController::GetLocation()
{
return "HID: " + location;
}
std::string AlienwareAW3423DWFController::GetSerialString()
{
wchar_t serial[256];
if(hid_get_serial_number_string(dev, serial, 256) >= 0)
{
std::wstring ws(serial);
return StringUtils::wstring_to_string(ws);
}
return "";
}
@@ -0,0 +1,38 @@
/*---------------------------------------------------------*\
| AlienwareAW3423DWFController.h |
| |
| Driver for the Alienware AW3423DWF monitor |
| |
| Ferréol DUBOIS COLI (Fefe_du_973) 23 Jan 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <hidapi.h>
#include <vector>
#include <string>
class AlienwareAW3423DWFController
{
public:
AlienwareAW3423DWFController(hid_device* dev_handle, const char* path);
~AlienwareAW3423DWFController();
std::string GetLocation();
std::string GetSerialString();
void SendColor(unsigned char led_id, unsigned char r, unsigned char g, unsigned char b);
private:
hid_device* dev;
std::string location;
static const std::vector<std::vector<unsigned char>> OEM_KEYS;
void PerformLogin();
std::vector<unsigned char> GenerateKey(const std::vector<unsigned char>& response);
void SendControlPacket(const unsigned char* data, size_t length);
std::vector<unsigned char> GetReportResponse();
};
@@ -0,0 +1,146 @@
/*---------------------------------------------------------*\
| AlienwareMonitorController.cpp |
| |
| Detector for Alienware monitors |
| |
| Adam Honse (CalcProgrammer1) 08 May 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <chrono>
#include <cstring>
#include <thread>
#include "AlienwareMonitorController.h"
AlienwareMonitorController::AlienwareMonitorController(hid_device *dev_handle, const char *path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
Initialize();
}
AlienwareMonitorController::~AlienwareMonitorController()
{
hid_close(dev);
}
std::string AlienwareMonitorController::GetLocation()
{
return("HID: " + location);
}
std::string AlienwareMonitorController::GetName()
{
return(name);
}
std::string AlienwareMonitorController::GetSerialString()
{
return("");
}
void fillInChecksum(unsigned char *packet)
{
unsigned char checksum = 110;
for(unsigned int index = 5; index <= 13; index++)
{
checksum ^= packet[index];
}
packet[14] = checksum;
}
void AlienwareMonitorController::SendColor(unsigned char led_id, unsigned char r, unsigned char g, unsigned char b)
{
unsigned char packet[65];
memset(packet, 0xFF, sizeof(packet));
packet[0] = 0x00;
packet[1] = 0x92;
packet[2] = 0x37;
packet[3] = 0x0a;
packet[4] = 0x00;
packet[5] = 0x51;
packet[6] = 0x87;
packet[7] = 0xd0;
packet[8] = 0x04;
packet[9] = led_id;
packet[10] = r;
packet[11] = g;
packet[12] = b;
packet[13] = 0x64;
fillInChecksum(packet);
hid_write(dev, packet, sizeof(packet));
/*-----------------------------------------------------*\
| Delay 50 milliseconds |
\*-----------------------------------------------------*/
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
void AlienwareMonitorController::Initialize()
{
unsigned char packet[65];
memset(packet, 0xFF, sizeof(packet));
packet[0] = 0x00;
packet[1] = 0x95;
packet[2] = 0x00;
packet[3] = 0x00;
packet[4] = 0x00;
hid_write(dev, packet, sizeof(packet));
/*-----------------------------------------------------*\
| Delay 50 milliseconds |
\*-----------------------------------------------------*/
std::this_thread::sleep_for(std::chrono::milliseconds(50));
memset(packet, 0xFF, sizeof(packet));
packet[0] = 0x00;
packet[1] = 0x92;
packet[2] = 0x37;
packet[3] = 0x08;
packet[4] = 0x00;
packet[5] = 0x51;
packet[6] = 0x85;
packet[7] = 0x01;
packet[8] = 0xFE;
packet[9] = 0x03;
packet[10] = 0x00;
packet[11] = 0x06;
packet[12] = 0x40;
hid_write(dev, packet, sizeof(packet));
/*-----------------------------------------------------*\
| Delay 50 milliseconds |
\*-----------------------------------------------------*/
std::this_thread::sleep_for(std::chrono::milliseconds(50));
memset(packet, 0x00, sizeof(packet));
packet[0] = 0x00;
packet[1] = 0x93;
packet[2] = 0x37;
packet[3] = 0x12;
hid_write(dev, packet, sizeof(packet));
/*-----------------------------------------------------*\
| Delay 50 milliseconds |
\*-----------------------------------------------------*/
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| AlienwareMonitorController.h |
| |
| Detector for Alienware monitors |
| |
| Adam Honse (CalcProgrammer1) 08 May 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <hidapi.h>
#include <vector>
#include <string>
class AlienwareMonitorController
{
public:
AlienwareMonitorController(hid_device* dev_handle, const char* path, std::string dev_name);
~AlienwareMonitorController();
std::string GetLocation();
std::string GetName();
std::string GetSerialString();
void SendColor(unsigned char led_id, unsigned char r, unsigned char g, unsigned char b);
private:
hid_device* dev;
std::string location;
std::string name;
void Initialize();
};
@@ -0,0 +1,66 @@
/*---------------------------------------------------------*\
| AlienwareMonitorControllerDetect.cpp |
| |
| Detector for Alienware monitors |
| |
| Adam Honse (CalcProgrammer1) 08 May 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "Detector.h"
#include "AlienwareAW3423DWFController.h"
#include "AlienwareMonitorController.h"
#include "RGBController_AlienwareAW3423DWF.h"
#include "RGBController_AlienwareMonitor.h"
#include <hidapi.h>
/*---------------------------------------------------------*\
| Alienware Vendor ID |
\*---------------------------------------------------------*/
#define ALIENWARE_VID 0x187C
/*---------------------------------------------------------*\
| Alienware Vendor ID |
\*---------------------------------------------------------*/
#define ALIENWARE_AW3423DWF_PID 0x100E
#define ALIENWARE_AW3225QF_PID 0x1013
#define ALIENWARE_USAGE_PAGE 0xFFDA
#define ALIENWARE_USAGE 0x00DA
/******************************************************************************************\
* *
* AlienwareAW3423DWFControllerDetect *
* *
* Tests the USB address to see if an Alienware AW3423DWF exists there. *
* *
\******************************************************************************************/
void DetectAlienwareAW3423DWFControllers(hid_device_info* info, const std::string&)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AlienwareAW3423DWFController* controller = new AlienwareAW3423DWFController(dev, info->path);
RGBController_AlienwareAW3423DWF* rgb_controller = new RGBController_AlienwareAW3423DWF(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectAlienwareMonitorControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AlienwareMonitorController* controller = new AlienwareMonitorController(dev, info->path, name);
RGBController_AlienwareMonitor* rgb_controller = new RGBController_AlienwareMonitor(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR("Alienware AW3423DWF", DetectAlienwareAW3423DWFControllers, ALIENWARE_VID, ALIENWARE_AW3423DWF_PID);
REGISTER_HID_DETECTOR("Alienware AW3225QF", DetectAlienwareMonitorControllers, ALIENWARE_VID, ALIENWARE_AW3225QF_PID);
@@ -0,0 +1,141 @@
/*---------------------------------------------------------*\
| RGBController_AlienwareAW3423DWF.cpp |
| |
| RGBController for the Alienware AW3423DWF monitor |
| |
| Ferréol DUBOIS COLI (Fefe_du_973) 23 Jan 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_AlienwareAW3423DWF.h"
/**------------------------------------------------------------------*\
@name AW3423DWF
@category Accessory
@type USB
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectAlienwareAW3423DWFControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_AlienwareAW3423DWF::RGBController_AlienwareAW3423DWF(AlienwareAW3423DWFController* controller_ptr)
{
controller = controller_ptr;
name = "Alienware AW3423DWF";
vendor = "Alienware";
type = DEVICE_TYPE_MONITOR;
description = "Alienware AW3423DWF Monitor Device";
location = controller->GetLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
active_mode = 0;
SetupZones();
}
RGBController_AlienwareAW3423DWF::~RGBController_AlienwareAW3423DWF()
{
delete controller;
}
void RGBController_AlienwareAW3423DWF::SetupZones()
{
zone Logo;
Logo.name = "Logo";
Logo.type = ZONE_TYPE_SINGLE;
Logo.leds_min = 1;
Logo.leds_max = 1;
Logo.leds_count = 1;
Logo.matrix_map = NULL;
zones.push_back(Logo);
led Logo_LED;
Logo_LED.name = "Logo";
Logo_LED.value = 0x01;
leds.push_back(Logo_LED);
zone Number;
Number.name = "Number";
Number.type = ZONE_TYPE_SINGLE;
Number.leds_min = 1;
Number.leds_max = 1;
Number.leds_count = 1;
Number.matrix_map = NULL;
zones.push_back(Number);
led Number_LED;
Number_LED.name = "Number";
Number_LED.value = 0x02;
leds.push_back(Number_LED);
zone PowerButton;
PowerButton.name = "Power Button";
PowerButton.type = ZONE_TYPE_SINGLE;
PowerButton.leds_min = 1;
PowerButton.leds_max = 1;
PowerButton.leds_count = 1;
PowerButton.matrix_map = NULL;
zones.push_back(PowerButton);
led PowerButton_LED;
PowerButton_LED.name = "Power Button";
PowerButton_LED.value = 0x08;
leds.push_back(PowerButton_LED);
SetupColors();
}
void RGBController_AlienwareAW3423DWF::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_AlienwareAW3423DWF::DeviceUpdateLEDs()
{
/*-----------------------------------------------------*\
| If all three colors are the same value, speed up the |
| direct mode by using the ALL target (0x0B) instead of |
| setting each LED individually. |
\*-----------------------------------------------------*/
if((colors[0] == colors[1]) && (colors[1] == colors[2]))
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
controller->SendColor(0x0B, red, grn, blu);
}
else
{
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
{
UpdateSingleLED(led_idx);
}
}
}
void RGBController_AlienwareAW3423DWF::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AlienwareAW3423DWF::UpdateSingleLED(int led)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SendColor(leds[led].value, red, grn, blu);
}
void RGBController_AlienwareAW3423DWF::DeviceUpdateMode()
{
}
@@ -0,0 +1,34 @@
/*---------------------------------------------------------*\
| RGBController_AlienwareAW3423DWF.h |
| |
| RGBController for the Alienware AW3423DWF monitor |
| |
| Ferréol DUBOIS COLI (Fefe_du_973) 23 Jan 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "AlienwareAW3423DWFController.h"
#include "RGBController.h"
class RGBController_AlienwareAW3423DWF : public RGBController
{
public:
explicit RGBController_AlienwareAW3423DWF(AlienwareAW3423DWFController* controller_ptr);
~RGBController_AlienwareAW3423DWF();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
AlienwareAW3423DWFController* controller;
};
@@ -0,0 +1,143 @@
/*---------------------------------------------------------*\
| RGBController_AlienwareMonitor.cpp |
| |
| RGBController for Alienware monitors |
| |
| Adam Honse (CalcProgrammer1) 08 May 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_AlienwareMonitor.h"
/**------------------------------------------------------------------*\
@name Alienware Monitor
@category Accessory
@type USB
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectAlienwareMonitorControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_AlienwareMonitor::RGBController_AlienwareMonitor(AlienwareMonitorController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetName();
description = "Alienware Monitor";
vendor = "Alienware";
type = DEVICE_TYPE_MONITOR;
location = controller->GetLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
active_mode = 0;
SetupZones();
}
RGBController_AlienwareMonitor::~RGBController_AlienwareMonitor()
{
delete controller;
}
void RGBController_AlienwareMonitor::SetupZones()
{
zone Logo;
Logo.name = "Logo";
Logo.type = ZONE_TYPE_SINGLE;
Logo.leds_min = 1;
Logo.leds_max = 1;
Logo.leds_count = 1;
Logo.matrix_map = NULL;
zones.push_back(Logo);
led Logo_LED;
Logo_LED.name = "Logo";
Logo_LED.value = 0x01;
leds.push_back(Logo_LED);
zone Number;
Number.name = "Number";
Number.type = ZONE_TYPE_SINGLE;
Number.leds_min = 1;
Number.leds_max = 1;
Number.leds_count = 1;
Number.matrix_map = NULL;
zones.push_back(Number);
led Number_LED;
Number_LED.name = "Number";
Number_LED.value = 0x02;
leds.push_back(Number_LED);
zone PowerButton;
PowerButton.name = "Power Button";
PowerButton.type = ZONE_TYPE_SINGLE;
PowerButton.leds_min = 1;
PowerButton.leds_max = 1;
PowerButton.leds_count = 1;
PowerButton.matrix_map = NULL;
zones.push_back(PowerButton);
led PowerButton_LED;
PowerButton_LED.name = "Power Button";
PowerButton_LED.value = 0x08;
leds.push_back(PowerButton_LED);
SetupColors();
}
void RGBController_AlienwareMonitor::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_AlienwareMonitor::DeviceUpdateLEDs()
{
/*-----------------------------------------------------*\
| If all three colors are the same value, speed up the |
| direct mode by using the ALL target (0x0B) instead of |
| setting each LED individually. |
\*-----------------------------------------------------*/
if((colors[0] == colors[1]) && (colors[1] == colors[2]))
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
controller->SendColor(0x0B, red, grn, blu);
}
else
{
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
{
UpdateSingleLED(led_idx);
}
}
}
void RGBController_AlienwareMonitor::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AlienwareMonitor::UpdateSingleLED(int led)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SendColor(leds[led].value, red, grn, blu);
}
void RGBController_AlienwareMonitor::DeviceUpdateMode()
{
}
@@ -0,0 +1,34 @@
/*---------------------------------------------------------*\
| RGBController_AlienwareMonitor.h |
| |
| RGBController for Alienware monitors |
| |
| Adam Honse (CalcProgrammer1) 08 May 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AlienwareMonitorController.h"
class RGBController_AlienwareMonitor : public RGBController
{
public:
RGBController_AlienwareMonitor(AlienwareMonitorController* controller_ptr);
~RGBController_AlienwareMonitor();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
AlienwareMonitorController* controller;
};