Skip to content

Commit 7a939c8

Browse files
moooorgCalcProgrammer1
authored andcommitted
Add support for Asus monitors. Closes #4174
1 parent 51a014f commit 7a939c8

5 files changed

Lines changed: 321 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*---------------------------------------------------------*\
2+
| AsusMonitorController.cpp |
3+
| |
4+
| Driver for Asus monitors |
5+
| |
6+
| Morgan Guimard (morg) 19 oct 2025 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-or-later |
10+
\*---------------------------------------------------------*/
11+
12+
#include <string.h>
13+
#include "AsusMonitorController.h"
14+
#include "StringUtils.h"
15+
16+
AsusMonitorController::AsusMonitorController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
17+
{
18+
dev = dev_handle;
19+
location = info.path;
20+
name = dev_name;
21+
}
22+
23+
AsusMonitorController::~AsusMonitorController()
24+
{
25+
hid_close(dev);
26+
}
27+
28+
std::string AsusMonitorController::GetDeviceLocation()
29+
{
30+
return("HID: " + location);
31+
}
32+
33+
std::string AsusMonitorController::GetNameString()
34+
{
35+
return(name);
36+
}
37+
38+
std::string AsusMonitorController::GetSerialString()
39+
{
40+
wchar_t serial_string[128];
41+
int ret = hid_get_serial_number_string(dev, serial_string, 128);
42+
43+
if(ret != 0)
44+
{
45+
return("");
46+
}
47+
48+
return(StringUtils::wstring_to_string(serial_string));
49+
}
50+
51+
unsigned int AsusMonitorController::GetNumberOfLEDs()
52+
{
53+
uint8_t usb_buf[ASUS_MONITOR_REPORT_SIZE];
54+
55+
memset(usb_buf, 0x00, sizeof(usb_buf));
56+
57+
usb_buf[0x00] = 0xEC;
58+
usb_buf[0x01] = 0xB0;
59+
60+
hid_write(dev, usb_buf, sizeof(usb_buf));
61+
62+
memset(usb_buf, 0x00, sizeof(usb_buf));
63+
64+
int bytes = hid_read(dev, usb_buf, sizeof(usb_buf));
65+
66+
return bytes > 0 ? usb_buf[32] : 0;
67+
}
68+
69+
void AsusMonitorController::SendInit()
70+
{
71+
uint8_t usb_buf[ASUS_MONITOR_REPORT_SIZE];
72+
73+
memset(usb_buf, 0x00, sizeof(usb_buf));
74+
75+
usb_buf[0x00] = 0xEC;
76+
usb_buf[0x01] = 0x35;
77+
usb_buf[0x05] = 0xFF;
78+
usb_buf[0x08] = 0x01;
79+
80+
hid_write(dev, usb_buf, sizeof(usb_buf));
81+
}
82+
83+
void AsusMonitorController::SetDirect(std::vector<RGBColor> colors)
84+
{
85+
uint8_t usb_buf[ASUS_MONITOR_REPORT_SIZE];
86+
87+
memset(usb_buf, 0x00, sizeof(usb_buf));
88+
89+
usb_buf[0x00] = 0xEC;
90+
usb_buf[0x01] = 0x40;
91+
usb_buf[0x02] = 0x84;
92+
usb_buf[0x04] = colors.size();
93+
94+
for(size_t i = 0; i < colors.size(); i++)
95+
{
96+
usb_buf[0x05 + (3 * i)] = RGBGetRValue(colors[i]);
97+
usb_buf[0x05 + (3 * i + 1)] = RGBGetGValue(colors[i]);
98+
usb_buf[0x05 + (3 * i + 2)] = RGBGetBValue(colors[i]);
99+
}
100+
101+
hid_write(dev, usb_buf, sizeof(usb_buf));
102+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*---------------------------------------------------------*\
2+
| AsusMonitorController.h |
3+
| |
4+
| Driver for Asus monitors |
5+
| |
6+
| Morgan Guimard (morg) 19 oct 2025 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-or-later |
10+
\*---------------------------------------------------------*/
11+
12+
#pragma once
13+
14+
#include <string>
15+
#include <hidapi.h>
16+
#include "RGBController.h"
17+
18+
#define ASUS_MONITOR_REPORT_SIZE 65
19+
20+
class AsusMonitorController
21+
{
22+
public:
23+
AsusMonitorController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
24+
~AsusMonitorController();
25+
26+
std::string GetDeviceLocation();
27+
std::string GetNameString();
28+
std::string GetSerialString();
29+
unsigned int GetNumberOfLEDs();
30+
void SetDirect(std::vector<RGBColor> colors);
31+
void SendInit();
32+
33+
protected:
34+
hid_device* dev;
35+
36+
private:
37+
std::string location;
38+
std::string name;
39+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*---------------------------------------------------------*\
2+
| AsusMonitorControllerDetect.cpp |
3+
| |
4+
| Detector for Asus monitors |
5+
| |
6+
| Morgan Guimard (morg) 19 oct 2025 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-or-later |
10+
\*---------------------------------------------------------*/
11+
12+
#include "Detector.h"
13+
#include "AsusMonitorController.h"
14+
#include "RGBController_AsusMonitor.h"
15+
16+
/*---------------------------------------------------------*\
17+
| Asus vendor ID |
18+
\*---------------------------------------------------------*/
19+
#define ASUS_VID 0x0B05
20+
21+
/*---------------------------------------------------------*\
22+
| Product ID |
23+
\*---------------------------------------------------------*/
24+
#define ASUS_ROG_STRIX_XG27AQDMG_PID 0x1BA3
25+
#define ASUS_ROG_SWIFT_XG27UCG_PID 0x1BB4
26+
#define ASUS_ROG_SWIFT_PG32UCDM_PID 0x1B2B
27+
28+
void DetectAsusMonitorControllers(hid_device_info* info, const std::string& name)
29+
{
30+
hid_device* dev = hid_open_path(info->path);
31+
32+
if(dev)
33+
{
34+
AsusMonitorController* controller = new AsusMonitorController(dev, *info, name);
35+
RGBController_AsusMonitor* rgb_controller = new RGBController_AsusMonitor(controller);
36+
37+
ResourceManager::get()->RegisterRGBController(rgb_controller);
38+
}
39+
}
40+
41+
REGISTER_HID_DETECTOR_IPU("Asus ROG STRIX XG27AQDMG", DetectAsusMonitorControllers, ASUS_VID, ASUS_ROG_STRIX_XG27AQDMG_PID, 1, 0xFF72, 0x00A1);
42+
REGISTER_HID_DETECTOR_IPU("Asus ROG STRIX XG27UCG", DetectAsusMonitorControllers, ASUS_VID, ASUS_ROG_SWIFT_XG27UCG_PID, 1, 0xFF72, 0x00A1);
43+
REGISTER_HID_DETECTOR_IPU("Asus ROG STRIX PG32UCDM", DetectAsusMonitorControllers, ASUS_VID, ASUS_ROG_SWIFT_PG32UCDM_PID, 1, 0xFF72, 0x00A1);
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*---------------------------------------------------------*\
2+
| RGBController_AsusMonitor.cpp |
3+
| |
4+
| RGBController for Asus monitors |
5+
| |
6+
| Morgan Guimard (morg) 19 oct 2025 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-or-later |
10+
\*---------------------------------------------------------*/
11+
12+
#include "RGBController_AsusMonitor.h"
13+
14+
/**------------------------------------------------------------------*\
15+
@name Asus monitors
16+
@category Monitor
17+
@type USB
18+
@save :x:
19+
@direct :white_check_mark:
20+
@effects :x:
21+
@detectors DetectAsusMonitorControllers
22+
@comment
23+
\*-------------------------------------------------------------------*/
24+
25+
RGBController_AsusMonitor::RGBController_AsusMonitor(AsusMonitorController* controller_ptr)
26+
{
27+
controller = controller_ptr;
28+
name = controller->GetNameString();
29+
vendor = "ASUS";
30+
type = DEVICE_TYPE_MONITOR;
31+
description = "ASUS monitor";
32+
location = controller->GetDeviceLocation();
33+
serial = controller->GetSerialString();
34+
number_of_leds = controller->GetNumberOfLEDs();
35+
36+
controller->SendInit();
37+
38+
mode Direct;
39+
Direct.name = "Direct";
40+
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
41+
Direct.color_mode = MODE_COLORS_PER_LED;
42+
modes.push_back(Direct);
43+
44+
SetupZones();
45+
}
46+
47+
RGBController_AsusMonitor::~RGBController_AsusMonitor()
48+
{
49+
delete controller;
50+
}
51+
52+
void RGBController_AsusMonitor::SetupZones()
53+
{
54+
zone new_zone;
55+
56+
new_zone.name = "Monitor";
57+
new_zone.type = ZONE_TYPE_LINEAR;
58+
59+
new_zone.leds_min = number_of_leds;
60+
new_zone.leds_max = number_of_leds;
61+
new_zone.leds_count = number_of_leds;
62+
63+
new_zone.matrix_map = nullptr;
64+
65+
zones.emplace_back(new_zone);
66+
67+
leds.resize(new_zone.leds_count);
68+
69+
for(unsigned int i = 0; i < number_of_leds; i++)
70+
{
71+
leds[i].name = "LED " + std::to_string(i);
72+
}
73+
74+
SetupColors();
75+
}
76+
77+
void RGBController_AsusMonitor::ResizeZone(int /*zone*/, int /*new_size*/)
78+
{
79+
/*---------------------------------------------------------*\
80+
| This device does not support resizing zones |
81+
\*---------------------------------------------------------*/
82+
}
83+
84+
void RGBController_AsusMonitor::DeviceUpdateLEDs()
85+
{
86+
controller->SetDirect(colors);
87+
}
88+
89+
void RGBController_AsusMonitor::UpdateZoneLEDs(int /*zone*/)
90+
{
91+
DeviceUpdateLEDs();
92+
}
93+
94+
void RGBController_AsusMonitor::UpdateSingleLED(int /*led*/)
95+
{
96+
DeviceUpdateLEDs();
97+
}
98+
99+
void RGBController_AsusMonitor::DeviceUpdateMode()
100+
{
101+
DeviceUpdateLEDs();
102+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*---------------------------------------------------------*\
2+
| RGBController_AsusMonitor.h |
3+
| |
4+
| RGBController for Asus monitors |
5+
| |
6+
| Morgan Guimard (morg) 19 oct 2025 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-or-later |
10+
\*---------------------------------------------------------*/
11+
12+
#pragma once
13+
14+
#include "RGBController.h"
15+
#include "AsusMonitorController.h"
16+
17+
class RGBController_AsusMonitor : public RGBController
18+
{
19+
public:
20+
RGBController_AsusMonitor(AsusMonitorController* controller_ptr);
21+
~RGBController_AsusMonitor();
22+
23+
void SetupZones();
24+
void ResizeZone(int zone, int new_size);
25+
26+
void DeviceUpdateLEDs();
27+
void UpdateZoneLEDs(int zone);
28+
void UpdateSingleLED(int led);
29+
30+
void DeviceUpdateMode();
31+
32+
private:
33+
AsusMonitorController* controller;
34+
unsigned int number_of_leds;
35+
};

0 commit comments

Comments
 (0)