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,189 @@
/*---------------------------------------------------------*\
| RGBController_XG270QG.cpp |
| |
| RGBController for ViewSonic XG270QG |
| |
| Lanzaa 23 Jan 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string>
#include "RGBController_XG270QG.h"
/**------------------------------------------------------------------*\
@name Viewsonic Monitor
@category Accessory
@type USB
@save :x:
@direct :x:
@effects :white_check_mark:
@detectors DetectViewSonic
@comment
\*-------------------------------------------------------------------*/
RGBController_XG270QG::RGBController_XG270QG(VS_XG270QG_Controller* controller_ptr)
{
controller = controller_ptr;
name = controller->GetName();
vendor = "ViewSonic";
type = DEVICE_TYPE_MONITOR;
description = "ViewSonic Monitor Device";
location = controller->GetLocation();
serial = controller->GetSerial();
mode Off;
Off.name = "Off";
Off.value = VS_XG270QG_Controller::VS_MODE_OFF;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Custom;
Custom.name = "Custom";
Custom.value = VS_XG270QG_Controller::VS_MODE_STATIC;
Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Custom.colors_min = 1;
Custom.colors_max = 1;
Custom.color_mode = MODE_COLORS_PER_LED;
Custom.colors.resize(1);
modes.push_back(Custom);
mode Rainbow;
Rainbow.name = "Rainbow Wave";
Rainbow.value = VS_XG270QG_Controller::VS_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_AUTOMATIC_SAVE;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
mode Breath;
Breath.name = "Breathing";
Breath.value = VS_XG270QG_Controller::VS_MODE_BREATHING;
Breath.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Breath.colors_min = 1;
Breath.colors_max = 1;
Breath.color_mode = MODE_COLORS_PER_LED;
Breath.colors.resize(1);
modes.push_back(Breath);
mode Waterfall;
Waterfall.name = "Waterfall";
Waterfall.value = VS_XG270QG_Controller::VS_MODE_WATERFALL;
Waterfall.flags = MODE_FLAG_AUTOMATIC_SAVE;
Waterfall.color_mode = MODE_COLORS_NONE;
modes.push_back(Waterfall);
mode Elite;
Elite.name = "Elite";
Elite.value = VS_XG270QG_Controller::VS_MODE_ELITE;
Elite.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Elite.colors_min = 1;
Elite.colors_max = 1;
Elite.color_mode = MODE_COLORS_PER_LED;
Elite.colors.resize(1);
modes.push_back(Elite);
//mode Jazz;
//Jazz.name = "Jazz Wave (Audio Reactive)";
//Jazz.value = VS_MODE_JAZZ;
////Jazz.color_mode = MODE_COLORS_NONE; // might have color
//Jazz.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
//Jazz.colors_min = 1;
//Jazz.colors_max = 1;
//Jazz.color_mode = MODE_COLORS_MODE_SPECIFIC;
//Jazz.colors.resize(1);
//modes.push_back(Jazz);
//mode EliteGlobal;
//EliteGlobal.name = "Elite Global (Audio Reactive)";
//EliteGlobal.value = VS_MODE_ELITEGLOBAL;
//EliteGlobal.flags = MODE_FLAG_AUTOMATIC_SAVE;
//EliteGlobal.color_mode = MODE_COLORS_NONE;
//modes.push_back(EliteGlobal);
RGBController_XG270QG::SetupZones();
}
void RGBController_XG270QG::SetupZones()
{
zone base;
base.name = "Base";
base.type = ZONE_TYPE_SINGLE;
base.leds_min = 1;
base.leds_max = 1;
base.leds_count = 1;
base.matrix_map = NULL;
zones.push_back(base);
zone rear;
rear.name = "Rear";
rear.type = ZONE_TYPE_SINGLE;
rear.leds_min = 1;
rear.leds_max = 1;
rear.leds_count = 1;
rear.matrix_map = NULL;
zones.push_back(rear);
led d;
d.name = "Base";
d.value = 0x00;
leds.push_back(d);
led back;
back.name = "Rear";
back.value = 0x01;
leds.push_back(back);
SetupColors();
}
void RGBController_XG270QG::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_XG270QG::DeviceUpdateLEDs()
{
DeviceUpdateMode();
}
void RGBController_XG270QG::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_XG270QG::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_XG270QG::DeviceUpdateMode()
{
uint8_t r1 = 0;
uint8_t g1 = 0;
uint8_t b1 = 0;
uint8_t r2 = 0;
uint8_t g2 = 0;
uint8_t b2 = 0;
if(modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
{
r1 = r2 = RGBGetRValue(modes[active_mode].colors[0]);
g1 = g2 = RGBGetGValue(modes[active_mode].colors[0]);
b1 = b2 = RGBGetBValue(modes[active_mode].colors[0]);
}
else if (modes[active_mode].flags & MODE_FLAG_HAS_PER_LED_COLOR)
{
r1 = RGBGetRValue(colors[0]);
g1 = RGBGetGValue(colors[0]);
b1 = RGBGetBValue(colors[0]);
r2 = RGBGetRValue(colors[1]);
g2 = RGBGetGValue(colors[1]);
b2 = RGBGetBValue(colors[1]);
}
controller->SetMode(modes[active_mode].value, r1, g1, b1, modes[active_mode].value, r2, g2, b2);
}
@@ -0,0 +1,33 @@
/*---------------------------------------------------------*\
| RGBController_XG270QG.h |
| |
| RGBController for ViewSonic XG270QG |
| |
| Lanzaa 23 Jan 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "VS_XG270QG_Controller.h"
#include "RGBController.h"
class RGBController_XG270QG : public RGBController
{
public:
RGBController_XG270QG(VS_XG270QG_Controller* controller_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
VS_XG270QG_Controller* controller;
};
@@ -0,0 +1,100 @@
/*---------------------------------------------------------*\
| VS_XG270QG_Controller.cpp |
| |
| Driver for ViewSonic XG270QG |
| |
| Lanzaa 23 Jan 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "LogManager.h"
#include "StringUtils.h"
#include "VS_XG270QG_Controller.h"
VS_XG270QG_Controller::VS_XG270QG_Controller(hid_device* device, const char* path, std::string dev_name)
{
dev = device;
location = path;
name = dev_name;
}
VS_XG270QG_Controller::~VS_XG270QG_Controller()
{
hid_close(dev);
}
std::string VS_XG270QG_Controller::GetLocation()
{
return(location);
}
std::string VS_XG270QG_Controller::GetName()
{
return(name);
}
std::string VS_XG270QG_Controller::GetSerial()
{
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 VS_XG270QG_Controller::SetMode(uint8_t mode1, uint8_t r1, uint8_t g1, uint8_t b1, uint8_t mode2, uint8_t r2, uint8_t g2, uint8_t b2)
{
SendModeComplete(mode1, r1, g1, b1, mode2, r2, g2, b2);
}
void VS_XG270QG_Controller::SendModeComplete
(
uint8_t mode1, uint8_t r1, uint8_t g1, uint8_t b1,
uint8_t mode2, uint8_t r2, uint8_t g2, uint8_t b2
)
{
uint8_t data[] =
{
0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00,
0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
data[0x01] = mode1; // Downward facing LEDs
data[0x02] = r1;
data[0x03] = g1;
data[0x04] = b1;
data[0x05] = 0x00;
data[0x06] = 0x0A;
data[0x07] = 0x00;
data[0x08] = mode2; // Back facing LEDs
data[0x09] = r2;
data[0x0A] = g2;
data[0x0B] = b2;
data[0x0C] = 0x00;
data[0x0D] = 0x0A; // Might be speed related
// original data packets are 0x40=64 long
SendCommand(data, 0x20);
}
void VS_XG270QG_Controller::SendCommand(uint8_t *data, size_t length)
{
hid_send_feature_report(dev, data, length);
}
@@ -0,0 +1,58 @@
/*---------------------------------------------------------*\
| VS_XG270QG_Controller.h |
| |
| Driver for ViewSonic XG270QG |
| |
| Lanzaa 23 Jan 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <hidapi.h>
#include "RGBController.h"
class VS_XG270QG_Controller
{
public:
enum ModeValues
{
VS_MODE_OFF = 0x00,
VS_MODE_STATIC = 0x01,
VS_MODE_BREATHING = 0x02,
VS_MODE_RAINBOW = 0x07,
VS_MODE_ELITE = 0x0A,
VS_MODE_JAZZ = 0x0C,
VS_MODE_WATERFALL = 0x12,
VS_MODE_ELITEGLOBAL = 0x13,
};
VS_XG270QG_Controller(hid_device* device, const char* path, std::string dev_name);
~VS_XG270QG_Controller();
std::string GetLocation();
std::string GetName();
std::string GetSerial();
void SetMode(uint8_t mode1, uint8_t r1, uint8_t g1, uint8_t b1,
uint8_t mode2, uint8_t r2, uint8_t g2, uint8_t b2);
private:
hid_device* dev;
std::string location;
std::string name;
std::string serial;
std::string ReadVersion();
void SendModeComplete
(
uint8_t mode1, uint8_t r1, uint8_t g1, uint8_t b1,
uint8_t mode2, uint8_t r2, uint8_t g2, uint8_t b2
);
void SendCommand(uint8_t *config, size_t length);
};