Compare commits

..
Author SHA1 Message Date
Adam Honse ebaed20534 Clean up unused hidapi files 2020-03-01 15:43:18 -06:00
Adam Honse 85d91d2d63 Add refreshing thread for HyperX keyboard Direct mode 2020-03-01 11:52:44 -06:00
Adam Honse 8d2f188c0b Add timeouts to fix HyperX and Poseidon Z RGB in Linux 2020-03-01 11:52:05 -06:00
Adam Honse 4ba3beab63 Get hidapi over libusb working on linux 2020-02-29 16:03:52 -06:00
Adam Honse b92082b545 libusb-based hidapi on Windows 2020-02-29 16:03:11 -06:00
Adam Honse c7960c090a Add software version information to CLI 2020-02-29 14:01:06 -06:00
Adam Honse 85b2545409 Fill in software information and set version to 0.0 for now 2020-02-29 13:45:43 -06:00
Adam Honse e10881db3e Add empty software information tab to information UI 2020-02-28 12:31:32 -06:00
Adam Honse 977feabe6e Add profile selection to system tray icon menu 2020-02-27 13:16:10 -06:00
Adam Honse a6c9d1232a Don't apply colors unless per LED mode 2020-02-26 21:16:02 -06:00
Adam Honse 4024e6de85 Fix build on Linux 2020-02-26 19:40:25 -06:00
Adam Honse f3df584d3a Don't update devices if the profile could not be loaded 2020-02-26 19:36:00 -06:00
Adam Honse 60a0ab5c93 Populate profile list with .orp files and load profile selected in list 2020-02-26 19:36:00 -06:00
Adam Honse c908847577 Add dialog to name profile. Save all controllers to a single file. Add a file header with version number and use extension .orp for OpenRgb Profile 2020-02-26 19:36:00 -06:00
Adam Honse bd027e596e Set colors when updating mode 2020-02-26 19:36:00 -06:00
Adam Honse 51c3568f7a Profile save and load test 2020-02-26 19:36:00 -06:00
Adam Honse 4f8db7d63f Add cstring include to fix build on Linux 2020-02-25 21:07:06 -06:00
Adam Honse f844c2fb07 Add functions to get/set RGBController parameters to/from a binary data buffer. Add a dummy RGBController object to load data into. 2020-02-25 18:09:14 -06:00
Adam Honse f7041988e4 Fix off-by-one errors in Aura RAM address assignment 2020-02-25 14:20:59 -06:00
Stefan Reiter 71c650cd45 Add cli.cpp and make it build at least
Not confirmed working as of yet, but at least it builds and
--list-devices works.

Code originally taken from Sam Lewis (@sam-masaki on gitlab.com), see:
https://gitlab.com/CalcProgrammer1/OpenRGB/-/merge_requests/9
2020-02-24 00:03:07 -06:00
Stefan Reiter 3c6ac31eab Introduce device_type_to_str 2020-02-23 23:40:26 -06:00
Stefan Reiter 20a99ef7ef Append LED number to Aura devices' LEDs
Makes identifying them easier then just 'Unknown' 8 times in a row.
2020-02-23 23:40:11 -06:00
Stefan Reiter c69a98096b Remove debug print
Annoying when in CLI mode
2020-02-23 23:39:13 -06:00
Adam Honse 92afebe2c7 Fix Windows build 2020-02-23 19:09:03 -06:00
jackun 5b82eb39a8 RGB Fusion 2 (IT8297BX) support based on Gigabyte X570 Elite. 2020-02-23 18:26:48 -06:00
Adam Honse 7b120515d8 Fix include path for NvAPI 2020-02-23 15:54:23 -06:00
Adam Honse b480bbd666 Clean up NvAPI I2C code and allow multiple GPUs 2020-02-23 15:54:14 -06:00
Adam Honse 5e5ac81f53 Get detection working (tested on nouveau in Linux) 2020-02-23 15:54:06 -06:00
Adam Honse adcd59848a Add RGB Fusion GPU controller and NVAPI I1C interface 2020-02-23 15:53:54 -06:00
Adam Honse 937cbc656e Add Windows application icon 2020-02-20 00:37:31 -06:00
Jan Rettig aead384282 Aura GPU Support 2020-02-19 21:24:36 -06:00
Adam Honse b717600c37 Add name, description, and type information to MSI-RGB controller 2020-02-19 21:05:04 -06:00
Adam Honse f38be5119e MSI-RGB driver based on https://github.com/nagisa/msi-rgb 2020-02-19 20:19:12 -06:00
Adam Honse f8de686296 Add LED numbers to Linux OpenRazer controller 2020-02-19 19:42:49 -06:00
51 changed files with 4818 additions and 273 deletions
@@ -135,7 +135,7 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
for (unsigned int bus = 0; bus < busses.size(); bus++) for (unsigned int bus = 0; bus < busses.size(); bus++)
{ {
int address_list_idx = 0; int address_list_idx = -1;
// Remap Aura-enabled RAM modules on 0x77 // Remap Aura-enabled RAM modules on 0x77
for (unsigned int slot = 0; slot < 8; slot++) for (unsigned int slot = 0; slot < 8; slot++)
@@ -151,8 +151,8 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
{ {
if(address_list_idx < AURA_RAM_ADDRESS_COUNT) if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
{ {
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
address_list_idx++; address_list_idx++;
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
} }
else else
{ {
@@ -0,0 +1,84 @@
/*-----------------------------------------*\
| AuraGPUController.cpp |
| |
| Driver for ASUS Aura RGB on GPUs |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "AuraGPUController.h"
#include <cstring>
AuraGPUController::AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id dev)
{
this->bus = bus;
this->dev = dev;
strcpy(device_name, "ASUS Aura GPU"); // Would be nice to get the actual GPU name. Using this as a placeholder.
}
AuraGPUController::~AuraGPUController()
{
}
std::string AuraGPUController::GetDeviceName()
{
return(device_name);
}
std::string AuraGPUController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned char AuraGPUController::GetLEDRed()
{
return(AuraGPURegisterRead(AURA_GPU_REG_RED));
}
unsigned char AuraGPUController::GetLEDGreen()
{
return(AuraGPURegisterRead(AURA_GPU_REG_GREEN));
}
unsigned char AuraGPUController::GetLEDBlue()
{
return(AuraGPURegisterRead(AURA_GPU_REG_BLUE));
}
void AuraGPUController::SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue) // Direct Mode is just Static Mode without applying color changes
{
AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
}
void AuraGPUController::SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
{
AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
}
void AuraGPUController::SetMode(unsigned char mode)
{
AuraGPURegisterWrite(AURA_GPU_REG_MODE, mode);
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
}
unsigned char AuraGPUController::AuraGPURegisterRead(unsigned char reg)
{
return(bus->i2c_smbus_read_byte_data(dev, reg));
}
void AuraGPUController::AuraGPURegisterWrite(unsigned char reg, unsigned char val)
{
bus->i2c_smbus_write_byte_data(dev, reg, val);
}
@@ -0,0 +1,64 @@
/*-----------------------------------------*\
| AuraGPUController.h |
| |
| Definitions for ASUS Aura RGB on GPUs |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char aura_gpu_dev_id;
#define AURA_GPU_MAGIC_VAL 0x1589 /* This magic value is present in all Aura GPU controllers */
#define AURA_GPU_APPLY_VAL 0x01 /* Value for Apply Changes Register */
enum
{
AURA_GPU_REG_RED = 0x04, /* AURA GPU RED Register */
AURA_GPU_REG_GREEN = 0x05, /* AURA GPU GREEN Register */
AURA_GPU_REG_BLUE = 0x06, /* AURA GPU BLUE Register */
AURA_GPU_REG_MODE = 0x07, /* AURA GPU Mode Selection Register */
AURA_GPU_REG_SYNC = 0x0C, /* AURA GPU "Sync" Register */
AURA_GPU_REG_APPLY = 0x0E, /* AURA GPU Apply Chnages Register */
};
enum
{
AURA_GPU_MODE_OFF = 0, /* OFF mode (not a real Mode! Doesn't do anything!) */
AURA_GPU_MODE_STATIC = 1, /* Static color mode */
AURA_GPU_MODE_BREATHING = 2, /* Breathing effect mode */
AURA_GPU_MODE_FLASHING = 3, /* Flashing effect mode */
AURA_GPU_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
AURA_GPU_MODE_DIRECT = 5, /* Direct mode (not a real Mode! Doesn't do anything!) */
AURA_GPU_NUMBER_MODES
};
class AuraGPUController
{
public:
AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id);
~AuraGPUController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned char GetLEDRed();
unsigned char GetLEDGreen();
unsigned char GetLEDBlue();
void SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
unsigned char AuraGPURegisterRead(unsigned char reg);
void AuraGPURegisterWrite(unsigned char reg, unsigned char val);
bool direct = false; // Temporary solution to check if we are in "Direct" mode
private:
char device_name[16];
i2c_smbus_interface * bus;
aura_gpu_dev_id dev;
};
@@ -0,0 +1,94 @@
/*-----------------------------------------*\
| AuraGPUControllerDetect.cpp |
| |
| Driver for ASUS Aura RGB on GPUs |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "AuraGPUController.h"
#include "RGBController.h"
#include "RGBController_AuraGPU.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
/*-------------------------------------------------------------*\
| This list contains the available I2C addresses for Aura GPUs |
\*-------------------------------------------------------------*/
#define AURA_GPU_ADDRESS_COUNT 3
static const unsigned char aura_gpu_addresses[] =
{
0x29,
0x2A,
0x60
};
/******************************************************************************************\
* *
* TestForAuraGPUController *
* *
* Tests the given address to see if an Aura GPU controller exists there. *
* *
\******************************************************************************************/
bool TestForAuraGPUController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
unsigned char aura_gpu_magic_high = bus->i2c_smbus_read_byte_data(address, 0x20); // High Byte of magic (0x15)
unsigned char aura_gpu_magic_low = bus->i2c_smbus_read_byte_data(address, 0x21); // Low Byte of magic (0x89)
if((aura_gpu_magic_high << 8) + aura_gpu_magic_low == AURA_GPU_MAGIC_VAL)
{
pass = true;
}
return(pass);
} /* TestForAuraGPUController() */
/******************************************************************************************\
* *
* DetectAuraGPUControllers *
* *
* Detect Aura GPU controllers on the enumerated I2C busses. *
* *
\******************************************************************************************/
void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
AuraGPUController* new_aura_gpu;
RGBController_AuraGPU* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Add Aura-enabled GPU controllers
for (unsigned int address_list_idx = 0; address_list_idx < AURA_GPU_ADDRESS_COUNT; address_list_idx++)
{
if (TestForAuraGPUController(busses[bus], aura_gpu_addresses[address_list_idx]))
{
new_aura_gpu = new AuraGPUController(busses[bus], aura_gpu_addresses[address_list_idx]);
new_controller = new RGBController_AuraGPU(new_aura_gpu);
rgb_controllers.push_back(new_controller);
}
Sleep(1);
}
}
} /* DetectAuraGPUControllers() */
@@ -137,7 +137,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
red_color_data red_color_data
); );
Sleep(2); Sleep(5);
SendDirect SendDirect
( (
@@ -145,7 +145,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
grn_color_data grn_color_data
); );
Sleep(2); Sleep(5);
SendDirect SendDirect
( (
@@ -153,7 +153,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
blu_color_data blu_color_data
); );
Sleep(2); Sleep(5);
SendDirectExtended SendDirectExtended
( (
@@ -189,6 +189,8 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
red_color_data red_color_data
); );
Sleep(5);
SendColor SendColor
( (
0x01, 0x01,
@@ -196,6 +198,8 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
grn_color_data grn_color_data
); );
Sleep(5);
SendColor SendColor
( (
0x01, 0x01,
@@ -203,6 +207,8 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
blu_color_data blu_color_data
); );
Sleep(5);
SendExtendedColor SendExtendedColor
( (
0x01, 0x01,
@@ -0,0 +1,99 @@
/*-----------------------------------------*\
| MSIRGBController.cpp |
| |
| Driver for MSI-RGB lighting controller |
| |
| Logic adapted from: |
| https://github.com/nagisa/msi-rgb |
| |
| Adam Honse (CalcProgrammer1) 2/11/2020 |
\*-----------------------------------------*/
#include "MSIRGBController.h"
#include "super_io.h"
MSIRGBController::MSIRGBController(int sioaddr)
{
msi_sioaddr = sioaddr;
/*-----------------------------------------------------*\
| This setup step isn't well documented |
| Without this, pulsing does not work |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, 0x09);
int val_at_2c = superio_inb(msi_sioaddr, 0x2C);
val_at_2c &= 0b11110111;
val_at_2c |= 0b00010000;
superio_outb(msi_sioaddr, 0x2C, val_at_2c);
/*-----------------------------------------------------*\
| Set logical device register to RGB controller |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, MSI_SIO_LOGDEV_RGB);
/*-----------------------------------------------------*\
| Test if RGB is enabled. If it is not, enable it. |
\*-----------------------------------------------------*/
int enable = superio_inb(msi_sioaddr, MSI_SIO_RGB_REG_ENABLE);
if((enable & MSI_SIO_RGB_ENABLE_MASK) != MSI_SIO_RGB_ENABLE_MASK)
{
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_ENABLE, MSI_SIO_RGB_ENABLE_MASK & (enable & !MSI_SIO_RGB_ENABLE_MASK));
}
/*-----------------------------------------------------*\
| Lighting enabled, no pulsing or blinking |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_CFG_1, 0x00);
/*-----------------------------------------------------*\
| Lighting enabled, RGB non-inverted, header on |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_CFG_3, 0xE2);
}
MSIRGBController::~MSIRGBController()
{
}
void MSIRGBController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
/*-----------------------------------------------------*\
| The MSI RGB controller uses 4 bits per color rather |
| than 8. Shift the values by 4 so that the 4 most |
| significant bits of each color are the new color value|
\*-----------------------------------------------------*/
red = red >> 4;
green = green >> 4;
blue = blue >> 4;
/*-----------------------------------------------------*\
| Set logical device register to RGB controller |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, MSI_SIO_LOGDEV_RGB);
/*-----------------------------------------------------*\
| Write the colors to the color sequence registers |
| Only static mode is supported right now - all colors |
| are the same. |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_1_0, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_3_2, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_5_4, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_7_6, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_1_0, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_3_2, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_5_4, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_7_6, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_1_0, (blue | (blue << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_3_2, (blue | (blue << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_5_4, (blue | (blue << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_7_6, (blue | (blue << 4)));
}
@@ -0,0 +1,56 @@
/*-----------------------------------------*\
| MSIRGBController.h |
| |
| Definitions and types for MSI-RGB |
| lighting controller |
| |
| Logic adapted from: |
| https://github.com/nagisa/msi-rgb |
| |
| Adam Honse (CalcProgrammer1) 2/11/2020 |
\*-----------------------------------------*/
#include <string>
#pragma once
#define MSI_SIO_LOGDEV_RGB 0x12
enum
{
MSI_SIO_RGB_REG_ENABLE = 0xE0,
MSI_SIO_RGB_REG_CFG_1 = 0xE4,
MSI_SIO_RGB_REG_RED_1_0 = 0xF0,
MSI_SIO_RGB_REG_RED_3_2 = 0xF1,
MSI_SIO_RGB_REG_RED_5_4 = 0xF2,
MSI_SIO_RGB_REG_RED_7_6 = 0xF3,
MSI_SIO_RGB_REG_GREEN_1_0 = 0xF4,
MSI_SIO_RGB_REG_GREEN_3_2 = 0xF5,
MSI_SIO_RGB_REG_GREEN_5_4 = 0xF6,
MSI_SIO_RGB_REG_GREEN_7_6 = 0xF7,
MSI_SIO_RGB_REG_BLUE_1_0 = 0xF8,
MSI_SIO_RGB_REG_BLUE_3_2 = 0xF9,
MSI_SIO_RGB_REG_BLUE_5_4 = 0xFA,
MSI_SIO_RGB_REG_BLUE_7_6 = 0xFB,
MSI_SIO_RGB_REG_CFG_2 = 0xFE,
MSI_SIO_RGB_REG_CFG_3 = 0xFF,
};
#define MSI_SIO_RGB_ENABLE_MASK 0xE0
class MSIRGBController
{
public:
MSIRGBController(int sioaddr);
~MSIRGBController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetMode();
void SetMode(unsigned char new_mode, unsigned char new_speed);
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
private:
int msi_sioaddr;
};
@@ -0,0 +1,40 @@
#include "MSIRGBController.h"
#include "RGBController.h"
#include "RGBController_MSIRGB.h"
#include "super_io.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* DetectMSIRGBControllers *
* *
* Detect MSI-RGB compatible Super-IO chips. *
* *
\******************************************************************************************/
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers)
{
int sio_addrs[2] = {0x2E, 0x4E};
for(int sioaddr_idx = 0; sioaddr_idx < 2; sioaddr_idx++)
{
int sioaddr = sio_addrs[sioaddr_idx];
superio_enter(sioaddr);
int val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) | superio_inb(sioaddr, SIO_REG_DEVID + 1);
switch (val & SIO_ID_MASK)
{
case SIO_NCT6795_ID:
case SIO_NCT6797_ID:
MSIRGBController* new_msi = new MSIRGBController(sioaddr);
RGBController_MSIRGB* new_rgb = new RGBController_MSIRGB(new_msi);
rgb_controllers.push_back(new_rgb);
break;
}
}
} /* DetectMSIRGBControllers() */
@@ -104,6 +104,9 @@ void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
| Send packets | | Send packets |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
hid_send_feature_report(dev, red_grn_buf, 264); hid_send_feature_report(dev, red_grn_buf, 264);
Sleep(5);
hid_send_feature_report(dev, blu_buf, 264); hid_send_feature_report(dev, blu_buf, 264);
} }
@@ -4,118 +4,282 @@
| Driver for Gigabyte Aorus RGB Fusion 2.0 | | Driver for Gigabyte Aorus RGB Fusion 2.0 |
| lighting controller | | lighting controller |
| | | |
| Adam Honse (CalcProgrammer1) 1/15/2020 | | jackun 1/8/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBFusion2Controller.h" #include "RGBFusion2Controller.h"
#include <cstring> #include <algorithm>
#include <stdio.h> #include <array>
#include <stdlib.h> #include <thread>
#include <chrono>
RGBFusion2Controller::RGBFusion2Controller(hid_device* dev_handle) static LEDCount LedCountToEnum(unsigned int c)
{ {
dev = dev_handle; if (c <= 32)
return(LEDS_32);
if (c <= 64)
return(LEDS_64);
if (c <= 256)
return(LEDS_256);
if (c <= 512)
return(LEDS_512);
// Set Device name return(LEDS_1024);
strcpy(device_name, "Gigabyte Motherboard"); }
// Set LED count RGBFusion2Controller::RGBFusion2Controller(hid_device* handle, const char *path) : dev(handle)
led_count = 8; {
int res = 0;
char text[64] {};
unsigned char buffer[64] {};
if( dev ) {
SetCalibration();
// hid report read needs 0x60 packet or it gives IO error
SendPacket(0x60, 0x00);
buffer[0] = report_id;
res = hid_get_feature_report(dev, buffer, 64);
if( res > 0 )
{
report = *reinterpret_cast<IT8297Report*>(buffer);
name = std::string(report.str_product, 32);
name.erase(std::find(name.begin(), name.end(), '\0'), name.end());
snprintf(text, 11, "0x%08X", report.fw_ver);
version = text;
snprintf(text, 11, "0x%08X", report.chip_id);
chip_id = text;
}
loc = path;
EnableBeat(false);
}
} }
RGBFusion2Controller::~RGBFusion2Controller() RGBFusion2Controller::~RGBFusion2Controller()
{ {
if( dev ) {
hid_close(dev);
}
}
void RGBFusion2Controller::SetMode(int m)
{
mode = m;
}
// Sets RGB color mapping to LED pins.
// "Custom" RGB packets don't seem to get remapped so use report.byteorderN and do it manually.
// Of course it all depends how we send data to the controller, but bios/rgb fusion 2 itself
// set it up like this.
void RGBFusion2Controller::SetCalibration()
{
uint8_t buffer[64] {};
buffer[0] = report_id;
buffer[1] = 0x33;
// D_LED1 WS2812 GRB, 0x00RRGGBB to 0x00GGRRBB
buffer[2] = 0x02; // B
buffer[3] = 0x00; // G
buffer[4] = 0x01; // R
buffer[5] = 0x00;
// D_LED2 WS2812 GRB
buffer[6] = 0x02;
buffer[7] = 0x00;
buffer[8] = 0x01;
buffer[9] = 0x00;
// LED C1/C2 12vGRB, seems pins already connect to LEDs correctly
buffer[10] = 0x00;
buffer[11] = 0x01;
buffer[12] = 0x02;
buffer[13] = 0x00;
SendPacket(buffer);
}
void RGBFusion2Controller::SetLedCount(unsigned int count)
{
led_count = count;
LEDCount s0 = LedCountToEnum(count);
SendPacket(0x34, s0 | (s0 << 4)); // D_LED1 | D_LED2
}
bool RGBFusion2Controller::DisableBuiltinEffect(int enable_bit, int mask)
{
if(effect_disabled & enable_bit)
return(true);
effect_disabled &= ~mask;
effect_disabled |= enable_bit;
int res = SendPacket(0x32, effect_disabled);
// Sometimes effect doesn't apply at first, delay a little and let MCU to react, if this packet is the cause
std::this_thread::sleep_for(std::chrono::milliseconds(50));
return res;
}
bool RGBFusion2Controller::EnableBeat(bool e)
{
return SendPacket(0x31, e ? 1 : 0);
} }
std::string RGBFusion2Controller::GetDeviceName() std::string RGBFusion2Controller::GetDeviceName()
{ {
return(device_name); return(name);
}
std::string RGBFusion2Controller::GetFWVersion()
{
return(version);
} }
std::string RGBFusion2Controller::GetDeviceLocation() std::string RGBFusion2Controller::GetDeviceLocation()
{ {
return(""); return(loc);
} }
unsigned int RGBFusion2Controller::GetLEDCount() std::string RGBFusion2Controller::GetSerial()
{ {
return(led_count); return(chip_id);
} }
unsigned char RGBFusion2Controller::GetMode() void RGBFusion2Controller::SetStripColors(unsigned int hdr, int start, int end, std::vector<RGBColor>& colors, int single_led)
{ {
return(0); PktRGB pkt;
} pkt.Init(hdr, report_id);
void RGBFusion2Controller::SetAllColors(unsigned char red, unsigned char green, unsigned char blue) // FIXME assuming that LED strips ports are 0x58/0x59 for all boards
{ uint32_t byteorder = hdr == HDR_D_LED1_RGB ? report.byteorder0 : report.byteorder1;
}
void RGBFusion2Controller::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue) unsigned char bo_r = byteorder >> 16;
{ unsigned char bo_g = byteorder >> 8;
unsigned char usb_buf[] = unsigned char bo_b = byteorder & 0xFF;
int res;
int leds_left = end - start;
int sent_data = 0;
int k = 0;
int leds_in_pkt = sizeof(pkt.s.leds) / sizeof(*pkt.s.leds); /* 19 */
// other leds stay at whatever the builtin effect was doing at that moment
// if breathing/pulse effect faded out then they stay dark
if(single_led > -1)
{ {
0xCC, 0x00, 0x00, 0x00, leds_left = 1;
0x00, 0x00, 0x00, 0x00, k = single_led - start;
0x00, 0x00, 0x00, 0x01, sent_data = k * 3;
0x5A, 0x00, 0x00, 0x00, leds_in_pkt = 1;
0x00, 0x00, 0x00, 0x00, }
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
usb_buf[0x01] = (0x20 | led); while(leds_left > 0)
usb_buf[0x02] = (0x01 << led );
usb_buf[0x0E] = blue;
usb_buf[0x0F] = green;
usb_buf[0x10] = red;
hid_send_feature_report(dev, usb_buf, 64);
SendApply();
}
void RGBFusion2Controller::SendApply()
{
unsigned char usb_buf[] =
{ {
0xCC, 0x28, 0xFF, 0x00, leds_in_pkt = (std::min)(leds_in_pkt, leds_left);
0x00, 0x00, 0x00, 0x00, leds_left -= leds_in_pkt;
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
hid_send_feature_report(dev, usb_buf, 64); pkt.s.bcount = leds_in_pkt * 3;
pkt.s.boffset = sent_data;
sent_data += pkt.s.bcount;
for(int i = 0; i < leds_in_pkt; i++)
{
RGBColor color = colors[start + k];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
pkt.buffer[5 + i * 3 + bo_r] = red;
pkt.buffer[5 + i * 3 + bo_g] = grn;
pkt.buffer[5 + i * 3 + bo_b] = blu;
k++;
}
res = SendPacket(pkt.buffer);
if(res < 0)
return;
}
if (hdr == HDR_D_LED1_RGB)
DisableBuiltinEffect(0x01, 0x01);
else
DisableBuiltinEffect(0x02, 0x02);
} }
void RGBFusion2Controller::SetMode(unsigned char mode) static const std::array< std::array<int, 3>, 5> speeds = {
{
{1600, 1600, 200},
{1200, 1200, 200},
{800, 800, 200},
{400, 400, 200},
{200, 200, 200},
},
};
void RGBFusion2Controller::SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char r, unsigned char g, unsigned char b)
{ {
PktEffect pkt;
pkt.Init(led, report_id);
pkt.e.effect_type = mode;
pkt.e.color0 = r << 16 | g << 8 | b;
if (speed < speeds.size()) {
const auto& s = speeds[speed];
pkt.e.period0 = s[0];
pkt.e.period1 = s[1];
pkt.e.period2 = s[2];
}
switch(mode)
{
case 0: break;
case 1: break; // static
case 2: // breathing
case 3: // blink
if (random)
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
break;
case 4: // color cycle
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
break;
// "fake" effects
case 10: // flashing, flashing color cycle
pkt.e.period0 = 200;
pkt.e.period1 = 200;
pkt.e.period2 = 5000 - 1000 * speed; // time between flashing, doesn't seem to be affected by period0/period1
pkt.e.effect_type = 3;
pkt.e.effect_param2 = 2; // flash twice
if (random)
pkt.e.effect_param0 = 7;
break;
}
SendPacket(pkt.buffer);
} }
void RGBFusion2Controller::dump() bool RGBFusion2Controller::ApplyEffect()
{ {
return SendPacket(0x28, 0xFF);
}
bool RGBFusion2Controller::SendPacket(uint8_t a, uint8_t b, uint8_t c)
{
unsigned char buffer[64] {};
buffer[0] = report_id;
buffer[1] = a;
buffer[2] = b;
buffer[3] = c;
return (SendPacket(buffer) == 64);
}
int RGBFusion2Controller::SendPacket(unsigned char* packet)
{
return hid_send_feature_report(dev, packet, 64);
} }
@@ -4,36 +4,187 @@
| Definitions and types for Gigabyte Aorus | | Definitions and types for Gigabyte Aorus |
| RGB Fusion 2.0 lighting controller | | RGB Fusion 2.0 lighting controller |
| | | |
| Adam Honse (CalcProgrammer1) 1/15/2020 | | jackun 1/8/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include <string> #include "RGBController.h"
#include <cstring>
#include <hidapi/hidapi.h> #include <hidapi/hidapi.h>
#pragma once #pragma once
// LED "headers" 0x20..0x27, As seen on Gigabyte X570 Elite board
const uint8_t HDR_BACK_IO = 0x20;
const uint8_t HDR_CPU = 0x21;
const uint8_t HDR_LED_2 = 0x22;
const uint8_t HDR_PCIE = 0x23;
const uint8_t HDR_LED_C1C2 = 0x24;
const uint8_t HDR_D_LED1 = 0x25;
const uint8_t HDR_D_LED2 = 0x26;
const uint8_t HDR_LED_7 = 0x27;
const uint8_t HDR_D_LED1_RGB = 0x58; // FIXME assuming that it is 0x58 for all boards
const uint8_t HDR_D_LED2_RGB = 0x59;
enum EffectType
{
EFFECT_NONE = 0,
EFFECT_STATIC = 1,
EFFECT_PULSE = 2,
EFFECT_BLINKING = 3,
EFFECT_COLORCYCLE = 4,
// to be continued...
};
enum LEDCount
{
LEDS_32 = 0,
LEDS_64,
LEDS_256,
LEDS_512,
LEDS_1024,
};
struct LEDs
{
uint8_t r;
uint8_t g;
uint8_t b;
};
#pragma pack(push, 1)
union PktRGB
{
unsigned char buffer[64];
struct RGBData
{
uint8_t report_id;
uint8_t header;
uint16_t boffset; // in bytes, absolute
uint8_t bcount;
LEDs leds[19];
uint16_t padding0;
} s;
PktRGB() : s {}
{
}
void Init(uint8_t header, uint8_t report_id)
{
s.report_id = report_id;
s.header = header;
s.boffset = 0;
s.bcount = 0;
memset(s.leds, 0, sizeof(s.leds));
}
};
union PktEffect
{
unsigned char buffer[64];
struct Effect
{
uint8_t report_id;
uint8_t header;
uint32_t zone0; // rgb fusion seems to set it to pow(2, header - 0x20)
uint32_t zone1;
uint8_t reserved0;
uint8_t effect_type;
uint8_t max_brightness;
uint8_t min_brightness;
uint32_t color0;
uint32_t color1;
uint16_t period0; // fade in
uint16_t period1; // fade out
uint16_t period2; // hold
uint16_t period3;
uint8_t effect_param0;
uint8_t effect_param1;
uint8_t effect_param2;
uint8_t effect_param3;
uint8_t padding0[30];
} e;
PktEffect() : e {}
{
}
void Init(int header, uint8_t report_id)
{
memset(buffer, 0, sizeof(buffer));
e.report_id = report_id;
if (header < 8)
e.header = 32 + header; // set as default
else
e.header = header;
e.zone0 = (uint32_t)(1 << (e.header - 32));
e.effect_type = EFFECT_STATIC;
e.max_brightness = 100;
e.min_brightness = 0;
e.color0 = 0x00FF2100; //orange
e.period0 = 1200;
e.period1 = 1200;
e.period2 = 200;
e.period3 = 200;
e.effect_param0 = 0; // ex color count to cycle through (max seems to be 7)
e.effect_param1 = 0;
e.effect_param2 = 1; // ex flash repeat count
e.effect_param3 = 0;
}
};
struct IT8297Report
{
uint8_t report_id;
uint8_t product;
uint8_t device_num;
uint8_t total_leds;
uint32_t fw_ver;
uint16_t curr_led_count;
uint16_t reserved0;
char str_product[32]; // might be 28 and an extra byteorder3
uint32_t byteorder0; // is little-endian 0x00RRGGBB ?
uint32_t byteorder1;
uint32_t byteorder2;
uint32_t chip_id;
uint32_t reserved1;
};
#pragma pack(pop)
class RGBFusion2Controller class RGBFusion2Controller
{ {
public: public:
RGBFusion2Controller(hid_device* dev_handle); RGBFusion2Controller(hid_device* handle, const char *path);
~RGBFusion2Controller(); ~RGBFusion2Controller();
void SetStripColors(unsigned int hdr, int start, int end, std::vector<RGBColor>& colors, int single_led = -1);
void SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char red, unsigned char green, unsigned char blue);
void SetLedCount(unsigned int count);
void SetMode(int mode);
bool ApplyEffect();
bool DisableBuiltinEffect(int enable_bit, int mask);
void SetCalibration();
std::string GetDeviceName(); std::string GetDeviceName();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
unsigned int GetLEDCount(); std::string GetFWVersion();
unsigned char GetMode(); std::string GetSerial();
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
private: private:
void dump(); bool EnableBeat(bool enable);
bool SendPacket(uint8_t a, uint8_t b, uint8_t c = 0);
int SendPacket(unsigned char* packet);
char device_name[32];
unsigned int led_count;
void SendApply();
hid_device* dev; hid_device* dev;
int mode;
unsigned int led_count;
IT8297Report report;
std::string name;
std::string loc;
std::string version;
std::string chip_id;
int effect_disabled = 0;
int report_id = 0xCC;
}; };
@@ -1,36 +1,37 @@
#include "RGBFusion2Controller.h" #include "RGBFusion2Controller.h"
#include "RGBController.h"
#include "RGBController_RGBFusion2.h" #include "RGBController_RGBFusion2.h"
#include <vector>
#include <hidapi/hidapi.h>
#define RGB_FUSION_2_VID 0x048D #define IT8297_VID 0x048D
#define RGB_FUSION_2_PID 0x8297 #define IT8297_PID 0x8297
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectRGBFusion2Controllers * * DetectRGBFusion2Controllers *
* * * *
* Detect RGB Fusion 2.0 controllers on the USB interface. * * Detect RGB Fusion 2 devices that use IT8297 RGB controller *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectRGBFusion2Controllers(std::vector<RGBController*>& rgb_controllers) void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers)
{ {
hid_device* dev; if (hid_init() < 0)
return;
//Look for RGB Fusion 2.0 Controller hid_device_info * device_list = hid_enumerate(IT8297_VID, IT8297_PID);
hid_init(); if (!device_list)
return;
dev = hid_open(RGB_FUSION_2_VID, RGB_FUSION_2_PID, 0); hid_device_info * device = device_list;
while (device)
if( dev )
{ {
RGBFusion2Controller* controller = new RGBFusion2Controller(dev); hid_device * dev = hid_open_path(device->path);
if (dev) {
RGBController_RGBFusion2* rgb_controller = new RGBController_RGBFusion2(controller); RGBFusion2Controller * controller = new RGBFusion2Controller(dev, device_list->path);
RGBController_RGBFusion2 * rgb_controller = new RGBController_RGBFusion2(controller);
rgb_controllers.push_back(rgb_controller); rgb_controllers.push_back(rgb_controller);
}
device = device->next;
} }
} /* DetectRGBFusionControllers() */ hid_free_enumeration(device_list);
}
+8 -9
View File
@@ -249,14 +249,7 @@ void DetectI2CBusses()
{ {
read(test_fd, device_string, sizeof(device_string)); read(test_fd, device_string, sizeof(device_string));
close(test_fd); close(test_fd);
//ignore nvidia adapters for now
if(strncmp(device_string, "NVIDIA", 6) == 0)
{
ent = readdir(dir);
continue;
}
bus = new i2c_smbus_linux(); bus = new i2c_smbus_linux();
strcpy(bus->device_name, device_string); strcpy(bus->device_name, device_string);
@@ -284,6 +277,7 @@ void DetectI2CBusses()
#endif /* WIN32 */ #endif /* WIN32 */
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers); void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers); void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers); void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers); void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
@@ -292,6 +286,7 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers); void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers); void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers); void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers);
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers); void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers);
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers); void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers);
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers); void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers);
@@ -306,6 +301,7 @@ void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controller
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers); void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers);
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers); void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers); void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers);
/******************************************************************************************\ /******************************************************************************************\
* * * *
@@ -314,12 +310,13 @@ void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controll
* Detect and populate RGB Controllers vector * * Detect and populate RGB Controllers vector *
* * * *
\******************************************************************************************/ \******************************************************************************************/
#include "RGBController_Dummy.h"
void DetectRGBControllers(void) void DetectRGBControllers(void)
{ {
DetectI2CBusses(); DetectI2CBusses();
DetectAuraControllers(busses, rgb_controllers); DetectAuraControllers(busses, rgb_controllers);
DetectAuraGPUControllers(busses, rgb_controllers);
DetectCorsairControllers(busses, rgb_controllers); DetectCorsairControllers(busses, rgb_controllers);
DetectCorsairProControllers(busses, rgb_controllers); DetectCorsairProControllers(busses, rgb_controllers);
DetectCrucialControllers(busses, rgb_controllers); DetectCrucialControllers(busses, rgb_controllers);
@@ -329,6 +326,7 @@ void DetectRGBControllers(void)
DetectRGBFusionGPUControllers(busses, rgb_controllers); DetectRGBFusionGPUControllers(busses, rgb_controllers);
DetectRGBFusionControllers(busses, rgb_controllers); DetectRGBFusionControllers(busses, rgb_controllers);
DetectMSIRGBControllers(rgb_controllers);
DetectLEDStripControllers(rgb_controllers); DetectLEDStripControllers(rgb_controllers);
DetectHue2Controllers(rgb_controllers); DetectHue2Controllers(rgb_controllers);
@@ -342,6 +340,7 @@ void DetectRGBControllers(void)
DetectCorsairKeyboardControllers(rgb_controllers); DetectCorsairKeyboardControllers(rgb_controllers);
DetectCorsairNodeProControllers(rgb_controllers); DetectCorsairNodeProControllers(rgb_controllers);
DetectThermaltakeRiingControllers(rgb_controllers); DetectThermaltakeRiingControllers(rgb_controllers);
DetectRGBFusion2Controllers(rgb_controllers);
DetectE131Controllers(rgb_controllers); DetectE131Controllers(rgb_controllers);
+41 -13
View File
@@ -5,6 +5,22 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = OpenRGB TARGET = OpenRGB
TEMPLATE = app TEMPLATE = app
VERSION = 0.0
win32:BUILDDATE = $$system(date /t)
unix:BUILDDATE = $$system(date -R)
GIT_COMMIT_ID = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ rev-parse HEAD)
GIT_COMMIT_DATE = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ show -s --format=%ci HEAD)
GIT_BRANCH = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ rev-parse --abbrev-ref HEAD)
DEFINES += \
VERSION_STRING=\\"\"\"$$VERSION\\"\"\" \
BUILDDATE_STRING=\\"\"\"$$BUILDDATE\\"\"\" \
GIT_COMMIT_ID=\\"\"\"$$GIT_COMMIT_ID\\"\"\" \
GIT_COMMIT_DATE=\\"\"\"$$GIT_COMMIT_DATE\\"\"\" \
GIT_BRANCH=\\"\"\"$$GIT_BRANCH\\"\"\"
RC_ICONS = qt/OpenRGB.ico
INCLUDEPATH += \ INCLUDEPATH += \
dependencies/libe131/src/ \ dependencies/libe131/src/ \
i2c_smbus/ \ i2c_smbus/ \
@@ -14,6 +30,7 @@ INCLUDEPATH += \
super_io/ \ super_io/ \
Controllers/AMDWraithPrismController/ \ Controllers/AMDWraithPrismController/ \
Controllers/AuraController/ \ Controllers/AuraController/ \
Controllers/AuraGPUController/ \
Controllers/CorsairController/ \ Controllers/CorsairController/ \
Controllers/CorsairCmdrProController/ \ Controllers/CorsairCmdrProController/ \
Controllers/CorsairKeyboardController/ \ Controllers/CorsairKeyboardController/ \
@@ -26,6 +43,7 @@ INCLUDEPATH += \
Controllers/HyperXKeyboardController/ \ Controllers/HyperXKeyboardController/ \
Controllers/LEDStripController/ \ Controllers/LEDStripController/ \
Controllers/MSI3ZoneController/ \ Controllers/MSI3ZoneController/ \
Controllers/MSIRGBController/ \
Controllers/PatriotViperController/ \ Controllers/PatriotViperController/ \
Controllers/PolychromeController/ \ Controllers/PolychromeController/ \
Controllers/PoseidonZRGBController/ \ Controllers/PoseidonZRGBController/ \
@@ -39,6 +57,7 @@ INCLUDEPATH += \
SOURCES += \ SOURCES += \
dependencies/libe131/src/e131.c \ dependencies/libe131/src/e131.c \
main.cpp \ main.cpp \
cli.cpp \
OpenRGB.cpp \ OpenRGB.cpp \
qt/OpenRGBDeviceInfoPage.cpp \ qt/OpenRGBDeviceInfoPage.cpp \
qt/OpenRGBDevicePage.cpp \ qt/OpenRGBDevicePage.cpp \
@@ -47,6 +66,8 @@ SOURCES += \
i2c_tools/i2c_tools.cpp \ i2c_tools/i2c_tools.cpp \
net_port/net_port.cpp \ net_port/net_port.cpp \
qt/OpenRGBDialog2.cpp \ qt/OpenRGBDialog2.cpp \
qt/OpenRGBProfileSaveDialog.cpp \
qt/OpenRGBSoftwareInfoPage.cpp \
qt/OpenRGBSystemInfoPage.cpp \ qt/OpenRGBSystemInfoPage.cpp \
qt/hsv.cpp \ qt/hsv.cpp \
serial_port/serial_port.cpp \ serial_port/serial_port.cpp \
@@ -55,6 +76,8 @@ SOURCES += \
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \ Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
Controllers/AuraController/AuraController.cpp \ Controllers/AuraController/AuraController.cpp \
Controllers/AuraController/AuraControllerDetect.cpp \ Controllers/AuraController/AuraControllerDetect.cpp \
Controllers/AuraGPUController/AuraGPUController.cpp \
Controllers/AuraGPUController/AuraGPUControllerDetect.cpp \
Controllers/CorsairController/CorsairController.cpp \ Controllers/CorsairController/CorsairController.cpp \
Controllers/CorsairController/CorsairControllerDetect.cpp \ Controllers/CorsairController/CorsairControllerDetect.cpp \
Controllers/CorsairCmdrProController/CorsairCmdrProController.cpp \ Controllers/CorsairCmdrProController/CorsairCmdrProController.cpp \
@@ -79,6 +102,8 @@ SOURCES += \
Controllers/LEDStripController/LEDStripControllerDetect.cpp \ Controllers/LEDStripController/LEDStripControllerDetect.cpp \
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \ Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \ Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
Controllers/MSIRGBController/MSIRGBController.cpp \
Controllers/MSIRGBController/MSIRGBControllerDetect.cpp \
Controllers/PatriotViperController/PatriotViperController.cpp \ Controllers/PatriotViperController/PatriotViperController.cpp \
Controllers/PatriotViperController/PatriotViperControllerDetect.cpp \ Controllers/PatriotViperController/PatriotViperControllerDetect.cpp \
Controllers/PolychromeController/PolychromeController.cpp \ Controllers/PolychromeController/PolychromeController.cpp \
@@ -97,12 +122,14 @@ SOURCES += \
RGBController/E131ControllerDetect.cpp \ RGBController/E131ControllerDetect.cpp \
RGBController/RGBController_AMDWraithPrism.cpp \ RGBController/RGBController_AMDWraithPrism.cpp \
RGBController/RGBController_Aura.cpp \ RGBController/RGBController_Aura.cpp \
RGBController/RGBController_AuraGPU.cpp \
RGBController/RGBController_Corsair.cpp \ RGBController/RGBController_Corsair.cpp \
RGBController/RGBController_CorsairCmdrPro.cpp \ RGBController/RGBController_CorsairCmdrPro.cpp \
RGBController/RGBController_CorsairKeyboard.cpp \ RGBController/RGBController_CorsairKeyboard.cpp \
RGBController/RGBController_CorsairNodePro.cpp \ RGBController/RGBController_CorsairNodePro.cpp \
RGBController/RGBController_CorsairPro.cpp \ RGBController/RGBController_CorsairPro.cpp \
RGBController/RGBController_Crucial.cpp \ RGBController/RGBController_Crucial.cpp \
RGBController/RGBController_Dummy.cpp \
RGBController/RGBController_Hue2.cpp \ RGBController/RGBController_Hue2.cpp \
RGBController/RGBController_HuePlus.cpp \ RGBController/RGBController_HuePlus.cpp \
RGBController/RGBController_HyperX.cpp \ RGBController/RGBController_HyperX.cpp \
@@ -110,6 +137,7 @@ SOURCES += \
RGBController/RGBController_E131.cpp \ RGBController/RGBController_E131.cpp \
RGBController/RGBController_LEDStrip.cpp \ RGBController/RGBController_LEDStrip.cpp \
RGBController/RGBController_MSI3Zone.cpp \ RGBController/RGBController_MSI3Zone.cpp \
RGBController/RGBController_MSIRGB.cpp \
RGBController/RGBController_PatriotViper.cpp \ RGBController/RGBController_PatriotViper.cpp \
RGBController/RGBController_Polychrome.cpp \ RGBController/RGBController_Polychrome.cpp \
RGBController/RGBController_PoseidonZRGB.cpp \ RGBController/RGBController_PoseidonZRGB.cpp \
@@ -126,12 +154,15 @@ HEADERS += \
i2c_tools/i2c_tools.h \ i2c_tools/i2c_tools.h \
net_port/net_port.h \ net_port/net_port.h \
qt/OpenRGBDialog2.h \ qt/OpenRGBDialog2.h \
qt/OpenRGBProfileSaveDialog.h \
qt/OpenRGBSoftwareInfoPage.h \
qt/OpenRGBSystemInfoPage.h \ qt/OpenRGBSystemInfoPage.h \
serial_port/find_usb_serial_port.h \ serial_port/find_usb_serial_port.h \
serial_port/serial_port.h \ serial_port/serial_port.h \
super_io/super_io.h \ super_io/super_io.h \
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \ Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
Controllers/AuraController/AuraController.h \ Controllers/AuraController/AuraController.h \
Controllers/AuraGPUController/AuraGPUController.h \
Controllers/CorsairController/CorsairController.h \ Controllers/CorsairController/CorsairController.h \
Controllers/CorsairCmdrProController/CorsairCmdrProController.h \ Controllers/CorsairCmdrProController/CorsairCmdrProController.h \
Controllers/CorsairKeyboardController/CorsairKeyboardController.h \ Controllers/CorsairKeyboardController/CorsairKeyboardController.h \
@@ -144,6 +175,7 @@ HEADERS += \
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \ Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
Controllers/LEDStripController/LEDStripController.h \ Controllers/LEDStripController/LEDStripController.h \
Controllers/MSI3ZoneController/MSI3ZoneController.h \ Controllers/MSI3ZoneController/MSI3ZoneController.h \
Controllers/MSIRGBController/MSIRGBController.h \
Controllers/PatriotViperController/PatriotViperController.h \ Controllers/PatriotViperController/PatriotViperController.h \
Controllers/PolychromeController/PolychromeController.h \ Controllers/PolychromeController/PolychromeController.h \
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \ Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
@@ -154,11 +186,13 @@ HEADERS += \
RGBController/RGBController.h \ RGBController/RGBController.h \
RGBController/RGBController_AMDWraithPrism.h \ RGBController/RGBController_AMDWraithPrism.h \
RGBController/RGBController_Aura.h \ RGBController/RGBController_Aura.h \
RGBController/RGBController_AuraGPU.h \
RGBController/RGBController_Corsair.h \ RGBController/RGBController_Corsair.h \
RGBController/RGBController_CorsairCmdrPro.h \ RGBController/RGBController_CorsairCmdrPro.h \
RGBController/RGBController_CorsairNodePro.h \ RGBController/RGBController_CorsairNodePro.h \
RGBController/RGBController_CorsairPro.h \ RGBController/RGBController_CorsairPro.h \
RGBController/RGBController_Crucial.h \ RGBController/RGBController_Crucial.h \
RGBController/RGBController_Dummy.h \
RGBController/RGBController_E131.h \ RGBController/RGBController_E131.h \
RGBController/RGBController_Hue2.h \ RGBController/RGBController_Hue2.h \
RGBController/RGBController_HuePlus.h \ RGBController/RGBController_HuePlus.h \
@@ -166,6 +200,7 @@ HEADERS += \
RGBController/RGBController_HyperXKeyboard.h \ RGBController/RGBController_HyperXKeyboard.h \
RGBController/RGBController_LEDStrip.h \ RGBController/RGBController_LEDStrip.h \
RGBController/RGBController_MSI3Zone.h \ RGBController/RGBController_MSI3Zone.h \
RGBController/RGBController_MSIRGB.h \
RGBController/RGBController_PatriotViper.h \ RGBController/RGBController_PatriotViper.h \
RGBController/RGBController_Polychrome.h \ RGBController/RGBController_Polychrome.h \
RGBController/RGBController_PoseidonZRGB.h \ RGBController/RGBController_PoseidonZRGB.h \
@@ -182,6 +217,8 @@ FORMS += \
qt/OpenRGBDevicePage.ui \ qt/OpenRGBDevicePage.ui \
qt/OpenRGBDialog.ui \ qt/OpenRGBDialog.ui \
qt/OpenRGBDialog2.ui \ qt/OpenRGBDialog2.ui \
qt/OpenRGBProfileSaveDialog.ui \
qt/OpenRGBSoftwareInfoPage.ui \
qt/OpenRGBSystemInfoPage.ui qt/OpenRGBSystemInfoPage.ui
#----------------------------------------------- #-----------------------------------------------
@@ -197,6 +234,7 @@ win32:INCLUDEPATH += \
win32:SOURCES += \ win32:SOURCES += \
dependencies/NVFC/nvapi.cpp \ dependencies/NVFC/nvapi.cpp \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_i801.cpp \ i2c_smbus/i2c_smbus_i801.cpp \
i2c_smbus/i2c_smbus_nct6775.cpp \ i2c_smbus/i2c_smbus_nct6775.cpp \
i2c_smbus/i2c_smbus_nvapi.cpp \ i2c_smbus/i2c_smbus_nvapi.cpp \
@@ -221,7 +259,6 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
-lws2_32 \ -lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \ -L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \
-L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \ -L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x64/" -lhidapi
} }
win32:contains(QMAKE_TARGET.arch, x86) { win32:contains(QMAKE_TARGET.arch, x86) {
@@ -229,7 +266,6 @@ win32:contains(QMAKE_TARGET.arch, x86) {
-lws2_32 \ -lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \ -L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \ -L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi
} }
win32:DEFINES -= \ win32:DEFINES -= \
@@ -263,6 +299,7 @@ win32:contains(QMAKE_TARGET.arch, x86) {
# Linux specific project configuration # Linux specific project configuration
#----------------------------------------------- #-----------------------------------------------
unix:INCLUDEPATH += \ unix:INCLUDEPATH += \
dependencies/hidapi \
unix:HEADERS += \ unix:HEADERS += \
i2c_smbus/i2c_smbus_linux.h \ i2c_smbus/i2c_smbus_linux.h \
@@ -270,19 +307,10 @@ unix:HEADERS += \
unix:LIBS += \ unix:LIBS += \
-lusb-1.0 \ -lusb-1.0 \
-lstdc++fs \
packagesExist(hidapi-libusb){
unix:LIBS += -lhidapi-libusb
} else {
packagesExist(hidapi) {
unix:LIBS += -lhidapi
} else {
unix:LIBS += -lhidapi-libusb
}
}
unix:SOURCES += \ unix:SOURCES += \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_linux.cpp \ i2c_smbus/i2c_smbus_linux.cpp \
serial_port/find_usb_serial_port_linux.cpp \ serial_port/find_usb_serial_port_linux.cpp \
RGBController/OpenRazerDetect.cpp \ RGBController/OpenRazerDetect.cpp \
+684 -1
View File
@@ -1,4 +1,660 @@
#include "RGBController.h" #include "RGBController.h"
#include <cstring>
unsigned char * RGBController::GetDeviceDescription()
{
unsigned int data_ptr = 0;
unsigned int data_size = 0;
/*---------------------------------------------------------*\
| Calculate data size |
\*---------------------------------------------------------*/
unsigned short name_len = strlen(name.c_str()) + 1;
unsigned short description_len = strlen(description.c_str()) + 1;
unsigned short version_len = strlen(version.c_str()) + 1;
unsigned short serial_len = strlen(serial.c_str()) + 1;
unsigned short location_len = strlen(location.c_str()) + 1;
unsigned short num_modes = modes.size();
unsigned short num_zones = zones.size();
unsigned short num_leds = leds.size();
unsigned short num_colors = colors.size();
unsigned short *mode_name_len = new unsigned short[num_modes];
unsigned short *zone_name_len = new unsigned short[num_zones];
unsigned short *led_name_len = new unsigned short[num_leds];
unsigned short *mode_num_colors = new unsigned short[num_modes];
unsigned short *zone_map_rows = new unsigned short[num_zones];
data_size += sizeof(data_size);
data_size += sizeof(device_type);
data_size += name_len + sizeof(name_len);
data_size += description_len + sizeof(description_len);
data_size += version_len + sizeof(version_len);
data_size += serial_len + sizeof(serial_len);
data_size += location_len + sizeof(location_len);
data_size += sizeof(num_modes);
data_size += sizeof(active_mode);
for(int mode_index = 0; mode_index < num_modes; mode_index++)
{
mode_name_len[mode_index] = strlen(modes[mode_index].name.c_str()) + 1;
mode_num_colors[mode_index] = modes[mode_index].colors.size();
data_size += mode_name_len[mode_index] + sizeof(mode_name_len[mode_index]);
data_size += sizeof(modes[mode_index].value);
data_size += sizeof(modes[mode_index].flags);
data_size += sizeof(modes[mode_index].speed_min);
data_size += sizeof(modes[mode_index].speed_max);
data_size += sizeof(modes[mode_index].colors_min);
data_size += sizeof(modes[mode_index].colors_max);
data_size += sizeof(modes[mode_index].speed);
data_size += sizeof(modes[mode_index].direction);
data_size += sizeof(modes[mode_index].color_mode);
data_size += sizeof(mode_num_colors[mode_index]);
data_size += (mode_num_colors[mode_index] * sizeof(RGBColor));
}
data_size += sizeof(num_zones);
for(int zone_index = 0; zone_index < num_zones; zone_index++)
{
zone_name_len[zone_index] = strlen(zones[zone_index].name.c_str()) + 1;
zone_map_rows[zone_index] = zones[zone_index].map.size();
data_size += zone_name_len[zone_index] + sizeof(zone_name_len[zone_index]);
data_size += sizeof(zones[zone_index].type);
data_size += sizeof(zone_map_rows[zone_index]);
for(int row_index = 0; row_index < zone_map_rows[zone_index]; row_index++)
{
data_size += sizeof(unsigned short);
for(int row_led_index = 0; row_led_index < zones[zone_index].map[row_index].size(); row_led_index++)
{
data_size += sizeof(int);
}
}
}
data_size += sizeof(num_leds);
for(int led_index = 0; led_index < num_leds; led_index++)
{
led_name_len[led_index] = strlen(leds[led_index].name.c_str()) + 1;
data_size += led_name_len[led_index] + sizeof(led_name_len[led_index]);
}
data_size += sizeof(num_colors);
data_size += num_colors * sizeof(RGBColor);
/*---------------------------------------------------------*\
| Create data buffer |
\*---------------------------------------------------------*/
unsigned char *data_buf = new unsigned char[data_size];
/*---------------------------------------------------------*\
| Copy in data size |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &data_size, sizeof(data_size));
data_ptr += sizeof(data_size);
/*---------------------------------------------------------*\
| Copy in type |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &type, sizeof(device_type));
data_ptr += sizeof(device_type);
/*---------------------------------------------------------*\
| Copy in name (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &name_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], name.c_str());
data_ptr += name_len;
/*---------------------------------------------------------*\
| Copy in description (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &description_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], description.c_str());
data_ptr += description_len;
/*---------------------------------------------------------*\
| Copy in version (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &version_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], version.c_str());
data_ptr += version_len;
/*---------------------------------------------------------*\
| Copy in serial (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &serial_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], serial.c_str());
data_ptr += serial_len;
/*---------------------------------------------------------*\
| Copy in location (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &location_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], location.c_str());
data_ptr += location_len;
/*---------------------------------------------------------*\
| Copy in number of modes (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_modes, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in active mode (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &active_mode, sizeof(active_mode));
data_ptr += sizeof(active_mode);
/*---------------------------------------------------------*\
| Copy in modes |
\*---------------------------------------------------------*/
for(int mode_index = 0; mode_index < num_modes; mode_index++)
{
/*---------------------------------------------------------*\
| Copy in mode name (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &mode_name_len[mode_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], modes[mode_index].name.c_str());
data_ptr += mode_name_len[mode_index];
/*---------------------------------------------------------*\
| Copy in mode value (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].value, sizeof(modes[mode_index].value));
data_ptr += sizeof(modes[mode_index].value);
/*---------------------------------------------------------*\
| Copy in mode flags (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].flags, sizeof(modes[mode_index].flags));
data_ptr += sizeof(modes[mode_index].flags);
/*---------------------------------------------------------*\
| Copy in mode speed_min (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].speed_min, sizeof(modes[mode_index].speed_min));
data_ptr += sizeof(modes[mode_index].speed_min);
/*---------------------------------------------------------*\
| Copy in mode speed_max (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].speed_max, sizeof(modes[mode_index].speed_max));
data_ptr += sizeof(modes[mode_index].speed_max);
/*---------------------------------------------------------*\
| Copy in mode colors_min (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].colors_min, sizeof(modes[mode_index].colors_min));
data_ptr += sizeof(modes[mode_index].colors_min);
/*---------------------------------------------------------*\
| Copy in mode colors_max (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].colors_max, sizeof(modes[mode_index].colors_max));
data_ptr += sizeof(modes[mode_index].colors_max);
/*---------------------------------------------------------*\
| Copy in mode speed (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].speed, sizeof(modes[mode_index].speed));
data_ptr += sizeof(modes[mode_index].speed);
/*---------------------------------------------------------*\
| Copy in mode direction (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].direction, sizeof(modes[mode_index].direction));
data_ptr += sizeof(modes[mode_index].direction);
/*---------------------------------------------------------*\
| Copy in mode color_mode (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].color_mode, sizeof(modes[mode_index].color_mode));
data_ptr += sizeof(modes[mode_index].color_mode);
/*---------------------------------------------------------*\
| Copy in mode number of colors |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &mode_num_colors[mode_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in mode mode colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < mode_num_colors[mode_index]; color_index++)
{
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].colors[color_index], sizeof(modes[mode_index].colors[color_index]));
data_ptr += sizeof(modes[mode_index].colors[color_index]);
}
}
/*---------------------------------------------------------*\
| Copy in number of zones (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_zones, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in zones |
\*---------------------------------------------------------*/
for(int zone_index = 0; zone_index < num_zones; zone_index++)
{
/*---------------------------------------------------------*\
| Copy in zone name (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zone_name_len[zone_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], zones[zone_index].name.c_str());
data_ptr += zone_name_len[zone_index];
/*---------------------------------------------------------*\
| Copy in zone type (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zones[zone_index].type, sizeof(zones[zone_index].type));
data_ptr += sizeof(zones[zone_index].type);
/*---------------------------------------------------------*\
| Copy in zone map number of rows |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zone_map_rows[zone_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in rows |
\*---------------------------------------------------------*/
for(int row_index = 0; row_index < zone_map_rows[zone_index]; row_index++)
{
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
unsigned short zone_map_row_size = zones[zone_index].map[row_index].size();
memcpy(&data_buf[data_ptr], &zone_map_row_size, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in row LEDs |
\*---------------------------------------------------------*/
for(int row_led_index = 0; row_led_index < zone_map_row_size; row_led_index++)
{
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zones[zone_index].map[row_index][row_led_index], sizeof(zones[zone_index].map[row_index][row_led_index]));
data_ptr += sizeof(zones[zone_index].map[row_index][row_led_index]);
}
}
}
/*---------------------------------------------------------*\
| Copy in number of LEDs (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_leds, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in LEDs |
\*---------------------------------------------------------*/
for(int led_index = 0; led_index < num_leds; led_index++)
{
/*---------------------------------------------------------*\
| Copy in LED name (size+data) |
\*---------------------------------------------------------*/
unsigned short ledname_len = strlen(leds[led_index].name.c_str()) + 1;
memcpy(&data_buf[data_ptr], &ledname_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], leds[led_index].name.c_str());
data_ptr += ledname_len;
}
/*---------------------------------------------------------*\
| Copy in number of colors (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_colors, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < num_colors; color_index++)
{
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &colors[color_index], sizeof(colors[color_index]));
data_ptr += sizeof(colors[color_index]);
}
delete[] mode_name_len;
delete[] zone_name_len;
delete[] led_name_len;
delete[] mode_num_colors;
delete[] zone_map_rows;
return(data_buf);
}
void RGBController::ReadDeviceDescription(unsigned char* data_buf)
{
unsigned int data_ptr = 0;
data_ptr += sizeof(unsigned int);
/*---------------------------------------------------------*\
| Copy in type |
\*---------------------------------------------------------*/
memcpy(&type, &data_buf[data_ptr], sizeof(device_type));
data_ptr += sizeof(device_type);
/*---------------------------------------------------------*\
| Copy in name |
\*---------------------------------------------------------*/
unsigned short name_len;
memcpy(&name_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
name = (char *)&data_buf[data_ptr];
data_ptr += name_len;
/*---------------------------------------------------------*\
| Copy in description |
\*---------------------------------------------------------*/
unsigned short description_len;
memcpy(&description_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
description = (char *)&data_buf[data_ptr];
data_ptr += description_len;
/*---------------------------------------------------------*\
| Copy in version |
\*---------------------------------------------------------*/
unsigned short version_len;
memcpy(&version_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
version = (char *)&data_buf[data_ptr];
data_ptr += version_len;
/*---------------------------------------------------------*\
| Copy in serial |
\*---------------------------------------------------------*/
unsigned short serial_len;
memcpy(&serial_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
serial = (char *)&data_buf[data_ptr];
data_ptr += serial_len;
/*---------------------------------------------------------*\
| Copy in location |
\*---------------------------------------------------------*/
unsigned short location_len;
memcpy(&location_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
location = (char *)&data_buf[data_ptr];
data_ptr += location_len;
/*---------------------------------------------------------*\
| Copy in number of modes (data) |
\*---------------------------------------------------------*/
unsigned short num_modes;
memcpy(&num_modes, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in active mode (data) |
\*---------------------------------------------------------*/
memcpy(&active_mode, &data_buf[data_ptr], sizeof(active_mode));
data_ptr += sizeof(active_mode);
/*---------------------------------------------------------*\
| Copy in modes |
\*---------------------------------------------------------*/
for(int mode_index = 0; mode_index < num_modes; mode_index++)
{
mode new_mode;
/*---------------------------------------------------------*\
| Copy in mode name (size+data) |
\*---------------------------------------------------------*/
unsigned short modename_len;
memcpy(&modename_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
new_mode.name = (char *)&data_buf[data_ptr];
data_ptr += modename_len;
/*---------------------------------------------------------*\
| Copy in mode value (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.value, &data_buf[data_ptr], sizeof(new_mode.value));
data_ptr += sizeof(new_mode.value);
/*---------------------------------------------------------*\
| Copy in mode flags (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.flags, &data_buf[data_ptr], sizeof(new_mode.flags));
data_ptr += sizeof(new_mode.flags);
/*---------------------------------------------------------*\
| Copy in mode speed_min (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.speed_min, &data_buf[data_ptr], sizeof(new_mode.speed_min));
data_ptr += sizeof(new_mode.speed_min);
/*---------------------------------------------------------*\
| Copy in mode speed_max (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.speed_max, &data_buf[data_ptr], sizeof(new_mode.speed_max));
data_ptr += sizeof(new_mode.speed_max);
/*---------------------------------------------------------*\
| Copy in mode colors_min (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.colors_min, &data_buf[data_ptr], sizeof(new_mode.colors_min));
data_ptr += sizeof(new_mode.colors_min);
/*---------------------------------------------------------*\
| Copy in mode colors_max (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.colors_max, &data_buf[data_ptr], sizeof(new_mode.colors_max));
data_ptr += sizeof(new_mode.colors_max);
/*---------------------------------------------------------*\
| Copy in mode speed (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.speed, &data_buf[data_ptr], sizeof(new_mode.speed));
data_ptr += sizeof(new_mode.speed);
/*---------------------------------------------------------*\
| Copy in mode direction (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.direction, &data_buf[data_ptr], sizeof(new_mode.direction));
data_ptr += sizeof(new_mode.direction);
/*---------------------------------------------------------*\
| Copy in mode color_mode (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.color_mode, &data_buf[data_ptr], sizeof(new_mode.color_mode));
data_ptr += sizeof(new_mode.color_mode);
/*---------------------------------------------------------*\
| Copy in mode number of colors |
\*---------------------------------------------------------*/
unsigned short mode_num_colors;
memcpy(&mode_num_colors, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in mode mode colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < mode_num_colors; color_index++)
{
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
RGBColor new_color;
memcpy(&new_color, &data_buf[data_ptr], sizeof(RGBColor));
data_ptr += sizeof(modes[mode_index].colors[color_index]);
new_mode.colors.push_back(new_color);
}
modes.push_back(new_mode);
}
/*---------------------------------------------------------*\
| Copy in number of zones (data) |
\*---------------------------------------------------------*/
unsigned short num_zones;
memcpy(&num_zones, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in zones |
\*---------------------------------------------------------*/
for(int zone_index = 0; zone_index < num_zones; zone_index++)
{
zone new_zone;
/*---------------------------------------------------------*\
| Copy in zone name (size+data) |
\*---------------------------------------------------------*/
unsigned short zonename_len;
memcpy(&zonename_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
new_zone.name = (char *)&data_buf[data_ptr];
data_ptr += zonename_len;
/*---------------------------------------------------------*\
| Copy in zone type (data) |
\*---------------------------------------------------------*/
memcpy(&new_zone.type, &data_buf[data_ptr], sizeof(new_zone.type));
data_ptr += sizeof(new_zone.type);
/*---------------------------------------------------------*\
| Copy in zone map number of rows |
\*---------------------------------------------------------*/
unsigned short zone_map_rows;
memcpy(&zone_map_rows, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in rows |
\*---------------------------------------------------------*/
for(int row_index = 0; row_index < zone_map_rows; row_index++)
{
std::vector<int> new_zone_map_row;
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
unsigned short zone_map_row_size;
memcpy(&zone_map_row_size, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in row LEDs |
\*---------------------------------------------------------*/
for(int row_led_index = 0; row_led_index < zone_map_row_size; row_led_index++)
{
int new_index;
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
memcpy(&new_index, &data_buf[data_ptr], sizeof(int));
data_ptr += sizeof(int);
new_zone_map_row.push_back(new_index);
}
new_zone.map.push_back(new_zone_map_row);
}
zones.push_back(new_zone);
}
/*---------------------------------------------------------*\
| Copy in number of LEDs (data) |
\*---------------------------------------------------------*/
unsigned short num_leds;
memcpy(&num_leds, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in LEDs |
\*---------------------------------------------------------*/
for(int led_index = 0; led_index < num_leds; led_index++)
{
led new_led;
/*---------------------------------------------------------*\
| Copy in LED name (size+data) |
\*---------------------------------------------------------*/
unsigned short ledname_len;
memcpy(&ledname_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
new_led.name = (char *)&data_buf[data_ptr];
data_ptr += ledname_len;
leds.push_back(new_led);
}
/*---------------------------------------------------------*\
| Copy in number of colors (data) |
\*---------------------------------------------------------*/
unsigned short num_colors;
memcpy(&num_colors, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < num_colors; color_index++)
{
RGBColor new_color;
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
memcpy(&new_color, &data_buf[data_ptr], sizeof(RGBColor));
data_ptr += sizeof(RGBColor);
colors.push_back(new_color);
}
}
RGBColor RGBController::GetLED(int led) RGBColor RGBController::GetLED(int led)
{ {
@@ -55,4 +711,31 @@ void RGBController::SetMode(int mode)
active_mode = mode; active_mode = mode;
UpdateMode(); UpdateMode();
} }
std::string device_type_to_str(device_type type)
{
switch(type)
{
case DEVICE_TYPE_MOTHERBOARD:
return "Motherboard";
case DEVICE_TYPE_DRAM:
return "DRAM";
case DEVICE_TYPE_GPU:
return "GPU";
case DEVICE_TYPE_COOLER:
return "Cooler";
case DEVICE_TYPE_LEDSTRIP:
return "LED Strip";
case DEVICE_TYPE_KEYBOARD:
return "Keyboard";
case DEVICE_TYPE_MOUSE:
return "Mouse";
case DEVICE_TYPE_MOUSEMAT:
return "Mousemat";
case DEVICE_TYPE_HEADSET:
return "Headset";
default:
return "Unknown";
}
}
+5
View File
@@ -112,6 +112,8 @@ enum
DEVICE_TYPE_UNKNOWN DEVICE_TYPE_UNKNOWN
}; };
std::string device_type_to_str(device_type type);
typedef struct typedef struct
{ {
std::string name; /* Zone name */ std::string name; /* Zone name */
@@ -148,6 +150,9 @@ public:
int GetMode(); int GetMode();
void SetMode(int mode); void SetMode(int mode);
unsigned char * GetDeviceDescription();
void ReadDeviceDescription(unsigned char* data_buf);
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Functions to be implemented in device implementation | | Functions to be implemented in device implementation |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
+1
View File
@@ -214,6 +214,7 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
led* new_led = new led(); led* new_led = new led();
new_led->name = aura->GetChannelName(i); new_led->name = aura->GetChannelName(i);
new_led->name.append(std::to_string(i));
leds.push_back(*new_led); leds.push_back(*new_led);
+176
View File
@@ -0,0 +1,176 @@
/*-----------------------------------------*\
| RGBController_AuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "RGBController_AuraGPU.h"
int RGBController_AuraGPU::GetDeviceMode()
{
int dev_mode = aura_gpu->AuraGPURegisterRead(AURA_GPU_REG_MODE);
int color_mode = MODE_COLORS_PER_LED;
if(dev_mode == AURA_GPU_MODE_STATIC)
{
if (aura_gpu->direct)
{
dev_mode = AURA_GPU_MODE_DIRECT;
}
}
switch(dev_mode)
{
case AURA_GPU_MODE_OFF:
case AURA_GPU_MODE_SPECTRUM_CYCLE:
color_mode = MODE_COLORS_NONE;
break;
}
for(int mode = 0; mode < modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
active_mode = mode;
modes[mode].color_mode = color_mode;
}
}
return(active_mode);
}
void RGBController_AuraGPU::UpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
aura_gpu->SetLEDColorsDirect(red, grn, blu);
}
else
{
aura_gpu->SetLEDColorsEffect(red, grn, blu);
}
}
}
void RGBController_AuraGPU::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_AuraGPU::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
{
aura_gpu = aura_gpu_ptr;
name = aura_gpu->GetDeviceName();
version = "0.00.1";
location = aura_gpu->GetDeviceLocation();
type = DEVICE_TYPE_GPU;
mode Direct;
Direct.name = "Direct";
Direct.value = AURA_GPU_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Off;
Off.name = "Off";
Off.value = AURA_GPU_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Static;
Static.name = "Static";
Static.value = AURA_GPU_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AURA_GPU_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing);
mode Spectrum_Cycle;
Spectrum_Cycle.name = "Spectrum Cycle";
Spectrum_Cycle.value = AURA_GPU_MODE_SPECTRUM_CYCLE;
Spectrum_Cycle.flags = 0;
Spectrum_Cycle.color_mode = MODE_COLORS_NONE;
modes.push_back(Spectrum_Cycle);
colors.resize(1);
led aura_gpu_led;
aura_gpu_led.name = "GPU";
leds.push_back(aura_gpu_led);
zone aura_gpu_zone;
aura_gpu_zone.name = "GPU";
aura_gpu_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> aura_gpu_zone_map;
aura_gpu_zone_map.push_back(0);
aura_gpu_zone.map.push_back(aura_gpu_zone_map);
zones.push_back(aura_gpu_zone);
unsigned char red = aura_gpu->GetLEDRed();
unsigned char grn = aura_gpu->GetLEDGreen();
unsigned char blu = aura_gpu->GetLEDBlue();
colors[0] = ToRGBColor(red, grn, blu);
active_mode = GetDeviceMode();
}
void RGBController_AuraGPU::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraGPU::UpdateMode()
{
int new_mode = modes[active_mode].value;
aura_gpu->direct = false;
switch(new_mode)
{
// Set all LEDs to 0 and Mode to static as a workaround for the non existing Off Mode
case AURA_GPU_MODE_OFF:
aura_gpu->SetLEDColorsEffect(0, 0, 0);
new_mode = AURA_GPU_MODE_STATIC;
break;
// Direct mode is done by switching to Static and not applying color changes
case AURA_GPU_MODE_DIRECT:
aura_gpu->direct = true;
new_mode = AURA_GPU_MODE_STATIC;
break;
}
aura_gpu->SetMode(new_mode);
}
+29
View File
@@ -0,0 +1,29 @@
/*-----------------------------------------*\
| RGBController_AuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AuraGPUController.h"
class RGBController_AuraGPU : public RGBController
{
public:
RGBController_AuraGPU(AuraGPUController* aura_gpu_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
AuraGPUController* aura_gpu;
int GetDeviceMode();
};
+39
View File
@@ -0,0 +1,39 @@
/*-----------------------------------------*\
| RGBController_Dummy.cpp |
| |
| Generic RGB Interface Dummy Class |
| |
| Adam Honse (CalcProgrammer1) 2/25/2020 |
\*-----------------------------------------*/
#include "RGBController_Dummy.h"
RGBController_Dummy::RGBController_Dummy()
{
}
void RGBController_Dummy::UpdateLEDs()
{
}
void RGBController_Dummy::UpdateZoneLEDs(int zone)
{
}
void RGBController_Dummy::UpdateSingleLED(int led)
{
}
void RGBController_Dummy::SetCustomMode()
{
}
void RGBController_Dummy::UpdateMode()
{
}
+23
View File
@@ -0,0 +1,23 @@
/*-----------------------------------------*\
| RGBController_Dummy.h |
| |
| Generic RGB Interface Dummy Class |
| |
| Adam Honse (CalcProgrammer1) 2/25/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
class RGBController_Dummy : public RGBController
{
public:
RGBController_Dummy();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
};
@@ -9,6 +9,41 @@
#include "RGBController_HyperXKeyboard.h" #include "RGBController_HyperXKeyboard.h"
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
//Thread functions have different types in Windows and Linux
#ifdef WIN32
#define THREAD static void
#define THREADRETURN
#else
#define THREAD static void*
#define THREADRETURN return(NULL);
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
THREAD keepalive_thread(void *param)
{
RGBController_HyperXKeyboard* controller = static_cast<RGBController_HyperXKeyboard*>(param);
controller->KeepaliveThread();
THREADRETURN
}
static const char* zone_names[] = static const char* zone_names[] =
{ {
"Keyboard", "Keyboard",
@@ -223,6 +258,19 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
zones.push_back(new_zone); zones.push_back(new_zone);
} }
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
| 20 seconds of sending the lighting change in order |
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 5s |
\*-----------------------------------------------------*/
#ifdef WIN32
_beginthread(keepalive_thread, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &keepalive_thread, this);
#endif
} }
RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard() RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard()
@@ -269,3 +317,15 @@ void RGBController_HyperXKeyboard::UpdateMode()
hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors); hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors);
} }
} }
void RGBController_HyperXKeyboard::KeepaliveThread()
{
while(1)
{
if(active_mode == 0)
{
hyperx->SetLEDsDirect(colors);
}
Sleep(200);
}
}
@@ -23,6 +23,8 @@ public:
void SetCustomMode(); void SetCustomMode();
void UpdateMode(); void UpdateMode();
void KeepaliveThread();
private: private:
HyperXKeyboardController* hyperx; HyperXKeyboardController* hyperx;
}; };
+75
View File
@@ -0,0 +1,75 @@
/*-----------------------------------------*\
| RGBController_MSIRGB.cpp |
| |
| Generic RGB Interface for MSI-RGB |
| |
| Adam Honse (CalcProgrammer1) 2/14/2020 |
\*-----------------------------------------*/
#include "RGBController_MSIRGB.h"
RGBController_MSIRGB::RGBController_MSIRGB(MSIRGBController* msi_ptr)
{
msi = msi_ptr;
name = "MSI Motherboard";
description = "MSI-RGB Device";
type = DEVICE_TYPE_MOTHERBOARD;
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
led msi_led;
msi_led.name = "MSI LED";
leds.push_back(msi_led);
zone msi_zone;
msi_zone.name = "MSI Zone";
msi_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> msi_zone_map;
msi_zone_map.push_back(0);
msi_zone.map.push_back(msi_zone_map);
zones.push_back(msi_zone);
colors.push_back(0x00000000);
}
RGBController_MSIRGB::~RGBController_MSIRGB()
{
}
void RGBController_MSIRGB::UpdateLEDs()
{
RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
msi->SetColor(red, grn, blu);
}
void RGBController_MSIRGB::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_MSIRGB::UpdateSingleLED(int led)
{
UpdateLEDs();
}
void RGBController_MSIRGB::SetCustomMode()
{
}
void RGBController_MSIRGB::UpdateMode()
{
}
+27
View File
@@ -0,0 +1,27 @@
/*-----------------------------------------*\
| RGBController_MSIRGB.h |
| |
| Generic RGB Interface for MSI-RGB |
| |
| Adam Honse (CalcProgrammer1) 2/14/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "MSIRGBController.h"
class RGBController_MSIRGB : public RGBController
{
public:
RGBController_MSIRGB(MSIRGBController* msi_ptr);
~RGBController_MSIRGB();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
MSIRGBController* msi;
};
+5 -1
View File
@@ -348,11 +348,15 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
for (unsigned int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++) for (unsigned int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
{ {
char id_buf[8];
snprintf(id_buf, 8, "%d", col_id + 1);
RGBColor new_color = 0x00000000; RGBColor new_color = 0x00000000;
colors.push_back(new_color); colors.push_back(new_color);
led* new_led = new led(); led* new_led = new led();
new_led->name = device_list[i]->zones[zone_id]->name; new_led->name = device_list[i]->zones[zone_id]->name + " LED ";
new_led->name.append(id_buf);
leds.push_back(*new_led); leds.push_back(*new_led);
new_zone_map.push_back(led_count); new_zone_map.push_back(led_count);
+254 -58
View File
@@ -4,81 +4,187 @@
| Generic RGB Interface for OpenRGB | | Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 Driver | | Gigabyte RGB Fusion 2.0 Driver |
| | | |
| Adam Honse (CalcProgrammer1) 1/15/2020 | | jackun 1/8/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#include "RGBController_RGBFusion2.h" #include "RGBController_RGBFusion2.h"
#include <sstream>
#include <array>
void RGBController_RGBFusion2::UpdateLEDs() enum
{
ZONE_MB,
ZONE_STRIP1,
ZONE_STRIP2,
};
static const std::array<const char *, 3> led_zones
{
"Motherboard",
"LED Strip 1", // WS2812(B) strips
"LED Strip 2",
};
static const KnownChannels known_channels
{ {
for (std::size_t led = 0; led < colors.size(); led++)
{ {
RGBColor color = colors[led]; "Generic",
unsigned char red = RGBGetRValue(color); {
unsigned char grn = RGBGetGValue(color); {
unsigned char blu = RGBGetBValue(color); { "Led 1", 0x20 },
{ "Led 2", 0x21 },
{ "Led 3", 0x22 },
{ "Led 4", 0x23 },
{ "Led 5", 0x24 },
{ "Led 6", 0x25 },
{ "Led 7", 0x26 },
{ "Led 8", 0x27 },
},
// Zone 1
{
{ "LED Strip 1, LED 0", HDR_D_LED1 },
},
// Zone 2
{
{ "LED Strip 2, LED 0", HDR_D_LED2 },
}
}
},
{
"IT8297BX-GBX570",
{
// Zone 0
{
{ "Back I/O", HDR_BACK_IO },
{ "CPU", HDR_CPU },
{ "PCIe", HDR_PCIE },
{ "LED C1/C2", HDR_LED_C1C2 }, // 12VGRB headers seem to be connected
},
// Zone 1
{
{ "LED Strip 1, LED 0", HDR_D_LED1 },
},
// Zone 2
{
{ "LED Strip 2, LED 0", HDR_D_LED2 },
}
}
},
};
rgb_fusion->SetLEDColor(led, red, grn, blu); RGBController_RGBFusion2::RGBController_RGBFusion2(RGBFusion2Controller* controller_ptr)
}
}
void RGBController_RGBFusion2::UpdateZoneLEDs(int zone)
{ {
RGBColor color = colors[zone]; controller = controller_ptr;
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
rgb_fusion->SetLEDColor(zone, red, grn, blu);
}
void RGBController_RGBFusion2::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
RGBController_RGBFusion2::RGBController_RGBFusion2(RGBFusion2Controller* rgb_fusion_ptr)
{
rgb_fusion = rgb_fusion_ptr;
name = rgb_fusion->GetDeviceName();
description = "RGB Fusion 2.0";
location = rgb_fusion->GetDeviceLocation();
name = "RGB Fusion 2 Controller";
type = DEVICE_TYPE_MOTHERBOARD; type = DEVICE_TYPE_MOTHERBOARD;
description = controller->GetDeviceName();
version = controller->GetFWVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerial();
mode Direct; auto it = known_channels.find(controller->GetDeviceName());
Direct.name = "Direct"; if (it == known_channels.end())
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
colors.resize(rgb_fusion->GetLEDCount());
// Search through all LEDs and create zones for each channel type
for (unsigned int i = 0; i < rgb_fusion->GetLEDCount(); i++)
{ {
zone* new_zone = new zone(); it = known_channels.find("Generic");
led* new_led = new led(); }
std::vector<int>* zone_row = new std::vector<int>(); size_t mb_led_cnt = it->second[0].size();
// Set zone name to channel name mode Static;
new_zone->name = "Zone"; Static.name = "Static";
new_led->name = "LED"; Static.value = EFFECT_STATIC;
Static.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
zone_row->push_back(i); mode Breathing;
Breathing.name = "Breathing";
Breathing.value = EFFECT_PULSE;
Breathing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.speed_min = 0;
Breathing.speed_max = 4;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed = 2;
modes.push_back(Breathing);
// Aura devices can be either single or linear, never matrix mode Blinking;
// That means only one row is needed Blinking.name = "Blinking";
new_zone->map.push_back(*zone_row); Blinking.value = EFFECT_BLINKING;
Blinking.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Blinking.speed_min = 0;
Blinking.speed_max = 4;
Blinking.color_mode = MODE_COLORS_PER_LED;
Blinking.speed = 2;
modes.push_back(Blinking);
// Push new LED to LEDs vector mode ColorCycle;
leds.push_back(*new_led); ColorCycle.name = "Color Cycle";
ColorCycle.value = EFFECT_COLORCYCLE;
ColorCycle.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
ColorCycle.speed_min = 0;
ColorCycle.speed_max = 4;
ColorCycle.color_mode = MODE_COLORS_NONE;
ColorCycle.speed = 2;
modes.push_back(ColorCycle);
// Push new zone to zones vector mode Flashing;
zones.push_back(*new_zone); Flashing.name = "Flashing";
Flashing.value = 10;
Flashing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Flashing.speed_min = 0;
Flashing.speed_max = 4;
Flashing.color_mode = MODE_COLORS_PER_LED;
Flashing.speed = 2;
modes.push_back(Flashing);
per_strip_led_cnt = 64; // TODO needs GUI option
colors.resize(mb_led_cnt + per_strip_led_cnt * 2, 0x000021FF);
controller->SetLedCount(per_strip_led_cnt);
controller->DisableBuiltinEffect(0, 0x3);
unsigned int led_idx = 0;
std::stringstream ss;
for(size_t i = 0; i < led_zones.size(); i++)
{
std::vector<int> new_zone_map;
zone new_zone;
new_zone.name = led_zones[i];
new_zone.type = ZONE_TYPE_LINEAR; // TODO
unsigned int zone_led_cnt = mb_led_cnt;
if( i > 0 )
{
zone_led_cnt = per_strip_led_cnt;
}
for(unsigned int zone_led_idx = 0; zone_led_idx < zone_led_cnt; zone_led_idx++)
{
led new_led;
if( it != known_channels.end() && i < it->second.size() && zone_led_idx < it->second[i].size())
{
new_led.name = it->second[i][zone_led_idx].name;
}
else
{
ss.clear(); ss.str("");
ss << led_zones[i];
if (zone_led_cnt > 1)
{
ss << ", LED " << zone_led_idx;
}
new_led.name = ss.str();
}
leds.push_back(new_led);
new_zone_map.push_back(led_idx);
led_idx++;
}
new_zone.map.push_back(new_zone_map);
zones.push_back(new_zone);
} }
} }
@@ -87,7 +193,97 @@ void RGBController_RGBFusion2::SetCustomMode()
active_mode = 0; active_mode = 0;
} }
void RGBController_RGBFusion2::UpdateLEDs()
{
for(size_t i = 0; i < led_zones.size(); i++)
{
UpdateZoneLEDs(i);
}
}
void RGBController_RGBFusion2::UpdateZoneLEDs(int zone)
{
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
auto it = known_channels.find(controller->GetDeviceName());
if (it == known_channels.end())
{
it = known_channels.find("Generic");
}
if (it == known_channels.end() || zone >= (int)it->second.size())
{
return;
}
if(zone == ZONE_MB)
{
std::vector<int>& leds = zones[zone].map[0];
for(size_t i = 0; i < leds.size(); i++)
{
unsigned char red = RGBGetRValue(colors[leds[i]]);
unsigned char grn = RGBGetGValue(colors[leds[i]]);
unsigned char blu = RGBGetBValue(colors[leds[i]]);
controller->SetLEDEffect(it->second[zone][i].header, modes[active_mode].value, modes[active_mode].speed, random, red, grn, blu);
}
controller->ApplyEffect();
}
else // assuming other two zones are LED strips
{
int led = zones[zone].map[0][0];
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
int hdr = it->second[zone].size() ? it->second[zone].front().header : led;
// apply built-in effects to LED strips
controller->DisableBuiltinEffect(0, zone == 1 ? 0x01 : 0x02);
controller->SetLEDEffect(hdr, modes[active_mode].value, modes[active_mode].speed, random, red, grn, blu);
controller->ApplyEffect();
}
}
void RGBController_RGBFusion2::UpdateSingleLED(int led)
{
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
if (led >= zones[ZONE_STRIP1].map[0].front() && led <= zones[ZONE_STRIP1].map[0].back())
{
controller->SetStripColors(HDR_D_LED1_RGB,
zones[ZONE_STRIP1].map[0].front(),
zones[ZONE_STRIP1].map[0].back(),
colors, led);
}
else if (led >= zones[ZONE_STRIP2].map[0].front() && led <= zones[ZONE_STRIP2].map[0].back())
{
controller->SetStripColors(HDR_D_LED2_RGB,
zones[ZONE_STRIP2].map[0].front(),
zones[ZONE_STRIP2].map[0].back(),
colors, led);
}
else
{
int header = led;
auto it = known_channels.find(controller->GetDeviceName());
if (it == known_channels.end() || it->second.size() == 0)
header = it->second[ZONE_MB][led].header;
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SetLEDEffect(header, modes[active_mode].value, modes[active_mode].speed, random, red, grn, blu);
controller->ApplyEffect();
}
}
void RGBController_RGBFusion2::UpdateMode() void RGBController_RGBFusion2::UpdateMode()
{ {
rgb_fusion->SetMode(modes[active_mode].value); // XXX Comment out to allow each zone or motherboard LED have different modes
UpdateLEDs();
} }
+18 -7
View File
@@ -4,25 +4,36 @@
| Generic RGB Interface for OpenRGB | | Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 Driver | | Gigabyte RGB Fusion 2.0 Driver |
| | | |
| Adam Honse (CalcProgrammer1) 1/15/2020 | | jackun 1/8/2020 |
\*-----------------------------------------*/ \*-----------------------------------------*/
#pragma once #pragma once
#include "RGBController.h" #include "RGBController.h"
#include "RGBFusion2Controller.h" #include "RGBFusion2Controller.h"
#include <map>
#include <vector>
class RGBController_RGBFusion2 : public RGBController struct LedPort
{
const char* name;
int header;
};
typedef std::vector< std::vector<LedPort> > ZoneLeds;
typedef std::map< std::string, ZoneLeds > KnownChannels;
class RGBController_RGBFusion2: public RGBController
{ {
public: public:
RGBController_RGBFusion2(RGBFusion2Controller* rgb_fusion_ptr); RGBController_RGBFusion2(RGBFusion2Controller* controller_ptr);
void SetCustomMode();
void UpdateLEDs(); void UpdateLEDs();
void UpdateZoneLEDs(int zone); void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led); void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode(); void UpdateMode();
private: private:
RGBFusion2Controller* rgb_fusion; RGBFusion2Controller* controller;
IT8297Report report;
unsigned int per_strip_led_cnt;
}; };
+368
View File
@@ -0,0 +1,368 @@
#include <vector>
#include <cstring>
#include <string>
#include <tuple>
#include <iostream>
#include "OpenRGB.h"
#include "RGBController.h"
#include "i2c_smbus.h"
extern std::vector<i2c_smbus_interface*> busses;
extern std::vector<RGBController*> rgb_controllers;
struct DeviceOptions
{
int device;
std::vector<std::tuple<unsigned char, unsigned char, unsigned char>> colors;
std::string mode;
bool hasOption;
};
struct Options
{
std::vector<DeviceOptions> devices;
// if hasDevice is false, devices above is empty and allDeviceOptions
// shall be applied to all available devices
bool hasDevice;
DeviceOptions allDeviceOptions;
};
void PrintHelp()
{
std::string help_text;
help_text += "OpenRGB ";
help_text += VERSION_STRING;
help_text += ", for controlling RGB lighting.\n";
help_text += "Usage: OpenRGB (--device [--mode] [--color])...\n";
help_text += "\nOptions:\n";
help_text += "--gui\t\t\t\t\t Show GUI, also appears when not passing any parameters\n";
help_text += "-l, --list-devices\t\t\t Lists every compatible device with their number\n";
help_text += "-d, --device [0-9]\t\t\t Selects device to apply colors and/or effect to, or applies to all devices if omitted\n";
help_text += "\t\t\t\t\t Can be specified multiple times with different modes and colors\n";
help_text += "-c, --color \"FFFFFF,00AAFF...\"\t\t Sets colors on each device directly if no effect is specified, and sets the effect color if an effect is specified\n";
help_text += "\t\t\t\t\t If there are more LEDs than colors given, the last color will be applied to the remaining LEDs\n";
help_text += "-m, --mode [breathing | static | ...] Sets the mode to be applied, check --list-devices to see which modes are supported on your device\n";
help_text += "-v, --version\t\t\t\t Display version and software build information\n";
std::cout << help_text << std::endl;
}
void PrintVersion()
{
std::string version_text;
version_text += "OpenRGB ";
version_text += VERSION_STRING;
version_text += ", for controlling RGB lighting.\n";
version_text += " Version:\t\t ";
version_text += VERSION_STRING;
version_text += "\n Build Date\t\t ";
version_text += BUILDDATE_STRING;
version_text += "\n Git Commit ID\t\t ";
version_text += GIT_COMMIT_ID;
version_text += "\n Git Commit Date\t ";
version_text += GIT_COMMIT_DATE;
version_text += "\n Git Branch\t\t ";
version_text += GIT_BRANCH;
version_text += "\n";
std::cout << version_text << std::endl;
}
bool ParseColors(std::string colors_string, DeviceOptions *options)
{
while (colors_string.length() >= 6)
{
int rgb_end = colors_string.find_first_of(',');
std::string color = colors_string.substr(0, rgb_end);
if (color.length() != 6)
break;
try
{
unsigned char r = std::stoi(color.substr(0, 2), nullptr, 16);
unsigned char g = std::stoi(color.substr(2, 2), nullptr, 16);
unsigned char b = std::stoi(color.substr(4, 2), nullptr, 16);
options->colors.push_back(std::make_tuple(r, g, b));
}
catch (...)
{
break;
}
// If there are no more colors
if (rgb_end == std::string::npos)
break;
// Remove the current color and the next color's leading comma
colors_string = colors_string.substr(color.length() + 1);
}
return options->colors.size() > 0;
}
int ParseMode(DeviceOptions& options)
{
auto availableModes = rgb_controllers[options.device]->modes;
for (int i = 0; i < availableModes.size(); i++)
{
if (availableModes[i].name == options.mode)
{
return i;
}
}
std::cout << "Error: Mode '" + options.mode + "' not available for device '" +
rgb_controllers[options.device]->name + "'" << std::endl;
return false;
}
DeviceOptions* GetDeviceOptionsForDevID(Options *opts, int device)
{
if (device == -1)
{
return &opts->allDeviceOptions;
}
for (int i = 0; i < opts->devices.size(); i++)
{
if (opts->devices[i].device == device)
{
return &opts->devices[i];
}
}
// should never happen
std::cout << "Internal error: Tried setting an option on a device that wasn't specified" << std::endl;
abort();
}
std::string QuoteIfNecessary(std::string str)
{
if (str.find(' ') == std::string::npos)
{
return str;
}
else
{
return "'" + str + "'";
}
}
bool ProcessOptions(int argc, char *argv[], Options *res)
{
int arg_index = 1;
int currentDev = -1;
while (arg_index < argc)
{
std::string option = argv[arg_index];
// Handle options that take no arguments
if (option == "--list-devices" || option == "-l")
{
for (int i = 0; i < rgb_controllers.size(); i++)
{
RGBController *c = rgb_controllers[i];
std::cout << i << ": " << c->name << std::endl;
std::cout << " Type: " << device_type_to_str(c->type) << std::endl;
if (!c->serial.empty())
{
std::cout << " Serial: " << c->serial << std::endl;
}
if (!c->description.empty())
{
std::cout << " Description: " << c->description << std::endl;
}
if (!c->modes.empty())
{
std::cout << " Modes:";
int curMode = c->GetMode();
for (int i = 0; i < c->modes.size(); i++)
{
std::string modeStr = QuoteIfNecessary(c->modes[i].name);
if (curMode == i) {
modeStr = "[" + modeStr + "]";
}
std::cout << " " << modeStr;
}
std::cout << std::endl;
}
if (!c->zones.empty())
{
std::cout << " Zones:";
for (int i = 0; i < c->zones.size(); i++)
{
std::cout << " " << QuoteIfNecessary(c->zones[i].name);
}
std::cout << std::endl;
}
if (!c->leds.empty())
{
std::cout << " LEDs:";
for (int i = 0; i < c->leds.size(); i++)
{
std::cout << " " << QuoteIfNecessary(c->leds[i].name);
}
std::cout << std::endl;
}
std::cout << std::endl;
}
exit(0);
}
else if (arg_index + 1 < argc) // Handle options that take an argument
{
std::string argument = argv[arg_index + 1];
if (option == "--device" || option == "-d")
{
try
{
currentDev = std::stoi(argument);
if (rgb_controllers.size() <= currentDev || currentDev < 0)
{
throw;
}
DeviceOptions newDev;
newDev.device = currentDev;
if (!res->hasDevice)
{
res->hasDevice = true;
}
res->devices.push_back(newDev);
}
catch (...)
{
std::cout << "Error: Invalid device ID: " + argument << std::endl;
return false;
}
}
else if (option == "--color" || option == "-c")
{
DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, currentDev);
if (ParseColors(argument, currentDevOpts))
{
currentDevOpts->hasOption = true;
}
else
{
std::cout << "Error: Invalid argument to " + option + ": " + argument << std::endl;
return false;
}
}
else if (option == "--mode" || option == "-m")
{
DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, currentDev);
currentDevOpts->mode = argument;
currentDevOpts->hasOption = true;
}
else
{
std::cout << "Error: Invalid option: " + option << std::endl;
return false;
}
arg_index++;
}
else
{
return false;
}
arg_index++;
}
if (res->hasDevice)
{
for (int i = 0; i < res->devices.size(); i++)
{
if (!res->devices[i].hasOption)
{
std::cout << "Error: Device " + std::to_string(i) + " specified, but neither mode nor color given" << std::endl;
return false;
}
}
}
else
{
return res->allDeviceOptions.hasOption;
}
return true;
}
void ApplyOptions(DeviceOptions& options)
{
RGBController *device = rgb_controllers[options.device];
// Set mode first, in case it's 'direct' (which affects SetLED below)
int mode = ParseMode(options);
device->SetMode(mode);
if (options.colors.size() != 0)
{
int last_set_color;
for (int i = 0; i < device->leds.size(); i++)
{
if (i < options.colors.size())
{
last_set_color = i;
}
device->SetLED(i, ToRGBColor(std::get<0>(options.colors[last_set_color]),
std::get<1>(options.colors[last_set_color]),
std::get<2>(options.colors[last_set_color])));
}
}
}
int cli_main(int argc, char *argv[])
{
if (argc == 2 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")))
{
PrintHelp();
return 0;
}
if (argc == 2 && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")))
{
PrintVersion();
return 0;
}
DetectRGBControllers();
Options options;
if (!ProcessOptions(argc, argv, &options))
{
PrintHelp();
return -1;
}
if (options.hasDevice)
{
for (int i = 0; i < options.devices.size(); i++)
{
ApplyOptions(options.devices[i]);
}
}
else
{
for (int i = 0; i < rgb_controllers.size(); i++)
{
options.allDeviceOptions.device = i;
ApplyOptions(options.allDeviceOptions);
}
}
return 0;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1383
View File
File diff suppressed because it is too large Load Diff
+28 -32
View File
@@ -30,7 +30,7 @@
#include <wchar.h> #include <wchar.h>
#ifdef _WIN32 #ifdef _WIN32
#define HID_API_EXPORT __declspec(dllexport) #define HID_API_EXPORT
#define HID_API_CALL #define HID_API_CALL
#else #else
#define HID_API_EXPORT /**< API export macro */ #define HID_API_EXPORT /**< API export macro */
@@ -69,13 +69,9 @@ extern "C" {
(Windows/Mac only).*/ (Windows/Mac only).*/
unsigned short usage; unsigned short usage;
/** The USB interface which this logical device /** The USB interface which this logical device
represents. represents. Valid on both Linux implementations
in all cases, and valid on the Windows implementation
* Valid on both Linux implementations in all cases. only if the device contains more than one interface. */
* Valid on the Windows implementation only if the device
contains more than one interface.
* Valid on the Mac implementation if and only if the device
is a USB HID device. */
int interface_number; int interface_number;
/** Pointer to the next device */ /** Pointer to the next device */
@@ -129,7 +125,7 @@ extern "C" {
@returns @returns
This function returns a pointer to a linked list of type This function returns a pointer to a linked list of type
struct #hid_device_info, containing information about the HID devices struct #hid_device, containing information about the HID devices
attached to the system, or NULL in the case of failure. Free attached to the system, or NULL in the case of failure. Free
this linked list by calling hid_free_enumeration(). this linked list by calling hid_free_enumeration().
*/ */
@@ -195,7 +191,7 @@ extern "C" {
the Control Endpoint (Endpoint 0). the Control Endpoint (Endpoint 0).
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data The data to send, including the report number as @param data The data to send, including the report number as
the first byte. the first byte.
@param length The length in bytes of the data to send. @param length The length in bytes of the data to send.
@@ -204,7 +200,7 @@ extern "C" {
This function returns the actual number of bytes written and This function returns the actual number of bytes written and
-1 on error. -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length);
/** @brief Read an Input report from a HID device with timeout. /** @brief Read an Input report from a HID device with timeout.
@@ -213,7 +209,7 @@ extern "C" {
contain the Report number if the device uses numbered reports. contain the Report number if the device uses numbered reports.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data A buffer to put the read data into. @param data A buffer to put the read data into.
@param length The number of bytes to read. For devices with @param length The number of bytes to read. For devices with
multiple reports, make sure to read an extra byte for multiple reports, make sure to read an extra byte for
@@ -234,7 +230,7 @@ extern "C" {
contain the Report number if the device uses numbered reports. contain the Report number if the device uses numbered reports.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data A buffer to put the read data into. @param data A buffer to put the read data into.
@param length The number of bytes to read. For devices with @param length The number of bytes to read. For devices with
multiple reports, make sure to read an extra byte for multiple reports, make sure to read an extra byte for
@@ -245,7 +241,7 @@ extern "C" {
-1 on error. If no packet was available to be read and -1 on error. If no packet was available to be read and
the handle is in non-blocking mode, this function returns 0. the handle is in non-blocking mode, this function returns 0.
*/ */
int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length);
/** @brief Set the device handle to be non-blocking. /** @brief Set the device handle to be non-blocking.
@@ -257,7 +253,7 @@ extern "C" {
Nonblocking can be turned on and off at any time. Nonblocking can be turned on and off at any time.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param nonblock enable or not the nonblocking reads @param nonblock enable or not the nonblocking reads
- 1 to enable nonblocking - 1 to enable nonblocking
- 0 to disable nonblocking. - 0 to disable nonblocking.
@@ -265,7 +261,7 @@ extern "C" {
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock); int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock);
/** @brief Send a Feature report to the device. /** @brief Send a Feature report to the device.
@@ -283,7 +279,7 @@ extern "C" {
in would be 17. in would be 17.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data The data to send, including the report number as @param data The data to send, including the report number as
the first byte. the first byte.
@param length The length in bytes of the data to send, including @param length The length in bytes of the data to send, including
@@ -293,7 +289,7 @@ extern "C" {
This function returns the actual number of bytes written and This function returns the actual number of bytes written and
-1 on error. -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length);
/** @brief Get a feature report from a HID device. /** @brief Get a feature report from a HID device.
@@ -304,7 +300,7 @@ extern "C" {
start in data[1]. start in data[1].
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param data A buffer to put the read data into, including @param data A buffer to put the read data into, including
the Report ID. Set the first byte of @p data[] to the the Report ID. Set the first byte of @p data[] to the
Report ID of the report to be read, or set it to zero Report ID of the report to be read, or set it to zero
@@ -318,55 +314,55 @@ extern "C" {
one for the report ID (which is still in the first one for the report ID (which is still in the first
byte), or -1 on error. byte), or -1 on error.
*/ */
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length); int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length);
/** @brief Close a HID device. /** @brief Close a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
*/ */
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev); void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device);
/** @brief Get The Manufacturer String from a HID device. /** @brief Get The Manufacturer String from a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen);
/** @brief Get The Product String from a HID device. /** @brief Get The Product String from a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen);
/** @brief Get The Serial Number String from a HID device. /** @brief Get The Serial Number String from a HID device.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen);
/** @brief Get a string from a HID device, based on its string index. /** @brief Get a string from a HID device, based on its string index.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@param string_index The index of the string to get. @param string_index The index of the string to get.
@param string A wide string buffer to put the data into. @param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t. @param maxlen The length of the buffer in multiples of wchar_t.
@@ -374,18 +370,18 @@ extern "C" {
@returns @returns
This function returns 0 on success and -1 on error. This function returns 0 on success and -1 on error.
*/ */
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen); int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen);
/** @brief Get a string describing the last error which occurred. /** @brief Get a string describing the last error which occurred.
@ingroup API @ingroup API
@param dev A device handle returned from hid_open(). @param device A device handle returned from hid_open().
@returns @returns
This function returns a string containing the last error This function returns a string containing the last error
which occurred or NULL if none has occurred. which occurred or NULL if none has occurred.
*/ */
HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *dev); HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device);
#ifdef __cplusplus #ifdef __cplusplus
} }
Binary file not shown.
+8
View File
@@ -19,6 +19,9 @@
extern std::vector<i2c_smbus_interface*> busses; extern std::vector<i2c_smbus_interface*> busses;
extern std::vector<RGBController*> rgb_controllers; extern std::vector<RGBController*> rgb_controllers;
// See cli.cpp
extern int cli_main(int argc, char *argv[]);
/******************************************************************************************\ /******************************************************************************************\
* * * *
* main * * main *
@@ -29,6 +32,11 @@ extern std::vector<RGBController*> rgb_controllers;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (argc > 1 && strcmp(argv[1], "--gui"))
{
return cli_main(argc, argv);
}
DetectRGBControllers(); DetectRGBControllers();
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

+1 -32
View File
@@ -8,38 +8,7 @@ OpenRGBDeviceInfoPage::OpenRGBDeviceInfoPage(RGBController *dev, QWidget *parent
{ {
ui->setupUi(this); ui->setupUi(this);
switch(dev->type) ui->TypeValue->setText(device_type_to_str(dev->type).c_str());
{
case DEVICE_TYPE_MOTHERBOARD:
ui->TypeValue->setText("Motherboard");
break;
case DEVICE_TYPE_DRAM:
ui->TypeValue->setText("DRAM");
break;
case DEVICE_TYPE_GPU:
ui->TypeValue->setText("GPU");
break;
case DEVICE_TYPE_COOLER:
ui->TypeValue->setText("Cooler");
break;
case DEVICE_TYPE_LEDSTRIP:
ui->TypeValue->setText("LED Strip");
break;
case DEVICE_TYPE_KEYBOARD:
ui->TypeValue->setText("Keyboard");
break;
case DEVICE_TYPE_MOUSE:
ui->TypeValue->setText("Mouse");
break;
case DEVICE_TYPE_MOUSEMAT:
ui->TypeValue->setText("Mousemat");
break;
case DEVICE_TYPE_HEADSET:
ui->TypeValue->setText("Headset");
break;
default:
ui->TypeValue->setText("Unknown");
}
ui->NameValue->setText(QString::fromStdString(dev->name)); ui->NameValue->setText(QString::fromStdString(dev->name));
ui->DescriptionValue->setText(QString::fromStdString(dev->description)); ui->DescriptionValue->setText(QString::fromStdString(dev->description));
+14
View File
@@ -597,6 +597,11 @@ void Ui::OpenRGBDevicePage::UpdateMode()
| Change device mode | | Change device mode |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
device->SetMode(current_mode); device->SetMode(current_mode);
if(device->modes[current_mode].color_mode == MODE_COLORS_PER_LED)
{
device->UpdateLEDs();
}
} }
} }
} }
@@ -613,6 +618,15 @@ void Ui::OpenRGBDevicePage::SetDevice(unsigned char red, unsigned char green, un
on_SetDeviceButton_clicked(); on_SetDeviceButton_clicked();
} }
void Ui::OpenRGBDevicePage::UpdateDevice()
{
ui->ModeBox->blockSignals(true);
ui->ModeBox->setCurrentIndex(device->active_mode);
ui->ModeBox->blockSignals(false);
UpdateModeUi();
UpdateMode();
}
void Ui::OpenRGBDevicePage::SetCustomMode() void Ui::OpenRGBDevicePage::SetCustomMode()
{ {
device->SetCustomMode(); device->SetCustomMode();
+1
View File
@@ -20,6 +20,7 @@ public:
void SetDevice(unsigned char red, unsigned char green, unsigned char blue); void SetDevice(unsigned char red, unsigned char green, unsigned char blue);
void SetCustomMode(); void SetCustomMode();
void UpdateDevice();
void UpdateMode(); void UpdateMode();
void UpdateModeUi(); void UpdateModeUi();
+384 -1
View File
@@ -1,9 +1,18 @@
#include <fstream>
#include "OpenRGBDialog2.h" #include "OpenRGBDialog2.h"
#include "OpenRGBDevicePage.h" #include "OpenRGBDevicePage.h"
#include "OpenRGBDeviceInfoPage.h" #include "OpenRGBDeviceInfoPage.h"
#include "OpenRGBSoftwareInfoPage.h"
#include "OpenRGBSystemInfoPage.h" #include "OpenRGBSystemInfoPage.h"
#include "OpenRGBProfileSaveDialog.h"
#include "RGBController_Dummy.h"
#include <QLabel> #include <QLabel>
#include <QTabBar> #include <QTabBar>
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
using namespace Ui; using namespace Ui;
@@ -14,6 +23,44 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
QIcon logo(":OpenRGB.png"); QIcon logo(":OpenRGB.png");
setWindowIcon(logo); setWindowIcon(logo);
/*---------------------------------------------------------*\
| Load profiles by looking for .orp files in current dir |
\*---------------------------------------------------------*/
for(const auto & entry : fs::directory_iterator("."))
{
std::string filename = entry.path().filename().string();
if(filename.find(".orp") != std::string::npos)
{
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream profile_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
profile_file.read(header_string, 16);
profile_file.read((char *)&header_version, sizeof(unsigned int));
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Add this profile to the list |
\*---------------------------------------------------------*/
ui->comboBox->addItem(filename.c_str());
}
}
profile_file.close();
}
}
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Set up tray icon menu | | Set up tray icon menu |
\*-----------------------------------------------------*/ \*-----------------------------------------------------*/
@@ -25,6 +72,18 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
connect(actionShowHide, SIGNAL(triggered()), this, SLOT(on_ShowHide())); connect(actionShowHide, SIGNAL(triggered()), this, SLOT(on_ShowHide()));
trayIconMenu->addAction(actionShowHide); trayIconMenu->addAction(actionShowHide);
QMenu* profileMenu = new QMenu("Profiles", this);
for(int profile_index = 0; profile_index < ui->comboBox->count(); profile_index++)
{
QAction* actionProfileSelected = new QAction(ui->comboBox->itemText(profile_index), this);
actionProfileSelected->setObjectName(ui->comboBox->itemText(profile_index));
connect(actionProfileSelected, SIGNAL(triggered()), this, SLOT(on_ProfileSelected()));
profileMenu->addAction(actionProfileSelected);
}
trayIconMenu->addMenu(profileMenu);
QMenu* quickColorsMenu = new QMenu("Quick Colors", this); QMenu* quickColorsMenu = new QMenu("Quick Colors", this);
QAction* actionQuickRed = new QAction("Red", this); QAction* actionQuickRed = new QAction("Red", this);
@@ -200,6 +259,25 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
SystemTabLabel->setGeometry(0, 0, 200, 20); SystemTabLabel->setGeometry(0, 0, 200, 20);
InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SystemTabLabel); InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SystemTabLabel);
OpenRGBSoftwareInfoPage *SoftInfoPage = new OpenRGBSoftwareInfoPage();
ui->InformationTabBar->addTab(SoftInfoPage, "");
/*-----------------------------------------------------*\
| Use Qt's HTML capabilities to display both icon and |
| text in the tab label. Choose icon based on device |
| type and append device name string. |
\*-----------------------------------------------------*/
QString SoftwareLabelString = "<html><table><tr><td width='30'><img src='";
SoftwareLabelString += ":/keyboard.svg";
SoftwareLabelString += "' height='15' width='15'></td><td>Software</td></tr></table></html>";
QLabel *SoftwareTabLabel = new QLabel();
SoftwareTabLabel->setText(SoftwareLabelString);
SoftwareTabLabel->setIndent(20);
SoftwareTabLabel->setGeometry(0, 0, 200, 20);
InformationTabBar->setTabButton(control.size() + 1, QTabBar::LeftSide, SoftwareTabLabel);
} }
OpenRGBDialog2::~OpenRGBDialog2() OpenRGBDialog2::~OpenRGBDialog2()
@@ -276,4 +354,309 @@ void OpenRGBDialog2::on_ShowHide()
{ {
hide(); hide();
} }
} }
void Ui::OpenRGBDialog2::on_ProfileSelected()
{
std::vector<RGBController*> temp_controllers;
unsigned int controller_size;
unsigned int controller_offset = 0;
std::string filename = QObject::sender()->objectName().toStdString();
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream controller_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
controller_file.read(header_string, 16);
controller_file.read((char *)&header_version, sizeof(unsigned int));
controller_offset += 16 + sizeof(unsigned int);
controller_file.seekg(controller_offset);
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Read controller data from file until EOF |
\*---------------------------------------------------------*/
while(!(controller_file.peek() == EOF))
{
controller_file.read((char *)&controller_size, sizeof(controller_size));
unsigned char *controller_data = new unsigned char[controller_size];
controller_file.seekg(controller_offset);
controller_file.read((char *)controller_data, controller_size);
RGBController_Dummy *temp_controller = new RGBController_Dummy();
temp_controller->ReadDeviceDescription(controller_data);
temp_controllers.push_back(temp_controller);
delete[] controller_data;
controller_offset += controller_size;
controller_file.seekg(controller_offset);
}
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
{
RGBController *temp_controller = temp_controllers[controller_index];
RGBController *controller_ptr = controllers[controller_index];
/*---------------------------------------------------------*\
| Test if saved controller data matches this controller |
\*---------------------------------------------------------*/
if((temp_controller->type == controller_ptr->type )
&&(temp_controller->name == controller_ptr->name )
&&(temp_controller->description == controller_ptr->description)
&&(temp_controller->version == controller_ptr->version )
&&(temp_controller->serial == controller_ptr->serial )
&&(temp_controller->location == controller_ptr->location ))
{
/*---------------------------------------------------------*\
| Update all modes |
\*---------------------------------------------------------*/
if(temp_controller->modes.size() == controller_ptr->modes.size())
{
for(int mode_index = 0; mode_index < temp_controller->modes.size(); mode_index++)
{
if((temp_controller->modes[mode_index].name == controller_ptr->modes[mode_index].name )
&&(temp_controller->modes[mode_index].value == controller_ptr->modes[mode_index].value )
&&(temp_controller->modes[mode_index].flags == controller_ptr->modes[mode_index].flags )
&&(temp_controller->modes[mode_index].speed_min == controller_ptr->modes[mode_index].speed_min )
&&(temp_controller->modes[mode_index].speed_max == controller_ptr->modes[mode_index].speed_max )
&&(temp_controller->modes[mode_index].colors_min == controller_ptr->modes[mode_index].colors_min)
&&(temp_controller->modes[mode_index].colors_max == controller_ptr->modes[mode_index].colors_max))
{
controller_ptr->modes[mode_index].speed = temp_controller->modes[mode_index].speed;
controller_ptr->modes[mode_index].direction = temp_controller->modes[mode_index].direction;
controller_ptr->modes[mode_index].color_mode = temp_controller->modes[mode_index].color_mode;
controller_ptr->modes[mode_index].colors.resize(temp_controller->modes[mode_index].colors.size());
for(int mode_color_index = 0; mode_color_index < temp_controller->modes[mode_index].colors.size(); mode_color_index++)
{
controller_ptr->modes[mode_index].colors[mode_color_index] = temp_controller->modes[mode_index].colors[mode_color_index];
}
}
}
controller_ptr->active_mode = temp_controller->active_mode;
}
/*---------------------------------------------------------*\
| Update all colors |
\*---------------------------------------------------------*/
if(temp_controller->colors.size() == controller_ptr->colors.size())
{
for(int color_index = 0; color_index < temp_controller->colors.size(); color_index++)
{
controller_ptr->colors[color_index] = temp_controller->colors[color_index];
}
}
}
}
}
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
}
}
}
void Ui::OpenRGBDialog2::on_ButtonSaveProfile_clicked()
{
OpenRGBProfileSaveDialog dialog;
/*---------------------------------------------------------*\
| Open Profile Name Dialog |
\*---------------------------------------------------------*/
std::string profile_name = dialog.show();
/*---------------------------------------------------------*\
| If a name was entered, save the profile file |
\*---------------------------------------------------------*/
if(profile_name != "")
{
/*---------------------------------------------------------*\
| Extension .orp - OpenRgb Profile |
\*---------------------------------------------------------*/
std::string filename = profile_name + ".orp";
/*---------------------------------------------------------*\
| Open an output file in binary mode |
\*---------------------------------------------------------*/
std::ofstream controller_file(filename, std::ios::out | std::ios::binary);
/*---------------------------------------------------------*\
| Write header |
| 16 bytes - "OPENRGB_PROFILE" |
| 4 bytes - Version, unsigned int |
\*---------------------------------------------------------*/
unsigned int profile_version = 1;
controller_file.write("OPENRGB_PROFILE", 16);
controller_file.write((char *)&profile_version, sizeof(unsigned int));
/*---------------------------------------------------------*\
| Write controller data for each controller |
\*---------------------------------------------------------*/
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
{
unsigned char *controller_data = controllers[controller_index]->GetDeviceDescription();
unsigned int controller_size;
memcpy(&controller_size, controller_data, sizeof(controller_size));
controller_file.write((const char *)controller_data, controller_size);
}
/*---------------------------------------------------------*\
| Close the file when done |
\*---------------------------------------------------------*/
controller_file.close();
/*---------------------------------------------------------*\
| Add the new file to the profile list |
\*---------------------------------------------------------*/
ui->comboBox->addItem(filename.c_str());
}
}
void Ui::OpenRGBDialog2::on_ButtonLoadProfile_clicked()
{
std::vector<RGBController*> temp_controllers;
unsigned int controller_size;
unsigned int controller_offset = 0;
/*---------------------------------------------------------*\
| Get the profile filename from the profiles list |
\*---------------------------------------------------------*/
std::string filename = ui->comboBox->currentText().toStdString();
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream controller_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
controller_file.read(header_string, 16);
controller_file.read((char *)&header_version, sizeof(unsigned int));
controller_offset += 16 + sizeof(unsigned int);
controller_file.seekg(controller_offset);
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Read controller data from file until EOF |
\*---------------------------------------------------------*/
while(!(controller_file.peek() == EOF))
{
controller_file.read((char *)&controller_size, sizeof(controller_size));
unsigned char *controller_data = new unsigned char[controller_size];
controller_file.seekg(controller_offset);
controller_file.read((char *)controller_data, controller_size);
RGBController_Dummy *temp_controller = new RGBController_Dummy();
temp_controller->ReadDeviceDescription(controller_data);
temp_controllers.push_back(temp_controller);
delete[] controller_data;
controller_offset += controller_size;
controller_file.seekg(controller_offset);
}
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
{
RGBController *temp_controller = temp_controllers[controller_index];
RGBController *controller_ptr = controllers[controller_index];
/*---------------------------------------------------------*\
| Test if saved controller data matches this controller |
\*---------------------------------------------------------*/
if((temp_controller->type == controller_ptr->type )
&&(temp_controller->name == controller_ptr->name )
&&(temp_controller->description == controller_ptr->description)
&&(temp_controller->version == controller_ptr->version )
&&(temp_controller->serial == controller_ptr->serial )
&&(temp_controller->location == controller_ptr->location ))
{
/*---------------------------------------------------------*\
| Update all modes |
\*---------------------------------------------------------*/
if(temp_controller->modes.size() == controller_ptr->modes.size())
{
for(int mode_index = 0; mode_index < temp_controller->modes.size(); mode_index++)
{
if((temp_controller->modes[mode_index].name == controller_ptr->modes[mode_index].name )
&&(temp_controller->modes[mode_index].value == controller_ptr->modes[mode_index].value )
&&(temp_controller->modes[mode_index].flags == controller_ptr->modes[mode_index].flags )
&&(temp_controller->modes[mode_index].speed_min == controller_ptr->modes[mode_index].speed_min )
&&(temp_controller->modes[mode_index].speed_max == controller_ptr->modes[mode_index].speed_max )
&&(temp_controller->modes[mode_index].colors_min == controller_ptr->modes[mode_index].colors_min)
&&(temp_controller->modes[mode_index].colors_max == controller_ptr->modes[mode_index].colors_max))
{
controller_ptr->modes[mode_index].speed = temp_controller->modes[mode_index].speed;
controller_ptr->modes[mode_index].direction = temp_controller->modes[mode_index].direction;
controller_ptr->modes[mode_index].color_mode = temp_controller->modes[mode_index].color_mode;
controller_ptr->modes[mode_index].colors.resize(temp_controller->modes[mode_index].colors.size());
for(int mode_color_index = 0; mode_color_index < temp_controller->modes[mode_index].colors.size(); mode_color_index++)
{
controller_ptr->modes[mode_index].colors[mode_color_index] = temp_controller->modes[mode_index].colors[mode_color_index];
}
}
}
controller_ptr->active_mode = temp_controller->active_mode;
}
/*---------------------------------------------------------*\
| Update all colors |
\*---------------------------------------------------------*/
if(temp_controller->colors.size() == controller_ptr->colors.size())
{
for(int color_index = 0; color_index < temp_controller->colors.size(); color_index++)
{
controller_ptr->colors[color_index] = temp_controller->colors[color_index];
}
}
}
}
}
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
}
}
}
+3
View File
@@ -48,6 +48,9 @@ private slots:
void on_QuickWhite(); void on_QuickWhite();
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue); void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
void on_ShowHide(); void on_ShowHide();
void on_ProfileSelected();
void on_ButtonSaveProfile_clicked();
void on_ButtonLoadProfile_clicked();
}; };
#endif // OPENRGBDIALOG2_H #endif // OPENRGBDIALOG2_H
+19 -2
View File
@@ -15,7 +15,24 @@
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="3" column="1">
<widget class="QPushButton" name="ButtonLoadProfile">
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="ButtonSaveProfile">
<property name="text">
<string>Save Profile</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="2" column="0" colspan="3">
<widget class="QTabWidget" name="MainTabBar"> <widget class="QTabWidget" name="MainTabBar">
<property name="tabShape"> <property name="tabShape">
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
@@ -34,7 +51,7 @@
<string>Devices</string> <string>Devices</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0"> <item row="1" column="0">
<widget class="QTabWidget" name="DevicesTabBar"> <widget class="QTabWidget" name="DevicesTabBar">
<property name="tabPosition"> <property name="tabPosition">
<enum>QTabWidget::West</enum> <enum>QTabWidget::West</enum>
+31
View File
@@ -0,0 +1,31 @@
#include "OpenRGBProfileSaveDialog.h"
#include "ui_OpenRGBProfileSaveDialog.h"
Ui::OpenRGBProfileSaveDialog::OpenRGBProfileSaveDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::OpenRGBProfileSaveDialogUi)
{
ui->setupUi(this);
}
Ui::OpenRGBProfileSaveDialog::~OpenRGBProfileSaveDialog()
{
delete ui;
}
std::string Ui::OpenRGBProfileSaveDialog::show()
{
std::string return_string;
int result = this->exec();
if(result == QDialog::Rejected)
{
return_string = "";
}
else
{
return_string = ui->lineEdit->text().toStdString();
}
return(return_string);
}
+26
View File
@@ -0,0 +1,26 @@
#ifndef OPENRGBPROFILESAVEDIALOG_H
#define OPENRGBPROFILESAVEDIALOG_H
#include <QDialog>
#include "ui_OpenRGBProfileSaveDialog.h"
namespace Ui
{
class OpenRGBProfileSaveDialog;
}
class Ui::OpenRGBProfileSaveDialog : public QDialog
{
Q_OBJECT
public:
explicit OpenRGBProfileSaveDialog(QWidget *parent = nullptr);
~OpenRGBProfileSaveDialog();
std::string show();
private:
Ui::OpenRGBProfileSaveDialogUi *ui;
};
#endif // OPENRGBPROFILESAVEDIALOG_H
+91
View File
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBProfileSaveDialogUi</class>
<widget class="QDialog" name="OpenRGBProfileSaveDialogUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>160</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>120</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>341</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>341</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>New Profile Name:</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>OpenRGBProfileSaveDialogUi</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OpenRGBProfileSaveDialogUi</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+21
View File
@@ -0,0 +1,21 @@
#include "OpenRGBSoftwareInfoPage.h"
using namespace Ui;
OpenRGBSoftwareInfoPage::OpenRGBSoftwareInfoPage(QWidget *parent) :
QFrame(parent),
ui(new Ui::OpenRGBSoftwareInfoPageUi)
{
ui->setupUi(this);
ui->VersionValue->setText(VERSION_STRING);
ui->BuildDateValue->setText(BUILDDATE_STRING);
ui->GitCommitIDValue->setText(GIT_COMMIT_ID);
ui->GitCommitDateValue->setText(GIT_COMMIT_DATE);
ui->GitBranchValue->setText(GIT_BRANCH);
}
OpenRGBSoftwareInfoPage::~OpenRGBSoftwareInfoPage()
{
delete ui;
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef OPENRGBSOFTWAREINFOPAGE_H
#define OPENRGBSOFTWAREINFOPAGE_H
#include <QFrame>
#include "ui_OpenRGBSoftwareInfoPage.h"
namespace Ui {
class OpenRGBSoftwareInfoPage;
}
class Ui::OpenRGBSoftwareInfoPage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBSoftwareInfoPage(QWidget *parent = nullptr);
~OpenRGBSoftwareInfoPage();
private:
Ui::OpenRGBSoftwareInfoPageUi *ui;
};
#endif // OPENRGBSOFTWAREINFOPAGE_H
+91
View File
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBSoftwareInfoPageUi</class>
<widget class="QFrame" name="OpenRGBSoftwareInfoPageUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="GitBranchLabel">
<property name="text">
<string>Git Branch:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="GitCommitIDValue">
<property name="text">
<string>Git Commit ID Value</string>
</property>
</widget>
</item>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="BuildDateLabel">
<property name="text">
<string>Build Date:</string>
</property>
</widget>
</item>
<item row="3" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="GitCommitDateLabel">
<property name="text">
<string>Git Commit Date:</string>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="GitCommitIDLabel">
<property name="text">
<string>Git Commit ID:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="BuildDateValue">
<property name="text">
<string>Build Date Value</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="GitBranchValue">
<property name="text">
<string>Git Branch Value</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="GitCommitDateValue">
<property name="text">
<string>Git Commit Date Value</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="VersionValue">
<property name="text">
<string>Version Value</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+4 -4
View File
@@ -36,9 +36,9 @@ void superio_enter(int ioreg)
#else #else
unsigned char temp = 0x87; unsigned char temp = 0x87;
dev_port_fd = open("/dev/port", O_RDWR, "rw"); dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_CUR); lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &temp, 1); write(dev_port_fd, &temp, 1);
lseek(dev_port_fd, ioreg, SEEK_CUR); lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &temp, 1); write(dev_port_fd, &temp, 1);
close(dev_port_fd); close(dev_port_fd);
#endif #endif
@@ -60,7 +60,7 @@ void superio_outb(int ioreg, int reg, int val)
Out32(ioreg + 1, val); Out32(ioreg + 1, val);
#else #else
dev_port_fd = open("/dev/port", O_RDWR, "rw"); dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_CUR); lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &reg, 1); write(dev_port_fd, &reg, 1);
write(dev_port_fd, &val, 1); write(dev_port_fd, &val, 1);
close(dev_port_fd); close(dev_port_fd);
@@ -84,7 +84,7 @@ int superio_inb(int ioreg, int reg)
#else #else
unsigned char temp; unsigned char temp;
dev_port_fd = open("/dev/port", O_RDWR, "rw"); dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_CUR); lseek(dev_port_fd, ioreg, SEEK_SET);
write(dev_port_fd, &reg, 1); write(dev_port_fd, &reg, 1);
read(dev_port_fd, &temp, 1); read(dev_port_fd, &temp, 1);
close(dev_port_fd); close(dev_port_fd);