mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-09-16 07:07:12 -04:00
Split detector file for Alienware monitors and organize into folders
This commit is contained in:
1 parent
e971c619b1
commit
2147291c52
10 files changed
+47
-22
No files matched your search
+146
@@ -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));
|
||||
}
|
||||
+35
@@ -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();
|
||||
};
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| 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 <hidapi.h>
|
||||
#include "AlienwareMonitorController.h"
|
||||
#include "DetectionManager.h"
|
||||
#include "RGBController_AlienwareMonitor.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Alienware Vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ALIENWARE_VID 0x187C
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Alienware Vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ALIENWARE_AW3225QF_PID 0x1013
|
||||
#define ALIENWARE_USAGE_PAGE 0xFFDA
|
||||
#define ALIENWARE_USAGE 0x00DA
|
||||
|
||||
DetectedControllers DetectAlienwareMonitorControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
AlienwareMonitorController* controller = new AlienwareMonitorController(dev, info->path, name);
|
||||
RGBController_AlienwareMonitor* rgb_controller = new RGBController_AlienwareMonitor(controller);
|
||||
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR("Alienware AW3225QF", DetectAlienwareMonitorControllers, ALIENWARE_VID, ALIENWARE_AW3225QF_PID);
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| 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()
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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::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++)
|
||||
{
|
||||
DeviceUpdateSingleLED(led_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AlienwareMonitor::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AlienwareMonitor::DeviceUpdateSingleLED(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()
|
||||
{
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| 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 DeviceUpdateLEDs();
|
||||
void DeviceUpdateZoneLEDs(int zone);
|
||||
void DeviceUpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AlienwareMonitorController* controller;
|
||||
};
|
||||
Reference in new issue
Block a user