Compare commits

...
32 changed files with 958 additions and 197 deletions
@@ -44,6 +44,7 @@ static const gpu_pci_device device_list[] =
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1080TI_GAMING, 0x29, "ASUS ROG Strix GTX1080 Ti Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1080TI_11G_GAMING, 0x29, "ASUS ROG Strix GTX1080 Ti 11G Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1650S_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1650S_OC, 0x2A, "ASUS ROG Strix GTX 1650S OC 4G" },
{ NVIDIA_VEN, NVIDIA_GTX1660S_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1660S_O6G_GAMING, 0x2A, "ASUS ROG Strix GTX 1660S O6G Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1660TI_DEV, ASUS_SUB_VEN, ASUS_ROG_GTX1660TI_OC, 0x2A, "ASUS ROG GTX 1660 Ti OC 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060_TU106_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2060_EVO_GAMING, 0x2A, "ASUS ROG STRIX RTX 2060 EVO Gaming 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2060S_A8G_EVO_GAMING, 0x2A, "ASUS ROG STRIX RTX 2060S A8G EVO Gaming 8G"},
@@ -320,136 +320,28 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
void DetectLogitechKeyboardG915(hid_device_info* info, const std::string& name)
{
/*-------------------------------------------------------------------------------------------------*\
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
\*-------------------------------------------------------------------------------------------------*/
#ifdef USE_HID_USAGE
hid_device* dev_usage_0x0001 = nullptr;
hid_device* dev_usage_0x0002 = nullptr;
hid_device_info* info_temp = info;
while(info_temp)
{
if(info_temp->vendor_id == info->vendor_id // constant LOGITECH_VID
&& info_temp->product_id == info->product_id // NON-constant
&& info_temp->interface_number == info->interface_number // constant 2
&& info_temp->usage_page == info->usage_page) // constant 0xFF00
{
if(info_temp->usage == 0x0001)
{
dev_usage_0x0001 = hid_open_path(info_temp->path);
}
else if(info_temp->usage == 0x0002)
{
dev_usage_0x0002 = hid_open_path(info_temp->path);
}
}
if(dev_usage_0x0001 && dev_usage_0x0002)
{
break;
}
info_temp = info_temp->next;
}
if(dev_usage_0x0001 && dev_usage_0x0002)
{
LogitechG915Controller* controller = new LogitechG915Controller(dev_usage_0x0001, dev_usage_0x0002, false);
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
else
{
/*-------------------------------------------------*\
| Not all of them could be opened, do some cleanup |
\*-------------------------------------------------*/
if(dev_usage_0x0001)
{
hid_close(dev_usage_0x0001);
}
if(dev_usage_0x0002)
{
hid_close(dev_usage_0x0002);
}
}
#else
hid_device* dev = hid_open_path(info->path);
if(dev)
{
LogitechG915Controller* controller = new LogitechG915Controller(dev, dev, false);
LogitechG915Controller* controller = new LogitechG915Controller(dev, false);
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
#endif
}
void DetectLogitechKeyboardG915Wired(hid_device_info* info, const std::string& name)
{
/*-------------------------------------------------------------------------------------------------*\
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
\*-------------------------------------------------------------------------------------------------*/
#ifdef USE_HID_USAGE
hid_device* dev_usage_0x0001 = nullptr;
hid_device* dev_usage_0x0002 = nullptr;
hid_device_info* info_temp = info;
while(info_temp)
{
if(info_temp->vendor_id == info->vendor_id // constant LOGITECH_VID
&& info_temp->product_id == info->product_id // NON-constant
&& info_temp->interface_number == info->interface_number // constant 2
&& info_temp->usage_page == info->usage_page) // constant 0xFF00
{
if(info_temp->usage == 0x0001)
{
dev_usage_0x0001 = hid_open_path(info_temp->path);
}
else if(info_temp->usage == 0x0002)
{
dev_usage_0x0002 = hid_open_path(info_temp->path);
}
}
if(dev_usage_0x0001 && dev_usage_0x0002)
{
break;
}
info_temp = info_temp->next;
}
if(dev_usage_0x0001 && dev_usage_0x0002)
{
LogitechG915Controller* controller = new LogitechG915Controller(dev_usage_0x0001, dev_usage_0x0002, true);
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
else
{
/*-------------------------------------------------*\
| Not all of them could be opened, do some cleanup |
\*-------------------------------------------------*/
if(dev_usage_0x0001)
{
hid_close(dev_usage_0x0001);
}
if(dev_usage_0x0002)
{
hid_close(dev_usage_0x0002);
}
}
#else
hid_device* dev = hid_open_path(info->path);
if(dev)
{
LogitechG915Controller* controller = new LogitechG915Controller(dev, dev, true);
LogitechG915Controller* controller = new LogitechG915Controller(dev, true);
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
#endif
}
/*-----------------------------------------------------*\
@@ -677,8 +569,8 @@ REGISTER_HID_DETECTOR_IP ("Logitech G813 RGB Mechanical Gaming Keyboard",
REGISTER_HID_DETECTOR_IP ("Logitech G815 RGB Mechanical Gaming Keyboard", DetectLogitechKeyboardG815, LOGITECH_VID, LOGITECH_G815_PID, 1, 0xFF43);
REGISTER_HID_DETECTOR_IP ("Logitech G910 Orion Spark", DetectLogitechKeyboardG910, LOGITECH_VID, LOGITECH_G910_ORION_SPARK_PID, 1, 0xFF43);
REGISTER_HID_DETECTOR_IP ("Logitech G910 Orion Spectrum", DetectLogitechKeyboardG910, LOGITECH_VID, LOGITECH_G910_PID, 1, 0xFF43);
REGISTER_HID_DETECTOR_IP ("Logitech G915 Wireless RGB Mechanical Gaming Keyboard", DetectLogitechKeyboardG915, LOGITECH_VID, LOGITECH_G915_RECEIVER_PID, 2, 0xFF00);
REGISTER_HID_DETECTOR_IP ("Logitech G915 Wireless RGB Mechanical Gaming Keyboard (Wired)", DetectLogitechKeyboardG915Wired, LOGITECH_VID, LOGITECH_G915_WIRED_PID, 2, 0xFF00);
REGISTER_HID_DETECTOR_IPU("Logitech G915 Wireless RGB Mechanical Gaming Keyboard", DetectLogitechKeyboardG915, LOGITECH_VID, LOGITECH_G915_RECEIVER_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G915 Wireless RGB Mechanical Gaming Keyboard (Wired)", DetectLogitechKeyboardG915Wired, LOGITECH_VID, LOGITECH_G915_WIRED_PID, 2, 0xFF00, 2);
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
@@ -10,10 +10,9 @@
#include "LogitechG915Controller.h"
#include <cstring>
LogitechG915Controller::LogitechG915Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, bool wired)
LogitechG915Controller::LogitechG915Controller(hid_device* dev_handle, bool wired)
{
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
this->dev_handle = dev_handle;
if(wired)
{
@@ -39,7 +38,7 @@ LogitechG915Controller::~LogitechG915Controller()
std::string LogitechG915Controller::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128);
int ret = hid_get_serial_number_string(dev_handle, serial_string, 128);
if(ret != 0)
{
@@ -104,8 +103,8 @@ void LogitechG915Controller::SendCommit()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read_timeout(dev_pkt_0x11, (unsigned char *)usb_buf, 20, LOGITECH_READ_TIMEOUT);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read_timeout(dev_handle, (unsigned char *)usb_buf, 20, LOGITECH_READ_TIMEOUT);
}
void LogitechG915Controller::InitializeDirect()
@@ -128,8 +127,8 @@ void LogitechG915Controller::InitializeDirect()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -147,8 +146,8 @@ void LogitechG915Controller::InitializeDirect()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -167,8 +166,8 @@ void LogitechG915Controller::InitializeDirect()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -188,8 +187,8 @@ void LogitechG915Controller::InitializeDirect()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
}
void LogitechG915Controller::SendSingleLed
@@ -224,8 +223,8 @@ void LogitechG915Controller::SendSingleLed
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
}
void LogitechG915Controller::SendDirectFrame
@@ -257,8 +256,8 @@ void LogitechG915Controller::SendDirectFrame
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read_timeout(dev_pkt_0x11, (unsigned char *)usb_buf, 20, LOGITECH_READ_TIMEOUT);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read_timeout(dev_handle, (unsigned char *)usb_buf, 20, LOGITECH_READ_TIMEOUT);
}
void LogitechG915Controller::SendMode
@@ -316,6 +315,6 @@ void LogitechG915Controller::SendMode
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
}
@@ -64,7 +64,7 @@ enum
class LogitechG915Controller
{
public:
LogitechG915Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, bool wired);
LogitechG915Controller(hid_device* dev_handle, bool wired);
~LogitechG915Controller();
std::string GetSerialString();
@@ -92,8 +92,7 @@ public:
);
private:
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
hid_device* dev_handle;
char feature_4522_idx;
char feature_8040_idx;
char feature_8071_idx;
@@ -16,6 +16,7 @@
#include "RGBController.h"
#include "RGBController_QMKOpenRGBRev9.h"
#include "RGBController_QMKOpenRGBRevB.h"
#include "LogManager.h"
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
@@ -23,6 +24,7 @@
\*-----------------------------------------------------*/
#define QMK_OPENRGB_PROTOCOL_VERSION_9 0x09
#define QMK_OPENRGB_PROTOCOL_VERSION_B 0x0B
#define QMK_OPENRGB_PROTOCOL_VERSION_C 0x0C
/*-----------------------------------------------------*\
| Usage and Usage Page |
@@ -77,14 +79,36 @@ void DetectQMKOpenRGBControllers(hid_device_info *info, const std::string&)
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
break;
case QMK_OPENRGB_PROTOCOL_VERSION_B:
{
QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path);
RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller);
RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, false);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
break;
case QMK_OPENRGB_PROTOCOL_VERSION_C:
{
QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path);
RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, true);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
break;
default:
if (version == 0)
{
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard does not have the OpenRGB protocol feature enabled! \n"
"Please make sure your keyboard supports RGB Matrix, add OPENRGB_ENABLE = yes to the rules.mk inside your keymap folder, compile and flash again!");
}
else if (version < QMK_OPENRGB_PROTOCOL_VERSION_9)
{
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard is using an outdated protocol version %i. Please update to to the update to the latest version of QMK-OpenRGB! \n"
"For officaly supported QMK boards grab <a href=\"https://github.com/Kasper24/QMK-OpenRGB\">url</a> \n"
"For Sonix boards grab <a href=\"https://github.com/SonixQMK/qmk_firmware/tree/sn32_openrgb\">url</a>", version);
}
else if (version > QMK_OPENRGB_PROTOCOL_VERSION_C)
{
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard is using version protocol %i which is not supported by this OpenRGB build. Please update OpenRGB!", version);
}
}
}
}
@@ -11,6 +11,8 @@
#include "QMKOpenRGBRev9Controller.h"
using namespace std::chrono_literals;
static std::map<uint8_t, std::string> QMKKeycodeToKeynameMap
{
{ 0, "" }, { 1, "Right Fn" }, { 2, "" }, { 3, "" },
@@ -85,6 +87,15 @@ QMKOpenRGBRev9Controller::QMKOpenRGBRev9Controller(hid_device *dev_handle, const
leds_per_update = 20;
}
if(qmk_settings.contains("delay"))
{
delay = (unsigned int)qmk_settings["delay"] * 1ms;
}
else
{
delay = 0ms;
}
dev = dev_handle;
location = path;
@@ -451,6 +462,11 @@ void QMKOpenRGBRev9Controller::DirectModeSetLEDs(std::vector<RGBColor> colors, u
hid_write(dev, usb_buf, 65);
if(delay > 0ms)
{
std::this_thread::sleep_for(delay);
}
leds_sent += tmp_leds_per_update;
}
}
@@ -56,6 +56,8 @@ private:
std::string device_name;
std::string device_vendor;
std::chrono::milliseconds delay;
unsigned int total_number_of_leds;
unsigned int total_number_of_leds_with_empty_space;
unsigned int mode;
@@ -9,6 +9,8 @@
#include "QMKOpenRGBRevBController.h"
using namespace std::chrono_literals;
static std::map<uint8_t, std::string> QMKKeycodeToKeynameMap
{
{ 0, "" }, { 1, "Right Fn" }, { 2, "" }, { 3, "" },
@@ -83,6 +85,15 @@ QMKOpenRGBRevBController::QMKOpenRGBRevBController(hid_device *dev_handle, const
leds_per_update = 20;
}
if(qmk_settings.contains("delay"))
{
delay = (unsigned int)qmk_settings["delay"] * 1ms;
}
else
{
delay = 0ms;
}
dev = dev_handle;
location = path;
@@ -382,7 +393,7 @@ std::vector<unsigned int> QMKOpenRGBRevBController::GetEnabledModes()
return enabled_modes;
}
void QMKOpenRGBRevBController::SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed)
void QMKOpenRGBRevBController::SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed, bool save)
{
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
@@ -401,6 +412,7 @@ void QMKOpenRGBRevBController::SetMode(hsv_t hsv_color, unsigned char mode, unsi
usb_buf[0x04] = hsv_color.value;
usb_buf[0x05] = mode;
usb_buf[0x06] = speed;
usb_buf[0x07] = save;
/*-----------------------------------------------------*\
| Send packet |
@@ -472,6 +484,11 @@ void QMKOpenRGBRevBController::DirectModeSetLEDs(std::vector<RGBColor> colors, u
hid_write(dev, usb_buf, 65);
if(delay > 0ms)
{
std::this_thread::sleep_for(delay);
}
leds_sent += tmp_leds_per_update;
}
}
}
@@ -39,7 +39,7 @@ public:
void GetLEDInfo(unsigned int leds_count);
std::vector<unsigned int> GetEnabledModes();
void SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed);
void SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed, bool save);
void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int num_colors);
@@ -54,6 +54,8 @@ private:
std::string device_name;
std::string device_vendor;
std::chrono::milliseconds delay;
unsigned int total_number_of_leds;
unsigned int total_number_of_leds_with_empty_space;
unsigned int mode;
@@ -8,9 +8,10 @@
\*-------------------------------------------------------------------*/
#include "hsv.h"
#include "LogManager.h"
#include "RGBController_QMKOpenRGBRevB.h"
RGBController_QMKOpenRGBRevB::RGBController_QMKOpenRGBRevB(QMKOpenRGBRevBController* controller_ptr)
RGBController_QMKOpenRGBRevB::RGBController_QMKOpenRGBRevB(QMKOpenRGBRevBController* controller_ptr, bool save)
{
controller = controller_ptr;
@@ -26,212 +27,212 @@ RGBController_QMKOpenRGBRevB::RGBController_QMKOpenRGBRevB(QMKOpenRGBRevBControl
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_COLOR) != enabled_modes.end())
{
InitializeMode("Static", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Static", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_ALPHA_MOD) != enabled_modes.end())
{
InitializeMode("Alpha Mod", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Alpha Mod", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_GRADIENT_UP_DOWN) != enabled_modes.end())
{
InitializeMode("Gradient Up Down", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Gradient Up Down", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_GRADIENT_LEFT_RIGHT) != enabled_modes.end())
{
InitializeMode("Gradient Left Right", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Gradient Left Right", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_BREATHING) != enabled_modes.end())
{
InitializeMode("Breathing", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Breathing", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_BAND_SAT) != enabled_modes.end())
{
InitializeMode("Band Saturation", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Band Saturation", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_BAND_VAL) != enabled_modes.end())
{
InitializeMode("Band Value", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Band Value", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_BAND_PINWHEEL_SAT) != enabled_modes.end())
{
InitializeMode("Band Pinwheel Saturation", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Band Pinwheel Saturation", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_BAND_PINWHEEL_VAL) != enabled_modes.end())
{
InitializeMode("Band Pinwheel Value", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Band Pinwheel Value", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_BAND_SPIRAL_SAT) != enabled_modes.end())
{
InitializeMode("Band Spiral Saturation", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Band Spiral Saturation", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_BAND_SPIRAL_VAL) != enabled_modes.end())
{
InitializeMode("Band Spiral Value", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Band Spiral Value", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_CYCLE_ALL) != enabled_modes.end())
{
InitializeMode("Cycle All", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Cycle All", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_CYCLE_LEFT_RIGHT) != enabled_modes.end())
{
InitializeMode("Cycle Left Right", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Cycle Left Right", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_CYCLE_UP_DOWN) != enabled_modes.end())
{
InitializeMode("Cycle Up Down", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Cycle Up Down", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_CYCLE_OUT_IN) != enabled_modes.end())
{
InitializeMode("Cycle Out In", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Cycle Out In", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_CYCLE_OUT_IN_DUAL) != enabled_modes.end())
{
InitializeMode("Cycle Out In Dual", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Cycle Out In Dual", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_RAINBOW_MOVING_CHEVRON) != enabled_modes.end())
{
InitializeMode("Rainbow Moving Chevron", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Rainbow Moving Chevron", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_CYCLE_PINWHEEL) != enabled_modes.end())
{
InitializeMode("Cycle Pinwheel", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Cycle Pinwheel", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_CYCLE_SPIRAL) != enabled_modes.end())
{
InitializeMode("Cycle Spiral", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Cycle Spiral", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_DUAL_BEACON) != enabled_modes.end())
{
InitializeMode("Dual Beacon", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Dual Beacon", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_RAINBOW_BEACON) != enabled_modes.end())
{
InitializeMode("Rainbow Beacon", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Rainbow Beacon", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_RAINBOW_PINWHEELS) != enabled_modes.end())
{
InitializeMode("Rainbow Pinwheels", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Rainbow Pinwheels", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_RAINDROPS) != enabled_modes.end())
{
InitializeMode("Raindrops", current_mode, 0, MODE_COLORS_NONE);
InitializeMode("Raindrops", current_mode, 0, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_JELLYBEAN_RAINDROPS) != enabled_modes.end())
{
InitializeMode("Jellybean Raindrops", current_mode, 0, MODE_COLORS_NONE);
InitializeMode("Jellybean Raindrops", current_mode, 0, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_HUE_BREATHING) != enabled_modes.end())
{
InitializeMode("Hue Breathing", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Hue Breathing", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_HUE_PENDULUM) != enabled_modes.end())
{
InitializeMode("Hue Pendulum", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Hue Pendulum", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_HUE_WAVE) != enabled_modes.end())
{
InitializeMode("Hue Wave", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Hue Wave", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_TYPING_HEATMAP) != enabled_modes.end())
{
InitializeMode("Typing Heatmap", current_mode, 0, MODE_COLORS_NONE);
InitializeMode("Typing Heatmap", current_mode, 0, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_DIGITAL_RAIN) != enabled_modes.end())
{
InitializeMode("Digital Rain", current_mode, 0, MODE_COLORS_NONE);
InitializeMode("Digital Rain", current_mode, 0, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE_SIMPLE) != enabled_modes.end())
{
InitializeMode("Solid Reactive Simple", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Simple", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE) != enabled_modes.end())
{
InitializeMode("Solid Reactive", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE_WIDE) != enabled_modes.end())
{
InitializeMode("Solid Reactive Wide", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Wide", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTIWIDE) != enabled_modes.end())
{
InitializeMode("Solid Reactive Multi Wide", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Multi Wide", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE_CROSS) != enabled_modes.end())
{
InitializeMode("Solid Reactive Cross", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Cross", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTICROSS) != enabled_modes.end())
{
InitializeMode("Solid Reactive Multi Cross", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Multi Cross", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE_NEXUS) != enabled_modes.end())
{
InitializeMode("Solid Reactive Nexus", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Nexus", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTINEXUS) != enabled_modes.end())
{
InitializeMode("Solid Reactive Multi Nexus", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Multi Nexus", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SPLASH) != enabled_modes.end())
{
InitializeMode("Rainbow Reactive Splash", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Rainbow Reactive Splash", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_MULTISPLASH) != enabled_modes.end())
{
InitializeMode("Rainbow Reactive Multi Splash", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE);
InitializeMode("Rainbow Reactive Multi Splash", current_mode, MODE_FLAG_HAS_SPEED, MODE_COLORS_NONE, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_SPLASH) != enabled_modes.end())
{
InitializeMode("Solid Reactive Splash", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Splash", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_SOLID_MULTISPLASH) != enabled_modes.end())
{
InitializeMode("Solid Reactive Multi Splash", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC);
InitializeMode("Solid Reactive Multi Splash", current_mode, MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED, MODE_COLORS_MODE_SPECIFIC, save);
}
if(std::find(enabled_modes.begin(), enabled_modes.end(), QMK_OPENRGB_MODE_OPENRGB_DIRECT) != enabled_modes.end())
{
InitializeMode("Direct", current_mode, MODE_FLAG_HAS_PER_LED_COLOR, MODE_COLORS_PER_LED);
InitializeMode("Direct", current_mode, MODE_FLAG_HAS_PER_LED_COLOR, MODE_COLORS_PER_LED, save);
}
/*-----------------------------------------------------*\
@@ -430,11 +431,11 @@ void RGBController_QMKOpenRGBRevB::DeviceUpdateMode()
{
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{
controller->SetMode({ 0, 255, 255 }, modes[active_mode].value, 127);
controller->SetMode({ 0, 255, 255 }, modes[active_mode].value, 127, false);
}
else if(modes[active_mode].color_mode == MODE_COLORS_NONE)
{
controller->SetMode({ 0, 255, 255 }, modes[active_mode].value, modes[active_mode].speed);
controller->SetMode({ 0, 255, 255 }, modes[active_mode].value, modes[active_mode].speed, false);
}
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
@@ -444,11 +445,34 @@ void RGBController_QMKOpenRGBRevB::DeviceUpdateMode()
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
{
controller->SetMode(hsv_color, modes[active_mode].value, modes[active_mode].speed);
controller->SetMode(hsv_color, modes[active_mode].value, modes[active_mode].speed, false);
}
else
{
controller->SetMode(hsv_color, modes[active_mode].value, 127);
controller->SetMode(hsv_color, modes[active_mode].value, 127, false);
}
}
}
void RGBController_QMKOpenRGBRevB::DeviceSaveMode()
{
if(modes[active_mode].color_mode == MODE_COLORS_NONE)
{
controller->SetMode({ 0, 255, 255 }, modes[active_mode].value, modes[active_mode].speed, true);
}
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
RGBColor rgb_color = modes[active_mode].colors[0];
hsv_t hsv_color;
rgb2hsv(rgb_color, &hsv_color);
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
{
controller->SetMode(hsv_color, modes[active_mode].value, modes[active_mode].speed, true);
}
else
{
controller->SetMode(hsv_color, modes[active_mode].value, 127, true);
}
}
}
@@ -458,7 +482,8 @@ void RGBController_QMKOpenRGBRevB::InitializeMode
std::string name,
unsigned int &current_mode,
unsigned int flags,
unsigned int color_mode
unsigned int color_mode,
bool save
)
{
mode qmk_mode;
@@ -491,6 +516,13 @@ void RGBController_QMKOpenRGBRevB::InitializeMode
}
else
{
/*-----------------------------------------------------*\
| Every mode apart from direct is save-able |
\*-----------------------------------------------------*/
if(save == true)
{
qmk_mode.flags = flags | MODE_FLAG_MANUAL_SAVE;
}
modes.push_back(qmk_mode);
}
}
@@ -23,7 +23,7 @@ typedef std::vector<std::vector<unsigned int>> VectorMatrix;
class RGBController_QMKOpenRGBRevB : public RGBController
{
public:
RGBController_QMKOpenRGBRevB(QMKOpenRGBRevBController* controller_ptr);
RGBController_QMKOpenRGBRevB(QMKOpenRGBRevBController* controller_ptr, bool save);
~RGBController_QMKOpenRGBRevB();
void SetupZones();
@@ -35,6 +35,7 @@ public:
void SetCustomMode();
void DeviceUpdateMode();
void DeviceSaveMode();
private:
QMKOpenRGBRevBController* controller;
@@ -46,7 +47,8 @@ private:
std::string name,
unsigned int &current_mode,
unsigned int flags,
unsigned int color_mode
unsigned int color_mode,
bool save
);
unsigned int CalculateDivisor
+17 -3
View File
@@ -175,7 +175,8 @@ HEADERS +=
qt/DeviceView.h \
qt/OpenRGBDialog2.h \
qt/OpenRGBPluginContainer.h \
qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.h \
qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.h \
qt/OpenRGBPluginsPage/OpenRGBPluginsList.h \
qt/OpenRGBPluginsPage/OpenRGBPluginsPage.h \
qt/OpenRGBProfileSaveDialog.h \
qt/OpenRGBServerInfoPage.h \
@@ -186,10 +187,14 @@ HEADERS +=
qt/OpenRGBZoneResizeDialog.h \
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.h \
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h \
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.h \
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.h \
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.h \
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h \
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsEntry.h \
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.h \
qt/OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsEntry.h \
qt/OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsPage.h \
qt/OpenRGBZonesBulkResizer.h \
qt/TabLabel.h \
serial_port/find_usb_serial_port.h \
@@ -503,7 +508,8 @@ SOURCES +=
qt/DeviceView.cpp \
qt/OpenRGBDialog2.cpp \
qt/OpenRGBPluginContainer.cpp \
qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.cpp \
qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.cpp \
qt/OpenRGBPluginsPage/OpenRGBPluginsList.cpp \
qt/OpenRGBPluginsPage/OpenRGBPluginsPage.cpp \
qt/OpenRGBProfileSaveDialog.cpp \
qt/OpenRGBServerInfoPage.cpp \
@@ -517,10 +523,14 @@ SOURCES +=
qt/hsv.cpp \
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.cpp \
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.cpp \
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.cpp \
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.cpp \
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.cpp \
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.cpp \
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsEntry.cpp \
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.cpp \
qt/OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsEntry.cpp \
qt/OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsPage.cpp \
serial_port/serial_port.cpp \
super_io/super_io.cpp \
AutoStart/AutoStart.cpp \
@@ -853,7 +863,7 @@ FORMS +=
qt/OpenRGBDialog.ui \
qt/OpenRGBDialog2.ui \
qt/OpenRGBPluginContainer.ui \
qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.ui \
qt/OpenRGBPluginsPage/OpenRGBPluginsEntry.ui \
qt/OpenRGBPluginsPage/OpenRGBPluginsPage.ui \
qt/OpenRGBProfileSaveDialog.ui \
qt/OpenRGBServerInfoPage.ui \
@@ -864,10 +874,14 @@ FORMS +=
qt/OpenRGBZoneResizeDialog.ui \
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.ui \
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.ui \
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.ui \
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.ui \
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.ui \
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.ui \
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsEntry.ui \
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.ui \
qt/OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsEntry.ui \
qt/OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsPage.ui \
qt/OpenRGBZonesBulkResizer.ui \
qt/TabLabel.ui \
+1
View File
@@ -102,6 +102,7 @@
#define ASUS_ROG_STRIX_GTX1080TI_11G_GAMING 0x85F1
#define ASUS_ROG_STRIX_GTX1080TI_GAMING 0x85EA
#define ASUS_ROG_STRIX_GTX1650S_OC 0x874F
#define ASUS_ROG_STRIX_GTX1660S_O6G_GAMING 0x8752
#define ASUS_ROG_GTX1660TI_OC 0x86A5
#define ASUS_ROG_STRIX_RTX2060_EVO_GAMING 0x86D3
#define ASUS_ROG_STRIX_RTX2060S_A8G_EVO_GAMING 0x8703
+66
View File
@@ -453,6 +453,16 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
\*-----------------------------------------------------*/
AddQMKORGBSettingsPage();
/*-----------------------------------------------------*\
| Add the Philips Wiz settings page |
\*-----------------------------------------------------*/
AddPhilipsWizSettingsPage();
/*-----------------------------------------------------*\
| Add the Yeelight settings page |
\*-----------------------------------------------------*/
AddYeelightSettingsPage();
/*-----------------------------------------------------*\
| Add the SMBus Tools page if enabled |
\*-----------------------------------------------------*/
@@ -651,6 +661,34 @@ void OpenRGBDialog2::AddE131SettingsPage()
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
}
void OpenRGBDialog2::AddPhilipsWizSettingsPage()
{
/*-----------------------------------------------------*\
| Create the Settings page |
\*-----------------------------------------------------*/
PhilipsWizSettingsPage = new OpenRGBPhilipsWizSettingsPage();
ui->SettingsTabBar->addTab(PhilipsWizSettingsPage, "");
QString SettingsLabelString;
if(IsDarkTheme())
{
SettingsLabelString = "light_dark.png";
}
else
{
SettingsLabelString = "light.png";
}
/*-----------------------------------------------------*\
| Create the tab label |
\*-----------------------------------------------------*/
TabLabel* SettingsTabLabel = new TabLabel(SettingsLabelString, "Philips Wiz Devices");
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
}
void OpenRGBDialog2::AddQMKORGBSettingsPage()
{
/*-----------------------------------------------------*\
@@ -707,6 +745,34 @@ void OpenRGBDialog2::AddSerialSettingsPage()
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
}
void OpenRGBDialog2::AddYeelightSettingsPage()
{
/*-----------------------------------------------------*\
| Create the Settings page |
\*-----------------------------------------------------*/
YeelightSettingsPage = new OpenRGBYeelightSettingsPage();
ui->SettingsTabBar->addTab(YeelightSettingsPage, "");
QString SettingsLabelString;
if(IsDarkTheme())
{
SettingsLabelString = "light_dark.png";
}
else
{
SettingsLabelString = "light.png";
}
/*-----------------------------------------------------*\
| Create the tab label |
\*-----------------------------------------------------*/
TabLabel* SettingsTabLabel = new TabLabel(SettingsLabelString, "Yeelight Devices");
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
}
void OpenRGBDialog2::AddPlugin(OpenRGBPluginEntry* plugin)
{
/*-----------------------------------------------------*\
+6
View File
@@ -10,8 +10,10 @@
#include "OpenRGBSupportedDevicesPage.h"
#include "OpenRGBSettingsPage.h"
#include "OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h"
#include "OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.h"
#include "OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h"
#include "OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.h"
#include "OpenRGBYeelightSettingsPage/OpenRGBYeelightSettingsPage.h"
#include "PluginManager.h"
#include <vector>
@@ -64,8 +66,10 @@ private:
OpenRGBSupportedDevicesPage *SupportedPage;
OpenRGBSettingsPage *SettingsPage;
OpenRGBE131SettingsPage *E131SettingsPage;
OpenRGBPhilipsWizSettingsPage *PhilipsWizSettingsPage;
OpenRGBQMKORGBSettingsPage *QMKORGBSettingsPage;
OpenRGBSerialSettingsPage *SerialSettingsPage;
OpenRGBYeelightSettingsPage *YeelightSettingsPage;
bool ShowI2CTools = false;
@@ -85,8 +89,10 @@ private:
void AddSupportedDevicesPage();
void AddSettingsPage();
void AddE131SettingsPage();
void AddPhilipsWizSettingsPage();
void AddQMKORGBSettingsPage();
void AddSerialSettingsPage();
void AddYeelightSettingsPage();
void AddPluginsPage(PluginManager* plugin_manager);
void ClearDevicesList();
@@ -0,0 +1,16 @@
#include "OpenRGBPhilipsWizSettingsEntry.h"
#include "ui_OpenRGBPhilipsWizSettingsEntry.h"
using namespace Ui;
OpenRGBPhilipsWizSettingsEntry::OpenRGBPhilipsWizSettingsEntry(QWidget *parent) :
QWidget(parent),
ui(new Ui::OpenRGBPhilipsWizSettingsEntryUi)
{
ui->setupUi(this);
}
OpenRGBPhilipsWizSettingsEntry::~OpenRGBPhilipsWizSettingsEntry()
{
delete ui;
}
@@ -0,0 +1,21 @@
#ifndef OPENRGBPHILIPSWIZSETTINGSENTRY_H
#define OPENRGBPHILIPSWIZSETTINGSENTRY_H
#include "ui_OpenRGBPhilipsWizSettingsEntry.h"
#include <QWidget>
namespace Ui {
class OpenRGBPhilipsWizSettingsEntry;
}
class Ui::OpenRGBPhilipsWizSettingsEntry : public QWidget
{
Q_OBJECT
public:
explicit OpenRGBPhilipsWizSettingsEntry(QWidget *parent = nullptr);
~OpenRGBPhilipsWizSettingsEntry();
Ui::OpenRGBPhilipsWizSettingsEntryUi *ui;
};
#endif // OPENRGBPHILIPSWIZSETTINGSENTRY_H
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBPhilipsWizSettingsEntryUi</class>
<widget class="QWidget" name="OpenRGBPhilipsWizSettingsEntryUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>59</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="3">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>IPEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,105 @@
#include "OpenRGBPhilipsWizSettingsPage.h"
#include "ui_OpenRGBPhilipsWizSettingsPage.h"
#include "ResourceManager.h"
using namespace Ui;
OpenRGBPhilipsWizSettingsPage::OpenRGBPhilipsWizSettingsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::OpenRGBPhilipsWizSettingsPageUi)
{
ui->setupUi(this);
json wiz_settings;
/*-------------------------------------------------*\
| Get Philips Wiz settings |
\*-------------------------------------------------*/
wiz_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("PhilipsWizDevices");
/*-------------------------------------------------*\
| If the Wiz settings contains devices, process |
\*-------------------------------------------------*/
if(wiz_settings.contains("devices"))
{
for(unsigned int device_idx = 0; device_idx < wiz_settings["devices"].size(); device_idx++)
{
OpenRGBPhilipsWizSettingsEntry* entry = new OpenRGBPhilipsWizSettingsEntry;
if(wiz_settings["devices"][device_idx].contains("ip"))
{
entry->ui->IPEdit->setText(QString::fromStdString(wiz_settings["devices"][device_idx]["ip"]));
}
entries.push_back(entry);
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->PhilipsWizDeviceList->addItem(item);
ui->PhilipsWizDeviceList->setItemWidget(item, entry);
ui->PhilipsWizDeviceList->show();
}
}
}
OpenRGBPhilipsWizSettingsPage::~OpenRGBPhilipsWizSettingsPage()
{
delete ui;
}
void Ui::OpenRGBPhilipsWizSettingsPage::on_AddPhilipsWizDeviceButton_clicked()
{
OpenRGBPhilipsWizSettingsEntry* entry = new OpenRGBPhilipsWizSettingsEntry;
entries.push_back(entry);
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->PhilipsWizDeviceList->addItem(item);
ui->PhilipsWizDeviceList->setItemWidget(item, entry);
ui->PhilipsWizDeviceList->show();
}
void Ui::OpenRGBPhilipsWizSettingsPage::on_RemovePhilipsWizDeviceButton_clicked()
{
int cur_row = ui->PhilipsWizDeviceList->currentRow();
if(cur_row < 0)
{
return;
}
QListWidgetItem* item = ui->PhilipsWizDeviceList->takeItem(cur_row);
ui->PhilipsWizDeviceList->removeItemWidget(item);
delete item;
delete entries[cur_row];
entries.erase(entries.begin() + cur_row);
}
void Ui::OpenRGBPhilipsWizSettingsPage::on_SavePhilipsWizConfigurationButton_clicked()
{
json wiz_settings;
/*-------------------------------------------------*\
| Get Philips Wiz settings |
\*-------------------------------------------------*/
wiz_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("PhilipsWizDevices");
wiz_settings["devices"].clear();
for(unsigned int device_idx = 0; device_idx < entries.size(); device_idx++)
{
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
wiz_settings["devices"][device_idx]["ip"] = entries[device_idx]->ui->IPEdit->text().toStdString();
}
ResourceManager::get()->GetSettingsManager()->SetSettings("PhilipsWizDevices", wiz_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
@@ -0,0 +1,34 @@
#ifndef OPENRGBPHILIPSWIZSETTINGSPAGE_H
#define OPENRGBPHILIPSWIZSETTINGSPAGE_H
#include "ui_OpenRGBPhilipsWizSettingsPage.h"
#include <QWidget>
#include "OpenRGBPhilipsWizSettingsEntry.h"
namespace Ui {
class OpenRGBPhilipsWizSettingsPage;
}
class Ui::OpenRGBPhilipsWizSettingsPage : public QWidget
{
Q_OBJECT
public:
explicit OpenRGBPhilipsWizSettingsPage(QWidget *parent = nullptr);
~OpenRGBPhilipsWizSettingsPage();
private slots:
void on_AddPhilipsWizDeviceButton_clicked();
void on_RemovePhilipsWizDeviceButton_clicked();
void on_SavePhilipsWizConfigurationButton_clicked();
private:
Ui::OpenRGBPhilipsWizSettingsPageUi *ui;
std::vector<OpenRGBPhilipsWizSettingsEntry*> entries;
};
#endif // OPENRGBPHILIPSWIZSETTINGSPAGE_H
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBPhilipsWizSettingsPageUi</class>
<widget class="QWidget" name="OpenRGBPhilipsWizSettingsPageUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="AddPhilipsWizDeviceButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="RemovePhilipsWizDeviceButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="SavePhilipsWizConfigurationButton">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QListWidget" name="PhilipsWizDeviceList">
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,45 @@
#include "OpenRGBPluginsList.h"
#include <QMimeData>
#include <QUrl>
OpenRGBPluginsList::OpenRGBPluginsList(QWidget *parent) : QListWidget (parent)
{
setAcceptDrops(true);
}
void OpenRGBPluginsList::dropEvent(QDropEvent *event)
{
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasUrls())
{
std::vector<std::string> path_list;
QList<QUrl> urls = mimeData->urls();
for(const QUrl& url: urls)
{
path_list.push_back(url.toLocalFile().toStdString());
}
emit PluginsDropped(path_list);
}
}
void OpenRGBPluginsList::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls())
{
event->acceptProposedAction();
}
else
{
event->ignore();
}
}
void OpenRGBPluginsList::dragMoveEvent(QDragMoveEvent *event)
{
event->acceptProposedAction();
}
@@ -0,0 +1,24 @@
#ifndef OPENRGBPLUGINSLIST_H
#define OPENRGBPLUGINSLIST_H
#include <QListWidget>
#include <QDropEvent>
#include <QDragEnterEvent>
class OpenRGBPluginsList : public QListWidget
{
Q_OBJECT
public:
OpenRGBPluginsList(QWidget *parent = nullptr);
signals:
void PluginsDropped(std::vector<std::string>);
protected:
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
};
#endif // OPENRGBPLUGINSLIST_H
+39 -3
View File
@@ -88,7 +88,17 @@ void Ui::OpenRGBPluginsPage::on_InstallPluginButton_clicked()
\*-----------------------------------------------------*/
QString install_file = QFileDialog::getOpenFileName(this, "Install OpenRGB Plugin", "", "DLL Files (*.dll; *.dylib; *.so; *.so.*)");
std::string from_path = install_file.toStdString();
bool installed = InstallPlugin(install_file.toStdString());
if(installed)
{
RefreshList();
}
}
bool Ui::OpenRGBPluginsPage::InstallPlugin(std::string install_file)
{
std::string from_path = install_file;
std::string to_path = ResourceManager::get()->GetConfigurationDirectory() + "plugins/";
std::string to_file = to_path + filesystem::path(from_path).filename().string();
bool match = false;
@@ -116,7 +126,7 @@ void Ui::OpenRGBPluginsPage::on_InstallPluginButton_clicked()
if(reply != QMessageBox::Yes)
{
return;
return false;
}
}
@@ -132,12 +142,14 @@ void Ui::OpenRGBPluginsPage::on_InstallPluginButton_clicked()
plugin_manager->AddPlugin(to_file);
RefreshList();
return true;
}
catch(std::exception& e)
{
}
return false;
}
void Ui::OpenRGBPluginsPage::on_RemovePluginButton_clicked()
@@ -298,3 +310,27 @@ void Ui::OpenRGBPluginsPage::on_EnableButton_clicked(OpenRGBPluginsEntry* entry)
plugin_manager->UnloadPlugin(entry_path);
}
}
void Ui::OpenRGBPluginsPage::on_PluginsList_itemSelectionChanged()
{
/*-----------------------------------------------------*\
| Enable the remove button when there's a selected item |
\*-----------------------------------------------------*/
ui->RemovePluginButton->setEnabled(!ui->PluginsList->selectedItems().empty());
}
void Ui::OpenRGBPluginsPage::on_PluginsList_PluginsDropped(std::vector<std::string> path_list)
{
bool installed = false;
for(const std::string& file_path: path_list)
{
installed |= InstallPlugin(file_path);
}
if(installed)
{
RefreshList();
}
}
@@ -26,11 +26,16 @@ private slots:
void on_RemovePluginButton_clicked();
void on_PluginsList_itemSelectionChanged();
void on_PluginsList_PluginsDropped(std::vector<std::string>);
private:
Ui::OpenRGBPluginsPageUi* ui;
PluginManager* plugin_manager;
std::vector<OpenRGBPluginsEntry*> entries;
bool InstallPlugin(std::string path);
void RefreshList();
};
+11 -1
View File
@@ -23,13 +23,16 @@
</item>
<item row="1" column="1">
<widget class="QPushButton" name="RemovePluginButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove Plugin</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QListWidget" name="PluginsList">
<widget class="OpenRGBPluginsList" name="PluginsList">
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
@@ -37,6 +40,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>OpenRGBPluginsList</class>
<extends>QListWidget</extends>
<header>qt/OpenRGBPluginsPage/OpenRGBPluginsList.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,16 @@
#include "OpenRGBYeelightSettingsEntry.h"
#include "ui_OpenRGBYeelightSettingsEntry.h"
using namespace Ui;
OpenRGBYeelightSettingsEntry::OpenRGBYeelightSettingsEntry(QWidget *parent) :
QWidget(parent),
ui(new Ui::OpenRGBYeelightSettingsEntryUi)
{
ui->setupUi(this);
}
OpenRGBYeelightSettingsEntry::~OpenRGBYeelightSettingsEntry()
{
delete ui;
}
@@ -0,0 +1,21 @@
#ifndef OPENRGBYEELIGHTSETTINGSENTRY_H
#define OPENRGBYEELIGHTSETTINGSENTRY_H
#include "ui_OpenRGBYeelightSettingsEntry.h"
#include <QWidget>
namespace Ui {
class OpenRGBYeelightSettingsEntry;
}
class Ui::OpenRGBYeelightSettingsEntry : public QWidget
{
Q_OBJECT
public:
explicit OpenRGBYeelightSettingsEntry(QWidget *parent = nullptr);
~OpenRGBYeelightSettingsEntry();
Ui::OpenRGBYeelightSettingsEntryUi *ui;
};
#endif // OPENRGBYeelightSETTINGSENTRY_H
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBYeelightSettingsEntryUi</class>
<widget class="QWidget" name="OpenRGBYeelightSettingsEntryUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>85</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="3">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="MusicModeCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="MusicModeLabel">
<property name="text">
<string>Music Mode:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>IPEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,111 @@
#include "OpenRGBYeelightSettingsPage.h"
#include "ui_OpenRGBYeelightSettingsPage.h"
#include "ResourceManager.h"
using namespace Ui;
OpenRGBYeelightSettingsPage::OpenRGBYeelightSettingsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::OpenRGBYeelightSettingsPageUi)
{
ui->setupUi(this);
json yeelight_settings;
/*-------------------------------------------------*\
| Get Philips Wiz settings |
\*-------------------------------------------------*/
yeelight_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("YeelightDevices");
/*-------------------------------------------------*\
| If the Wiz settings contains devices, process |
\*-------------------------------------------------*/
if(yeelight_settings.contains("devices"))
{
for(unsigned int device_idx = 0; device_idx < yeelight_settings["devices"].size(); device_idx++)
{
OpenRGBYeelightSettingsEntry* entry = new OpenRGBYeelightSettingsEntry;
if(yeelight_settings["devices"][device_idx].contains("ip"))
{
entry->ui->IPEdit->setText(QString::fromStdString(yeelight_settings["devices"][device_idx]["ip"]));
}
if(yeelight_settings["devices"][device_idx].contains("music_mode"))
{
entry->ui->MusicModeCheckBox->setChecked(yeelight_settings["devices"][device_idx]["music_mode"]);
}
entries.push_back(entry);
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->YeelightDeviceList->addItem(item);
ui->YeelightDeviceList->setItemWidget(item, entry);
ui->YeelightDeviceList->show();
}
}
}
OpenRGBYeelightSettingsPage::~OpenRGBYeelightSettingsPage()
{
delete ui;
}
void Ui::OpenRGBYeelightSettingsPage::on_AddYeelightDeviceButton_clicked()
{
OpenRGBYeelightSettingsEntry* entry = new OpenRGBYeelightSettingsEntry;
entries.push_back(entry);
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->YeelightDeviceList->addItem(item);
ui->YeelightDeviceList->setItemWidget(item, entry);
ui->YeelightDeviceList->show();
}
void Ui::OpenRGBYeelightSettingsPage::on_RemoveYeelightDeviceButton_clicked()
{
int cur_row = ui->YeelightDeviceList->currentRow();
if(cur_row < 0)
{
return;
}
QListWidgetItem* item = ui->YeelightDeviceList->takeItem(cur_row);
ui->YeelightDeviceList->removeItemWidget(item);
delete item;
delete entries[cur_row];
entries.erase(entries.begin() + cur_row);
}
void Ui::OpenRGBYeelightSettingsPage::on_SaveYeelightConfigurationButton_clicked()
{
json yeelight_settings;
/*-------------------------------------------------*\
| Get Philips Wiz settings |
\*-------------------------------------------------*/
yeelight_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("YeelightDevices");
yeelight_settings["devices"].clear();
for(unsigned int device_idx = 0; device_idx < entries.size(); device_idx++)
{
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
yeelight_settings["devices"][device_idx]["ip"] = entries[device_idx]->ui->IPEdit->text().toStdString();
yeelight_settings["devices"][device_idx]["music_mode"] = entries[device_idx]->ui->MusicModeCheckBox->isChecked();
}
ResourceManager::get()->GetSettingsManager()->SetSettings("YeelightDevices", yeelight_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
@@ -0,0 +1,34 @@
#ifndef OPENRGBYEELIGHTSETTINGSPAGE_H
#define OPENRGBYEELIGHTSETTINGSPAGE_H
#include "ui_OpenRGBYeelightSettingsPage.h"
#include <QWidget>
#include "OpenRGBYeelightSettingsEntry.h"
namespace Ui {
class OpenRGBYeelightSettingsPage;
}
class Ui::OpenRGBYeelightSettingsPage : public QWidget
{
Q_OBJECT
public:
explicit OpenRGBYeelightSettingsPage(QWidget *parent = nullptr);
~OpenRGBYeelightSettingsPage();
private slots:
void on_AddYeelightDeviceButton_clicked();
void on_RemoveYeelightDeviceButton_clicked();
void on_SaveYeelightConfigurationButton_clicked();
private:
Ui::OpenRGBYeelightSettingsPageUi *ui;
std::vector<OpenRGBYeelightSettingsEntry*> entries;
};
#endif // OPENRGBYEELIGHTSETTINGSPAGE_H
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBYeelightSettingsPageUi</class>
<widget class="QWidget" name="OpenRGBYeelightSettingsPageUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="AddYeelightDeviceButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="RemoveYeelightDeviceButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="SaveYeelightConfigurationButton">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QListWidget" name="YeelightDeviceList">
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>