Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6e9ee3978 | ||
|
|
e4692cb562 | ||
|
|
4f62d68f6d | ||
|
|
70a2fa81c8 | ||
|
|
04c430e31b | ||
|
|
56640b5922 | ||
|
|
96427c4015 | ||
|
|
5b02b3430e | ||
|
|
4991e7744b | ||
|
|
d0260a7eb0 | ||
|
|
a6da9a25b7 | ||
|
|
00197be5fa | ||
|
|
c0d5529083 | ||
|
|
2e032314a4 | ||
|
|
7036c05bc2 | ||
|
|
1045af20b2 | ||
|
|
70024faabd | ||
|
|
344e7c7551 | ||
|
|
3699889250 | ||
|
|
bdc1b6f3f4 | ||
|
|
b4e76c8281 | ||
|
|
b72dbf4638 | ||
|
|
61e4c74d6a | ||
|
|
94ab89c95d | ||
|
|
ea238cf6e6 |
+8
-2
@@ -348,6 +348,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0cf2", ATTR{idProduct}=="7750", TAG+="uacces
|
||||
# Logitech G810 #2 #
|
||||
# Logitech G813 #
|
||||
# Logitech G815 #
|
||||
# Logitech G915 #
|
||||
# #
|
||||
# Mice: #
|
||||
# Logitech G203 Prodigy #
|
||||
@@ -388,6 +389,8 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c337", TAG+="uacces
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c232", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c33f", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c335", TAG+="uaccess" #G910
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c541", TAG+="uaccess" #G915 Receiver
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c33e", TAG+="uaccess" #G915 Wired
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c084", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c092", TAG+="uaccess"
|
||||
@@ -723,8 +726,9 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="054c", ATTR{idProduct}=="0ba0", TAG+="uacces
|
||||
# SteelSeries Rival 300 Blackops Edition #
|
||||
# SteelSeries Rival 310 #
|
||||
# SteelSeries Rival 310 CS:GO Howl Edition #
|
||||
# SteelSeries Rival 310 PubG Edition #
|
||||
# SteelSeries Rival 650 Wireless #
|
||||
# SteelSeries Rival 310 PubG Edition #
|
||||
# SteelSeries Rival 650 Wireless #
|
||||
# SteelSeries Rival 3 #
|
||||
# SteelSeries Rival Sensei Ten #
|
||||
# SteelSeries Rival Sensei Ten CS:GO Neon Rider #
|
||||
# SteelSeries Rival Sensei 310 #
|
||||
@@ -761,6 +765,8 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1834", TAG+="uacces
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1722", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1726", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="172B", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1824", TAG+="uaccess" #Rival3_Old
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="184c", TAG+="uaccess" #Rival3
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1229", TAG+="uaccess"
|
||||
|
||||
|
||||
+3
-3
@@ -54,11 +54,11 @@ void DetectPolychromeSMBusControllers(std::vector<i2c_smbus_interface*>& busses)
|
||||
{
|
||||
IF_MOBO_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
{
|
||||
LOG_TRACE("%s Bus %02d is an Motherboard, checking for for a device at 0x6A", ASROCK_DETECTOR_NAME, bus);
|
||||
LOG_TRACE("%s Bus %02d is a motherboard, checking for a device at 0x6A", ASROCK_DETECTOR_NAME, bus);
|
||||
// Check for Polychrome controller at 0x6A
|
||||
if (TestForPolychromeSMBusController(busses[bus], 0x6A))
|
||||
{
|
||||
LOG_TRACE("%s Detected a device at address 0x6A, Testing for a known controller", ASROCK_DETECTOR_NAME);
|
||||
LOG_TRACE("%s Detected a device at address 0x6A, testing for a known controller", ASROCK_DETECTOR_NAME);
|
||||
new_polychrome = new PolychromeController(busses[bus], 0x6A);
|
||||
|
||||
if(new_polychrome->GetASRockType() != ASROCK_TYPE_UNKNOWN)
|
||||
@@ -80,7 +80,7 @@ void DetectPolychromeSMBusControllers(std::vector<i2c_smbus_interface*>& busses)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_TRACE("%s Bus %02d not a Motherboard", ASROCK_DETECTOR_NAME, bus);
|
||||
LOG_TRACE("%s Bus %02d not a motherboard", ASROCK_DETECTOR_NAME, bus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -12,24 +12,44 @@
|
||||
|
||||
CMMKController::CMMKController(hid_device* dev, hid_device_info* dev_info)
|
||||
{
|
||||
location = dev_info->path;
|
||||
location = dev_info->path;
|
||||
|
||||
const int szTemp = 256;
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
device_name = std::string(wName.begin(), wName.end());
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
vendor_name = std::string(wName.begin(), wName.end());
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
device_name.append(" ").append(std::string(wName.begin(), wName.end()));
|
||||
device_name = std::string(wName.begin(), wName.end());
|
||||
|
||||
cmmk_attach_path(&cmmk_handle, dev_info->path, dev_info->product_id, -1);
|
||||
|
||||
char buf[32] = {0};
|
||||
cmmk_get_firmware_version(&cmmk_handle, buf, 32);
|
||||
|
||||
/*--------------------------------------------------------------*\
|
||||
| Adjust the row count for keyboards without the front light bar |
|
||||
| Adjust the column count for TKL keyboards (i.e. x30 vs x50) |
|
||||
\*--------------------------------------------------------------*/
|
||||
enum cmmk_product_type kb_type = cmmk_get_device_model(&cmmk_handle);
|
||||
row_count = (kb_type == CMMK_PRODUCT_MASTERKEYS_MK750) ? CMMK_ROWS_MAX : CMMK_ROWS_MAX - 1;
|
||||
switch(kb_type)
|
||||
{
|
||||
case CMMK_PRODUCT_MASTERKEYS_PRO_S:
|
||||
case CMMK_PRODUCT_MASTERKEYS_SK630:
|
||||
column_count = CMMK_COLS_MAX - 4;
|
||||
break;
|
||||
|
||||
case CMMK_PRODUCT_MASTERKEYS_PRO_L:
|
||||
case CMMK_PRODUCT_MASTERKEYS_MK750:
|
||||
case CMMK_PRODUCT_MASTERKEYS_SK650:
|
||||
default:
|
||||
column_count = CMMK_COLS_MAX;
|
||||
}
|
||||
|
||||
firmware_version = buf;
|
||||
}
|
||||
|
||||
@@ -43,6 +63,11 @@ std::string CMMKController::GetDeviceName()
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string CMMKController::GetDeviceVendor()
|
||||
{
|
||||
return vendor_name;
|
||||
}
|
||||
|
||||
std::string CMMKController::GetLocation()
|
||||
{
|
||||
return location;
|
||||
@@ -53,6 +78,16 @@ std::string CMMKController::GetFirmwareVersion()
|
||||
return firmware_version;
|
||||
}
|
||||
|
||||
uint8_t CMMKController::GetRowCount()
|
||||
{
|
||||
return row_count;
|
||||
}
|
||||
|
||||
uint8_t CMMKController::GetColumnCount()
|
||||
{
|
||||
return column_count;
|
||||
}
|
||||
|
||||
void CMMKController::SetFirmwareControl()
|
||||
{
|
||||
ActivateMode(CMMK_FIRMWARE);
|
||||
|
||||
@@ -20,8 +20,11 @@ public:
|
||||
~CMMKController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceVendor();
|
||||
std::string GetLocation();
|
||||
std::string GetFirmwareVersion();
|
||||
uint8_t GetRowCount();
|
||||
uint8_t GetColumnCount();
|
||||
|
||||
void SetFirmwareControl();
|
||||
void SetManualControl();
|
||||
@@ -51,8 +54,11 @@ private:
|
||||
int current_effect = -1;
|
||||
|
||||
std::string device_name;
|
||||
std::string vendor_name;
|
||||
std::string location;
|
||||
std::string firmware_version;
|
||||
uint8_t row_count;
|
||||
uint8_t column_count;
|
||||
|
||||
mutable struct cmmk cmmk_handle;
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@ RGBController_CMMKController::RGBController_CMMKController(CMMKController* cmmk_
|
||||
cmmk = cmmk_ctrl;
|
||||
|
||||
name = cmmk->GetDeviceName();
|
||||
vendor = cmmk->GetDeviceVendor();
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Cooler Master MasterKeys Device";
|
||||
version = cmmk->GetFirmwareVersion();
|
||||
@@ -198,9 +199,12 @@ void RGBController_CMMKController::SetupMatrixMap()
|
||||
|
||||
void RGBController_CMMKController::SetupZones()
|
||||
{
|
||||
for(int y = 0; y < CMMK_ROWS_MAX; y++)
|
||||
uint8_t row_count = cmmk->GetRowCount();
|
||||
uint8_t column_count = cmmk->GetColumnCount();
|
||||
|
||||
for(int y = 0; y < row_count; y++)
|
||||
{
|
||||
for(int x = 0; x < CMMK_COLS_MAX; x++)
|
||||
for(int x = 0; x < column_count; x++)
|
||||
{
|
||||
if(!cmmk->PositionValid(y, x))
|
||||
{
|
||||
@@ -227,8 +231,8 @@ void RGBController_CMMKController::SetupZones()
|
||||
KeyboardZone.leds_max = leds.size();
|
||||
KeyboardZone.leds_count = leds.size();
|
||||
KeyboardZone.matrix_map = new matrix_map_type;
|
||||
KeyboardZone.matrix_map->height = CMMK_ROWS_MAX;
|
||||
KeyboardZone.matrix_map->width = CMMK_COLS_MAX;
|
||||
KeyboardZone.matrix_map->height = row_count;
|
||||
KeyboardZone.matrix_map->width = column_count;
|
||||
KeyboardZone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
|
||||
zones.push_back(KeyboardZone);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "LogitechG810Controller.h"
|
||||
#include "LogitechG910Controller.h"
|
||||
#include "LogitechG815Controller.h"
|
||||
#include "LogitechG915Controller.h"
|
||||
#include "LogitechGLightsyncController.h"
|
||||
#include "LogitechLightspeedController.h"
|
||||
#include "LogitechX56Controller.h"
|
||||
@@ -19,6 +20,7 @@
|
||||
#include "RGBController_LogitechG810.h"
|
||||
#include "RGBController_LogitechG910.h"
|
||||
#include "RGBController_LogitechG815.h"
|
||||
#include "RGBController_LogitechG915.h"
|
||||
#include "RGBController_LogitechGLightsync.h"
|
||||
#include "RGBController_LogitechGLightsync1zone.h"
|
||||
#include "RGBController_LogitechLightspeed.h"
|
||||
@@ -49,6 +51,8 @@ using namespace std::chrono_literals;
|
||||
#define LOGITECH_G810_2_PID 0xC337
|
||||
#define LOGITECH_G813_PID 0xC232
|
||||
#define LOGITECH_G815_PID 0xC33F
|
||||
#define LOGITECH_G915_WIRED_PID 0xC33E
|
||||
#define LOGITECH_G915_RECEIVER_PID 0xC541
|
||||
#define LOGITECH_G910_ORION_SPARK_PID 0xC32B
|
||||
#define LOGITECH_G910_PID 0xC335
|
||||
|
||||
@@ -314,6 +318,32 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
|
||||
#endif
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardG915(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
LogitechG915Controller* controller = new LogitechG915Controller(dev, false);
|
||||
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardG915Wired(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
LogitechG915Controller* controller = new LogitechG915Controller(dev, true);
|
||||
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech Mice |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -525,44 +555,46 @@ void DetectLogitechX56(hid_device_info* info, const std::string& name)
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G213", DetectLogitechKeyboardG213, LOGITECH_VID, LOGITECH_G213_PID, 1, 0xFF43, 0x0602);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G512", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G512_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G512 RGB", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G512_RGB_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G610 Orion", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G610_1_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G610 Orion", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G610_2_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G810 Orion Spectrum", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G810_1_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G810 Orion Spectrum", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G810_2_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G813 RGB Mechanical Gaming Keyboard", DetectLogitechKeyboardG815, LOGITECH_VID, LOGITECH_G813_PID, 1, 0xFF43);
|
||||
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);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G203 Prodigy", DetectLogitechMouseG203, LOGITECH_VID, LOGITECH_G203_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G203 Lightsync", DetectLogitechMouseG203L, LOGITECH_VID, LOGITECH_G203_LIGHTSYNC_PID, 1, 0xFF00, 2);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G303 Daedalus Apex", DetectLogitechMouseG303, LOGITECH_VID, LOGITECH_G303_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G403 Hero", DetectLogitechMouseG403, LOGITECH_VID, LOGITECH_G403_HERO_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G502 Proteus Spectrum Gaming Mouse", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502_PROTEUS_SPECTRUM_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G502 Hero Gaming Mouse", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502_HERO_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G Pro Gaming Mouse", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_G_PRO_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G Pro (HERO) Gaming Mouse", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_G_PRO_HERO_PID, 1, 0xFF00);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Speakers |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G560 Lightsync Speaker", DetectLogitechG560, LOGITECH_VID, LOGITECH_G560_PID, 2, 0xFF43, 514);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Headsets |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G933 Lightsync Headset", DetectLogitechG933, LOGITECH_VID, LOGITECH_G933_PID, 3, 0xFF43, 514);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Joysticks |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IP("Logitech X56 Rhino Hotas Joystick", DetectLogitechX56, LOGITECH_X56_VID, LOGITECH_X56_JOYSTICK_PID, 2, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP("Logitech X56 Rhino Hotas Throttle", DetectLogitechX56, LOGITECH_X56_VID, LOGITECH_X56_THROTTLE_PID, 2, 0xFF00);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G213", DetectLogitechKeyboardG213, LOGITECH_VID, LOGITECH_G213_PID, 1, 0xFF43, 0x0602);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G512", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G512_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G512 RGB", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G512_RGB_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G610 Orion", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G610_1_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G610 Orion", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G610_2_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G810 Orion Spectrum", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G810_1_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G810 Orion Spectrum", DetectLogitechKeyboardG810, LOGITECH_VID, LOGITECH_G810_2_PID, 1, 0xFF43);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G813 RGB Mechanical Gaming Keyboard", DetectLogitechKeyboardG815, LOGITECH_VID, LOGITECH_G813_PID, 1, 0xFF43);
|
||||
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_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 |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G203 Prodigy", DetectLogitechMouseG203, LOGITECH_VID, LOGITECH_G203_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G203 Lightsync", DetectLogitechMouseG203L, LOGITECH_VID, LOGITECH_G203_LIGHTSYNC_PID, 1, 0xFF00, 2);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G303 Daedalus Apex", DetectLogitechMouseG303, LOGITECH_VID, LOGITECH_G303_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G403 Hero", DetectLogitechMouseG403, LOGITECH_VID, LOGITECH_G403_HERO_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G502 Proteus Spectrum Gaming Mouse", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502_PROTEUS_SPECTRUM_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G502 Hero Gaming Mouse", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502_HERO_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G Pro Gaming Mouse", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_G_PRO_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP ("Logitech G Pro (HERO) Gaming Mouse", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_G_PRO_HERO_PID, 1, 0xFF00);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Speakers |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G560 Lightsync Speaker", DetectLogitechG560, LOGITECH_VID, LOGITECH_G560_PID, 2, 0xFF43, 514);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Headsets |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IPU("Logitech G933 Lightsync Headset", DetectLogitechG933, LOGITECH_VID, LOGITECH_G933_PID, 3, 0xFF43, 514);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Joysticks |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IP("Logitech X56 Rhino Hotas Joystick", DetectLogitechX56, LOGITECH_X56_VID, LOGITECH_X56_JOYSTICK_PID, 2, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP("Logitech X56 Rhino Hotas Throttle", DetectLogitechX56, LOGITECH_X56_VID, LOGITECH_X56_THROTTLE_PID, 2, 0xFF00);
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
| Windows and MacOS Lightspeed Detection |
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG915Controller.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G915 |
|
||||
| RGB Mechanical Gaming Keyboard |
|
||||
| |
|
||||
| Cheerpipe 3/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "LogitechG915Controller.h"
|
||||
#include <cstring>
|
||||
|
||||
LogitechG915Controller::LogitechG915Controller(hid_device* dev_handle, bool wired)
|
||||
{
|
||||
this->dev_handle = dev_handle;
|
||||
|
||||
if(wired)
|
||||
{
|
||||
feature_4522_idx = 0x0E;
|
||||
feature_8040_idx = 0x13;
|
||||
feature_8071_idx = 0x09;
|
||||
feature_8081_idx = 0x0A;
|
||||
}
|
||||
else
|
||||
{
|
||||
feature_4522_idx = 0x0F;
|
||||
feature_8040_idx = 0x14;
|
||||
feature_8071_idx = 0x0A;
|
||||
feature_8081_idx = 0x0B;
|
||||
}
|
||||
}
|
||||
|
||||
LogitechG915Controller::~LogitechG915Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string LogitechG915Controller::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev_handle, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void LogitechG915Controller::Commit()
|
||||
{
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void LogitechG915Controller::SetDirect
|
||||
(
|
||||
unsigned char frame_type,
|
||||
unsigned char * frame_data
|
||||
)
|
||||
{
|
||||
SendDirectFrame(frame_type, frame_data);
|
||||
}
|
||||
|
||||
void LogitechG915Controller::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
SendMode(LOGITECH_G915_ZONE_MODE_KEYBOARD, mode, speed, red, green, blue);
|
||||
SendMode(LOGITECH_G915_ZONE_MODE_LOGO, mode, speed, red, green, blue);
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void LogitechG915Controller::SendCommit()
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_8081_idx;
|
||||
usb_buf[0x03] = LOGITECH_G915_COMMIT_BYTE;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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()
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_4522_idx;
|
||||
usb_buf[0x03] = 0x3E;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_4522_idx;
|
||||
usb_buf[0x03] = 0x1E;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_8071_idx;
|
||||
usb_buf[0x03] = 0x1E;
|
||||
usb_buf[0x10] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_8071_idx;
|
||||
usb_buf[0x03] = 0x1E;
|
||||
usb_buf[0x04] = 0x01;
|
||||
usb_buf[0x10] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
|
||||
void LogitechG915Controller::SendSingleLed
|
||||
(
|
||||
unsigned char keyCode,
|
||||
unsigned char r,
|
||||
unsigned char g,
|
||||
unsigned char b
|
||||
)
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up a 6F packet with a single color |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_8081_idx;
|
||||
usb_buf[0x03] = LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE;
|
||||
|
||||
usb_buf[0x04] = keyCode;
|
||||
|
||||
usb_buf[0x05] = r;
|
||||
usb_buf[0x06] = g;
|
||||
usb_buf[0x07] = b;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
|
||||
void LogitechG915Controller::SendDirectFrame
|
||||
(
|
||||
unsigned char frame_type,
|
||||
unsigned char * frame_data
|
||||
)
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_8081_idx;
|
||||
usb_buf[0x03] = frame_type;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in frame data |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x04], frame_data, 16);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0x01;
|
||||
usb_buf[0x02] = feature_8040_idx;
|
||||
usb_buf[0x03] = 0x3D; //TODO: Check if it is the correct value for G915
|
||||
usb_buf[0x04] = zone;
|
||||
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
usb_buf[0x06] = red;
|
||||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 100 * speed;
|
||||
|
||||
if(mode == LOGITECH_G915_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = speed >> 8;
|
||||
usb_buf[0x0C] = speed & 0xFF;
|
||||
usb_buf[0x0D] = 0x64;
|
||||
}
|
||||
else if(mode == LOGITECH_G915_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = speed >> 8;
|
||||
usb_buf[0x0A] = speed & 0xFF;
|
||||
usb_buf[0x0C] = 0x64;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev_handle, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG915Controller.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G915 |
|
||||
| RGB Mechanical Gaming Keyboard |
|
||||
| |
|
||||
| Cheerpipe 3/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define LOGITECH_G915_COMMIT_BYTE 0x7F
|
||||
#define LOGITECH_READ_TIMEOUT 300 //Timeout in ms
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G915_ZONE_MODE_KEYBOARD = 0x00,
|
||||
LOGITECH_G915_ZONE_MODE_LOGO = 0x01,
|
||||
LOGITECH_G915_ZONE_MODE_MULTIMEDIA = 0X02,
|
||||
LOGITECH_G915_ZONE_MODE_GKEYS = 0x03,
|
||||
LOGITECH_G915_ZONE_MODE_MODIFIERS = 0x04
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE = 0x1F,
|
||||
LOGITECH_G915_ZONE_FRAME_TYPE_BIG = 0x6F
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G915_ZONE_DIRECT_KEYBOARD = 0x01,
|
||||
LOGITECH_G915_ZONE_DIRECT_MEDIA = 0x02,
|
||||
LOGITECH_G915_ZONE_DIRECT_LOGO = 0x10,
|
||||
LOGITECH_G915_ZONE_DIRECT_INDICATORS = 0x40,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G915_MODE_OFF = 0x00,
|
||||
LOGITECH_G915_MODE_STATIC = 0x01,
|
||||
LOGITECH_G915_MODE_BREATHING = 0x02,
|
||||
LOGITECH_G915_MODE_CYCLE = 0x03,
|
||||
LOGITECH_G915_MODE_WAVE = 0x04,
|
||||
LOGITECH_G915_MODE_DIRECT = 0x05,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------------------------*\
|
||||
| Speed is 1000 for fast and 20000 for slow. |
|
||||
| Values are multiplied by 100 later to give lots of GUI steps. |
|
||||
\*---------------------------------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
LOGITECH_G915_SPEED_SLOWEST = 0xC8, /* Slowest speed */
|
||||
LOGITECH_G915_SPEED_NORMAL = 0x32, /* Normal speed */
|
||||
LOGITECH_G915_SPEED_FASTEST = 0x0A, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechG915Controller
|
||||
{
|
||||
public:
|
||||
LogitechG915Controller(hid_device* dev_handle, bool wired);
|
||||
~LogitechG915Controller();
|
||||
|
||||
std::string GetSerialString();
|
||||
void Commit();
|
||||
void InitializeDirect();
|
||||
void SetDirect
|
||||
(
|
||||
unsigned char frame_type,
|
||||
unsigned char * frame_data
|
||||
);
|
||||
void SendSingleLed
|
||||
(
|
||||
unsigned char keyCode,
|
||||
unsigned char r,
|
||||
unsigned char g,
|
||||
unsigned char b
|
||||
);
|
||||
void SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev_handle;
|
||||
char feature_4522_idx;
|
||||
char feature_8040_idx;
|
||||
char feature_8071_idx;
|
||||
char feature_8081_idx;
|
||||
|
||||
void SendDirectFrame
|
||||
(
|
||||
unsigned char frame_type,
|
||||
unsigned char * frame_data
|
||||
);
|
||||
|
||||
void SendMode
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
void SendCommit();
|
||||
};
|
||||
@@ -0,0 +1,526 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG915.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G915 |
|
||||
| RGB Mechanical Gaming Keyboard |
|
||||
| |
|
||||
| Cheerpipe 3/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG915.h"
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
||||
#define NA 0xFFFFFFFF
|
||||
const size_t max_key_per_color = 13;
|
||||
const size_t data_size = 16;
|
||||
|
||||
static unsigned int matrix_map[7][27] =
|
||||
{ { 110, NA, NA, NA, NA, NA, NA, NA, NA, NA, 111, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA },
|
||||
{ NA, NA, 37, NA, 54, 55, 56, 57, NA, 58, 59, 60, 61, NA, 62, 63, 64, 65, NA, 66, 67, 68, NA, 106, 107, 108, 109 },
|
||||
{ 112, NA, 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, NA, 41, 42, 38, NA, NA, 69, 70, 71, NA, 79, 80, 81, 82 },
|
||||
{ 113, NA, 39, NA, 16, 22, 4, 17, NA, 19, 24, 20, 8, 14, 15, 43, 44, 45, NA, 72, 73, 74, NA, 91, 92, 93, 83 },
|
||||
{ 114, NA, 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 46, 36, NA, NA, NA, NA, NA, 88, 89, 90, NA },
|
||||
{ 115, NA, 99, NA, 25, 23, 2, 21, NA, 1, NA, 13, 12, 50, 51, 52, 103, NA, NA, NA, 78, NA, NA, 85, 86, 87, 84 },
|
||||
{ 116, NA, 98, 101, 100, NA, NA, NA, NA, 40, NA, NA, NA, NA, 104, 105, 97, 102, NA, 76, 77, 75, NA, 94, NA, 95, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
117,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
const unsigned char zone;
|
||||
const unsigned char idx;
|
||||
} led_type;
|
||||
|
||||
static const led_type led_names[] =
|
||||
{
|
||||
/* Key Label Zone, Index */
|
||||
{ "Key: A", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x04 },
|
||||
{ "Key: B", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x05 },
|
||||
{ "Key: C", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x06 },
|
||||
{ "Key: D", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x07 },
|
||||
{ "Key: E", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x08 },
|
||||
{ "Key: F", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x09 },
|
||||
{ "Key: G", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x0A },
|
||||
{ "Key: H", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x0B },
|
||||
{ "Key: I", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x0C },
|
||||
{ "Key: J", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x0D },
|
||||
{ "Key: K", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x0E },
|
||||
{ "Key: L", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x0F },
|
||||
{ "Key: M", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x10 },
|
||||
{ "Key: N", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x11 },
|
||||
{ "Key: O", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x12 },
|
||||
{ "Key: P", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x13 },
|
||||
{ "Key: Q", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x14 },
|
||||
{ "Key: R", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x15 },
|
||||
{ "Key: S", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x16 },
|
||||
{ "Key: T", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x17 },
|
||||
{ "Key: U", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x18 },
|
||||
{ "Key: V", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x19 },
|
||||
{ "Key: W", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x1A },
|
||||
{ "Key: X", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x1B },
|
||||
{ "Key: Y", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x1C },
|
||||
{ "Key: Z", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x1D },
|
||||
{ "Key: 1", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x1E },
|
||||
{ "Key: 2", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x1F },
|
||||
{ "Key: 3", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x20 },
|
||||
{ "Key: 4", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x21 },
|
||||
{ "Key: 5", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x22 },
|
||||
{ "Key: 6", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x23 },
|
||||
{ "Key: 7", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x24 },
|
||||
{ "Key: 8", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x25 },
|
||||
{ "Key: 9", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x26 },
|
||||
{ "Key: 0", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x27 },
|
||||
{ "Key: Enter", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x28 },
|
||||
{ "Key: Escape", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x29 },
|
||||
{ "Key: Backspace", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x2A },
|
||||
{ "Key: Tab", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x2B },
|
||||
{ "Key: Space", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x2C },
|
||||
{ "Key: -", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x2D },
|
||||
{ "Key: =", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x2E },
|
||||
{ "Key: [", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x2F },
|
||||
{ "Key: ]", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x30 },
|
||||
{ "Key: \\ (ANSI)", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x31 },//ANSI only
|
||||
{ "Key: #", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x32 },//ISO only
|
||||
{ "Key: ;", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x33 },
|
||||
{ "Key: '", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x34 },
|
||||
{ "Key: `", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x35 },
|
||||
{ "Key: ,", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x36 },
|
||||
{ "Key: .", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x37 },
|
||||
{ "Key: /", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x38 },
|
||||
{ "Key: Caps Lock", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x39 },
|
||||
{ "Key: F1", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x3A },
|
||||
{ "Key: F2", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x3B },
|
||||
{ "Key: F3", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x3C },
|
||||
{ "Key: F4", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x3D },
|
||||
{ "Key: F5", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x3E },
|
||||
{ "Key: F6", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x3F },
|
||||
{ "Key: F7", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x40 },
|
||||
{ "Key: F8", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x41 },
|
||||
{ "Key: F9", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x42 },
|
||||
{ "Key: F10", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x43 },
|
||||
{ "Key: F11", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x44 },
|
||||
{ "Key: F12", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x45 },
|
||||
{ "Key: Print Screen", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x46 },
|
||||
{ "Key: Scroll Lock", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x47 },
|
||||
{ "Key: Pause/Break", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x48 },
|
||||
{ "Key: Insert", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x49 },
|
||||
{ "Key: Home", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x4A },
|
||||
{ "Key: Page Up", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x4B },
|
||||
{ "Key: Delete", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x4C },
|
||||
{ "Key: End", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x4D },
|
||||
{ "Key: Page Down", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x4E },
|
||||
{ "Key: Right Arrow", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x4F },
|
||||
{ "Key: Left Arrow", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x50 },
|
||||
{ "Key: Down Arrow", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x51 },
|
||||
{ "Key: Up Arrow", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x52 },
|
||||
{ "Key: Num Lock", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x53 },
|
||||
{ "Key: Number Pad /", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x54 },
|
||||
{ "Key: Number Pad *", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x55 },
|
||||
{ "Key: Number Pad -", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x56 },
|
||||
{ "Key: Number Pad +", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x57 },
|
||||
{ "Key: Number Pad Enter", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x58 },
|
||||
{ "Key: Number Pad 1", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x59 },
|
||||
{ "Key: Number Pad 2", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x5A },
|
||||
{ "Key: Number Pad 3", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x5B },
|
||||
{ "Key: Number Pad 4", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x5C },
|
||||
{ "Key: Number Pad 5", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x5D },
|
||||
{ "Key: Number Pad 6", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x5E },
|
||||
{ "Key: Number Pad 7", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x5F },
|
||||
{ "Key: Number Pad 8", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x60 },
|
||||
{ "Key: Number Pad 9", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x61 },
|
||||
{ "Key: Number Pad 0", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x62 },
|
||||
{ "Key: Number Pad .", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x63 },
|
||||
{ "Key: \\ (ISO)", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x64 },//ISO only
|
||||
{ "Key: Menu", LOGITECH_G915_ZONE_DIRECT_KEYBOARD, 0x65 },
|
||||
{ "Key: Left Control", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE0 },
|
||||
{ "Key: Left Shift", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE1 },
|
||||
{ "Key: Left Alt", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE2 },
|
||||
{ "Key: Left Windows", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE3 },
|
||||
{ "Key: Right Control", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE4 },
|
||||
{ "Key: Right Shift", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE5 },
|
||||
{ "Key: Right Alt", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE6 },
|
||||
{ "Key: Right Windows", LOGITECH_G915_ZONE_MODE_MODIFIERS, 0xE7 },
|
||||
{ "Key: Media Previous", LOGITECH_G915_ZONE_DIRECT_MEDIA, 0x9E },
|
||||
{ "Key: Media Play/Pause", LOGITECH_G915_ZONE_DIRECT_MEDIA, 0x9B },
|
||||
{ "Key: Media Next", LOGITECH_G915_ZONE_DIRECT_MEDIA, 0x9D },
|
||||
{ "Key: Media Mute", LOGITECH_G915_ZONE_DIRECT_MEDIA, 0x9C },
|
||||
{ "Logo", LOGITECH_G915_ZONE_DIRECT_LOGO, 0x01 },
|
||||
{ "Lighting", LOGITECH_G915_ZONE_DIRECT_INDICATORS, 0x99 },
|
||||
{ "Key: G1", LOGITECH_G915_ZONE_MODE_GKEYS, 0x01 },
|
||||
{ "Key: G2", LOGITECH_G915_ZONE_MODE_GKEYS, 0x02 },
|
||||
{ "Key: G3", LOGITECH_G915_ZONE_MODE_GKEYS, 0x03 },
|
||||
{ "Key: G4", LOGITECH_G915_ZONE_MODE_GKEYS, 0x04 },
|
||||
{ "Key: G5", LOGITECH_G915_ZONE_MODE_GKEYS, 0x05 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG915::RGBController_LogitechG915(LogitechG915Controller* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech G915 Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech G915 Keyboard Device";
|
||||
serial = logitech->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = LOGITECH_G915_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G915_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G915_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G915_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G915_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G915_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G915_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G915_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = LOGITECH_G915_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G915_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G915_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
std::copy(colors.begin(), colors.end(),std::back_inserter(current_colors));
|
||||
}
|
||||
|
||||
RGBController_LogitechG915::~RGBController_LogitechG915()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 27;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::DeviceUpdateLEDs()
|
||||
{
|
||||
std::map<RGBColor, std::vector<char>> ledsByColors;
|
||||
std::vector<RGBColor> new_colors;
|
||||
unsigned char zone = 0;
|
||||
unsigned char idx = 0;
|
||||
unsigned char frame_buffer_big_mode[data_size];
|
||||
unsigned char frame_buffer_little_mode[data_size];
|
||||
RGBColor colorkey;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Freeze colors array because prepare framebuffers |
|
||||
| may take some time. |
|
||||
\*---------------------------------------------------------*/
|
||||
std::copy(colors.begin(), colors.end(),std::back_inserter(new_colors));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get unique colors to create mode 1F and 6F frame_buffers |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
zone = ( leds[led_idx].value >> 8 );
|
||||
idx = ( leds[led_idx].value );
|
||||
|
||||
if (current_colors[led_idx]==new_colors[led_idx])
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Don't send if key color is not changed |
|
||||
\*-------------------------------------------------*/
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (zone)
|
||||
{
|
||||
case LOGITECH_G915_ZONE_MODE_GKEYS:
|
||||
idx = ((idx & 0x00ff) + 0xb3);
|
||||
break;
|
||||
|
||||
case LOGITECH_G915_ZONE_MODE_MODIFIERS:
|
||||
idx = ((idx & 0x00ff) - 0x78);
|
||||
break;
|
||||
|
||||
case LOGITECH_G915_ZONE_DIRECT_KEYBOARD:
|
||||
idx = ((idx & 0x00ff) - 0x03);
|
||||
break;
|
||||
|
||||
case LOGITECH_G915_ZONE_DIRECT_LOGO:
|
||||
idx = ((idx & 0x00ff) + 0xd1);
|
||||
break;
|
||||
|
||||
default:
|
||||
idx = (idx & 0x00ff);
|
||||
break;
|
||||
}
|
||||
|
||||
colorkey = new_colors[led_idx];
|
||||
|
||||
if (ledsByColors.count(colorkey) == 0)
|
||||
{
|
||||
ledsByColors.insert(std::pair<RGBColor, std::vector<char>>(colorkey, {}));
|
||||
}
|
||||
|
||||
ledsByColors[colorkey].push_back(idx);
|
||||
}
|
||||
|
||||
uint8_t led_in_little_frame = 0;
|
||||
uint8_t bi = 0;
|
||||
size_t frame_pos = 3;
|
||||
uint8_t li = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create frame_buffers of type 1F (Little, up to 4 leds |
|
||||
| per packet) and 6F (big, up to 13 leds per packet). |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::pair<const RGBColor, std::vector<char>>& x: ledsByColors)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| For colors with more than 4 keys. Better to use big |
|
||||
| (6F) packets to save USB transfers. |
|
||||
\*-----------------------------------------------------*/
|
||||
if(x.second.size() > 4)
|
||||
{
|
||||
bi = 0;
|
||||
|
||||
while(bi < x.second.size())
|
||||
{
|
||||
frame_buffer_big_mode[0] = RGBGetRValue(x.first);
|
||||
frame_buffer_big_mode[1] = RGBGetGValue(x.first);
|
||||
frame_buffer_big_mode[2] = RGBGetBValue(x.first);
|
||||
frame_pos = 3;
|
||||
|
||||
for(uint8_t i = 0; i < max_key_per_color; i++)
|
||||
{
|
||||
if(bi + i < x.second.size())
|
||||
{
|
||||
frame_buffer_big_mode[frame_pos] = x.second[bi+i];
|
||||
frame_pos++;
|
||||
}
|
||||
}
|
||||
|
||||
if (frame_pos < data_size)
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| Zeroing just what is needed and if needed |
|
||||
\*-----------------------------------------*/
|
||||
memset(frame_buffer_big_mode + frame_pos, 0x00, sizeof(frame_buffer_big_mode) - frame_pos);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| End of Data byte |
|
||||
\*-----------------------------------------*/
|
||||
frame_buffer_big_mode[frame_pos] = 0xFF;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zeroing just what is needed |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_BIG, frame_buffer_big_mode);
|
||||
bi = bi + max_key_per_color;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| For colors with up to 4 keys. Use 1F packet to send |
|
||||
| up to 4 colors-keys combinations per packet. |
|
||||
\*-----------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
li = 0;
|
||||
|
||||
while(li < x.second.size())
|
||||
{
|
||||
frame_buffer_little_mode[led_in_little_frame*4 + 0] = x.second[li];
|
||||
frame_buffer_little_mode[led_in_little_frame*4 + 1] = RGBGetRValue(x.first);
|
||||
frame_buffer_little_mode[led_in_little_frame*4 + 2] = RGBGetGValue(x.first);
|
||||
frame_buffer_little_mode[led_in_little_frame*4 + 3] = RGBGetBValue(x.first);
|
||||
li++;
|
||||
led_in_little_frame++;
|
||||
|
||||
if (led_in_little_frame == 4)
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| No End of Data byte if the packet is full |
|
||||
\*-----------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
led_in_little_frame=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If there is a left 1F packet with less than 4 keys, send |
|
||||
| it and add an End of Data byte. |
|
||||
\*---------------------------------------------------------*/
|
||||
if(led_in_little_frame > 0)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Zeroing just what is needed |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(frame_buffer_little_mode + (led_in_little_frame * 4 + 1), 0x00, sizeof(frame_buffer_little_mode) - led_in_little_frame * 4);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Data byte |
|
||||
\*-----------------------------------------------------*/
|
||||
frame_buffer_little_mode[led_in_little_frame*4 + 0] = 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send little frame and clear little frame buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
}
|
||||
if(ledsByColors.size() > 0)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the current color vector to avoid set keys that |
|
||||
| has not being |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->Commit();
|
||||
std::copy(new_colors.begin(), new_colors.end(),current_colors.begin());
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::DeviceUpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Direct mode does not send a mode packet |
|
||||
| Call UpdateLEDs to send direct packet |
|
||||
\*---------------------------------------------------------*/
|
||||
if(modes[active_mode].value == LOGITECH_G915_MODE_DIRECT)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Send real direct mode initialization. I used same |
|
||||
| sequence as GHUB for screen capture. |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->InitializeDirect();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set one key to get direct mode engaged. |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SendSingleLed(0x29,0,0,0);
|
||||
logitech->Commit();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG915.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G915 |
|
||||
| RGB Mechanical Gaming Keyboard |
|
||||
| |
|
||||
| Cheerpipe 3/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG915Controller.h"
|
||||
|
||||
class RGBController_LogitechG915 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG915(LogitechG915Controller* logitech_ptr);
|
||||
~RGBController_LogitechG915();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG915Controller* logitech;
|
||||
std::vector<RGBColor> current_colors;
|
||||
};
|
||||
@@ -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 ¤t_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 ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode
|
||||
unsigned int color_mode,
|
||||
bool save
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
|
||||
@@ -93,14 +93,20 @@ void DetectRazerARGBControllers(hid_device_info* info, const std::string& name)
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Razer's ARGB controller uses two different interfaces, one for 90-byte Razer report packets and |
|
||||
| one for 320-byte ARGB packets. Interface 0 for 90-byte and interface 1 for 320-byte. |
|
||||
| |
|
||||
| Create a local copy of the HID enumerations for the Razer ARGB controller VID/PID and iterate |
|
||||
| through it. This prevents detection from failing if interface 1 comes before interface 0 in the |
|
||||
| main info list. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
hid_device* dev_interface_0 = nullptr;
|
||||
hid_device* dev_interface_1 = nullptr;
|
||||
hid_device_info* info_temp = info;
|
||||
hid_device_info* info_full = hid_enumerate(RAZER_VID, RAZER_CHROMA_ADDRESSABLE_RGB_CONTROLLER_PID);
|
||||
hid_device_info* info_temp = info_full;
|
||||
|
||||
while(info_temp)
|
||||
{
|
||||
if(info_temp->vendor_id == info->vendor_id // constant LOGITECH_VID
|
||||
&& info_temp->product_id == info->product_id ) // NON-constant
|
||||
if(info_temp->vendor_id == info->vendor_id
|
||||
&& info_temp->product_id == info->product_id )
|
||||
{
|
||||
if(info_temp->interface_number == 0)
|
||||
{
|
||||
@@ -117,6 +123,9 @@ void DetectRazerARGBControllers(hid_device_info* info, const std::string& name)
|
||||
}
|
||||
info_temp = info_temp->next;
|
||||
}
|
||||
|
||||
hid_free_enumeration(info_full);
|
||||
|
||||
if(dev_interface_0 && dev_interface_1)
|
||||
{
|
||||
RazerController* controller = new RazerController(dev_interface_0, dev_interface_1, info->path, info->product_id, name);
|
||||
|
||||
@@ -0,0 +1,465 @@
|
||||
/*------------------------------------------*\
|
||||
| RGBController_SinowealthKeyboard16.cpp |
|
||||
| |
|
||||
| Definitions and types for Sinowealth |
|
||||
| Keyboard with PID:0016, |
|
||||
| Hopefully generic for this PID, |
|
||||
| this was made spefically for ZUOYA X51 |
|
||||
| |
|
||||
| Zagorodnikov Aleksey (glooom) 26.07.2021 |
|
||||
| based on initial implementation from |
|
||||
| Dmitri Kalinichenko (Dima-Kal) 23/06/2021 |
|
||||
\*-----------------------------------------=*/
|
||||
|
||||
#include "RGBController_SinowealthKeyboard16.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
using namespace kbd16;
|
||||
|
||||
static unsigned int matrix_map[6][22] =
|
||||
{ { 0, NA, 2, 3, 4, 5, NA, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, NA, NA, NA, NA },
|
||||
{ 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, NA, 36, 37, 38, 39, 40, 41, 42, 43 },
|
||||
{ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, NA, 59, 60, 61, 62, 63, 64, 65 },
|
||||
{ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, NA, 79, NA, NA, NA, NA, 84, 85, 86, 87 },
|
||||
{ 88, NA, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, NA, NA, 102, NA, 104, NA, 106, 107, 108, 109 },
|
||||
{ 110, 111, 112, NA, NA, 115, NA, NA, 118, 119, 120, NA, 122, NA, NA, 125, 126, 127, 128, 129, 130, 131 }
|
||||
};
|
||||
|
||||
static const char *led_names_tkl[] =
|
||||
{
|
||||
"Key: Escape",
|
||||
"",
|
||||
"Key: F1",
|
||||
"Key: F2",
|
||||
"Key: F3",
|
||||
"Key: F4",
|
||||
"",
|
||||
"Key: F5",
|
||||
"Key: F6",
|
||||
"Key: F7",
|
||||
"Key: F8",
|
||||
"Key: F9",
|
||||
"Key: F10",
|
||||
"Key: F11",
|
||||
"Key: F12",
|
||||
"Key: Print Screen",
|
||||
"Key: Scroll Lock",
|
||||
"Key: Pause/Break",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
|
||||
"Key: `",
|
||||
"Key: 1",
|
||||
"Key: 2",
|
||||
"Key: 3",
|
||||
"Key: 4",
|
||||
"Key: 5",
|
||||
"Key: 6",
|
||||
"Key: 7",
|
||||
"Key: 8",
|
||||
"Key: 9",
|
||||
"Key: 0",
|
||||
"Key: -",
|
||||
"Key: =",
|
||||
"Undefined",
|
||||
"Key: Backspace",
|
||||
"Key: Insert",
|
||||
"Key: Home",
|
||||
"Key: Page Up",
|
||||
"Key: Num Lock",
|
||||
"Key: Number Pad /",
|
||||
"Key: Number Pad *",
|
||||
"Key: Number Pad -",
|
||||
|
||||
"Key: Tab",
|
||||
"Key: Q",
|
||||
"Key: W",
|
||||
"Key: E",
|
||||
"Key: R",
|
||||
"Key: T",
|
||||
"Key: Y",
|
||||
"Key: U",
|
||||
"Key: I",
|
||||
"Key: O",
|
||||
"Key: P",
|
||||
"Key: [",
|
||||
"Key: ]",
|
||||
"Key: \\ (ANSI)",
|
||||
"",
|
||||
"Key: Delete",
|
||||
"Key: End",
|
||||
"Key: Page Down",
|
||||
"Key: Number Pad 7",
|
||||
"Key: Number Pad 8",
|
||||
"Key: Number Pad 9",
|
||||
"Key: Number Pad +",
|
||||
|
||||
"Key: Caps Lock",
|
||||
"Key: A",
|
||||
"Key: S",
|
||||
"Key: D",
|
||||
"Key: F",
|
||||
"Key: G",
|
||||
"Key: H",
|
||||
"Key: J",
|
||||
"Key: K",
|
||||
"Key: L",
|
||||
"Key: ;",
|
||||
"Key: '",
|
||||
"",
|
||||
"Key: Enter",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Key: Number Pad 4",
|
||||
"Key: Number Pad 5",
|
||||
"Key: Number Pad 6",
|
||||
"Key: Number Pad +",
|
||||
|
||||
"Key: Left Shift",
|
||||
"",
|
||||
"Key: Z",
|
||||
"Key: X",
|
||||
"Key: C",
|
||||
"Key: V",
|
||||
"Key: B",
|
||||
"Key: N",
|
||||
"Key: M",
|
||||
"Key: ,",
|
||||
"Key: .",
|
||||
"Key: /",
|
||||
"",
|
||||
"",
|
||||
"Key: Right Shift",
|
||||
"",
|
||||
"Key: Up Arrow",
|
||||
"",
|
||||
"Key: Number Pad 1",
|
||||
"Key: Number Pad 2",
|
||||
"Key: Number Pad 3",
|
||||
"Key: Number Pad Enter",
|
||||
|
||||
"Key: Left Control",
|
||||
"Key: Left Windows",
|
||||
"Key: Left Alt",
|
||||
"",
|
||||
"",
|
||||
"Key: Space",
|
||||
"","",
|
||||
"Key: Right Alt",
|
||||
"Key: Right Fn",
|
||||
"Key: Right Windows",
|
||||
"",
|
||||
"Key: Right Control",
|
||||
"",
|
||||
"",
|
||||
"Key: Left Arrow",
|
||||
"Key: Down Arrow",
|
||||
"Key: Right Arrow",
|
||||
"Key: Number Pad 0",
|
||||
"Key: Number Pad 0",
|
||||
"Key: Number Pad .",
|
||||
"Key: Number Pad Enter"
|
||||
};
|
||||
|
||||
RGBController_SinowealthKeyboard16::RGBController_SinowealthKeyboard16(SinowealthKeyboard16Controller* sinowealth_ptr)
|
||||
{
|
||||
sinowealth = sinowealth_ptr;
|
||||
|
||||
name = "Sinowealth Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Generic Sinowealth Keyboard";
|
||||
location = sinowealth->GetLocation();
|
||||
serial = sinowealth->GetSerialString();
|
||||
|
||||
std::vector<ModeCfg> modes_cfg = sinowealth->GetDeviceModes();
|
||||
std::vector<ModeColorCfg> color_presets = sinowealth->GetDeviceColors();
|
||||
|
||||
int mode_id = 0;
|
||||
|
||||
for(const ModeCfg &cfg : modes_cfg)
|
||||
{
|
||||
mode Mode = getModeItem(mode_id);
|
||||
|
||||
Mode.brightness = cfg.brightness;
|
||||
Mode.speed = cfg.speed;
|
||||
Mode.direction = cfg.direction_left;
|
||||
|
||||
if(cfg.color == COLOR_PRESET_RANDOM)
|
||||
{
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
Mode.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
}
|
||||
|
||||
ModeColorCfg mode_color = color_presets[mode_id];
|
||||
|
||||
for(unsigned int i = Mode.colors_min; i < Mode.colors_max; i++)
|
||||
{
|
||||
RGBColor color = (mode_color.preset[i].blue << 16) | (mode_color.preset[i].green << 8) | (mode_color.preset[i].red);
|
||||
Mode.colors.push_back(color);
|
||||
}
|
||||
|
||||
modes.push_back(Mode);
|
||||
mode_id++;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| This keyboard supports 5 configurable custom profiles. |
|
||||
| The first one is named "Custom" and the others are "Custom 2" to |
|
||||
| "Custom 5". Leaving the first one just "Custom" to adhere to |
|
||||
| common mode names scheme. |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for(unsigned int i = 0; i < 5; i++)
|
||||
{
|
||||
mode PerLed;
|
||||
|
||||
PerLed.name = "Custom";
|
||||
|
||||
if(i > 0)
|
||||
{
|
||||
PerLed.name += " " + std::to_string(i + 1);
|
||||
}
|
||||
|
||||
PerLed.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
PerLed.color_mode = MODE_COLORS_PER_LED;
|
||||
PerLed.value = MODE_PER_KEY1+i;
|
||||
|
||||
modes.push_back(PerLed);
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
|
||||
int device_mode = sinowealth->GetCurrentMode();
|
||||
|
||||
if(device_mode >= MODE_PER_KEY1)
|
||||
{
|
||||
device_mode = mode_id+(device_mode & 0x0F);
|
||||
colors = sinowealth->GetPerLedColors();
|
||||
}
|
||||
|
||||
active_mode = device_mode;
|
||||
}
|
||||
|
||||
RGBController_SinowealthKeyboard16::~RGBController_SinowealthKeyboard16()
|
||||
{
|
||||
delete sinowealth;
|
||||
}
|
||||
|
||||
mode RGBController_SinowealthKeyboard16::getModeItem(unsigned int mode_id)
|
||||
{
|
||||
mode Mode;
|
||||
|
||||
Mode.value = mode_id;
|
||||
Mode.brightness_min = BRIGHTNESS_OFF;
|
||||
Mode.brightness_max = BRIGHTNESS_FULL;
|
||||
Mode.speed_min = SPEED_SLOW;
|
||||
Mode.speed_max = SPEED_FASTEST;
|
||||
Mode.colors_min = 0;
|
||||
Mode.colors_max = COLOR_PRESETS_IN_MODE;
|
||||
|
||||
switch(mode_id)
|
||||
{
|
||||
case 0:
|
||||
Mode.name = "Off";
|
||||
Mode.flags = 0;
|
||||
Mode.color_mode = MODE_COLORS_NONE;
|
||||
break;
|
||||
case 1:
|
||||
Mode.name = "Spectrum Cycle";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Mode.color_mode = MODE_COLORS_NONE;
|
||||
break;
|
||||
case 2:
|
||||
Mode.name = "Breathing";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 3:
|
||||
Mode.name = "Static";
|
||||
Mode.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 4:
|
||||
Mode.name = "Ripples Shining";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 5:
|
||||
Mode.name = "Reactive";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 6:
|
||||
Mode.name = "Flash Away";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 7:
|
||||
Mode.name = "Sine Wave";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 8:
|
||||
Mode.name = "Raindrops";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 9:
|
||||
Mode.name = "Rainbow Wave";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 10:
|
||||
Mode.name = "Rainbow Wheel";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 11:
|
||||
Mode.name = "Adorn";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 12:
|
||||
Mode.name = "Stars Twinkle";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 13:
|
||||
Mode.name = "Shadow Disappear";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
case 14:
|
||||
Mode.name = "Retro Snake";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
default:
|
||||
Mode.name = "Unknown Mode";
|
||||
Mode.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Mode.color_mode = MODE_COLORS_RANDOM;
|
||||
break;
|
||||
}
|
||||
|
||||
return Mode;
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Keyboard";
|
||||
new_zone.type = ZONE_TYPE_MATRIX;
|
||||
new_zone.leds_count = sinowealth->GetLEDCount();
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 6;
|
||||
new_zone.matrix_map->width = 22;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int led_idx = 0; led_idx < new_zone.leds_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names_tkl[led_idx];
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::DeviceUpdateLEDs()
|
||||
{
|
||||
sinowealth->SetLEDsDirect(colors);
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::SetCustomMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Search the mode list and find Custom mode |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int mode_idx = 0; mode_idx < modes.size(); mode_idx++)
|
||||
{
|
||||
if(modes[mode_idx].name == "Custom")
|
||||
{
|
||||
active_mode = mode_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::DeviceUpdateMode()
|
||||
{
|
||||
mode ActiveMode = modes[active_mode];
|
||||
|
||||
int color_mode;
|
||||
|
||||
if(ActiveMode.color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
color_mode = COLOR_PRESET_0;
|
||||
}
|
||||
else
|
||||
{
|
||||
color_mode = COLOR_PRESET_RANDOM;
|
||||
}
|
||||
|
||||
sinowealth->ClearMode();
|
||||
|
||||
if(ActiveMode.colors.size())
|
||||
{
|
||||
sinowealth->SetColorsForMode(ActiveMode.value, &ActiveMode.colors[0]);
|
||||
}
|
||||
|
||||
sinowealth->SetMode(ActiveMode.value, ActiveMode.brightness, ActiveMode.speed, ActiveMode.direction, color_mode);
|
||||
|
||||
if(ActiveMode.value >= MODE_PER_KEY1)
|
||||
{
|
||||
colors = sinowealth->GetPerLedColors();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(color_mode == COLOR_PRESET_RANDOM)
|
||||
{
|
||||
std::generate(colors.begin(), colors.end(), std::rand);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::fill(colors.begin(), colors.end(), ActiveMode.colors[0]);
|
||||
}
|
||||
}
|
||||
|
||||
SignalUpdate();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*------------------------------------------*\
|
||||
| RGBController_SinowealthKeyboard16.h |
|
||||
| |
|
||||
| Definitions and types for Sinowealth |
|
||||
| Keyboard with PID:0016, |
|
||||
| Hopefully generic for this PID, |
|
||||
| this was made spefically for ZUOYA X51 |
|
||||
| |
|
||||
| Zagorodnikov Aleksey (glooom) 26.07.2021 |
|
||||
| based on initial implementation from |
|
||||
| Dmitri Kalinichenko (Dima-Kal) 23/06/2021 |
|
||||
\*-----------------------------------------=*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "SinowealthKeyboard16Controller.h"
|
||||
|
||||
class RGBController_SinowealthKeyboard16 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_SinowealthKeyboard16(SinowealthKeyboard16Controller* sinowealth_ptr);
|
||||
~RGBController_SinowealthKeyboard16();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
SinowealthKeyboard16Controller* sinowealth;
|
||||
|
||||
mode getModeItem(unsigned int mode_id);
|
||||
};
|
||||
@@ -1,10 +1,13 @@
|
||||
#include "Detector.h"
|
||||
#include "SinowealthController.h"
|
||||
#include "SinowealthKeyboardController.h"
|
||||
#include "SinowealthKeyboard16Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Sinowealth.h"
|
||||
#include "RGBController_SinowealthKeyboard.h"
|
||||
#include "RGBController_SinowealthKeyboard16.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
#include "LogManager.h"
|
||||
|
||||
#define SINOWEALTH_VID 0x258A
|
||||
|
||||
@@ -12,6 +15,7 @@
|
||||
#define Glorious_Model_D_PID 0x0033
|
||||
#define Everest_GT100_PID 0x0029
|
||||
#define Fl_Esports_F11_PID 0x0049
|
||||
#define RGB_KEYBOARD_0016PID 0x0016
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -93,7 +97,55 @@ void DetectSinowealthMouse(hid_device_info* info, const std::string& name)
|
||||
#endif
|
||||
}
|
||||
|
||||
void DetectSinowealthKeyboard(hid_device_info* info, const std::string& name)
|
||||
bool DetectCmdAndDataUsages(hid_device* usages[], int usage_count, std::string name, hid_device** dev_cmd, hid_device** dev_data)
|
||||
{
|
||||
unsigned char tmp_buf[1032];
|
||||
|
||||
// Try to find which device allow us to send ReportID 0x05
|
||||
for(int i = 0; i < usage_count; i++)
|
||||
{
|
||||
memset(tmp_buf, 0x00, sizeof(tmp_buf));
|
||||
tmp_buf[0] = 0x05;
|
||||
tmp_buf[1] = 0x83;
|
||||
|
||||
if(hid_send_feature_report(usages[i], tmp_buf, 6) != -1)
|
||||
{
|
||||
*dev_cmd = usages[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(*dev_cmd == nullptr)
|
||||
{
|
||||
LOG_ERROR("[%s] Can't find working hid_device for ReportId 0x05", name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try other devices for support ReportID 0x06
|
||||
for(int i = 0; i < usage_count; i++)
|
||||
{
|
||||
if(usages[i] == *dev_cmd)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
memset(tmp_buf, 0x00, sizeof(tmp_buf));
|
||||
tmp_buf[0] = 0x06;
|
||||
if(hid_get_feature_report(usages[i], tmp_buf, 1032) != -1)
|
||||
{
|
||||
*dev_data = usages[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(*dev_data == nullptr)
|
||||
{
|
||||
LOG_ERROR("[%s] Can't find working hid_device for ReportId 0x06", name.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DetectSinowealthKeyboard(hid_device_info* info, const std::string& name, unsigned int pid)
|
||||
{
|
||||
#ifdef USE_HID_USAGE
|
||||
hid_device* usages[3];
|
||||
@@ -102,8 +154,24 @@ void DetectSinowealthKeyboard(hid_device_info* info, const std::string& name)
|
||||
|
||||
if(usage_count == 3)
|
||||
{
|
||||
SinowealthKeyboardController* controller = new SinowealthKeyboardController(usages[1], usages[2], info->path);
|
||||
RGBController_SinowealthKeyboard* rgb_controller = new RGBController_SinowealthKeyboard(controller);
|
||||
RGBController *rgb_controller;
|
||||
if(pid == RGB_KEYBOARD_0016PID)
|
||||
{
|
||||
hid_device* dev_cmd = nullptr;
|
||||
hid_device* dev_data = nullptr;
|
||||
if(!DetectCmdAndDataUsages(usages, usage_count, name, &dev_cmd, &dev_data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SinowealthKeyboard16Controller* controller = new SinowealthKeyboard16Controller(dev_cmd, dev_data, info->path, name);
|
||||
rgb_controller = new RGBController_SinowealthKeyboard16(controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
SinowealthKeyboardController* controller = new SinowealthKeyboardController(usages[1], usages[2], info->path);
|
||||
rgb_controller = new RGBController_SinowealthKeyboard(controller);
|
||||
}
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
@@ -121,23 +189,45 @@ void DetectSinowealthKeyboard(hid_device_info* info, const std::string& name)
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
SinowealthController* controller = new SinowealthController(dev, dev, info->path);
|
||||
RGBController_Sinowealth* rgb_controller = new RGBController_Sinowealth(controller);
|
||||
RGBController *rgb_controller;
|
||||
|
||||
if(pid == RGB_KEYBOARD_0016PID)
|
||||
{
|
||||
SinowealthKeyboard16Controller* controller = new SinowealthKeyboard16Controller(dev, dev, info->path, name);
|
||||
rgb_controller = new RGBController_SinowealthKeyboard16(controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
SinowealthController* controller = new SinowealthController(dev, dev, info->path);
|
||||
rgb_controller = new RGBController_Sinowealth(controller);
|
||||
}
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DetectSinowealthKeyboard49(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
DetectSinowealthKeyboard(info, name, Fl_Esports_F11_PID);
|
||||
}
|
||||
|
||||
void DetectSinowealthKeyboard16(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
DetectSinowealthKeyboard(info, name, RGB_KEYBOARD_0016PID);
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_HID_USAGE
|
||||
REGISTER_HID_DETECTOR_P("Glorious Model O / O-", DetectSinowealthMouse, SINOWEALTH_VID, Glorious_Model_O_PID, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_P("Glorious Model D / D-", DetectSinowealthMouse, SINOWEALTH_VID, Glorious_Model_D_PID, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_P("Everest GT-100 RGB", DetectSinowealthMouse, SINOWEALTH_VID, Everest_GT100_PID, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_P("FL ESPORTS F11", DetectSinowealthKeyboard, SINOWEALTH_VID, Fl_Esports_F11_PID, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_P("FL ESPORTS F11", DetectSinowealthKeyboard49, SINOWEALTH_VID, Fl_Esports_F11_PID, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_P("Sinowealth Keyboard", DetectSinowealthKeyboard16, SINOWEALTH_VID, RGB_KEYBOARD_0016PID, 0xFF00);
|
||||
#else
|
||||
REGISTER_HID_DETECTOR_I("Glorious Model O / O-", DetectSinowealthMouse, SINOWEALTH_VID, Glorious_Model_O_PID, 1);
|
||||
REGISTER_HID_DETECTOR_I("Glorious Model D / D-", DetectSinowealthMouse, SINOWEALTH_VID, Glorious_Model_D_PID, 1);
|
||||
REGISTER_HID_DETECTOR_I("Everest GT-100 RGB", DetectSinowealthMouse, SINOWEALTH_VID, Everest_GT100_PID, 1);
|
||||
REGISTER_HID_DETECTOR_I("FL ESPORTS F11", DetectSinowealthKeyboard, SINOWEALTH_VID, Fl_Esports_F11_PID, 1);
|
||||
REGISTER_HID_DETECTOR_I("FL ESPORTS F11", DetectSinowealthKeyboard49, SINOWEALTH_VID, Fl_Esports_F11_PID, 1);
|
||||
REGISTER_HID_DETECTOR_I("Sinowealth Keyboard", DetectSinowealthKeyboard16, SINOWEALTH_VID, RGB_KEYBOARD_0016PID, 1);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
/*------------------------------------------*\
|
||||
| SinowealthKeyboard16Controller.cpp |
|
||||
| |
|
||||
| Definitions and types for Sinowealth |
|
||||
| Keyboard with PID:0016, |
|
||||
| Hopefully generic for this PID, |
|
||||
| this was made spefically for ZUOYA X51 |
|
||||
| |
|
||||
| Zagorodnikov Aleksey (glooom) 26.07.2021 |
|
||||
| based on initial implementation from |
|
||||
| Dmitri Kalinichenko (Dima-Kal) 23/06/2021 |
|
||||
\*-----------------------------------------=*/
|
||||
|
||||
#include "SinowealthKeyboard16Controller.h"
|
||||
#include "LogManager.h"
|
||||
#include <cstring>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace kbd16;
|
||||
|
||||
static unsigned char request_init[] = {0x05, 0x01, 0xAA, 0xBB, 0x2F, 0x3E};
|
||||
static unsigned char request_modes[] = {0x05, 0x83, 0x00, 0x00, 0x00, 0x00};
|
||||
static unsigned char request_colors[] = {0x05, 0x88, 0xA8, 0x00, 0x40, 0x00};
|
||||
static unsigned char request_per_led_cm12[] = {0x05, 0x89, 0xAC, 0x00, 0x40, 0x00};
|
||||
static unsigned char request_per_led_cm34[] = {0x05, 0x89, 0xB0, 0x00, 0x40, 0x00};
|
||||
static unsigned char request_per_led_cm5[] = {0x05, 0x89, 0xB4, 0x00, 0x40, 0x00};
|
||||
|
||||
|
||||
SinowealthKeyboard16Controller::SinowealthKeyboard16Controller(hid_device* cmd_handle, hid_device* data_handle, char* path, std::string dev_name)
|
||||
{
|
||||
dev_cmd = cmd_handle;
|
||||
dev_data = data_handle;
|
||||
name = dev_name;
|
||||
|
||||
led_count = 132;
|
||||
|
||||
current_mode = MODE_OFF;
|
||||
location = path;
|
||||
|
||||
memset(mode_config_buf, 0x00, sizeof(mode_config_buf));
|
||||
|
||||
initCommunication();
|
||||
UpdateConfigurationFromDevice();
|
||||
}
|
||||
|
||||
SinowealthKeyboard16Controller::~SinowealthKeyboard16Controller()
|
||||
{
|
||||
hid_close(dev_cmd);
|
||||
hid_close(dev_data);
|
||||
}
|
||||
|
||||
std::string SinowealthKeyboard16Controller::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
unsigned char SinowealthKeyboard16Controller::GetCurrentMode()
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
unsigned int SinowealthKeyboard16Controller::GetLEDCount()
|
||||
{
|
||||
return led_count;
|
||||
}
|
||||
|
||||
std::string SinowealthKeyboard16Controller::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev_cmd, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
const int colors_offset = led_count;
|
||||
int i = colors_start_idx;
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| CM2 and CM4 presets are located in second half of corresponding arrays |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
if(current_custom_preset == 1 || current_custom_preset == 3)
|
||||
{
|
||||
i += (led_count * 3);
|
||||
}
|
||||
|
||||
for(const RGBColor &color : colors)
|
||||
{
|
||||
per_button_color_buf[i] = RGBGetBValue(color);
|
||||
per_button_color_buf[i + colors_offset] = RGBGetGValue(color);
|
||||
per_button_color_buf[i + colors_offset + colors_offset] = RGBGetRValue(color);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
sendConfig(per_button_color_buf);
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::SetMode(unsigned char mode, unsigned char brightness, unsigned char speed, bool direction_left, unsigned char color_mode)
|
||||
{
|
||||
if(mode >= MODE_PER_KEY1)
|
||||
{
|
||||
current_custom_preset = (mode & 0x0F);
|
||||
mode_config_buf[current_mode_idx] = MODE_PER_KEY;
|
||||
mode_config_buf[per_key_mode_idx] = 1;
|
||||
mode_config_buf[current_mode_idx+1] = (0x20 | current_custom_preset);
|
||||
|
||||
GetButtonColorsConfig(per_button_color_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_config_buf[current_mode_idx] = mode;
|
||||
device_modes[mode].brightness = brightness;
|
||||
device_modes[mode].speed = speed;
|
||||
device_modes[mode].color = color_mode;
|
||||
device_modes[mode].direction_left = direction_left;
|
||||
mode_config_buf[per_key_mode_idx] = 0;
|
||||
}
|
||||
|
||||
if(sendConfig(mode_config_buf))
|
||||
{
|
||||
current_mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::SetColorsForMode(unsigned char mode, RGBColor *profiles)
|
||||
{
|
||||
if(mode >= MODE_PER_KEY1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < COLOR_PRESETS_IN_MODE; i++)
|
||||
{
|
||||
modes_colors[mode].preset[i].red = RGBGetRValue(profiles[i]);
|
||||
modes_colors[mode].preset[i].green = RGBGetGValue(profiles[i]);
|
||||
modes_colors[mode].preset[i].blue = RGBGetBValue(profiles[i]);
|
||||
}
|
||||
|
||||
sendConfig(colors_config_buf);
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::ClearMode()
|
||||
{
|
||||
mode_config_buf[per_key_mode_idx] = 0;
|
||||
mode_config_buf[current_mode_idx] = 0;
|
||||
mode_config_buf[current_mode_idx+1] = 0;
|
||||
|
||||
sendConfig(mode_config_buf);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Before apply new settings, keyboard needs turn off LEDs and wait |
|
||||
| ~200ms, otherwise sometime glitches happens. |
|
||||
\*-----------------------------------------------------------------*/
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
|
||||
std::vector<ModeCfg> SinowealthKeyboard16Controller::GetDeviceModes()
|
||||
{
|
||||
std::vector<ModeCfg> modes;
|
||||
|
||||
for(int i = 0; i < profiles_count; i++)
|
||||
{
|
||||
modes.push_back(device_modes[i]);
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
std::vector<ModeColorCfg> SinowealthKeyboard16Controller::GetDeviceColors()
|
||||
{
|
||||
std::vector<ModeColorCfg> presets;
|
||||
|
||||
for(int i = 0; i < profiles_count; i++)
|
||||
{
|
||||
presets.push_back(modes_colors[i]);
|
||||
}
|
||||
|
||||
return presets;
|
||||
}
|
||||
|
||||
std::vector<RGBColor> SinowealthKeyboard16Controller::GetPerLedColors()
|
||||
{
|
||||
const int colors_offset = led_count;
|
||||
int start_idx = colors_start_idx;
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| CM2 and CM4 presets are located in second half of corresponding arrays |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
if(current_custom_preset == 1 || current_custom_preset == 3)
|
||||
{
|
||||
start_idx += (led_count * 3);
|
||||
}
|
||||
|
||||
std::vector<RGBColor> res;
|
||||
res.resize(led_count);
|
||||
|
||||
for(unsigned int i = 0; i < led_count; i++)
|
||||
{
|
||||
RGBColor color = (per_button_color_buf[start_idx+i] << 16)
|
||||
| (per_button_color_buf[start_idx+i+colors_offset] << 8)
|
||||
| (per_button_color_buf[start_idx+i+colors_offset+colors_offset]);
|
||||
|
||||
res[i] = color;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::UpdateConfigurationFromDevice()
|
||||
{
|
||||
GetModesConfig(mode_config_buf);
|
||||
GetColorsConfig(colors_config_buf);
|
||||
|
||||
current_mode = mode_config_buf[current_mode_idx];
|
||||
device_modes = (struct ModeCfg*) &mode_config_buf[profiles_start_idx];
|
||||
modes_colors = (struct ModeColorCfg*) &colors_config_buf[colors_start_idx];
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| When OEM software switch keyboard to custom mode it set 0x0F into 0x15 |
|
||||
| byte and 01 into 0x14 byte. However if user manually switch to this mode |
|
||||
| through Fn+1 the keyboard only sets 0x14 byte by itself, but not touched |
|
||||
| 0x15 byte. Not sure what part is more important, so managing both bytes. |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
if(current_mode == MODE_PER_KEY || mode_config_buf[per_key_mode_idx] == 1)
|
||||
{
|
||||
current_custom_preset = (mode_config_buf[current_mode_idx+1] & 0x0F);
|
||||
current_mode = ((MODE_PER_KEY&0xF) << 4) | current_custom_preset;
|
||||
|
||||
GetButtonColorsConfig(per_button_color_buf);
|
||||
}
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::GetModesConfig(unsigned char *buf)
|
||||
{
|
||||
if(!getConfig(request_modes, buf))
|
||||
{
|
||||
LOG_ERROR("[%s] Could not read modes config table", name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::GetColorsConfig(unsigned char *buf)
|
||||
{
|
||||
if(!getConfig(request_colors, buf))
|
||||
{
|
||||
LOG_ERROR("[%s] Could not read colors config table", name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::GetButtonColorsConfig(unsigned char *buf)
|
||||
{
|
||||
unsigned char *req;
|
||||
|
||||
switch(current_custom_preset)
|
||||
{
|
||||
case 2: // CM3
|
||||
case 3: // CM4
|
||||
req = request_per_led_cm34;
|
||||
break;
|
||||
case 4: // CM5
|
||||
req = request_per_led_cm5;
|
||||
break;
|
||||
case 0: // CM1
|
||||
case 1: // CM2
|
||||
default:
|
||||
req = request_per_led_cm12;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!getConfig(req, buf))
|
||||
{
|
||||
LOG_ERROR("[%s] Could not read per LED config table", name.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void SinowealthKeyboard16Controller::initCommunication()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This needs to be sent first time after powerup keyboard. |
|
||||
\*---------------------------------------------------------*/
|
||||
hid_send_feature_report(dev_cmd, request_init, 6);
|
||||
}
|
||||
|
||||
bool SinowealthKeyboard16Controller::getConfig(unsigned char *request, unsigned char *buf)
|
||||
{
|
||||
hid_send_feature_report(dev_cmd, request, 6);
|
||||
|
||||
unsigned char response[PAYLOAD_LEN];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
memset(response, 0x00, PAYLOAD_LEN);
|
||||
|
||||
response[0] = 0x06;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get the response and put it in the response buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
if(hid_get_feature_report(dev_data, response, PAYLOAD_LEN) != -1)
|
||||
{
|
||||
response[1] &= ~0x80; // Clear response flag
|
||||
response[2] = request[2];
|
||||
response[3] = request[3];
|
||||
response[4] = request[4];
|
||||
response[5] = request[5];
|
||||
memcpy(buf,response,PAYLOAD_LEN);
|
||||
read_config_error = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
read_config_error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SinowealthKeyboard16Controller::sendConfig(unsigned char *buf)
|
||||
{
|
||||
if(read_config_error)
|
||||
{
|
||||
LOG_ERROR("[%s] Can't send new config if reading old config fail", name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int result = hid_send_feature_report(dev_data, buf, PAYLOAD_LEN);
|
||||
return (result != -1);
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/*------------------------------------------*\
|
||||
| SinowealthKeyboard16Controller.h |
|
||||
| |
|
||||
| Definitions and types for Sinowealth |
|
||||
| Keyboard with PID:0016, |
|
||||
| Hopefully generic for this PID, |
|
||||
| this was made spefically for ZUOYA X51 |
|
||||
| |
|
||||
| Zagorodnikov Aleksey (glooom) 26.07.2021 |
|
||||
| based on initial implementation from |
|
||||
| Dmitri Kalinichenko (Dima-Kal) 23/06/2021 |
|
||||
\*-----------------------------------------=*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define PAYLOAD_LEN 1032
|
||||
#define COLOR_PRESETS_IN_MODE 7
|
||||
|
||||
namespace kbd16
|
||||
{
|
||||
enum
|
||||
{
|
||||
MODE_OFF = 0,
|
||||
/*
|
||||
MODE_COLOR_LOOP = 1,
|
||||
MODE_RESPIRE = 2,
|
||||
MODE_STATIC = 3,
|
||||
MODE_RIPPLES_SHINING = 4,
|
||||
MODE_REACTION = 5,
|
||||
MODE_FLASH_AWAY = 6,
|
||||
MODE_SINE_WAVE = 7,
|
||||
MODE_RAINDROPS = 8,
|
||||
MODE_NEON_STREAM = 9,
|
||||
MODE_RAINBOW_WHEEL = 10,
|
||||
MODE_ADORN = 11,
|
||||
MODE_STARS_TWINKLE = 12,
|
||||
MODE_SHADOW_DISAPPEAR = 13,
|
||||
MODE_RETRO_SNAKE = 14,
|
||||
*/
|
||||
MODE_PER_KEY = 0x0F, // General mode for custom presets
|
||||
MODE_PER_KEY1 = 0xF0,
|
||||
MODE_PER_KEY2 = 0xF1,
|
||||
MODE_PER_KEY3 = 0xF2,
|
||||
MODE_PER_KEY4 = 0xF3,
|
||||
MODE_PER_KEY5 = 0xF4,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SPEED_SLOW = 0x00,
|
||||
SPEED_NORMAL = 0x01,
|
||||
SPEED_FAST = 0x02,
|
||||
SPEED_FASTER = 0x03,
|
||||
SPEED_FASTEST = 0x04,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
BRIGHTNESS_OFF = 0x00,
|
||||
BRIGHTNESS_QUARTER = 0x01,
|
||||
BRIGHTNESS_HALF = 0x02,
|
||||
BRIGHTNESS_THREE_QUARTERS = 0x03,
|
||||
BRIGHTNESS_FULL = 0x04,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
COLOR_PRESET_0 = 0,
|
||||
COLOR_PRESET_1 = 1,
|
||||
COLOR_PRESET_2 = 2,
|
||||
COLOR_PRESET_3 = 3,
|
||||
COLOR_PRESET_4 = 4,
|
||||
COLOR_PRESET_5 = 5,
|
||||
COLOR_PRESET_6 = 6,
|
||||
COLOR_PRESET_RANDOM = 7,
|
||||
};
|
||||
}
|
||||
|
||||
struct ModeCfg
|
||||
{
|
||||
unsigned char color:3;
|
||||
unsigned char :4;
|
||||
unsigned char direction_left:1;
|
||||
unsigned char brightness:4;
|
||||
unsigned char speed:4;
|
||||
};
|
||||
|
||||
struct ColorCfg
|
||||
{
|
||||
unsigned char blue:8;
|
||||
unsigned char green:8;
|
||||
unsigned char red:8;
|
||||
};
|
||||
|
||||
struct ModeColorCfg
|
||||
{
|
||||
ColorCfg preset[COLOR_PRESETS_IN_MODE];
|
||||
};
|
||||
|
||||
class SinowealthKeyboard16Controller
|
||||
{
|
||||
public:
|
||||
SinowealthKeyboard16Controller(hid_device* cmd_handle, hid_device* data_handle, char *_path, std::string dev_name);
|
||||
~SinowealthKeyboard16Controller();
|
||||
|
||||
unsigned int GetLEDCount();
|
||||
std::string GetLocation();
|
||||
std::string GetSerialString();
|
||||
unsigned char GetCurrentMode();
|
||||
std::vector<ModeCfg> GetDeviceModes();
|
||||
std::vector<ModeColorCfg> GetDeviceColors();
|
||||
std::vector<RGBColor> GetPerLedColors();
|
||||
|
||||
void SetLEDColor(RGBColor* color_buf);
|
||||
void SetMode(unsigned char mode, unsigned char brightness, unsigned char speed, RGBColor* color_buf);
|
||||
void ClearMode();
|
||||
void SetMode(unsigned char mode, unsigned char brightness, unsigned char speed, bool direction_left, unsigned char color_mode);
|
||||
void SetColorsForMode(unsigned char mode, RGBColor profiles[COLOR_PRESETS_IN_MODE]);
|
||||
void GetProfile();
|
||||
void ReadFirmwareInfo();
|
||||
void SetLEDsDirect(std::vector<RGBColor> colors);
|
||||
|
||||
const int per_key_mode_idx = 20;
|
||||
const int current_mode_idx = 21;
|
||||
const int profiles_start_idx = 32;
|
||||
const int profiles_count = 15;
|
||||
const int colors_start_idx = 8;
|
||||
|
||||
private:
|
||||
hid_device* dev_cmd;
|
||||
hid_device* dev_data;
|
||||
device_type type;
|
||||
std::string name;
|
||||
|
||||
unsigned int led_count;
|
||||
|
||||
unsigned char current_mode;
|
||||
struct ModeCfg* device_modes;
|
||||
struct ModeColorCfg* modes_colors;
|
||||
|
||||
std::string location;
|
||||
|
||||
unsigned char mode_config_buf[PAYLOAD_LEN];
|
||||
unsigned char colors_config_buf[PAYLOAD_LEN];
|
||||
unsigned char per_button_color_buf[PAYLOAD_LEN];
|
||||
bool read_config_error = false;
|
||||
unsigned char current_custom_preset = 0;
|
||||
|
||||
void GetModesConfig(unsigned char *buf);
|
||||
void GetColorsConfig(unsigned char *buf);
|
||||
void GetButtonColorsConfig(unsigned char *buf);
|
||||
|
||||
void initCommunication();
|
||||
bool getConfig(unsigned char reqest[], unsigned char *buf);
|
||||
bool sendConfig(unsigned char *buf);
|
||||
|
||||
void UpdateConfigurationFromDevice();
|
||||
};
|
||||
@@ -0,0 +1,164 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_SteelSeriesRival.cpp |
|
||||
| |
|
||||
| Generic RGB Interface SteelSeriesRival3 |
|
||||
| Class |
|
||||
| |
|
||||
| B Horn (bahorn) 29/08/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_SteelSeriesRival3.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
const int value;
|
||||
} steelseries_rival_led_info;
|
||||
|
||||
static const steelseries_rival_led_info rival_3_leds[]=
|
||||
{
|
||||
{"Front", 0x01},
|
||||
{"Middle", 0x02},
|
||||
{"Rear", 0x03},
|
||||
{"Logo", 0x04}
|
||||
};
|
||||
|
||||
RGBController_SteelSeriesRival3::RGBController_SteelSeriesRival3(SteelSeriesRival3Controller* rival_ptr)
|
||||
{
|
||||
rival = rival_ptr;
|
||||
|
||||
name = rival->GetDeviceName();
|
||||
vendor = "SteelSeries";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "SteelSeries Rival 3 Device";
|
||||
location = rival->GetDeviceLocation();
|
||||
serial = rival->GetSerialString();
|
||||
version = rival->GetFirmwareVersion();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = STEELSERIES_RIVAL_3_EFFECT_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = 0x00;
|
||||
Direct.brightness_max = STEELSERIES_RIVAL_3_BRIGHTNESS_MAX;
|
||||
Direct.brightness = STEELSERIES_RIVAL_3_BRIGHTNESS_MAX;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = STEELSERIES_RIVAL_3_EFFECT_BREATHING_MIN;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = 0;
|
||||
Breathing.speed_max = 2;
|
||||
Breathing.speed = 1;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = STEELSERIES_RIVAL_3_EFFECT_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode RainbowBreathing;
|
||||
RainbowBreathing.name = "Rainbow Breathing";
|
||||
RainbowBreathing.value = STEELSERIES_RIVAL_3_EFFECT_RAINBOW_BREATHING;
|
||||
RainbowBreathing.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
modes.push_back(RainbowBreathing);
|
||||
|
||||
/*------------------------------------------------------------------------*\
|
||||
| This is a pretty cool mode where it flashes random colors. |
|
||||
| |
|
||||
| However, the flashes are in the frequency range where it probably needs |
|
||||
| a proper warning for it to be compiled in by default. |
|
||||
| |
|
||||
| It is disabled in the vendor software, and is only known about as it is |
|
||||
| documented in rivalcfg. |
|
||||
| |
|
||||
| If this does get re-enabled, worth noting it has an issue where this |
|
||||
| mode is black if you come directly from one of the pulsating modes. |
|
||||
\*------------------------------------------------------------------------*/
|
||||
/*
|
||||
mode Disco;
|
||||
Disco.name = "Disco";
|
||||
Disco.value = STEELSERIES_RIVAL_3_EFFECT_DISCO;
|
||||
Disco.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
modes.push_back(Disco);
|
||||
*/
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::DeviceSaveMode()
|
||||
{
|
||||
rival->Save();
|
||||
}
|
||||
|
||||
RGBController_SteelSeriesRival3::~RGBController_SteelSeriesRival3()
|
||||
{
|
||||
delete rival;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::SetupZones()
|
||||
{
|
||||
for(const steelseries_rival_led_info led_info: rival_3_leds)
|
||||
{
|
||||
zone zone;
|
||||
zone.name = led_info.name;
|
||||
zone.type = ZONE_TYPE_SINGLE;
|
||||
zone.leds_min = 1;
|
||||
zone.leds_max = 1;
|
||||
zone.leds_count = 1;
|
||||
zone.matrix_map = NULL;
|
||||
zones.push_back(zone);
|
||||
|
||||
led mouse_led;
|
||||
mouse_led.name = led_info.name;
|
||||
mouse_led.value = led_info.value;
|
||||
leds.push_back(mouse_led);
|
||||
}
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::DeviceUpdateLEDs()
|
||||
{
|
||||
for(unsigned int i = 0; i < zones.size(); i++)
|
||||
{
|
||||
UpdateZoneLEDs(i);
|
||||
}
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
/*--------------------------------------------------*\
|
||||
| Subtracting one as the zone and led indexes differ |
|
||||
\*--------------------------------------------------*/
|
||||
UpdateSingleLED(zones[zone].leds[0].value - 1);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
rival->SetColor(leds[led].value, red, grn, blu, modes[active_mode].brightness);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::DeviceUpdateMode()
|
||||
{
|
||||
rival->SetLightEffectAll(modes[active_mode].value - modes[active_mode].speed);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_SteelSeriesRival.h |
|
||||
| |
|
||||
| Generic RGB Interface SteelSeriesRival3 |
|
||||
| Class |
|
||||
| |
|
||||
| B Horn (bahorn) 29/08/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "SteelSeriesRival3Controller.h"
|
||||
|
||||
class RGBController_SteelSeriesRival3 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_SteelSeriesRival3(SteelSeriesRival3Controller* rival_ptr);
|
||||
~RGBController_SteelSeriesRival3();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
|
||||
private:
|
||||
SteelSeriesRival3Controller* rival;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Detector.h"
|
||||
#include "SteelSeriesRivalController.h"
|
||||
#include "SteelSeriesRival3Controller.h"
|
||||
#include "SteelSeriesSiberiaController.h"
|
||||
#include "SteelSeriesQCKMatController.h"
|
||||
#include "SteelSeriesApexController.h"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "SteelSeriesGeneric.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_SteelSeriesRival.h"
|
||||
#include "RGBController_SteelSeriesRival3.h"
|
||||
#include "RGBController_SteelSeriesSiberia.h"
|
||||
#include "RGBController_SteelSeriesQCKMat.h"
|
||||
#include "RGBController_SteelSeriesApex.h"
|
||||
@@ -42,6 +44,8 @@
|
||||
#define STEELSERIES_RIVAL_600_DOTA_2_PID 0x172E
|
||||
#define STEELSERIES_RIVAL_650_PID 0x172B
|
||||
#define STEELSERIES_RIVAL_650_WIRELESS_PID 0x1726
|
||||
#define STEELSERIES_RIVAL_3_OLD_PID 0x1824
|
||||
#define STEELSERIES_RIVAL_3_PID 0x184C
|
||||
#define STEELSERIES_SENSEI_TEN_PID 0x1832
|
||||
#define STEELSERIES_SENSEI_TEN_CSGO_NEON_RIDER_PID 0x1834
|
||||
#define STEELSERIES_SENSEI_310_PID 0x1722
|
||||
@@ -187,6 +191,18 @@ void DetectSteelSeriesRival650(hid_device_info* info, const std::string& name)
|
||||
}
|
||||
}
|
||||
|
||||
void DetectSteelSeriesRival3(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
SteelSeriesRival3Controller* controller = new SteelSeriesRival3Controller(dev, RIVAL_3, info->path);
|
||||
RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectSteelSeriesSensei(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
@@ -221,6 +237,8 @@ REGISTER_HID_DETECTOR_I("SteelSeries Rival 600", Dete
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 600 Dota 2 Edition", DetectSteelSeriesRival600, STEELSERIES_VID, STEELSERIES_RIVAL_600_DOTA_2_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 650", DetectSteelSeriesRival650, STEELSERIES_VID, STEELSERIES_RIVAL_650_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 650 Wireless", DetectSteelSeriesRival650, STEELSERIES_VID, STEELSERIES_RIVAL_650_WIRELESS_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 3 (Old Firmware)", DetectSteelSeriesRival3, STEELSERIES_VID, STEELSERIES_RIVAL_3_OLD_PID, 3);
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 3", DetectSteelSeriesRival3, STEELSERIES_VID, STEELSERIES_RIVAL_3_PID, 3);
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Sensei TEN", DetectSteelSeriesSensei, STEELSERIES_VID, STEELSERIES_SENSEI_TEN_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Sensei TEN CS:GO Neon Rider Edition", DetectSteelSeriesSensei, STEELSERIES_VID, STEELSERIES_SENSEI_TEN_CSGO_NEON_RIDER_PID,0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Sensei 310", DetectSteelSeriesSensei, STEELSERIES_VID, STEELSERIES_SENSEI_310_PID, 0 );
|
||||
|
||||
@@ -27,5 +27,6 @@ typedef enum
|
||||
APEX_OLD = 0x07,
|
||||
SENSEI = 0x08,
|
||||
RIVAL_600 = 0x09,
|
||||
RIVAL_3 = 0x0a,
|
||||
} steelseries_type;
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesRival3Controller.h |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Rival 3 lighting controller |
|
||||
| |
|
||||
| B Horn (bahorn) 29/8/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "SteelSeriesRival3Controller.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
SteelSeriesRival3Controller::SteelSeriesRival3Controller
|
||||
(
|
||||
hid_device* dev_handle,
|
||||
steelseries_type proto_type,
|
||||
const char* path
|
||||
)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
proto = proto_type;
|
||||
}
|
||||
|
||||
SteelSeriesRival3Controller::~SteelSeriesRival3Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string SteelSeriesRival3Controller::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
char* SteelSeriesRival3Controller::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string SteelSeriesRival3Controller::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
std::string SteelSeriesRival3Controller::GetFirmwareVersion()
|
||||
{
|
||||
const uint8_t FW_BUFFER_SIZE = 3;
|
||||
uint8_t usb_buf[FW_BUFFER_SIZE] = { 0x00, 0x10, 0x00 };
|
||||
uint16_t version;
|
||||
std::string return_string;
|
||||
|
||||
hid_write(dev, usb_buf, FW_BUFFER_SIZE);
|
||||
hid_read(dev, (unsigned char *)&version, 2);
|
||||
|
||||
return_string = std::to_string(version);
|
||||
return return_string;
|
||||
}
|
||||
|
||||
steelseries_type SteelSeriesRival3Controller::GetMouseType()
|
||||
{
|
||||
return proto;
|
||||
}
|
||||
|
||||
void SteelSeriesRival3Controller::Save()
|
||||
{
|
||||
const uint8_t SAVE_BUFFER_SIZE = 10;
|
||||
uint8_t usb_buf[SAVE_BUFFER_SIZE] = { 0x00, 0x09 };
|
||||
|
||||
hid_write(dev, usb_buf, SAVE_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void SteelSeriesRival3Controller::SetLightEffectAll(uint8_t effect)
|
||||
{
|
||||
const uint8_t EFFECT_BUFFER_SIZE = 4;
|
||||
uint8_t usb_buf[EFFECT_BUFFER_SIZE] = { 0x00, 0x06, 0x00, effect };
|
||||
|
||||
hid_write(dev, usb_buf, EFFECT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void SteelSeriesRival3Controller::SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue,
|
||||
unsigned char brightness
|
||||
)
|
||||
{
|
||||
const uint8_t COLOR_BUFFER_SIZE = 8;
|
||||
uint8_t usb_buf[COLOR_BUFFER_SIZE];
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x05;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = zone_id;
|
||||
|
||||
usb_buf[0x04] = red;
|
||||
usb_buf[0x05] = green;
|
||||
usb_buf[0x06] = blue;
|
||||
usb_buf[0x07] = brightness;
|
||||
|
||||
hid_write(dev, usb_buf, COLOR_BUFFER_SIZE);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesRival3Controller.h |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Rival 3 lighting controller |
|
||||
| |
|
||||
| B Horn (bahorn) 29/8/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "SteelSeriesGeneric.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
#define STEELSERIES_RIVAL_3_BRIGHTNESS_MAX 0x64
|
||||
|
||||
/*-----------------------------------------------------------*\
|
||||
| Theses are the specific values that get sent to set a mode |
|
||||
\*-----------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
STEELSERIES_RIVAL_3_EFFECT_SPECTRUM_CYCLE = 0x00,
|
||||
STEELSERIES_RIVAL_3_EFFECT_BREATHING_MAX = 0x01,
|
||||
STEELSERIES_RIVAL_3_EFFECT_BREATHING_MID = 0x02,
|
||||
STEELSERIES_RIVAL_3_EFFECT_BREATHING_MIN = 0x03,
|
||||
STEELSERIES_RIVAL_3_EFFECT_DIRECT = 0x04,
|
||||
STEELSERIES_RIVAL_3_EFFECT_RAINBOW_BREATHING = 0x05,
|
||||
STEELSERIES_RIVAL_3_EFFECT_DISCO = 0x06
|
||||
};
|
||||
|
||||
class SteelSeriesRival3Controller
|
||||
{
|
||||
public:
|
||||
SteelSeriesRival3Controller
|
||||
(
|
||||
hid_device* dev_handle,
|
||||
steelseries_type proto_type,
|
||||
const char* path
|
||||
);
|
||||
|
||||
~SteelSeriesRival3Controller();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
char* GetDeviceName();
|
||||
std::string GetSerialString();
|
||||
std::string GetFirmwareVersion();
|
||||
|
||||
steelseries_type GetMouseType();
|
||||
|
||||
void Save();
|
||||
|
||||
void SetLightEffectAll(uint8_t effect);
|
||||
|
||||
void SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue,
|
||||
unsigned char brightness
|
||||
);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
steelseries_type proto;
|
||||
};
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "filesystem.h"
|
||||
|
||||
static const char* log_codes[] = {"FATAL:", "ERROR:", "Warning:", "Info:", "[verbose]", "Debug:", "Trace:"};
|
||||
static const char* log_codes[] = {"FATAL:", "ERROR:", "Warning:", "Info:", "Verbose:", "Debug:", "Trace:"};
|
||||
|
||||
LogManager::LogManager()
|
||||
{
|
||||
|
||||
+42
-4
@@ -20,6 +20,15 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5): DEFINES += _QT6
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# pkg-config Configuration #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||
PKG_CONFIG = $$pkgConfigExecutable()
|
||||
} else {
|
||||
PKG_CONFIG = "pkgconf"
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# Application Configuration #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
@@ -166,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 \
|
||||
@@ -177,10 +187,15 @@ 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 \
|
||||
serial_port/serial_port.h \
|
||||
@@ -332,6 +347,7 @@ HEADERS +=
|
||||
Controllers/LogitechController/LogitechG810Controller.h \
|
||||
Controllers/LogitechController/LogitechG910Controller.h \
|
||||
Controllers/LogitechController/LogitechG815Controller.h \
|
||||
Controllers/LogitechController/LogitechG915Controller.h \
|
||||
Controllers/LogitechController/LogitechGLightsyncController.h \
|
||||
Controllers/LogitechController/LogitechLightspeedController.h \
|
||||
Controllers/LogitechController/LogitechX56Controller.h \
|
||||
@@ -342,6 +358,7 @@ HEADERS +=
|
||||
Controllers/LogitechController/RGBController_LogitechG810.h \
|
||||
Controllers/LogitechController/RGBController_LogitechG910.h \
|
||||
Controllers/LogitechController/RGBController_LogitechG815.h \
|
||||
Controllers/LogitechController/RGBController_LogitechG915.h \
|
||||
Controllers/LogitechController/RGBController_LogitechGLightsync.h \
|
||||
Controllers/LogitechController/RGBController_LogitechGLightsync1zone.h \
|
||||
Controllers/LogitechController/RGBController_LogitechGPowerPlay.h \
|
||||
@@ -392,8 +409,10 @@ HEADERS +=
|
||||
Controllers/SapphireGPUController/RGBController_SapphireNitroGlowV3.h \
|
||||
Controllers/SinowealthController/SinowealthController.h \
|
||||
Controllers/SinowealthController/SinowealthKeyboardController.h \
|
||||
Controllers/SinowealthController/SinowealthKeyboard16Controller.h \
|
||||
Controllers/SinowealthController/RGBController_Sinowealth.h \
|
||||
Controllers/SinowealthController/RGBController_SinowealthKeyboard.h \
|
||||
Controllers/SinowealthController/RGBController_SinowealthKeyboard16.h \
|
||||
Controllers/SonyDS4Controller/SonyDS4Controller.h \
|
||||
Controllers/SonyDS4Controller/RGBController_SonyDS4.h \
|
||||
Controllers/SteelSeriesController/color32.h \
|
||||
@@ -403,12 +422,14 @@ HEADERS +=
|
||||
Controllers/SteelSeriesController/SteelSeriesGeneric.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesOldApexController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesRivalController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesRival3Controller.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesSenseiController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesSiberiaController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesQCKMatController.h \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesApex.h \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesOldApex.h \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesRival.h \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesRival3.h \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesSiberia.h \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesQCKMat.h \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesSensei.h \
|
||||
@@ -487,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 \
|
||||
@@ -496,14 +518,19 @@ SOURCES +=
|
||||
qt/OpenRGBSupportedDevicesPage.cpp \
|
||||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
qt/OpenRGBZoneResizeDialog.cpp \
|
||||
qt/OpenRGBZonesBulkResizer.cpp \
|
||||
qt/TabLabel.cpp \
|
||||
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 \
|
||||
@@ -701,6 +728,7 @@ SOURCES +=
|
||||
Controllers/LogitechController/LogitechG810Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG910Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG815Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG915Controller.cpp \
|
||||
Controllers/LogitechController/LogitechGLightsyncController.cpp \
|
||||
Controllers/LogitechController/LogitechLightspeedController.cpp \
|
||||
Controllers/LogitechController/LogitechX56Controller.cpp \
|
||||
@@ -711,6 +739,7 @@ SOURCES +=
|
||||
Controllers/LogitechController/RGBController_LogitechG810.cpp \
|
||||
Controllers/LogitechController/RGBController_LogitechG910.cpp \
|
||||
Controllers/LogitechController/RGBController_LogitechG815.cpp \
|
||||
Controllers/LogitechController/RGBController_LogitechG915.cpp \
|
||||
Controllers/LogitechController/RGBController_LogitechGLightsync.cpp \
|
||||
Controllers/LogitechController/RGBController_LogitechGLightsync1zone.cpp \
|
||||
Controllers/LogitechController/RGBController_LogitechGPowerPlay.cpp \
|
||||
@@ -774,9 +803,11 @@ SOURCES +=
|
||||
Controllers/SapphireGPUController/RGBController_SapphireNitroGlowV3.cpp \
|
||||
Controllers/SinowealthController/SinowealthController.cpp \
|
||||
Controllers/SinowealthController/SinowealthKeyboardController.cpp \
|
||||
Controllers/SinowealthController/SinowealthKeyboard16Controller.cpp \
|
||||
Controllers/SinowealthController/SinowealthControllerDetect.cpp \
|
||||
Controllers/SinowealthController/RGBController_Sinowealth.cpp \
|
||||
Controllers/SinowealthController/RGBController_SinowealthKeyboard.cpp \
|
||||
Controllers/SinowealthController/RGBController_SinowealthKeyboard16.cpp \
|
||||
Controllers/SonyDS4Controller/SonyDS4Controller.cpp \
|
||||
Controllers/SonyDS4Controller/SonyDS4ControllerDetect.cpp \
|
||||
Controllers/SonyDS4Controller/RGBController_SonyDS4.cpp \
|
||||
@@ -784,6 +815,7 @@ SOURCES +=
|
||||
Controllers/SteelSeriesController/SteelSeriesApexMController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesOldApexController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesRivalController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesRival3Controller.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesSenseiController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesSiberiaController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesQCKMatController.cpp \
|
||||
@@ -791,6 +823,7 @@ SOURCES +=
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesApex.cpp \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesOldApex.cpp \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesRival.cpp \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesRival3.cpp \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesSensei.cpp \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesSiberia.cpp \
|
||||
Controllers/SteelSeriesController/RGBController_SteelSeriesQCKMat.cpp \
|
||||
@@ -830,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 \
|
||||
@@ -841,10 +874,15 @@ 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 \
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
@@ -1088,7 +1126,7 @@ unix:!macx {
|
||||
# hidapi-hidraw >= 0.10.1 supports USAGE/USAGE_PAGE #
|
||||
# Define USE_HID_USAGE if hidapi-hidraw supports it #
|
||||
#---------------------------------------------------------------------------------------#
|
||||
HIDAPI_HIDRAW_VERSION = $$system(pkgconf --modversion hidapi-hidraw)
|
||||
HIDAPI_HIDRAW_VERSION = $$system($$PKG_CONFIG --modversion hidapi-hidraw)
|
||||
if(versionAtLeast(HIDAPI_HIDRAW_VERSION, "0.10.1")) {
|
||||
DEFINES += USE_HID_USAGE
|
||||
}
|
||||
|
||||
@@ -196,6 +196,7 @@ There have been two instances of hardware damage in OpenRGB's development and we
|
||||
* Scheduler Plugin (by morg): https://gitlab.com/OpenRGBDevelopers/OpenRGBSchedulerPlugin
|
||||
* Skin Plugin (by morg): https://gitlab.com/OpenRGBDevelopers/openrgbskinplugin
|
||||
* Hardware Sync Plugin (by morg): https://gitlab.com/OpenRGBDevelopers/OpenRGBHardwareSyncPlugin
|
||||
* Http Hook Plugin (by morg): https://gitlab.com/OpenRGBDevelopers/OpenRGBHttpHookPlugin
|
||||
|
||||
## Projects Used
|
||||
|
||||
|
||||
+6
-6
@@ -105,7 +105,7 @@ std::vector<i2c_smbus_interface*> & ResourceManager::GetI2CBusses()
|
||||
|
||||
void ResourceManager::RegisterRGBController(RGBController *rgb_controller)
|
||||
{
|
||||
LOG_INFO("Registering RGB controller: %s", rgb_controller->name.c_str());
|
||||
LOG_INFO("[%s] Registering RGB controller", rgb_controller->name.c_str());
|
||||
rgb_controllers_hw.push_back(rgb_controller);
|
||||
|
||||
UpdateDeviceList();
|
||||
@@ -113,7 +113,7 @@ void ResourceManager::RegisterRGBController(RGBController *rgb_controller)
|
||||
|
||||
void ResourceManager::UnregisterRGBController(RGBController* rgb_controller)
|
||||
{
|
||||
LOG_INFO("Unregistering RGB controller: %s", rgb_controller->name.c_str());
|
||||
LOG_INFO("[%s] Unregistering RGB controller", rgb_controller->name.c_str());
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Clear callbacks from the controller before removal |
|
||||
@@ -746,7 +746,7 @@ void ResourceManager::DetectDevicesThreadFunction()
|
||||
this_device_enabled = detector_settings["detectors"][detection_string];
|
||||
}
|
||||
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "Enabled" : "Disabled"));
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled"));
|
||||
if(this_device_enabled)
|
||||
{
|
||||
DetectionProgressChanged();
|
||||
@@ -845,7 +845,7 @@ void ResourceManager::DetectDevicesThreadFunction()
|
||||
this_device_enabled = detector_settings["detectors"][detection_string];
|
||||
}
|
||||
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "Enabled" : "Disabled"));
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled"));
|
||||
|
||||
if(this_device_enabled)
|
||||
{
|
||||
@@ -940,7 +940,7 @@ void ResourceManager::DetectDevicesThreadFunction()
|
||||
this_device_enabled = detector_settings["detectors"][detection_string];
|
||||
}
|
||||
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "Enabled" : "Disabled"));
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled"));
|
||||
|
||||
if(this_device_enabled)
|
||||
{
|
||||
@@ -1001,7 +1001,7 @@ void ResourceManager::DetectDevicesThreadFunction()
|
||||
this_device_enabled = detector_settings["detectors"][detection_string];
|
||||
}
|
||||
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "Enabled" : "Disabled"));
|
||||
LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled"));
|
||||
|
||||
if(this_device_enabled)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
+85
-2
@@ -7,6 +7,7 @@
|
||||
#include "OpenRGBProfileSaveDialog.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "TabLabel.h"
|
||||
#include "OpenRGBZonesBulkResizer.h"
|
||||
#include <QLabel>
|
||||
#include <QTabBar>
|
||||
#include <QMessageBox>
|
||||
@@ -110,6 +111,13 @@ static void DeletePluginCallback(void * this_ptr, OpenRGBPluginEntry* plugin)
|
||||
this_obj->RemovePlugin(plugin);
|
||||
}
|
||||
|
||||
static void DetectionEndedCallback(void * this_ptr)
|
||||
{
|
||||
OpenRGBDialog2 * this_obj = (OpenRGBDialog2 *)this_ptr;
|
||||
|
||||
QMetaObject::invokeMethod(this_obj, "onDetectionEnded", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
bool OpenRGBDialog2::IsDarkTheme()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -258,6 +266,7 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
||||
\*-----------------------------------------------------*/
|
||||
ResourceManager::get()->RegisterDetectionProgressCallback(UpdateDetectionProgressCallback, this);
|
||||
ResourceManager::get()->RegisterDeviceListChangeCallback(UpdateDeviceListCallback, this);
|
||||
ResourceManager::get()->RegisterDetectionEndCallback(DetectionEndedCallback, this);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize page pointers |
|
||||
@@ -334,7 +343,7 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
||||
connect(actionLightsOff, SIGNAL(triggered()), this, SLOT(on_LightsOff()));
|
||||
trayIconMenu->addAction(actionLightsOff);
|
||||
|
||||
QAction* actionExit = new QAction( "Exit", this );
|
||||
actionExit = new QAction( "Exit", this );
|
||||
connect( actionExit, SIGNAL( triggered() ), this, SLOT( on_Exit() ));
|
||||
trayIconMenu->addAction(actionExit);
|
||||
|
||||
@@ -444,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 |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -642,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()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -698,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)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -798,7 +873,7 @@ void OpenRGBDialog2::AddPlugin(OpenRGBPluginEntry* plugin)
|
||||
|
||||
if(NewTrayMenu)
|
||||
{
|
||||
trayIconMenu->addMenu(NewTrayMenu);
|
||||
trayIconMenu->insertMenu(actionExit, NewTrayMenu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1236,6 +1311,14 @@ void OpenRGBDialog2::onDetectionProgressUpdated()
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::onDetectionEnded()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Detect unconfigured zones and prompt for resizing |
|
||||
\*-----------------------------------------------------*/
|
||||
OpenRGBZonesBulkResizer::RunChecks(this);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
|
||||
|
||||
@@ -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();
|
||||
@@ -104,6 +110,8 @@ private:
|
||||
|
||||
PluginManager* plugin_manager = nullptr;
|
||||
|
||||
QAction* actionExit;
|
||||
|
||||
private slots:
|
||||
void on_Exit();
|
||||
void on_LightsOff();
|
||||
@@ -116,6 +124,7 @@ private slots:
|
||||
void on_QuickWhite();
|
||||
void onDeviceListUpdated();
|
||||
void onDetectionProgressUpdated();
|
||||
void onDetectionEnded();
|
||||
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void on_SaveSizeProfile();
|
||||
void on_ShowHide();
|
||||
|
||||
@@ -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
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -58,6 +58,15 @@ OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
if(ui_settings.contains("RunZoneChecks"))
|
||||
{
|
||||
ui->CheckboxRunZoneChecks->setChecked(ui_settings["RunZoneChecks"]);
|
||||
}
|
||||
else
|
||||
{ // default value
|
||||
ui->CheckboxRunZoneChecks->setChecked(true);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Load AutoStart settings |
|
||||
\*---------------------------------------------------------*/
|
||||
@@ -156,6 +165,14 @@ void Ui::OpenRGBSettingsPage::on_CheckboxSaveGeometry_clicked()
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBSettingsPage::on_CheckboxRunZoneChecks_clicked()
|
||||
{
|
||||
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
|
||||
ui_settings["RunZoneChecks"] = ui->CheckboxRunZoneChecks->isChecked();
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBSettingsPage::on_CheckboxAutoStart_clicked()
|
||||
{
|
||||
if(autostart_initialized)
|
||||
|
||||
@@ -47,6 +47,7 @@ private slots:
|
||||
void on_ComboBoxAutoStartProfile_currentTextChanged(const QString);
|
||||
void on_CheckboxAutoStartSetServerPort_clicked();
|
||||
void on_CheckboxAutoStartCustom_clicked();
|
||||
void on_CheckboxRunZoneChecks_clicked();
|
||||
};
|
||||
|
||||
#endif // OPENRGBSETTINGSPAGE_H
|
||||
|
||||
+93
-86
@@ -24,119 +24,47 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>412</width>
|
||||
<height>480</height>
|
||||
<width>449</width>
|
||||
<height>574</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSaveGeometry">
|
||||
<property name="text">
|
||||
<string>Save Geometry On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
|
||||
<property name="text">
|
||||
<string>Load Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QLineEdit" name="TextCustomArgs"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxTheme"/>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QLineEdit" name="TextServerPort">
|
||||
<property name="inputMask">
|
||||
<string>90000</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
|
||||
<property name="text">
|
||||
<string>Minimize On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="AutoStartLabel">
|
||||
<property name="text">
|
||||
<string>Start At Login Settings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartSetServerPort">
|
||||
<property name="text">
|
||||
<string>Set Server Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="ThemeLabel">
|
||||
<property name="text">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStart">
|
||||
<property name="text">
|
||||
<string>Start At Login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
|
||||
<property name="text">
|
||||
<string>Custom Arguments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
|
||||
<widget class="QLabel" name="AutoStartLabel">
|
||||
<property name="text">
|
||||
<string>Start Minimized</string>
|
||||
<string>Start At Login Settings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="AutoStartStatusLabel">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartProfile">
|
||||
<property name="text">
|
||||
<string>Start at Login Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QLineEdit" name="TextClientHost"/>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartClient">
|
||||
<property name="text">
|
||||
<string>Start Client</string>
|
||||
<string>Load Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
|
||||
<widget class="QLineEdit" name="TextCustomArgs"/>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartServer">
|
||||
<property name="text">
|
||||
<string>Start Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="12" column="1">
|
||||
<widget class="QLineEdit" name="TextClientHost"/>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxAutoStartProfile"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxLoadGeometry">
|
||||
@@ -146,6 +74,20 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="0">
|
||||
<widget class="QLabel" name="AutoStartStatusLabel">
|
||||
<property name="text">
|
||||
<string>Start at Login Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartServer">
|
||||
<property name="text">
|
||||
<string>Start Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -161,6 +103,71 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxTheme"/>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartCustom">
|
||||
<property name="text">
|
||||
<string>Custom Arguments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartClient">
|
||||
<property name="text">
|
||||
<string>Start Client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxAutoStartMinimized">
|
||||
<property name="text">
|
||||
<string>Start Minimized</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxSaveGeometry">
|
||||
<property name="text">
|
||||
<string>Save Geometry On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="ThemeLabel">
|
||||
<property name="text">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
|
||||
<property name="text">
|
||||
<string>Minimize On Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QLineEdit" name="TextServerPort">
|
||||
<property name="inputMask">
|
||||
<string>90000</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxRunZoneChecks">
|
||||
<property name="text">
|
||||
<string>Run zone checks on rescan</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,232 @@
|
||||
#include "OpenRGBZonesBulkResizer.h"
|
||||
#include "ui_OpenRGBZonesBulkResizer.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "LogManager.h"
|
||||
#include "OpenRGBDialog2.h"
|
||||
#include <QDialog>
|
||||
#include <QFile>
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
void OpenRGBZonesBulkResizer::RunChecks(QWidget *parent)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Determine if we should run (user setting) |
|
||||
\*---------------------------------------------------------*/
|
||||
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
|
||||
json ui_settings = settings_manager->GetSettings("UserInterface");
|
||||
|
||||
if(!ui_settings.is_null() && ui_settings.contains("RunZoneChecks"))
|
||||
{
|
||||
json run_zone_checks = ui_settings["RunZoneChecks"];
|
||||
|
||||
if(!run_zone_checks.is_null() && run_zone_checks.is_boolean())
|
||||
{
|
||||
bool should_run = run_zone_checks;
|
||||
|
||||
if(!should_run)
|
||||
{
|
||||
LOG_DEBUG("Skipping zones sizes checks.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG("Running zones sizes checks...");
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Collect the unconfigured zones |
|
||||
\*---------------------------------------------------------*/
|
||||
std::vector<RGBController*>& controllers = ResourceManager::get()->GetRGBControllers();
|
||||
|
||||
std::vector<std::tuple<RGBController*, unsigned int>> zones;
|
||||
|
||||
for(RGBController* controller: controllers)
|
||||
{
|
||||
for(unsigned int zone_index = 0; zone_index < controller->zones.size(); zone_index++)
|
||||
{
|
||||
// Consider unconfigured if 0 leds AND led_count < leds_max
|
||||
if(controller->zones[zone_index].leds_count == 0
|
||||
&& controller->zones[zone_index].leds_count < controller->zones[zone_index].leds_max)
|
||||
{
|
||||
zones.push_back({controller, zone_index});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG("Zones checks finished: %d unconfigured zone(s).", zones.size());
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Show the configuration tool GUI if we have some |
|
||||
| unconfigured zones |
|
||||
\*---------------------------------------------------------*/
|
||||
if(!zones.empty())
|
||||
{
|
||||
QDialog* dialog = new QDialog(parent);
|
||||
dialog->setWindowTitle("Resize the zones");
|
||||
|
||||
if (OpenRGBDialog2::IsDarkTheme())
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::WindowText, Qt::white);
|
||||
dialog->setPalette(pal);
|
||||
QFile dark_theme(":/windows_dark.qss");
|
||||
dark_theme.open(QFile::ReadOnly);
|
||||
dialog->setStyleSheet(dark_theme.readAll());
|
||||
dark_theme.close();
|
||||
}
|
||||
|
||||
dialog->setMinimumSize(600,480);
|
||||
dialog->setModal(true);
|
||||
|
||||
QVBoxLayout* dialog_layout = new QVBoxLayout(dialog);
|
||||
|
||||
OpenRGBZonesBulkResizer* widget = new OpenRGBZonesBulkResizer(dialog, zones);
|
||||
|
||||
dialog_layout->addWidget(widget);
|
||||
|
||||
connect(widget, &OpenRGBZonesBulkResizer::CloseRequest, [=](){
|
||||
dialog->reject();
|
||||
});
|
||||
|
||||
dialog->exec();
|
||||
}
|
||||
}
|
||||
|
||||
OpenRGBZonesBulkResizer::OpenRGBZonesBulkResizer(QWidget *parent, const std::vector<std::tuple<RGBController*, unsigned int>>& unconfigured_zones) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OpenRGBZonesBulkResizerUi),
|
||||
unconfigured_zones(unconfigured_zones)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set the table view settings (headers, resize behavior...) |
|
||||
\*---------------------------------------------------------*/
|
||||
ui->zones_table->setColumnCount(3);
|
||||
ui->zones_table->verticalHeader()->setVisible(false);
|
||||
ui->zones_table->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
|
||||
ui->zones_table->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
|
||||
|
||||
ui->zones_table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->zones_table->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
ui->zones_table->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
|
||||
|
||||
ui->zones_table->setHorizontalHeaderLabels({"Controller", "Zone", "Size"});
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Fill the table with widgets (labels, spinbox) |
|
||||
\*---------------------------------------------------------*/
|
||||
for(const std::tuple<RGBController*, unsigned int>& tuple: unconfigured_zones)
|
||||
{
|
||||
CreateZoneWidget(std::get<0>(tuple), std::get<1>(tuple));
|
||||
}
|
||||
}
|
||||
|
||||
OpenRGBZonesBulkResizer::~OpenRGBZonesBulkResizer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenRGBZonesBulkResizer::CreateZoneWidget(RGBController* controller, unsigned int zone_index)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Labels: controller name + zone name |
|
||||
\*---------------------------------------------------------*/
|
||||
QLabel* controller_label = new QLabel(this);
|
||||
controller_label->setText(QString::fromStdString(controller->name));
|
||||
|
||||
QLabel* zone_label = new QLabel(this);
|
||||
zone_label->setText(QString::fromStdString(controller->zones[zone_index].name));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Spin box: controls the zone size |
|
||||
\*---------------------------------------------------------*/
|
||||
QSpinBox* spin_box = new QSpinBox(this);
|
||||
spin_box->setValue(0);
|
||||
spin_box->setMinimum(controller->zones[zone_index].leds_min);
|
||||
spin_box->setMaximum(controller->zones[zone_index].leds_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Insert labels + spinbox |
|
||||
\*---------------------------------------------------------*/
|
||||
int row = ui->zones_table->rowCount();
|
||||
|
||||
ui->zones_table->insertRow(row);
|
||||
ui->zones_table->setCellWidget(row, 0, controller_label);
|
||||
ui->zones_table->setCellWidget(row, 1, zone_label);
|
||||
ui->zones_table->setCellWidget(row, 2, spin_box);
|
||||
}
|
||||
|
||||
void OpenRGBZonesBulkResizer::on_save_button_clicked()
|
||||
{
|
||||
bool has_changes = false;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Resize what needs to be resized |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int i = 0; i < unconfigured_zones.size(); i++)
|
||||
{
|
||||
unsigned int new_size = ((QSpinBox*)ui->zones_table->cellWidget(i,2))->value();
|
||||
|
||||
if(new_size > 0)
|
||||
{
|
||||
RGBController* controller = std::get<0>(unconfigured_zones[i]);
|
||||
unsigned int zone_index = std::get<1>(unconfigured_zones[i]);
|
||||
|
||||
controller->ResizeZone(zone_index, new_size);
|
||||
|
||||
has_changes = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the sizes if the user did any changes |
|
||||
\*---------------------------------------------------------*/
|
||||
if(has_changes)
|
||||
{
|
||||
ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager();
|
||||
|
||||
if(profile_manager != NULL)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the profile |
|
||||
\*---------------------------------------------------------*/
|
||||
profile_manager->SaveProfile("sizes", true);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the "Do not show again" checkbox state, then close |
|
||||
\*---------------------------------------------------------*/
|
||||
SaveDoNotRunState();
|
||||
|
||||
emit CloseRequest();
|
||||
}
|
||||
|
||||
void OpenRGBZonesBulkResizer::on_ignore_button_clicked()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the "Do not show again" checkbox state, then close |
|
||||
\*---------------------------------------------------------*/
|
||||
SaveDoNotRunState();
|
||||
|
||||
emit CloseRequest();
|
||||
}
|
||||
|
||||
void OpenRGBZonesBulkResizer::SaveDoNotRunState()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the "Do not show again" checkbox state in |
|
||||
| settings manager |
|
||||
\*---------------------------------------------------------*/
|
||||
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
|
||||
json ui_settings = settings_manager->GetSettings("UserInterface");
|
||||
|
||||
bool state = ui->do_not_show_again_checkbox->checkState() == Qt::Checked;
|
||||
|
||||
ui_settings["RunZoneChecks"] = !state;
|
||||
|
||||
settings_manager->SetSettings("UserInterface", ui_settings);
|
||||
settings_manager->SaveSettings();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef OPENRGBZONESBULKRESIZER_H
|
||||
#define OPENRGBZONESBULKRESIZER_H
|
||||
|
||||
#include "ui_OpenRGBZonesBulkResizer.h"
|
||||
#include "RGBController.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBZonesBulkResizer;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBZonesBulkResizer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static void RunChecks(QWidget *parent);
|
||||
|
||||
explicit OpenRGBZonesBulkResizer(QWidget*, const std::vector<std::tuple<RGBController*, unsigned int>>&);
|
||||
~OpenRGBZonesBulkResizer();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBZonesBulkResizerUi *ui;
|
||||
|
||||
const std::vector<std::tuple<RGBController*, unsigned int>>& unconfigured_zones;
|
||||
|
||||
void CreateZoneWidget(RGBController*, unsigned int);
|
||||
|
||||
void SaveDoNotRunState();
|
||||
|
||||
signals:
|
||||
void CloseRequest();
|
||||
|
||||
private slots:
|
||||
void on_save_button_clicked();
|
||||
void on_ignore_button_clicked();
|
||||
|
||||
};
|
||||
|
||||
#endif // OPENRGBZONESBULKRESIZER_H
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBZonesBulkResizerUi</class>
|
||||
<widget class="QWidget" name="OpenRGBZonesBulkResizerUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>980</width>
|
||||
<height>824</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="help_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>There are some Addressable RGB zones that are not yet configured.<br/> Please enter the count of LEDs attached to each zone below.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="do_not_show_again_checkbox">
|
||||
<property name="text">
|
||||
<string>Do not show again</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="save_button">
|
||||
<property name="text">
|
||||
<string>Save and close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QTableWidget" name="zones_table">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>100</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::NoPen</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="ignore_button">
|
||||
<property name="text">
|
||||
<string>Ignore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user