mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2025-12-23 23:37:48 -05:00
Add support for Asus monitors. Closes #4174
This commit is contained in:
102
Controllers/AsusMonitorController/AsusMonitorController.cpp
Normal file
102
Controllers/AsusMonitorController/AsusMonitorController.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AsusMonitorController.cpp |
|
||||
| |
|
||||
| Driver for Asus monitors |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 oct 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
#include "AsusMonitorController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
AsusMonitorController::AsusMonitorController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
AsusMonitorController::~AsusMonitorController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string AsusMonitorController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string AsusMonitorController::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string AsusMonitorController::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));
|
||||
}
|
||||
|
||||
unsigned int AsusMonitorController::GetNumberOfLEDs()
|
||||
{
|
||||
uint8_t usb_buf[ASUS_MONITOR_REPORT_SIZE];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = 0xB0;
|
||||
|
||||
hid_write(dev, usb_buf, sizeof(usb_buf));
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
int bytes = hid_read(dev, usb_buf, sizeof(usb_buf));
|
||||
|
||||
return bytes > 0 ? usb_buf[32] : 0;
|
||||
}
|
||||
|
||||
void AsusMonitorController::SendInit()
|
||||
{
|
||||
uint8_t usb_buf[ASUS_MONITOR_REPORT_SIZE];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = 0x35;
|
||||
usb_buf[0x05] = 0xFF;
|
||||
usb_buf[0x08] = 0x01;
|
||||
|
||||
hid_write(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
void AsusMonitorController::SetDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
uint8_t usb_buf[ASUS_MONITOR_REPORT_SIZE];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = 0x40;
|
||||
usb_buf[0x02] = 0x84;
|
||||
usb_buf[0x04] = colors.size();
|
||||
|
||||
for(size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
usb_buf[0x05 + (3 * i)] = RGBGetRValue(colors[i]);
|
||||
usb_buf[0x05 + (3 * i + 1)] = RGBGetGValue(colors[i]);
|
||||
usb_buf[0x05 + (3 * i + 2)] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
39
Controllers/AsusMonitorController/AsusMonitorController.h
Normal file
39
Controllers/AsusMonitorController/AsusMonitorController.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AsusMonitorController.h |
|
||||
| |
|
||||
| Driver for Asus monitors |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 oct 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#define ASUS_MONITOR_REPORT_SIZE 65
|
||||
|
||||
class AsusMonitorController
|
||||
{
|
||||
public:
|
||||
AsusMonitorController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~AsusMonitorController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetNameString();
|
||||
std::string GetSerialString();
|
||||
unsigned int GetNumberOfLEDs();
|
||||
void SetDirect(std::vector<RGBColor> colors);
|
||||
void SendInit();
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
|
||||
private:
|
||||
std::string location;
|
||||
std::string name;
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AsusMonitorControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Asus monitors |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 oct 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "AsusMonitorController.h"
|
||||
#include "RGBController_AsusMonitor.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Asus vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ASUS_VID 0x0B05
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Product ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ASUS_ROG_STRIX_XG27AQDMG_PID 0x1BA3
|
||||
#define ASUS_ROG_SWIFT_XG27UCG_PID 0x1BB4
|
||||
#define ASUS_ROG_SWIFT_PG32UCDM_PID 0x1B2B
|
||||
|
||||
void DetectAsusMonitorControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
AsusMonitorController* controller = new AsusMonitorController(dev, *info, name);
|
||||
RGBController_AsusMonitor* rgb_controller = new RGBController_AsusMonitor(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Asus ROG STRIX XG27AQDMG", DetectAsusMonitorControllers, ASUS_VID, ASUS_ROG_STRIX_XG27AQDMG_PID, 1, 0xFF72, 0x00A1);
|
||||
REGISTER_HID_DETECTOR_IPU("Asus ROG STRIX XG27UCG", DetectAsusMonitorControllers, ASUS_VID, ASUS_ROG_SWIFT_XG27UCG_PID, 1, 0xFF72, 0x00A1);
|
||||
REGISTER_HID_DETECTOR_IPU("Asus ROG STRIX PG32UCDM", DetectAsusMonitorControllers, ASUS_VID, ASUS_ROG_SWIFT_PG32UCDM_PID, 1, 0xFF72, 0x00A1);
|
||||
102
Controllers/AsusMonitorController/RGBController_AsusMonitor.cpp
Normal file
102
Controllers/AsusMonitorController/RGBController_AsusMonitor.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AsusMonitor.cpp |
|
||||
| |
|
||||
| RGBController for Asus monitors |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 oct 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusMonitor.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Asus monitors
|
||||
@category Monitor
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :x:
|
||||
@detectors DetectAsusMonitorControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_AsusMonitor::RGBController_AsusMonitor(AsusMonitorController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
name = controller->GetNameString();
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_MONITOR;
|
||||
description = "ASUS monitor";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
number_of_leds = controller->GetNumberOfLEDs();
|
||||
|
||||
controller->SendInit();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AsusMonitor::~RGBController_AsusMonitor()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_AsusMonitor::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Monitor";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
|
||||
new_zone.leds_min = number_of_leds;
|
||||
new_zone.leds_max = number_of_leds;
|
||||
new_zone.leds_count = number_of_leds;
|
||||
|
||||
new_zone.matrix_map = nullptr;
|
||||
|
||||
zones.emplace_back(new_zone);
|
||||
|
||||
leds.resize(new_zone.leds_count);
|
||||
|
||||
for(unsigned int i = 0; i < number_of_leds; i++)
|
||||
{
|
||||
leds[i].name = "LED " + std::to_string(i);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AsusMonitor::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AsusMonitor::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetDirect(colors);
|
||||
}
|
||||
|
||||
void RGBController_AsusMonitor::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AsusMonitor::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AsusMonitor::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AsusMonitor.h |
|
||||
| |
|
||||
| RGBController for Asus monitors |
|
||||
| |
|
||||
| Morgan Guimard (morg) 19 oct 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusMonitorController.h"
|
||||
|
||||
class RGBController_AsusMonitor : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AsusMonitor(AsusMonitorController* controller_ptr);
|
||||
~RGBController_AsusMonitor();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AsusMonitorController* controller;
|
||||
unsigned int number_of_leds;
|
||||
};
|
||||
Reference in New Issue
Block a user